Commit 1b113f73 authored by Anthony VH's avatar Anthony VH

Added extra tests to improve coverage.

parent c0a8b45b
...@@ -525,10 +525,18 @@ TEST_CASE("regression tests 2") ...@@ -525,10 +525,18 @@ TEST_CASE("regression tests 2")
{ {
SECTION("std::array") SECTION("std::array")
{ {
json j = { 7, 4 }; {
auto arr = j.get<std::array<NonDefaultConstructible, 2>>(); json j = { 7, 4 };
CHECK(arr[0].x == 7); auto arr = j.get<std::array<NonDefaultConstructible, 2>>();
CHECK(arr[1].x == 4); CHECK(arr[0].x == 7);
CHECK(arr[1].x == 4);
}
{
json j = 7;
CHECK_THROWS_AS((j.get<std::array<NonDefaultConstructible, 1>>()), json::type_error);
}
} }
SECTION("std::pair") SECTION("std::pair")
...@@ -556,6 +564,11 @@ TEST_CASE("regression tests 2") ...@@ -556,6 +564,11 @@ TEST_CASE("regression tests 2")
CHECK(p.first.x == 6); CHECK(p.first.x == 6);
CHECK(p.second == 7); CHECK(p.second == 7);
} }
{
json j = 7;
CHECK_THROWS_AS((j.get<std::pair<NonDefaultConstructible, int>>()), json::type_error);
}
} }
SECTION("std::tuple") SECTION("std::tuple")
...@@ -573,6 +586,11 @@ TEST_CASE("regression tests 2") ...@@ -573,6 +586,11 @@ TEST_CASE("regression tests 2")
CHECK(std::get<1>(t) == 8); CHECK(std::get<1>(t) == 8);
CHECK(std::get<2>(t).x == 7); CHECK(std::get<2>(t).x == 7);
} }
{
json j = 7;
CHECK_THROWS_AS((j.get<std::tuple<NonDefaultConstructible>>()), json::type_error);
}
} }
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment