From d1735172127c37bfee7a816d96d34647cfff6494 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 2 Jan 2017 09:21:26 +0100 Subject: [PATCH] :lipstick: clean up --- src/json.hpp | 9 +++++++++ src/json.hpp.re2c | 9 +++++++++ test/src/unit-allocator.cpp | 20 ++++++++++++++++---- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 5dc8e67c..afa35baa 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -873,8 +873,17 @@ class basic_json break; } + case value_t::null: + { + break; + } + default: { + if (t == value_t::null) + { + throw std::domain_error("961c151d2e87f2686a955a9be24d316f1362bf21"); // LCOV_EXCL_LINE + } break; } } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 49bccb02..db0b4c88 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -873,8 +873,17 @@ class basic_json break; } + case value_t::null: + { + break; + } + default: { + if (t == value_t::null) + { + throw std::domain_error("961c151d2e87f2686a955a9be24d316f1362bf21"); // LCOV_EXCL_LINE + } break; } } diff --git a/test/src/unit-allocator.cpp b/test/src/unit-allocator.cpp index c439c1c3..04f6ac9d 100644 --- a/test/src/unit-allocator.cpp +++ b/test/src/unit-allocator.cpp @@ -141,7 +141,10 @@ TEST_CASE("controlled bad_alloc") { next_construct_fails = false; auto t = my_json::value_t::object; - auto clean_up = [](my_json::json_value& j){ my_allocator_clean_up(j.object); }; + auto clean_up = [](my_json::json_value & j) + { + my_allocator_clean_up(j.object); + }; CHECK_NOTHROW(my_json::json_value j(t); clean_up(j)); next_construct_fails = true; CHECK_THROWS_AS(my_json::json_value j(t), std::bad_alloc); @@ -151,7 +154,10 @@ TEST_CASE("controlled bad_alloc") { next_construct_fails = false; auto t = my_json::value_t::array; - auto clean_up = [](my_json::json_value& j){ my_allocator_clean_up(j.array); }; + auto clean_up = [](my_json::json_value & j) + { + my_allocator_clean_up(j.array); + }; CHECK_NOTHROW(my_json::json_value j(t); clean_up(j)); next_construct_fails = true; CHECK_THROWS_AS(my_json::json_value j(t), std::bad_alloc); @@ -161,7 +167,10 @@ TEST_CASE("controlled bad_alloc") { next_construct_fails = false; auto t = my_json::value_t::string; - auto clean_up = [](my_json::json_value& j){ my_allocator_clean_up(j.string); }; + auto clean_up = [](my_json::json_value & j) + { + my_allocator_clean_up(j.string); + }; CHECK_NOTHROW(my_json::json_value j(t); clean_up(j)); next_construct_fails = true; CHECK_THROWS_AS(my_json::json_value j(t), std::bad_alloc); @@ -173,7 +182,10 @@ TEST_CASE("controlled bad_alloc") { next_construct_fails = false; my_json::string_t v("foo"); - auto clean_up = [](my_json::json_value& j){ my_allocator_clean_up(j.string); }; + auto clean_up = [](my_json::json_value & j) + { + my_allocator_clean_up(j.string); + }; CHECK_NOTHROW(my_json::json_value j(v); clean_up(j)); next_construct_fails = true; CHECK_THROWS_AS(my_json::json_value j(v), std::bad_alloc);