diff --git a/test/src/unit-constructor1.cpp b/test/src/unit-constructor1.cpp index 6bba7019c..b3354b58f 100644 --- a/test/src/unit-constructor1.cpp +++ b/test/src/unit-constructor1.cpp @@ -699,6 +699,15 @@ TEST_CASE("constructors") json j(n); CHECK(j.type() == json::value_t::number_float); } + + SECTION("infinity") + { + // infinity is stored as null + // should change in the future: https://github.com/nlohmann/json/issues/388 + json::number_float_t n(std::numeric_limits::infinity()); + json j(n); + CHECK(j.type() == json::value_t::null); + } } SECTION("create a floating-point number (implicit)") diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index 106e37de4..e4545fbe7 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -182,6 +182,10 @@ TEST_CASE("value conversion") std::vector v; CHECK_THROWS_AS(nlohmann::from_json(j, v), std::logic_error); CHECK(v.capacity() == j.size()); + + // make sure all values are properly copied + std::vector v2 = json({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); + CHECK(v2.size() == 10); } #endif } diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 83bb371ac..7980371bc 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -63,7 +63,7 @@ TEST_CASE("regression tests") SECTION("pull request #71 - handle enum type") { - enum { t = 0, u = 1}; + enum { t = 0, u = 102}; json j = json::array(); j.push_back(t); @@ -73,6 +73,9 @@ TEST_CASE("regression tests") auto anon_enum_value = j2.get(); CHECK(u == anon_enum_value); + // check if the actual value was stored + CHECK(j2 == 102); + static_assert(std::is_same::value, ""); j.push_back(json::object(