summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/common/ArgumentTest.cpp24
-rw-r--r--test/core/common/VariantReaderTest.cpp12
2 files changed, 33 insertions, 3 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)