From 1b113f73c2c79e7bd2c659b153becba747007bb1 Mon Sep 17 00:00:00 2001 From: Anthony VH Date: Sat, 9 Jan 2021 17:54:56 +0100 Subject: [PATCH] Added extra tests to improve coverage. --- test/src/unit-regression2.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index e2adff862..1046bb2e5 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -525,10 +525,18 @@ TEST_CASE("regression tests 2") { SECTION("std::array") { - json j = { 7, 4 }; - auto arr = j.get>(); - CHECK(arr[0].x == 7); - CHECK(arr[1].x == 4); + { + json j = { 7, 4 }; + auto arr = j.get>(); + CHECK(arr[0].x == 7); + CHECK(arr[1].x == 4); + + } + + { + json j = 7; + CHECK_THROWS_AS((j.get>()), json::type_error); + } } SECTION("std::pair") @@ -556,6 +564,11 @@ TEST_CASE("regression tests 2") CHECK(p.first.x == 6); CHECK(p.second == 7); } + + { + json j = 7; + CHECK_THROWS_AS((j.get>()), json::type_error); + } } SECTION("std::tuple") @@ -573,6 +586,11 @@ TEST_CASE("regression tests 2") CHECK(std::get<1>(t) == 8); CHECK(std::get<2>(t).x == 7); } + + { + json j = 7; + CHECK_THROWS_AS((j.get>()), json::type_error); + } } } }