✅ add regression test #2824
This commit is contained in:
parent
1c030cccf1
commit
2c030bac2c
@ -166,16 +166,16 @@ class sax_no_exception : public nlohmann::detail::json_sax_dom_parser<json>
|
||||
public:
|
||||
explicit sax_no_exception(json& j) : nlohmann::detail::json_sax_dom_parser<json>(j, false) {}
|
||||
|
||||
static bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex)
|
||||
static bool parse_error(std::size_t /*position*/, const std::string& /*last_token*/, const json::exception& ex)
|
||||
{
|
||||
error_string = ex.what();
|
||||
error_string = new std::string(ex.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::string error_string;
|
||||
static std::string* error_string;
|
||||
};
|
||||
|
||||
std::string sax_no_exception::error_string = "";
|
||||
std::string* sax_no_exception::error_string = nullptr;
|
||||
|
||||
|
||||
TEST_CASE("regression tests 2")
|
||||
@ -648,7 +648,8 @@ TEST_CASE("regression tests 2")
|
||||
sax_no_exception sax(j);
|
||||
|
||||
CHECK (!json::sax_parse("xyz", &sax));
|
||||
CHECK(sax_no_exception::error_string == "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: 'x'");
|
||||
CHECK(*sax_no_exception::error_string == "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: 'x'");
|
||||
delete sax_no_exception::error_string;
|
||||
}
|
||||
|
||||
SECTION("issue #2825 - Properly constrain the basic_json conversion operator")
|
||||
|
Loading…
Reference in New Issue
Block a user