diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2014-12-18 21:44:17 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2014-12-18 21:44:17 +0100 |
commit | 776fbb600da5fb5268e1b803e74fe7f8b0ea2746 (patch) | |
tree | 20236cd7eb138fe0e1b1d31330d5ffca026cf857 /test/core | |
parent | 94a60d364203f633370e1b0a77ec5b89428032e3 (diff) |
Finished the Domain test for now. Resolving mechanism works as expected (or at least well enough).
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/model/DomainTest.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/test/core/model/DomainTest.cpp b/test/core/model/DomainTest.cpp index b1538cf..57ec91c 100644 --- a/test/core/model/DomainTest.cpp +++ b/test/core/model/DomainTest.cpp @@ -28,7 +28,7 @@ namespace ousia { namespace model { void assert_path(std::vector<Rooted<Managed>> &result, size_t idx, - const std::type_info& expected_type, + const std::type_info &expected_type, std::vector<std::string> expected_path) { ASSERT_TRUE(result.size() > idx); @@ -62,6 +62,39 @@ TEST(Document, testDomainResolving) assert_path(res, 0, typeid(Domain), {"book"}); // Then the book structure. assert_path(res, 1, typeid(StructuredClass), {"book", "book"}); + ASSERT_EQ(2, res.size()); + + /* + * If we explicitly ask for the "book, book" path, then only the + * StructuredClass should be returned. + */ + res = domain->resolve(std::vector<std::string>{"book", "book"}); + assert_path(res, 0, typeid(StructuredClass), {"book", "book"}); + ASSERT_EQ(1, res.size()); + + /* + * If we ask for "section" the result should be unique as well. + */ + res = domain->resolve(std::vector<std::string>{"section"}); + // TODO: Is that the path result we want? + assert_path(res, 0, typeid(StructuredClass), {"book", "section"}); + ASSERT_EQ(1, res.size()); + + /* + * If we ask for the path "book", "book", "" we reference the + * FieldDescriptor of the StructuredClass "book". + */ + res = domain->resolve(std::vector<std::string>{"book", "book", ""}); + assert_path(res, 0, typeid(FieldDescriptor), {"book", "book", ""}); + ASSERT_EQ(1, res.size()); + + /* + * If we ask for "paragraph" it is references two times in the Domain graph, + * but should be returned only once. + */ + res = domain->resolve("paragraph"); + assert_path(res, 0, typeid(StructuredClass), {"book", "paragraph"}); + ASSERT_EQ(1, res.size()); } } } |