From c1bf0025229e875310ae430c999381c0ca993b6c Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 11 Feb 2015 11:57:36 +0100 Subject: [PATCH] more test cases (objects, floats) --- test/unit.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/unit.cpp b/test/unit.cpp index 947e62a1..af01e450 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -4133,6 +4133,11 @@ TEST_CASE("parser class") CHECK(json::parser("{}").parse() == json(json::value_t::object)); CHECK(json::parser("{ }").parse() == json(json::value_t::object)); } + + SECTION("nonempty object") + { + CHECK(json::parser("{\"\": true, \"one\": 1, \"two\": null}").parse() == json({{"", true}, {"one", 1}, {"two", nullptr}})); + } } SECTION("number") @@ -4160,6 +4165,16 @@ TEST_CASE("parser class") } } + SECTION("floating-point") + { + SECTION("without exponent") + { + CHECK(json::parser("-128.5").parse() == json(-128.5)); + CHECK(json::parser("0.999").parse() == json(0.999)); + CHECK(json::parser("128.5").parse() == json(128.5)); + } + } + SECTION("invalid numbers") { CHECK_THROWS_AS(json::parser("01").parse(), std::invalid_argument);