From 036ee7dd97f42efeecf1c66396731419a973126a Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Fri, 6 Feb 2015 19:21:11 +0100 Subject: made cardinality to an own class instead of using. --- test/core/RangeSetTest.cpp | 6 ++++++ test/core/model/DomainTest.cpp | 26 +++++++++++++------------- test/core/model/TestAdvanced.hpp | 4 ++-- test/core/model/TestDomain.hpp | 8 ++++---- test/plugins/xml/XmlParserTest.cpp | 8 ++++---- 5 files changed, 29 insertions(+), 23 deletions(-) (limited to 'test') diff --git a/test/core/RangeSetTest.cpp b/test/core/RangeSetTest.cpp index e158233..cbf8f59 100644 --- a/test/core/RangeSetTest.cpp +++ b/test/core/RangeSetTest.cpp @@ -216,5 +216,11 @@ TEST(RangeSet, Contains) ASSERT_TRUE(s.contains(Range(70, 74))); } +TEST(RangeSet, AnyCardinality){ + RangeSet expected; + expected.merge(Range::typeRange()); + ASSERT_EQ(expected, Cardinality::any()); +} + } diff --git a/test/core/model/DomainTest.cpp b/test/core/model/DomainTest.cpp index 8fcd21d..0c85d10 100644 --- a/test/core/model/DomainTest.cpp +++ b/test/core/model/DomainTest.cpp @@ -154,25 +154,25 @@ TEST(Descriptor, pathToAdvanced) // Let's create the classes that we need first Rooted A{new StructuredClass( - mgr, "A", domain, AnyCardinality, {nullptr}, false, true)}; + mgr, "A", domain, Cardinality::any(), {nullptr}, false, true)}; Rooted start{new StructuredClass( - mgr, "start", domain, AnyCardinality, A, false, false)}; + mgr, "start", domain, Cardinality::any(), A, false, false)}; Rooted B{new StructuredClass( - mgr, "B", domain, AnyCardinality, {nullptr}, true, false)}; + mgr, "B", domain, Cardinality::any(), {nullptr}, true, false)}; Rooted C{ - new StructuredClass(mgr, "C", domain, AnyCardinality, B, true, false)}; + new StructuredClass(mgr, "C", domain, Cardinality::any(), B, true, false)}; Rooted D{new StructuredClass( - mgr, "D", domain, AnyCardinality, {nullptr}, true, false)}; + mgr, "D", domain, Cardinality::any(), {nullptr}, true, false)}; Rooted E{new StructuredClass( - mgr, "E", domain, AnyCardinality, {nullptr}, true, false)}; + mgr, "E", domain, Cardinality::any(), {nullptr}, true, false)}; Rooted target{ - new StructuredClass(mgr, "target", domain, AnyCardinality)}; + new StructuredClass(mgr, "target", domain, Cardinality::any())}; // We create two fields for A Rooted A_field{new FieldDescriptor(mgr, A)}; @@ -223,19 +223,19 @@ TEST(StructuredClass, isSubclassOf) Rooted sys{new SystemTypesystem(mgr)}; Rooted domain{new Domain(mgr, sys, "inheritance")}; Rooted A{new StructuredClass( - mgr, "A", domain, AnyCardinality, {nullptr}, false, true)}; + mgr, "A", domain, Cardinality::any(), {nullptr}, false, true)}; // first branch Rooted B{ - new StructuredClass(mgr, "B", domain, AnyCardinality, A)}; + new StructuredClass(mgr, "B", domain, Cardinality::any(), A)}; Rooted C{ - new StructuredClass(mgr, "C", domain, AnyCardinality, B)}; + new StructuredClass(mgr, "C", domain, Cardinality::any(), B)}; // second branch Rooted D{ - new StructuredClass(mgr, "D", domain, AnyCardinality, A)}; + new StructuredClass(mgr, "D", domain, Cardinality::any(), A)}; Rooted E{ - new StructuredClass(mgr, "E", domain, AnyCardinality, D)}; + new StructuredClass(mgr, "E", domain, Cardinality::any(), D)}; Rooted F{ - new StructuredClass(mgr, "F", domain, AnyCardinality, D)}; + new StructuredClass(mgr, "F", domain, Cardinality::any(), D)}; // check function results ASSERT_FALSE(A->isSubclassOf(A)); diff --git a/test/core/model/TestAdvanced.hpp b/test/core/model/TestAdvanced.hpp index 2e4a541..56738af 100644 --- a/test/core/model/TestAdvanced.hpp +++ b/test/core/model/TestAdvanced.hpp @@ -86,7 +86,7 @@ static Rooted constructListDomain(Manager &mgr, Rooted p = resolveDescriptor(bookDomain, "paragraph"); // set up item StructuredClass; Rooted item{new StructuredClass( - mgr, "item", domain, AnyCardinality, {nullptr}, false)}; + mgr, "item", domain, Cardinality::any(), {nullptr}, false)}; // as field we want to copy the field of paragraph. item->copyFieldDescriptor(p->getFieldDescriptors()[0]); @@ -94,7 +94,7 @@ static Rooted constructListDomain(Manager &mgr, std::vector listTypes{"ol", "ul"}; for (auto &listType : listTypes) { Rooted list{new StructuredClass( - mgr, listType, domain, AnyCardinality, p, false)}; + mgr, listType, domain, Cardinality::any(), p, false)}; Rooted list_field{new FieldDescriptor(mgr, list)}; list_field->addChild(item); } diff --git a/test/core/model/TestDomain.hpp b/test/core/model/TestDomain.hpp index 18c42bd..8b572a8 100644 --- a/test/core/model/TestDomain.hpp +++ b/test/core/model/TestDomain.hpp @@ -46,7 +46,7 @@ static Rooted constructBookDomain(Manager &mgr, // From there on the "section". Rooted section{ - new StructuredClass(mgr, "section", domain, AnyCardinality)}; + new StructuredClass(mgr, "section", domain, Cardinality::any())}; book_field->addChild(section); // And the field of it. @@ -54,7 +54,7 @@ static Rooted constructBookDomain(Manager &mgr, // We also add the "paragraph", which is transparent. Rooted paragraph{new StructuredClass( - mgr, "paragraph", domain, AnyCardinality, {nullptr}, true)}; + mgr, "paragraph", domain, Cardinality::any(), {nullptr}, true)}; section_field->addChild(paragraph); book_field->addChild(paragraph); @@ -64,7 +64,7 @@ static Rooted constructBookDomain(Manager &mgr, // We append "subsection" to section. Rooted subsection{ - new StructuredClass(mgr, "subsection", domain, AnyCardinality)}; + new StructuredClass(mgr, "subsection", domain, Cardinality::any())}; section_field->addChild(subsection); // And the field of it. @@ -76,7 +76,7 @@ static Rooted constructBookDomain(Manager &mgr, // Finally we add the "text" node, which is transparent as well. Rooted text{new StructuredClass( - mgr, "text", domain, AnyCardinality, {nullptr}, true)}; + mgr, "text", domain, Cardinality::any(), {nullptr}, true)}; paragraph_field->addChild(text); // ... and has a primitive field. diff --git a/test/plugins/xml/XmlParserTest.cpp b/test/plugins/xml/XmlParserTest.cpp index 647fc6d..6110fcb 100644 --- a/test/plugins/xml/XmlParserTest.cpp +++ b/test/plugins/xml/XmlParserTest.cpp @@ -97,7 +97,7 @@ static void checkAttributes(Handle expected, static void checkStructuredClass( Handle n, const std::string &name, Handle domain, - Variant cardinality = AnyCardinality, + Variant cardinality = Cardinality::any(), Handle attributesDescriptor = nullptr, Handle superclass = nullptr, bool transparent = false, bool root = false) @@ -115,7 +115,7 @@ static void checkStructuredClass( static Rooted checkStructuredClass( const std::string &resolve, const std::string &name, Handle domain, - Variant cardinality = AnyCardinality, + Variant cardinality = Cardinality::any(), Handle attributesDescriptor = nullptr, Handle superclass = nullptr, bool transparent = false, bool root = false) @@ -230,9 +230,9 @@ TEST(XmlParser, domainParsing) checkStructuredClass("subsection", "subsection", book_domain); Rooted paragraph = checkStructuredClass("paragraph", "paragraph", book_domain, - AnyCardinality, nullptr, nullptr, true, false); + Cardinality::any(), nullptr, nullptr, true, false); Rooted text = - checkStructuredClass("text", "text", book_domain, AnyCardinality, + checkStructuredClass("text", "text", book_domain, Cardinality::any(), nullptr, nullptr, true, false); // check the FieldDescriptors. -- cgit v1.2.3