diff --git a/test/src/unit-constructor1.cpp b/test/src/unit-constructor1.cpp index e45edd4401f9e5694c237a63025b2ca157325f50..d8c9482cbc26418e3b8ffa8d86ea15a0b9333006 100644 --- a/test/src/unit-constructor1.cpp +++ b/test/src/unit-constructor1.cpp @@ -295,9 +295,12 @@ TEST_CASE("constructors") { json j{1}; - CHECK_THROWS((j.get>())); - CHECK_THROWS((j.get>())); - CHECK_THROWS((j.get>())); + CHECK_THROWS_AS((j.get>()), json::out_of_range); + CHECK_THROWS_WITH((j.get>()), "[json.exception.out_of_range.401] array index 1 is out of range"); + CHECK_THROWS_AS((j.get>()), json::out_of_range); + CHECK_THROWS_WITH((j.get>()), "[json.exception.out_of_range.401] array index 1 is out of range"); + CHECK_THROWS_AS((j.get>()), json::out_of_range); + CHECK_THROWS_WITH((j.get>()), "[json.exception.out_of_range.401] array index 1 is out of range"); } SECTION("std::forward_list") diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index 6a42bfb82030db3a5a56cb73cf8da3c0ac2428fd..fc37a1c85555e3bdc8f8f257f7ac29ffa320a3ee 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -1009,6 +1009,30 @@ TEST_CASE("value conversion") auto m5 = j5.get>(); } + SECTION("std::array") + { + auto m1 = j1.get>(); + auto m2 = j2.get>(); + auto m3 = j3.get>(); + auto m4 = j4.get>(); + auto m5 = j5.get>(); + + SECTION("std::array is larger than JSON") + { + std::array arr6 = {1, 2, 3, 4, 5, 6}; + CHECK_THROWS_AS(arr6 = j1, json::out_of_range); + CHECK_THROWS_WITH(arr6 = j1, "[json.exception.out_of_range.401] array index 4 is out of range"); + } + + SECTION("std::array is smaller than JSON") + { + std::array arr2 = {8, 9}; + arr2 = j1; + CHECK(arr2[0] == 1); + CHECK(arr2[1] == 2); + } + } + SECTION("std::valarray") { auto m1 = j1.get>(); diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 3b9f6b4a934bdcbec15b9d25459d1701b84a4cf3..b6f314c744b2a16370119f2c118316e11b175a08 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -1305,4 +1305,12 @@ TEST_CASE("regression tests") j = {{"nocopy", n}}; CHECK(j["nocopy"]["val"] == 0); } + + SECTION("issue #843 - converting to array not working") + { + json j; + std::array ar = {1, 1, 1, 1}; + j = ar; + ar = j; + } }