mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there. * Declared existing Entity APIs. * Added basic script context caching * Started Lua script module * Started Lua spell effect API * Started script state persistence * Started battle info callback binding * CommitPackage removed * Extracted spells::Caster to own header; Expanded Spell API. * implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C * !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented * Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key) * Re-enabled VERM macros. * !?GM0 added * !?TM implemented * Added !!MF:N * Started !?OB, !!BM, !!HE, !!OW, !!UN * Added basic support of w-variables * Added support for ERM indirect variables * Made !?FU regular trigger * !!re (ERA loop receiver) implemented * Fixed ERM receivers with zero args.
This commit is contained in:
@@ -63,10 +63,17 @@ bool JsonComparer::isEmpty(const JsonNode & value)
|
||||
|
||||
void JsonComparer::check(const bool condition, const std::string & message)
|
||||
{
|
||||
if(strict)
|
||||
ASSERT_TRUE(condition) << buildMessage(message);
|
||||
else
|
||||
EXPECT_TRUE(condition) << buildMessage(message);
|
||||
if(!condition)
|
||||
{
|
||||
if(strict)
|
||||
{
|
||||
GTEST_FAIL() << buildMessage(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
ADD_FAILURE() << buildMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JsonComparer::checkEqualInteger(const si64 actual, const si64 expected)
|
||||
@@ -79,7 +86,7 @@ void JsonComparer::checkEqualInteger(const si64 actual, const si64 expected)
|
||||
|
||||
void JsonComparer::checkEqualFloat(const double actual, const double expected)
|
||||
{
|
||||
if(std::abs(actual - expected) > 1e-6)
|
||||
if(std::abs(actual - expected) > 1e-8)
|
||||
{
|
||||
check(false, boost::str(boost::format("'%d' != '%d' (diff %d)") % actual % expected % (expected - actual)));
|
||||
}
|
||||
@@ -121,9 +128,8 @@ void JsonComparer::checkEqualJson(const JsonNode & actual, const JsonNode & expe
|
||||
|
||||
const bool validType = actual.getType() == expected.getType();
|
||||
|
||||
check(validType, "type mismatch");
|
||||
|
||||
//do detail checks avoiding assertions in JsonNode
|
||||
|
||||
if(validType)
|
||||
{
|
||||
switch (actual.getType())
|
||||
@@ -153,6 +159,14 @@ void JsonComparer::checkEqualJson(const JsonNode & actual, const JsonNode & expe
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(actual.isNumber() && expected.isNumber())
|
||||
{
|
||||
checkEqualFloat(actual.Float(),expected.Float());
|
||||
}
|
||||
else
|
||||
{
|
||||
check(false, "type mismatch. \n expected:\n"+expected.toJson(true)+"\n actual:\n" +actual.toJson(true));
|
||||
}
|
||||
}
|
||||
|
||||
void JsonComparer::checkExcessStructField(const JsonNode & actualValue, const std::string & name, const JsonMap & expected)
|
||||
|
||||
Reference in New Issue
Block a user