diff options
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/common/ArgumentTest.cpp | 24 | ||||
-rw-r--r-- | test/core/common/VariantReaderTest.cpp | 12 | ||||
-rw-r--r-- | test/core/model/DocumentTest.cpp | 8 | ||||
-rw-r--r-- | test/core/model/DomainTest.cpp | 30 | ||||
-rw-r--r-- | test/core/model/TestAdvanced.hpp | 2 | ||||
-rw-r--r-- | test/core/model/TestDomain.hpp | 14 |
6 files changed, 62 insertions, 28 deletions
diff --git a/test/core/common/ArgumentTest.cpp b/test/core/common/ArgumentTest.cpp index 0a2dcfa..ca93f45 100644 --- a/test/core/common/ArgumentTest.cpp +++ b/test/core/common/ArgumentTest.cpp @@ -792,8 +792,8 @@ TEST(Arguments, invalid) Variant::arrayType arr{1}; - ASSERT_TRUE(argsInvalid.validateArray(arr, logger)); // No error message - ASSERT_FALSE(argsValid.validateArray(arr, logger)); // Too many arguments + ASSERT_TRUE(argsInvalid.validateArray(arr, logger)); // No error message + ASSERT_FALSE(argsValid.validateArray(arr, logger)); // Too many arguments } TEST(Arguments, validateArray) @@ -879,6 +879,25 @@ TEST(Arguments, validateMap) {{"a", 2}, {"b", "test"}, {"c", true}, {"d", nullptr}}), map); } + + { + Variant::mapType map{{"#0", 2}, {"#1", "bla"}, {"#2", false}}; + ASSERT_FALSE(args.validateMap(map, logger, false, false)); + ASSERT_EQ(Variant::mapType({{"#0", 2}, + {"#1", "bla"}, + {"#2", false}, + {"a", 0}, + {"b", "test"}, + {"c", true}}), + map); + } + + { + Variant::mapType map{{"#0", 2}, {"#1", "bla"}, {"#2", false}}; + ASSERT_TRUE(args.validateMap(map, logger, false, true)); + ASSERT_EQ(Variant::mapType({{"a", 2}, {"b", "bla"}, {"c", false}}), + map); + } } TEST(Arguments, validateMissing) @@ -897,6 +916,5 @@ TEST(Arguments, validateMissing) ASSERT_EQ(Variant::arrayType({""}), arr); } } - } diff --git a/test/core/common/VariantReaderTest.cpp b/test/core/common/VariantReaderTest.cpp index a23af09..79e567b 100644 --- a/test/core/common/VariantReaderTest.cpp +++ b/test/core/common/VariantReaderTest.cpp @@ -1153,6 +1153,18 @@ TEST(VariantReader, parseGenericString) ASSERT_EQ(0U, loc.getStart()); ASSERT_EQ(15U, loc.getEnd()); } + + // Parse empty string + { + auto res = VariantReader::parseGenericString("", logger); + ASSERT_TRUE(res.first); + ASSERT_TRUE(res.second.isString()); + ASSERT_EQ("", res.second.asString()); + + SourceLocation loc = res.second.getLocation(); + ASSERT_EQ(0U, loc.getStart()); + ASSERT_EQ(0U, loc.getEnd()); + } } TEST(VariantReader, parseGenericComplex) diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp index 0c6eea6..1bb2356 100644 --- a/test/core/model/DocumentTest.cpp +++ b/test/core/model/DocumentTest.cpp @@ -147,7 +147,7 @@ TEST(Document, validate) // now let's extend the rootClass with a default field. Rooted<FieldDescriptor> rootField = - rootClass->createFieldDescriptor(logger); + rootClass->createFieldDescriptor(logger).first; // and add a child class for it. Rooted<StructuredClass> childClass{ new StructuredClass(mgr, "child", domain, single)}; @@ -194,7 +194,7 @@ TEST(Document, validate) * instances now. */ Rooted<FieldDescriptor> childField = - childClass->createFieldDescriptor(logger); + childClass->createFieldDescriptor(logger).first; childField->addChild(childClass); { /* @@ -214,7 +214,7 @@ TEST(Document, validate) */ Rooted<FieldDescriptor> childSubField = childSubClass->createFieldDescriptor( - logger, FieldDescriptor::FieldType::TREE, "dummy", true); + logger, FieldDescriptor::FieldType::TREE, "dummy", true).first; // add a child pro forma to make it valid. childSubField->addChild(childSubClass); { @@ -234,7 +234,7 @@ TEST(Document, validate) Rooted<FieldDescriptor> primitive_field = childSubClass->createPrimitiveFieldDescriptor( sys->getIntType(), logger, FieldDescriptor::FieldType::SUBTREE, - "int", false); + "int", false).first; { /* * Now a document with one instance of the Child subclass should be diff --git a/test/core/model/DomainTest.cpp b/test/core/model/DomainTest.cpp index 4cb4331..d68648e 100644 --- a/test/core/model/DomainTest.cpp +++ b/test/core/model/DomainTest.cpp @@ -186,21 +186,21 @@ TEST(Descriptor, pathToAdvanced) new StructuredClass(mgr, "target", domain, Cardinality::any())}; // We create a field for A - Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger); + Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger).first; A_field->addChild(B); A_field->addChild(D); // We create no field for B // One for C - Rooted<FieldDescriptor> C_field = C->createFieldDescriptor(logger); + Rooted<FieldDescriptor> C_field = C->createFieldDescriptor(logger).first; C_field->addChild(target); // One for D - Rooted<FieldDescriptor> D_field = D->createFieldDescriptor(logger); + Rooted<FieldDescriptor> D_field = D->createFieldDescriptor(logger).first; D_field->addChild(E); // One for E - Rooted<FieldDescriptor> E_field = E->createFieldDescriptor(logger); + Rooted<FieldDescriptor> E_field = E->createFieldDescriptor(logger).first; E_field->addChild(target); ASSERT_TRUE(domain->validate(logger)); @@ -239,7 +239,7 @@ TEST(Descriptor, getDefaultFields) // create a field. Rooted<FieldDescriptor> A_prim_field = - A->createPrimitiveFieldDescriptor(sys->getStringType(), logger); + A->createPrimitiveFieldDescriptor(sys->getStringType(), logger).first; // now we should find that. auto fields = A->getDefaultFields(); ASSERT_EQ(1U, fields.size()); @@ -262,7 +262,7 @@ TEST(Descriptor, getDefaultFields) ASSERT_EQ(A_prim_field, fields[0]); // and we should not be able to find it if we override the field. - Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger); + Rooted<FieldDescriptor> A_field = A->createFieldDescriptor(logger).first; ASSERT_TRUE(A->getDefaultFields().empty()); // add a transparent child class. @@ -273,7 +273,7 @@ TEST(Descriptor, getDefaultFields) // add a primitive field for it. Rooted<FieldDescriptor> C_field = - C->createPrimitiveFieldDescriptor(sys->getStringType(), logger); + C->createPrimitiveFieldDescriptor(sys->getStringType(), logger).first; // now we should find that. fields = A->getDefaultFields(); @@ -285,14 +285,14 @@ TEST(Descriptor, getDefaultFields) Rooted<StructuredClass> D{new StructuredClass( mgr, "D", domain, Cardinality::any(), nullptr, true, false)}; A_field->addChild(D); - Rooted<FieldDescriptor> D_field = D->createFieldDescriptor(logger); + Rooted<FieldDescriptor> D_field = D->createFieldDescriptor(logger).first; Rooted<StructuredClass> E{new StructuredClass( mgr, "E", domain, Cardinality::any(), nullptr, true, false)}; D_field->addChild(E); Rooted<StructuredClass> F{new StructuredClass( mgr, "E", domain, Cardinality::any(), E, true, false)}; Rooted<FieldDescriptor> F_field = - F->createPrimitiveFieldDescriptor(sys->getStringType(), logger); + F->createPrimitiveFieldDescriptor(sys->getStringType(), logger).first; // now we should find both primitive fields, but the C field first. fields = A->getDefaultFields(); @@ -436,7 +436,7 @@ TEST(Domain, validate) ASSERT_TRUE(domain->validate(logger)); // Let's add a primitive field (without a primitive type at first) Rooted<FieldDescriptor> base_field = - base->createPrimitiveFieldDescriptor(nullptr, logger); + base->createPrimitiveFieldDescriptor(nullptr, logger).first; // this should not be valid. ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); ASSERT_FALSE(domain->validate(logger)); @@ -464,7 +464,8 @@ TEST(Domain, validate) ASSERT_TRUE(domain->validate(logger)); ASSERT_EQ(base, sub->getSuperclass()); // add a non-primitive field to the child class. - Rooted<FieldDescriptor> sub_field = sub->createFieldDescriptor(logger); + Rooted<FieldDescriptor> sub_field = + sub->createFieldDescriptor(logger).first; // this should not be valid because we allow no children. ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); ASSERT_FALSE(domain->validate(logger)); @@ -489,8 +490,9 @@ TEST(Domain, validate) ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); ASSERT_TRUE(domain->validate(logger)); // It should be invalid if we set another TREE field. - Rooted<FieldDescriptor> sub_field2 = sub->createFieldDescriptor( - logger, FieldDescriptor::FieldType::TREE, "test", false); + Rooted<FieldDescriptor> sub_field2 = + sub->createFieldDescriptor(logger, FieldDescriptor::FieldType::TREE, + "test", false).first; ASSERT_EQ(ValidationState::UNKNOWN, domain->getValidationState()); ASSERT_FALSE(domain->validate(logger)); // but valid again if we remove it @@ -499,4 +501,4 @@ TEST(Domain, validate) ASSERT_TRUE(domain->validate(logger)); } } -} +}
\ No newline at end of file diff --git a/test/core/model/TestAdvanced.hpp b/test/core/model/TestAdvanced.hpp index 27f33cc..8e81554 100644 --- a/test/core/model/TestAdvanced.hpp +++ b/test/core/model/TestAdvanced.hpp @@ -66,7 +66,7 @@ static Rooted<Domain> constructHeadingDomain(Manager &mgr, for (auto &s : secclasses) { Rooted<StructuredClass> desc = resolveDescriptor(bookDomain, s); Rooted<FieldDescriptor> heading_field = desc->createFieldDescriptor( - logger, FieldDescriptor::FieldType::SUBTREE, "heading", true); + logger, FieldDescriptor::FieldType::SUBTREE, "heading", true).first; heading_field->addChild(heading); } return domain; diff --git a/test/core/model/TestDomain.hpp b/test/core/model/TestDomain.hpp index c107a0d..779ef03 100644 --- a/test/core/model/TestDomain.hpp +++ b/test/core/model/TestDomain.hpp @@ -42,7 +42,8 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, mgr, "book", domain, single, {nullptr}, false, true)}; // The structure field of it. - Rooted<FieldDescriptor> book_field = book->createFieldDescriptor(logger); + Rooted<FieldDescriptor> book_field = + book->createFieldDescriptor(logger).first; // From there on the "section". Rooted<StructuredClass> section{ @@ -51,7 +52,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // And the field of it. Rooted<FieldDescriptor> section_field = - section->createFieldDescriptor(logger); + section->createFieldDescriptor(logger).first; // We also add the "paragraph", which is transparent. Rooted<StructuredClass> paragraph{new StructuredClass( @@ -61,7 +62,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // And the field of it. Rooted<FieldDescriptor> paragraph_field = - paragraph->createFieldDescriptor(logger); + paragraph->createFieldDescriptor(logger).first; // We append "subsection" to section. Rooted<StructuredClass> subsection{ @@ -70,7 +71,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // And the field of it. Rooted<FieldDescriptor> subsection_field = - subsection->createFieldDescriptor(logger); + subsection->createFieldDescriptor(logger).first; // and we add the paragraph to subsections fields subsection_field->addChild(paragraph); @@ -82,10 +83,11 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, // ... and has a primitive field. Rooted<FieldDescriptor> text_field = - text->createPrimitiveFieldDescriptor(sys->getStringType(), logger); + text->createPrimitiveFieldDescriptor(sys->getStringType(), logger) + .first; return domain; } } -#endif /* _TEST_DOMAIN_HPP_ */ +#endif /* _TEST_DOMAIN_HPP_ */
\ No newline at end of file |