summaryrefslogtreecommitdiff
path: root/test/core/variant/ReaderTest.cpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-12-11 02:03:37 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-12-11 02:03:37 +0100
commitb74936760e28a92cadfaec47928ea478fe2d72ee (patch)
tree56f5ab70b6d4f4b7ebad99e61f45474dec60bc1e /test/core/variant/ReaderTest.cpp
parentb5d3f907b61d838325e4ee8a2c80d36fea438537 (diff)
using reader.fork for skipping invalid numbers in parseGeneric
Diffstat (limited to 'test/core/variant/ReaderTest.cpp')
-rw-r--r--test/core/variant/ReaderTest.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/test/core/variant/ReaderTest.cpp b/test/core/variant/ReaderTest.cpp
index 7349856..43e85a5 100644
--- a/test/core/variant/ReaderTest.cpp
+++ b/test/core/variant/ReaderTest.cpp
@@ -253,7 +253,7 @@ TEST(Reader, parseArray)
ASSERT_TRUE(res.first);
// Make sure array has the correct size
- ASSERT_EQ(7, res.second.size());
+ ASSERT_EQ(7U, res.second.size());
// Check the types
ASSERT_TRUE(res.second[0].isString());
@@ -280,7 +280,7 @@ TEST(Reader, parseArray)
ASSERT_TRUE(res.first);
// Make sure the array has the correct size
- ASSERT_EQ(1, res.second.size());
+ ASSERT_EQ(1U, res.second.size());
// Check the types
ASSERT_TRUE(res.second[0].isString());
@@ -290,22 +290,23 @@ TEST(Reader, parseArray)
}
// Recovery from invalid values
- // TODO: Actually parseGeneric should fall back to returning a simple string
- // if parsing of a special (non-string) type failed
{
CharReader reader("[ 0invalidNumber, str, 1invalid]");
auto res = Reader::parseArray(reader, logger);
- ASSERT_FALSE(res.first);
+ ASSERT_TRUE(res.first);
// Make sure the array has the correct size
- ASSERT_EQ(3, res.second.size());
+ ASSERT_EQ(3U, res.second.size());
- // Check the types (only for the valid entries, the other types are
- // undefined)
+ // Check the types (all must be strings since the numbers are invalid)
+ ASSERT_TRUE(res.second[0].isString());
ASSERT_TRUE(res.second[1].isString());
+ ASSERT_TRUE(res.second[2].isString());
// Check the values
+ ASSERT_EQ("0invalidNumber", res.second[0].asString());
ASSERT_EQ("str", res.second[1].asString());
+ ASSERT_EQ("1invalid", res.second[2].asString());
}
}