Add a template manager test that reveals an inheritance error in ParamNode.cpp which can trigger an OOS on rejoin. Patch by leper, refs #4316.

This was SVN commit r18941.
This commit is contained in:
elexis 2016-11-15 13:51:29 +00:00
parent 2bf1dbfd13
commit 3008533c8e
5 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity>
<Test2A datatype="tokens">
a b c
</Test2A>
</Entity>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="inherit_a">
<Test2A datatype="tokens">
d
</Test2A>
</Entity>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity>
<Test2A a="b">
a b c
</Test2A>
</Entity>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="inherit_c">
<Test2A c="d"/>
</Entity>

View File

@ -120,6 +120,28 @@ public:
const CParamNode* foundation = tempMan->LoadTemplate(ent2, "foundation|actor|example1", -1);
ScriptInterface::ToJSVal(cx, &val, &foundation->GetChild("VisualActor"));
TS_ASSERT_STR_EQUALS(man.GetScriptInterface().ToString(&val), "({Actor:\"example1\", ActorOnly:(void 0), Foundation:(void 0), SilhouetteDisplay:\"false\", SilhouetteOccluder:\"false\", VisibleInAtlasOnly:\"false\"})");
#define GET_FIRST_ELEMENT(n, templateName) \
const CParamNode* n = tempMan->LoadTemplate(ent2, templateName, -1); \
for (CParamNode::ChildrenMap::const_iterator it = n->GetChildren().begin(); it != n->GetChildren().end(); ++it) \
{ \
if (it->first[0] == '@') \
continue; \
ScriptInterface::ToJSVal(cx, &val, it->second); \
break; \
}
GET_FIRST_ELEMENT(n1, "inherit_a");
TS_ASSERT_STR_EQUALS(man.GetScriptInterface().ToString(&val), "({'@datatype':\"tokens\", _string:\"a b c\"})");
GET_FIRST_ELEMENT(n2, "inherit_b");
TS_ASSERT_STR_EQUALS(man.GetScriptInterface().ToString(&val), "({'@datatype':\"tokens\", _string:\"a b c d\"})");
GET_FIRST_ELEMENT(n3, "inherit_c");
TS_ASSERT_STR_EQUALS(man.GetScriptInterface().ToString(&val), "({'@a':\"b\", _string:\"a b c\"})");
GET_FIRST_ELEMENT(n4, "inherit_d");
TS_ASSERT_STR_EQUALS(man.GetScriptInterface().ToString(&val), "({'@a':\"b\", '@c':\"d\"})");
#undef GET_FIRST_ELEMENT
}
void test_LoadTemplate_errors()