fix test

parent 1b04092c
...@@ -43,6 +43,8 @@ static int assert_counter; ...@@ -43,6 +43,8 @@ static int assert_counter;
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using nlohmann::json;
// the test assumes exceptions to work
#if not defined(JSON_NOEXCEPTION)
TEST_CASE("JSON_ASSERT(x)") TEST_CASE("JSON_ASSERT(x)")
{ {
SECTION("basic_json(first, second)") SECTION("basic_json(first, second)")
...@@ -53,8 +55,11 @@ TEST_CASE("JSON_ASSERT(x)") ...@@ -53,8 +55,11 @@ TEST_CASE("JSON_ASSERT(x)")
json::iterator it; json::iterator it;
json j; json j;
// in case assertions do not abort execution, an exception is thrown
CHECK_THROWS_WITH_AS(json(it, j.end()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator); CHECK_THROWS_WITH_AS(json(it, j.end()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator);
// check that assertion actually happened
CHECK(assert_counter == 1); CHECK(assert_counter == 1);
} }
} }
#endif
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