From 7c2a187258738f3b1f83c987ac333a73ec68901b Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 20 Jun 2017 21:09:26 +0200 Subject: [PATCH] :white_check_mark: improved test coverage --- test/src/unit-comparison.cpp | 9 +++++++++ test/src/unit-deserialization.cpp | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/test/src/unit-comparison.cpp b/test/src/unit-comparison.cpp index ac243674..3219d595 100644 --- a/test/src/unit-comparison.cpp +++ b/test/src/unit-comparison.cpp @@ -31,6 +31,14 @@ SOFTWARE. #include "json.hpp" using nlohmann::json; +// helper function to check std::less +// see http://en.cppreference.com/w/cpp/utility/functional/less +template > +bool f(A a, B b, U u = U()) +{ + return u(a, b); +} + TEST_CASE("lexicographical comparison operators") { SECTION("types") @@ -69,6 +77,7 @@ TEST_CASE("lexicographical comparison operators") CAPTURE(j); // check precomputed values CHECK(operator<(j_types[i], j_types[j]) == expected[i][j]); + CHECK(f(j_types[i], j_types[j]) == expected[i][j]); } } } diff --git a/test/src/unit-deserialization.cpp b/test/src/unit-deserialization.cpp index 66fb5e1b..81ee2770 100644 --- a/test/src/unit-deserialization.cpp +++ b/test/src/unit-deserialization.cpp @@ -359,6 +359,13 @@ TEST_CASE("deserialization") CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); CHECK(not json::accept(std::begin(v), std::end(v))); } + + SECTION("case 16") + { + uint8_t v[] = {'{', '1', ',', ','}; + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK(not json::accept(std::begin(v), std::end(v))); + } } } }