fix test

parent 28ef8737
...@@ -45,15 +45,16 @@ using nlohmann::json; ...@@ -45,15 +45,16 @@ using nlohmann::json;
TEST_CASE("JSON_ASSERT(x)") TEST_CASE("JSON_ASSERT(x)")
{ {
assert_counter = 0; SECTION("basic_json(first, second)")
const json j = {{"bar", 1}};
CHECK(assert_counter == 0);
// accessing non-existing key in const value would assert
if (j["foo"] == 1)
{ {
CHECK(true); assert_counter = 0;
} CHECK(assert_counter == 0);
json::iterator it;
json j;
CHECK(assert_counter == 1); CHECK_THROWS_WITH_AS(json(it, j.end()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator);
CHECK(assert_counter == 1);
}
} }
...@@ -60,9 +60,9 @@ class person_with_private_data ...@@ -60,9 +60,9 @@ class person_with_private_data
class person_without_private_data_1 class person_without_private_data_1
{ {
public: public:
std::string name = ""; std::string name = "";
int age = 0; int age = 0;
json metadata = nullptr; json metadata = nullptr;
bool operator==(const person_without_private_data_1& rhs) const bool operator==(const person_without_private_data_1& rhs) const
{ {
...@@ -82,9 +82,9 @@ class person_without_private_data_1 ...@@ -82,9 +82,9 @@ class person_without_private_data_1
class person_without_private_data_2 class person_without_private_data_2
{ {
public: public:
std::string name = ""; std::string name = "";
int age = 0; int age = 0;
json metadata = nullptr; json metadata = nullptr;
bool operator==(const person_without_private_data_2& rhs) const bool operator==(const person_without_private_data_2& rhs) const
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment