mirror of
https://github.com/nlohmann/json
synced 2024-11-23 20:40:08 +00:00
Merge branch 'feature/noexcept_exceptions' into develop
This commit is contained in:
commit
d4d51460ab
@ -894,7 +894,7 @@ $ make json_unit -Ctest
|
||||
$ ./test/json_unit "*"
|
||||
|
||||
===============================================================================
|
||||
All tests passed (11202597 assertions in 47 test cases)
|
||||
All tests passed (11203022 assertions in 48 test cases)
|
||||
```
|
||||
|
||||
Alternatively, you can use [CMake](https://cmake.org) and run
|
||||
|
342
src/json.hpp
342
src/json.hpp
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -57,3 +57,21 @@ static_assert(noexcept(json(pod{})), "");
|
||||
static_assert(noexcept(j.get<pod>()), "");
|
||||
static_assert(not noexcept(j.get<pod_bis>()), "");
|
||||
static_assert(noexcept(json(pod{})), "");
|
||||
|
||||
TEST_CASE("runtime checks")
|
||||
{
|
||||
SECTION("nothrow-copy-constructible exceptions")
|
||||
{
|
||||
// for ERR60-CPP (https://github.com/nlohmann/json/issues/531):
|
||||
// Exceptions should be nothrow-copy-constructible. However, compilers
|
||||
// treat std::runtime_exception differently in this regard. Therefore,
|
||||
// we can only demand nothrow-copy-constructibility for our exceptions
|
||||
// if std::runtime_exception is.
|
||||
CHECK(std::is_nothrow_copy_constructible<json::exception>::value == std::is_nothrow_copy_constructible<std::runtime_error>::value);
|
||||
CHECK(std::is_nothrow_copy_constructible<json::parse_error>::value == std::is_nothrow_copy_constructible<std::runtime_error>::value);
|
||||
CHECK(std::is_nothrow_copy_constructible<json::invalid_iterator>::value == std::is_nothrow_copy_constructible<std::runtime_error>::value);
|
||||
CHECK(std::is_nothrow_copy_constructible<json::type_error>::value == std::is_nothrow_copy_constructible<std::runtime_error>::value);
|
||||
CHECK(std::is_nothrow_copy_constructible<json::out_of_range>::value == std::is_nothrow_copy_constructible<std::runtime_error>::value);
|
||||
CHECK(std::is_nothrow_copy_constructible<json::other_error>::value == std::is_nothrow_copy_constructible<std::runtime_error>::value);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user