aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-08-24 13:37:43 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-08-24 13:44:05 +0200
commitda9beb288d2ee35b9c70513dd18f220b2dc32f16 (patch)
tree5ab71efddf30d8db28357573e5892075998d731b /src/test
parent561f8af45040d9b306a85023d916b3196956bfdc (diff)
parente938122b7ba8723c8cab6de78e8a9b39ad188589 (diff)
Merge pull request #6576
e938122 Stop parsing JSON after first finished construct. (Daniel Kraft)
Diffstat (limited to 'src/test')
-rw-r--r--src/test/univalue_tests.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/univalue_tests.cpp b/src/test/univalue_tests.cpp
index 67cb9b9623..ee31c0955b 100644
--- a/src/test/univalue_tests.cpp
+++ b/src/test/univalue_tests.cpp
@@ -314,6 +314,21 @@ BOOST_AUTO_TEST_CASE(univalue_readwrite)
BOOST_CHECK(obj["key3"].isObject());
BOOST_CHECK_EQUAL(strJson1, v.write());
+
+ /* Check for (correctly reporting) a parsing error if the initial
+ JSON construct is followed by more stuff. Note that whitespace
+ is, of course, exempt. */
+
+ BOOST_CHECK(v.read(" {}\n "));
+ BOOST_CHECK(v.isObject());
+ BOOST_CHECK(v.read(" []\n "));
+ BOOST_CHECK(v.isArray());
+
+ BOOST_CHECK(!v.read("@{}"));
+ BOOST_CHECK(!v.read("{} garbage"));
+ BOOST_CHECK(!v.read("[]{}"));
+ BOOST_CHECK(!v.read("{}[]"));
+ BOOST_CHECK(!v.read("{} 42"));
}
BOOST_AUTO_TEST_SUITE_END()