From b792bf56601b33737b2abf2d10945d984075643f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 10 Aug 2021 10:29:13 +0200 Subject: [PATCH] :alembic: try minimal example --- test/src/unit-disabled_exceptions.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/src/unit-disabled_exceptions.cpp b/test/src/unit-disabled_exceptions.cpp index 31a9873cf..5a29958c9 100644 --- a/test/src/unit-disabled_exceptions.cpp +++ b/test/src/unit-disabled_exceptions.cpp @@ -53,11 +53,8 @@ class sax_no_exception : public nlohmann::detail::json_sax_dom_parser std::string* sax_no_exception::error_string = nullptr; // -#include // size_t #include // exception #include // runtime_error -#include // to_string -#include // vector // namespace nlohmann @@ -83,6 +80,13 @@ class exception : public std::exception class parse_error : public exception { public: + static parse_error create(const std::string& what_arg) + { + std::string w = "[json.exception.parse_error] " + what_arg; + return parse_error(w.c_str()); + } + + private: parse_error(const char* what_arg) : exception(what_arg) {} }; @@ -104,8 +108,7 @@ TEST_CASE("Tests with disabled exceptions") SECTION("test") { - std::string w = "[json.exception.parse_error] foo"; - auto error = nlohmann::detail2::parse_error(w.c_str()); + auto error = nlohmann::detail2::parse_error::create("foo"); CHECK(std::string(error.what()) == "[json.exception.parse_error] foo"); } }