✨ option to switch off exceptions
This commit is contained in:
parent
74cbd30cd0
commit
1ab26ab367
6 changed files with 335 additions and 261 deletions
|
@ -75,7 +75,7 @@ test-%: src/unit-%.cpp ../src/json.hpp thirdparty/catch/catch.hpp
|
|||
@echo "[CXXLD] $@"
|
||||
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -DCATCH_CONFIG_MAIN $< -o $@
|
||||
|
||||
TEST_PATTERN = "*"
|
||||
TEST_PATTERN ?= "*"
|
||||
TEST_PREFIX = ""
|
||||
check: $(TESTCASES)
|
||||
@cd .. ; for testcase in $(TESTCASES); do echo "Executing $$testcase..."; $(TEST_PREFIX)test/$$testcase $(TEST_PATTERN) || exit 1; done
|
||||
|
|
|
@ -1187,7 +1187,7 @@ TEST_CASE("single CBOR roundtrip")
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("CBOR regressions")
|
||||
TEST_CASE("CBOR regressions", "[!throws]")
|
||||
{
|
||||
SECTION("fuzz test results")
|
||||
{
|
||||
|
|
|
@ -298,25 +298,6 @@ TEST_CASE("element access 2")
|
|||
CHECK(j_const.value("/array"_json_pointer, json({10, 100})) == json({1, 2, 3}));
|
||||
}
|
||||
|
||||
SECTION("access non-existing value")
|
||||
{
|
||||
CHECK(j.value("/not/existing"_json_pointer, 2) == 2);
|
||||
CHECK(j.value("/not/existing"_json_pointer, 2u) == 2u);
|
||||
CHECK(j.value("/not/existing"_json_pointer, false) == false);
|
||||
CHECK(j.value("/not/existing"_json_pointer, "bar") == "bar");
|
||||
CHECK(j.value("/not/existing"_json_pointer, 12.34) == Approx(12.34));
|
||||
CHECK(j.value("/not/existing"_json_pointer, json({{"foo", "bar"}})) == json({{"foo", "bar"}}));
|
||||
CHECK(j.value("/not/existing"_json_pointer, json({10, 100})) == json({10, 100}));
|
||||
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, 2) == 2);
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, 2u) == 2u);
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, false) == false);
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, "bar") == "bar");
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, 12.34) == Approx(12.34));
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, json({{"foo", "bar"}})) == json({{"foo", "bar"}}));
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, json({10, 100})) == json({10, 100}));
|
||||
}
|
||||
|
||||
SECTION("access on non-object type")
|
||||
{
|
||||
SECTION("null")
|
||||
|
@ -957,3 +938,37 @@ TEST_CASE("element access 2")
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("element access 2 (throwing tests)", "[!throws]")
|
||||
{
|
||||
SECTION("object")
|
||||
{
|
||||
json j = {{"integer", 1}, {"unsigned", 1u}, {"floating", 42.23}, {"null", nullptr}, {"string", "hello world"}, {"boolean", true}, {"object", json::object()}, {"array", {1, 2, 3}}};
|
||||
const json j_const = j;
|
||||
|
||||
SECTION("access specified element with default value")
|
||||
{
|
||||
SECTION("given a JSON pointer")
|
||||
{
|
||||
SECTION("access non-existing value")
|
||||
{
|
||||
CHECK(j.value("/not/existing"_json_pointer, 2) == 2);
|
||||
CHECK(j.value("/not/existing"_json_pointer, 2u) == 2u);
|
||||
CHECK(j.value("/not/existing"_json_pointer, false) == false);
|
||||
CHECK(j.value("/not/existing"_json_pointer, "bar") == "bar");
|
||||
CHECK(j.value("/not/existing"_json_pointer, 12.34) == Approx(12.34));
|
||||
CHECK(j.value("/not/existing"_json_pointer, json({{"foo", "bar"}})) == json({{"foo", "bar"}}));
|
||||
CHECK(j.value("/not/existing"_json_pointer, json({10, 100})) == json({10, 100}));
|
||||
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, 2) == 2);
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, 2u) == 2u);
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, false) == false);
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, "bar") == "bar");
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, 12.34) == Approx(12.34));
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, json({{"foo", "bar"}})) == json({{"foo", "bar"}}));
|
||||
CHECK(j_const.value("/not/existing"_json_pointer, json({10, 100})) == json({10, 100}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue