From cf7786887c7ca80d86112f6b9f0aeba8cb1f2f9c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 25 Mar 2017 17:35:57 +0100 Subject: [PATCH] :hammer: fixed check for is_nothrow_copy_constructible We now only demand our exceptions to be is_nothrow_copy_constructible if std::runtime_exception is. --- test/src/unit-noexcept.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/test/src/unit-noexcept.cpp b/test/src/unit-noexcept.cpp index ed362f65..f2fbc8e6 100644 --- a/test/src/unit-noexcept.cpp +++ b/test/src/unit-noexcept.cpp @@ -58,10 +58,19 @@ static_assert(noexcept(j.get()), ""); static_assert(not noexcept(j.get()), ""); static_assert(noexcept(json(pod{})), ""); -// for ERR60-CPP (https://github.com/nlohmann/json/issues/531) -static_assert(std::is_nothrow_copy_constructible::value, "json::exception must be nothrow copy constructible"); -static_assert(std::is_nothrow_copy_constructible::value, "json::parse_error must be nothrow copy constructible"); -static_assert(std::is_nothrow_copy_constructible::value, "json::invalid_iterator must be nothrow copy constructible"); -static_assert(std::is_nothrow_copy_constructible::value, "json::type_error must be nothrow copy constructible"); -static_assert(std::is_nothrow_copy_constructible::value, "json::out_of_range must be nothrow copy constructible"); -static_assert(std::is_nothrow_copy_constructible::value, "json::other_error must be nothrow copy constructible"); +TEST_CASE("runtime checks") +{ + SECTION("nothrow-copy-constructible exceptions") + { + // for ERR60-CPP (https://github.com/nlohmann/json/issues/531) + if (std::is_nothrow_copy_constructible::value) + { + CHECK(std::is_nothrow_copy_constructible::value); + CHECK(std::is_nothrow_copy_constructible::value); + CHECK(std::is_nothrow_copy_constructible::value); + CHECK(std::is_nothrow_copy_constructible::value); + CHECK(std::is_nothrow_copy_constructible::value); + CHECK(std::is_nothrow_copy_constructible::value); + } + } +}