summaryrefslogtreecommitdiff
path: root/test/core/model/DomainTest.cpp
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-12 19:31:18 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-12 19:31:18 +0100
commit110fb7da850377e39b2879da44339dc936c266dc (patch)
treec421ed2ddf1d1371975fc8afd2745234fe859f75 /test/core/model/DomainTest.cpp
parentf0934f5484c58e7533f804735c8b31f7bcbc81e8 (diff)
further revised pathTo. Now only the TREE field is used in further exploration.
Diffstat (limited to 'test/core/model/DomainTest.cpp')
-rw-r--r--test/core/model/DomainTest.cpp36
1 files changed, 14 insertions, 22 deletions
diff --git a/test/core/model/DomainTest.cpp b/test/core/model/DomainTest.cpp
index 0097900..672b2d1 100644
--- a/test/core/model/DomainTest.cpp
+++ b/test/core/model/DomainTest.cpp
@@ -123,7 +123,9 @@ TEST(Descriptor, pathTo)
ASSERT_EQ(0U, path.size());
// try to construct the path between section and the text field.
- path = section->pathTo(text->getFieldDescriptor(), logger);
+ auto res = section->pathTo(text->getFieldDescriptor(), logger);
+ ASSERT_TRUE(res.second);
+ path = res.first;
ASSERT_EQ(4U, path.size());
ASSERT_TRUE(path[0]->isa(&RttiTypes::FieldDescriptor));
ASSERT_TRUE(path[1]->isa(&RttiTypes::StructuredClass));
@@ -144,15 +146,13 @@ TEST(Descriptor, pathToAdvanced)
*
* To achieve that we have the following structure:
* 1.) The start class inherits from A.
- * 2.) A has the target as child in the default field, but the default
- * field is overridden in the start class.
- * 3.) A has B as child in another field.
- * 4.) B is transparent and has no children (but C as subclass)
- * 5.) C is a subclass of B, transparent and has
+ * 2.) A has B as child in the default field.
+ * 3.) B is transparent and has no children (but C as subclass)
+ * 4.) C is a subclass of B, transparent and has
* the target as child (shortest path).
- * 6.) start has D as child in the default field.
- * 7.) D is transparent has E as child in the default field.
- * 8.) E is transparent and has target as child in the default field
+ * 5.) A has D as child in the default field.
+ * 6.) D is transparent has E as child in the default field.
+ * 7.) E is transparent and has target as child in the default field
* (longer path)
*
* So the path A_second_field, C, C_field should be returned.
@@ -185,30 +185,22 @@ TEST(Descriptor, pathToAdvanced)
Rooted<StructuredClass> target{
new StructuredClass(mgr, "target", domain, Cardinality::any())};
- // We create two fields for A
+ // We create a field for A
Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger);
+ A_field->addChild(B);
+ A_field->addChild(D);
- A_field->addChild(target);
- Rooted<FieldDescriptor> A_field2 = A->createFieldDescriptor(
- logger, FieldDescriptor::FieldType::SUBTREE, "second", false);
-
- A_field2->addChild(B);
// We create no field for B
// One for C
Rooted<FieldDescriptor> C_field = C->createFieldDescriptor(logger);
-
C_field->addChild(target);
- // one for start
- Rooted<FieldDescriptor> start_field = start->createFieldDescriptor(logger);
- start_field->addChild(D);
// One for D
Rooted<FieldDescriptor> D_field = D->createFieldDescriptor(logger);
-
D_field->addChild(E);
+
// One for E
Rooted<FieldDescriptor> E_field = E->createFieldDescriptor(logger);
-
E_field->addChild(target);
ASSERT_TRUE(domain->validate(logger));
@@ -222,7 +214,7 @@ TEST(Descriptor, pathToAdvanced)
NodeVector<Node> path = start->pathTo(target, logger);
ASSERT_EQ(3U, path.size());
ASSERT_TRUE(path[0]->isa(&RttiTypes::FieldDescriptor));
- ASSERT_EQ("second", path[0]->getName());
+ ASSERT_EQ("", path[0]->getName());
ASSERT_TRUE(path[1]->isa(&RttiTypes::StructuredClass));
ASSERT_EQ("C", path[1]->getName());
ASSERT_TRUE(path[2]->isa(&RttiTypes::FieldDescriptor));