From 1b04092c5c724941e75ed7b993440cec80e318b8 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 8 Jul 2020 12:38:46 +0200 Subject: [PATCH] :white_check_mark: fix test --- test/src/unit-assert_macro.cpp | 19 ++++++++++--------- test/src/unit-udt_macro.cpp | 12 ++++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/test/src/unit-assert_macro.cpp b/test/src/unit-assert_macro.cpp index c5cd3a01..416cda23 100644 --- a/test/src/unit-assert_macro.cpp +++ b/test/src/unit-assert_macro.cpp @@ -45,15 +45,16 @@ using nlohmann::json; TEST_CASE("JSON_ASSERT(x)") { - assert_counter = 0; - const json j = {{"bar", 1}}; - CHECK(assert_counter == 0); - - // accessing non-existing key in const value would assert - if (j["foo"] == 1) + SECTION("basic_json(first, second)") { - CHECK(true); - } + assert_counter = 0; + CHECK(assert_counter == 0); - CHECK(assert_counter == 1); + json::iterator it; + json j; + + CHECK_THROWS_WITH_AS(json(it, j.end()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator); + + CHECK(assert_counter == 1); + } } diff --git a/test/src/unit-udt_macro.cpp b/test/src/unit-udt_macro.cpp index a6b66e95..90d5e1cc 100644 --- a/test/src/unit-udt_macro.cpp +++ b/test/src/unit-udt_macro.cpp @@ -60,9 +60,9 @@ class person_with_private_data class person_without_private_data_1 { public: - std::string name = ""; - int age = 0; - json metadata = nullptr; + std::string name = ""; + int age = 0; + json metadata = nullptr; bool operator==(const person_without_private_data_1& rhs) const { @@ -82,9 +82,9 @@ class person_without_private_data_1 class person_without_private_data_2 { public: - std::string name = ""; - int age = 0; - json metadata = nullptr; + std::string name = ""; + int age = 0; + json metadata = nullptr; bool operator==(const person_without_private_data_2& rhs) const {