From 0ff4b8bbd46c1561490aeacf3814d1678fb8d403 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Wed, 4 Feb 2015 21:12:32 +0100 Subject: got headings domain to work. --- test/plugins/xml/XmlParserTest.cpp | 28 +++++++++++++++++++++++----- testdata/xmlparser/headings_domain.oxm | 14 +++++++------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/test/plugins/xml/XmlParserTest.cpp b/test/plugins/xml/XmlParserTest.cpp index c493643..2d0cb6f 100644 --- a/test/plugins/xml/XmlParserTest.cpp +++ b/test/plugins/xml/XmlParserTest.cpp @@ -114,7 +114,7 @@ static void checkFieldDescriptor( FieldDescriptor::FieldType type = FieldDescriptor::FieldType::TREE, Handle primitiveType = nullptr, bool optional = false) { - ASSERT_FALSE(n.isNull()); + ASSERT_FALSE(n == nullptr); Handle field = n.cast(); ASSERT_FALSE(field.isNull()); ASSERT_EQ(name, field->getName()); @@ -131,7 +131,7 @@ static void checkFieldDescriptor( static void checkFieldDescriptor( Handle desc, NodeVector children, - const std::string &name = "", + const std::string &name = DEFAULT_FIELD_NAME, FieldDescriptor::FieldType type = FieldDescriptor::FieldType::TREE, Handle primitiveType = nullptr, bool optional = false) { @@ -183,9 +183,27 @@ TEST(XmlParser, domainParsing) // check parent handling. Rooted headings_domain_node = env.parse("headings_domain.oxm", "", "", RttiSet{&RttiTypes::Domain}); - //TODO: Unfortunately this does not work yet. - //ASSERT_FALSE(headings_domain_node == nullptr); - //ASSERT_FALSE(logger.hasError()); + ASSERT_FALSE(headings_domain_node == nullptr); + ASSERT_FALSE(logger.hasError()); + Rooted headings_domain = headings_domain_node.cast(); + // now there should be a heading struct. + Rooted heading = + checkStructuredClass("heading", "heading", headings_domain, single, + nullptr, nullptr, true, false); + // which should allow text content + checkFieldDescriptor(heading, {text}); + // and each struct in the book domain (except for text) should have a + // heading field now. + checkFieldDescriptor(book, {heading}, "heading", + FieldDescriptor::FieldType::SUBTREE, nullptr, true); + checkFieldDescriptor(chapter, {heading}, "heading", + FieldDescriptor::FieldType::SUBTREE, nullptr, true); + checkFieldDescriptor(section, {heading}, "heading", + FieldDescriptor::FieldType::SUBTREE, nullptr, true); + checkFieldDescriptor(subsection, {heading}, "heading", + FieldDescriptor::FieldType::SUBTREE, nullptr, true); + checkFieldDescriptor(paragraph, {heading}, "heading", + FieldDescriptor::FieldType::SUBTREE, nullptr, true); } } diff --git a/testdata/xmlparser/headings_domain.oxm b/testdata/xmlparser/headings_domain.oxm index f83843c..2238792 100644 --- a/testdata/xmlparser/headings_domain.oxm +++ b/testdata/xmlparser/headings_domain.oxm @@ -3,31 +3,31 @@ - + - + - + - + - + - + - + -- cgit v1.2.3