Skip to content

Commit

Permalink
#5813: More test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Nov 21, 2021
1 parent 316bfda commit 6d143d3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
28 changes: 28 additions & 0 deletions test/Entity.cpp
Expand Up @@ -1631,4 +1631,32 @@ TEST_F(EntityTest, GetNonInheritedAttributeType)
EXPECT_EQ(eclass->getAttributeType("undefined_bool"), "bool");
}

TEST_F(EntityTest, GetInheritedAttributeType)
{
auto eclass = GlobalEntityClassManager().findClass("attribute_type_test");

// The "base_defined_bool" is described in the base, as is the key
EXPECT_EQ(eclass->getAttributeType("base_defined_bool"), "bool");

// The "bool_not_defined_in_base" is set on the subclass, the description is in base
EXPECT_EQ(eclass->getAttributeType("bool_not_defined_in_base"), "bool");

// The "bool_not_defined_anywhere" is not set anywhere, only the description is there
EXPECT_EQ(eclass->getAttributeType("bool_not_defined_anywhere"), "bool");
}

TEST_F(EntityTest, GetVariousAttributeTypes)
{
auto eclass = GlobalEntityClassManager().findClass("attribute_type_test");

// editor_var and editor_string will be converted to "text"
EXPECT_EQ(eclass->getAttributeType("a_var"), "text");
EXPECT_EQ(eclass->getAttributeType("a_string"), "text");

// Some definitions: the suffix after "editor_" should be accepted as type
EXPECT_EQ(eclass->getAttributeType("a_text"), "text");
EXPECT_EQ(eclass->getAttributeType("a_vector"), "vector");
EXPECT_EQ(eclass->getAttributeType("a_hurk"), "hurk");
}

}
20 changes: 19 additions & 1 deletion test/resources/tdm/def/attribute_types.def
@@ -1,7 +1,15 @@

entityDef attribute_type_base
{

// A boolean descriptor, the defined bool is defined on this same class
"editor_bool base_defined_bool" "Some bool description"
"base_defined_bool" "1"

// A description for a key that is not defined here, but maybe on the subclasses
"editor_bool bool_not_defined_in_base" "Some bool description"

// This bool is only described here, but there's no key for it anywhere
"editor_bool bool_not_defined_anywhere" "Some bool description"
}

entityDef attribute_type_test
Expand All @@ -17,4 +25,14 @@ entityDef attribute_type_test
// An editor bool key with the key defined on this same class
"editor_bool defined_bool" "Some bool description"
"defined_bool" "1"

// The description is defined in base
"bool_not_defined_in_base" "0"

// Some types
"editor_var a_var" "A var"
"editor_string a_string" "A string"
"editor_text a_text" "A text"
"editor_vector a_vector" "A vector"
"editor_hurk a_hurk" "A hurk"
}

0 comments on commit 6d143d3

Please sign in to comment.