From f77ec7ae614810bc317c23138279e115f930aa06 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Sat, 20 Dec 2014 15:14:28 +0100 Subject: Introduced global type variables for model classes and used them in the Domain resolve test, which makes it much easier to understand. --- test/core/model/DomainTest.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'test') diff --git a/test/core/model/DomainTest.cpp b/test/core/model/DomainTest.cpp index f6dff3c..204a862 100644 --- a/test/core/model/DomainTest.cpp +++ b/test/core/model/DomainTest.cpp @@ -28,23 +28,21 @@ namespace ousia { namespace model { void assert_path(std::vector> &result, size_t idx, - const std::type_info &expected_type, + const ManagedType &expected_type, std::vector expected_path) { ASSERT_TRUE(result.size() > idx); // check class/type - ASSERT_EQ(expected_type, typeid(*result[idx])); - // transform to node - Managed *m = &(*result[idx]); - Node *n = dynamic_cast(m); - ASSERT_TRUE(n); + ASSERT_TRUE(result[idx]->isa(expected_type)); + // cast to node + Rooted n = result[idx].cast(); // extract actual path std::vector actual_path = n->path(); // check path ASSERT_EQ(expected_path, actual_path); } -TEST(Document, testDomainResolving) +TEST(Domain, testDomainResolving) { // Construct Manager Manager mgr{1}; @@ -59,9 +57,9 @@ TEST(Document, testDomainResolving) std::vector> res = domain->resolve(std::vector{"book"}); // First we expect the book domain. - assert_path(res, 0, typeid(Domain), {"book"}); + assert_path(res, 0, DomainType, {"book"}); // Then the book structure. - assert_path(res, 1, typeid(StructuredClass), {"book", "book"}); + assert_path(res, 1, StructuredClassType, {"book", "book"}); ASSERT_EQ(2, res.size()); /* @@ -69,7 +67,7 @@ TEST(Document, testDomainResolving) * StructuredClass should be returned. */ res = domain->resolve(std::vector{"book", "book"}); - assert_path(res, 0, typeid(StructuredClass), {"book", "book"}); + assert_path(res, 0, StructuredClassType, {"book", "book"}); ASSERT_EQ(1, res.size()); /* @@ -77,7 +75,7 @@ TEST(Document, testDomainResolving) */ res = domain->resolve(std::vector{"section"}); // TODO: Is that the path result we want? - assert_path(res, 0, typeid(StructuredClass), {"book", "section"}); + assert_path(res, 0, StructuredClassType, {"book", "section"}); ASSERT_EQ(1, res.size()); /* @@ -85,7 +83,7 @@ TEST(Document, testDomainResolving) * FieldDescriptor of the StructuredClass "book". */ res = domain->resolve(std::vector{"book", "book", ""}); - assert_path(res, 0, typeid(FieldDescriptor), {"book", "book", ""}); + assert_path(res, 0, FieldDescriptorType, {"book", "book", ""}); ASSERT_EQ(1, res.size()); /* @@ -93,7 +91,7 @@ TEST(Document, testDomainResolving) * but should be returned only once. */ res = domain->resolve("paragraph"); - assert_path(res, 0, typeid(StructuredClass), {"book", "paragraph"}); + assert_path(res, 0, StructuredClassType, {"book", "paragraph"}); ASSERT_EQ(1, res.size()); } } -- cgit v1.2.3