mirror of
https://github.com/nlohmann/json.git
synced 2026-09-28 10:40:30 +00:00
Skip the vector<bool> failed-allocation check for VS 2015 with iterator debugging
AppVeyor's VS 2015 Debug build terminated in "converting into an existing value": to_json for std::vector<bool> default-constructs an array_t first, and VS 2015's std::vector default constructor is noexcept but, with iterator debugging, constructs its proxy through the test's allocator, which throws. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -487,9 +487,14 @@ TEST_CASE("a failed allocation leaves the value unchanged")
|
||||
CHECK_THROWS_AS(nlohmann::to_json(j, std::vector<int> {1, 2}), std::bad_alloc&);
|
||||
CHECK(j == "old");
|
||||
|
||||
// with iterator debugging, the default constructor of VS 2015's
|
||||
// std::vector is noexcept but constructs a proxy with the allocator,
|
||||
// which terminates when this allocator throws
|
||||
#if !(defined(_MSC_VER) && _MSC_VER < 1910 && defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL > 0)
|
||||
next_construct_fails = true;
|
||||
CHECK_THROWS_AS(nlohmann::to_json(j, std::vector<bool> {true, false}), std::bad_alloc&);
|
||||
CHECK(j == "old");
|
||||
#endif
|
||||
|
||||
next_construct_fails = true;
|
||||
CHECK_THROWS_AS(nlohmann::to_json(j, std::map<std::string, int> {{"a", 1}}), std::bad_alloc&);
|
||||
|
||||
Reference in New Issue
Block a user