From 6f89613acde82b81e824af5e43be132369c02fbf Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 23 Dec 2018 13:56:18 +0100 Subject: [PATCH] :rotating_light: fixed some warnings --- Makefile | 2 + .../nlohmann/detail/output/binary_writer.hpp | 4 +- single_include/nlohmann/json.hpp | 4 +- test/src/unit-bson.cpp | 14 +++--- test/src/unit-cbor.cpp | 46 +++++++++---------- test/src/unit-class_parser.cpp | 34 +++++++------- test/src/unit-comparison.cpp | 38 +++++++-------- test/src/unit-deserialization.cpp | 6 +-- test/src/unit-json_patch.cpp | 2 +- test/src/unit-msgpack.cpp | 42 ++++++++--------- test/src/unit-regression.cpp | 20 ++++---- test/src/unit-testsuites.cpp | 42 ++++++++--------- test/src/unit-to_chars.cpp | 12 ++--- test/src/unit-ubjson.cpp | 42 ++++++++--------- test/src/unit-unicode.cpp | 30 ++++++------ 15 files changed, 170 insertions(+), 168 deletions(-) diff --git a/Makefile b/Makefile index b6784151..9dd28947 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,7 @@ doctest: # -Wno-range-loop-analysis: items tests "for(const auto i...)" # -Wno-float-equal: not all comparisons in the tests can be replaced by Approx # -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches +# -Wno-c++2a-compat: u8 literals will behave differently in C++20... # -Wno-padded: padding is nothing to warn about pedantic_clang: $(MAKE) json_unit CXXFLAGS="\ @@ -131,6 +132,7 @@ pedantic_clang: -Wno-range-loop-analysis \ -Wno-float-equal \ -Wno-switch-enum -Wno-covered-switch-default \ + -Wno-c++2a-compat \ -Wno-padded" # calling GCC with most warnings diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index ca819540..2f1eed4b 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -933,7 +933,7 @@ class binary_writer assert(false); return 0ul; // LCOV_EXCL_STOP - }; + } } /*! @@ -977,7 +977,7 @@ class binary_writer assert(false); return; // LCOV_EXCL_STOP - }; + } } /*! diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index c9af0bed..5604944e 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -9374,7 +9374,7 @@ class binary_writer assert(false); return 0ul; // LCOV_EXCL_STOP - }; + } } /*! @@ -9418,7 +9418,7 @@ class binary_writer assert(false); return; // LCOV_EXCL_STOP - }; + } } /*! diff --git a/test/src/unit-bson.cpp b/test/src/unit-bson.cpp index 791e47df..7ae7db36 100644 --- a/test/src/unit-bson.cpp +++ b/test/src/unit-bson.cpp @@ -821,7 +821,7 @@ TEST_CASE("BSON numerical data") for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) json j = { @@ -893,7 +893,7 @@ TEST_CASE("BSON numerical data") for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) json j = { @@ -946,7 +946,7 @@ TEST_CASE("BSON numerical data") for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) json j = { @@ -1008,7 +1008,7 @@ TEST_CASE("BSON numerical data") for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) json j = { @@ -1063,7 +1063,7 @@ TEST_CASE("BSON numerical data") for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) json j = { @@ -1113,7 +1113,7 @@ TEST_CASE("BSON numerical data") for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) json j = { @@ -1159,7 +1159,7 @@ TEST_CASE("BSON roundtrips", "[hide]") "test/data/json.org/5.json" }) { - CAPTURE(filename); + CAPTURE(filename) SECTION(filename + ": std::vector") { diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index db7626e1..e96f4cd0 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -175,7 +175,7 @@ TEST_CASE("CBOR") numbers.push_back(-4294967297); for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -232,7 +232,7 @@ TEST_CASE("CBOR") numbers.push_back(-4294967296); for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -273,7 +273,7 @@ TEST_CASE("CBOR") { for (int32_t i = -65536; i <= -257; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -325,7 +325,7 @@ TEST_CASE("CBOR") { for (auto i = -256; i < -24; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -357,7 +357,7 @@ TEST_CASE("CBOR") { for (auto i = -24; i <= -1; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -387,7 +387,7 @@ TEST_CASE("CBOR") { for (size_t i = 0; i <= 23; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -418,7 +418,7 @@ TEST_CASE("CBOR") { for (size_t i = 24; i <= 255; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -451,7 +451,7 @@ TEST_CASE("CBOR") { for (size_t i = 256; i <= 65535; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -489,7 +489,7 @@ TEST_CASE("CBOR") 65536u, 77777u, 1048576u }) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -532,7 +532,7 @@ TEST_CASE("CBOR") 4294967296ul, 4611686018427387903ul }) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -580,7 +580,7 @@ TEST_CASE("CBOR") { for (int16_t i = -32768; i <= -129; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -616,7 +616,7 @@ TEST_CASE("CBOR") { for (size_t i = 0; i <= 23; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -646,7 +646,7 @@ TEST_CASE("CBOR") { for (size_t i = 24; i <= 255; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -679,7 +679,7 @@ TEST_CASE("CBOR") { for (size_t i = 256; i <= 65535; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -716,7 +716,7 @@ TEST_CASE("CBOR") 65536u, 77777u, 1048576u }) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -758,7 +758,7 @@ TEST_CASE("CBOR") 4294967296ul, 4611686018427387903ul }) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -934,7 +934,7 @@ TEST_CASE("CBOR") { for (size_t N = 0; N <= 0x17; ++N) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -968,7 +968,7 @@ TEST_CASE("CBOR") { for (size_t N = 24; N <= 255; ++N) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -1003,7 +1003,7 @@ TEST_CASE("CBOR") 256u, 999u, 1025u, 3333u, 2048u, 65535u }) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -1036,7 +1036,7 @@ TEST_CASE("CBOR") 65536u, 77777u, 1048576u }) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -1620,7 +1620,7 @@ TEST_CASE("CBOR regressions", "[!throws]") "test/data/cbor_regression/test21" }) { - CAPTURE(filename); + CAPTURE(filename) try { @@ -1825,7 +1825,7 @@ TEST_CASE("CBOR roundtrips", "[hide]") "test/data/nst_json_testsuite/test_parsing/y_structure_whitespace_array.json" }) { - CAPTURE(filename); + CAPTURE(filename) SECTION(filename + ": std::vector") { @@ -1968,7 +1968,7 @@ TEST_CASE("all CBOR first bytes", "[!throws]") { // check that parse_error.112 is only thrown if the // first byte is in the unsupported set - CAPTURE(e.what()); + CAPTURE(e.what()) if (std::find(unsupported.begin(), unsupported.end(), byte) != unsupported.end()) { CHECK(e.id == 112); diff --git a/test/src/unit-class_parser.cpp b/test/src/unit-class_parser.cpp index aaa39d62..2d2929ee 100644 --- a/test/src/unit-class_parser.cpp +++ b/test/src/unit-class_parser.cpp @@ -223,7 +223,7 @@ json parser_helper(const std::string& s) bool accept_helper(const std::string& s) { - CAPTURE(s); + CAPTURE(s) // 1. parse s without exceptions json j; @@ -1165,18 +1165,18 @@ TEST_CASE("parser class") if (valid(c)) { - CAPTURE(s1); + CAPTURE(s1) CHECK_NOTHROW(parser_helper(s1.c_str())); - CAPTURE(s2); + CAPTURE(s2) CHECK_NOTHROW(parser_helper(s2.c_str())); - CAPTURE(s3); + CAPTURE(s3) CHECK_NOTHROW(parser_helper(s3.c_str())); - CAPTURE(s4); + CAPTURE(s4) CHECK_NOTHROW(parser_helper(s4.c_str())); } else { - CAPTURE(s1); + CAPTURE(s1) CHECK_THROWS_AS(parser_helper(s1.c_str()), json::parse_error&); // only check error message if c is not a control character if (c > 0x1f) @@ -1185,7 +1185,7 @@ TEST_CASE("parser class") "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s1.substr(0, 7) + "'"); } - CAPTURE(s2); + CAPTURE(s2) CHECK_THROWS_AS(parser_helper(s2.c_str()), json::parse_error&); // only check error message if c is not a control character if (c > 0x1f) @@ -1194,7 +1194,7 @@ TEST_CASE("parser class") "[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s2.substr(0, 6) + "'"); } - CAPTURE(s3); + CAPTURE(s3) CHECK_THROWS_AS(parser_helper(s3.c_str()), json::parse_error&); // only check error message if c is not a control character if (c > 0x1f) @@ -1203,7 +1203,7 @@ TEST_CASE("parser class") "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s3.substr(0, 5) + "'"); } - CAPTURE(s4); + CAPTURE(s4) CHECK_THROWS_AS(parser_helper(s4.c_str()), json::parse_error&); // only check error message if c is not a control character if (c > 0x1f) @@ -1383,27 +1383,27 @@ TEST_CASE("parser class") if (valid(c)) { - CAPTURE(s1); + CAPTURE(s1) CHECK(json::parser(nlohmann::detail::input_adapter(std::string(s1.c_str()))).accept()); - CAPTURE(s2); + CAPTURE(s2) CHECK(json::parser(nlohmann::detail::input_adapter(std::string(s2.c_str()))).accept()); - CAPTURE(s3); + CAPTURE(s3) CHECK(json::parser(nlohmann::detail::input_adapter(std::string(s3.c_str()))).accept()); - CAPTURE(s4); + CAPTURE(s4) CHECK(json::parser(nlohmann::detail::input_adapter(std::string(s4.c_str()))).accept()); } else { - CAPTURE(s1); + CAPTURE(s1) CHECK(json::parser(nlohmann::detail::input_adapter(std::string(s1.c_str()))).accept() == false); - CAPTURE(s2); + CAPTURE(s2) CHECK(json::parser(nlohmann::detail::input_adapter(std::string(s2.c_str()))).accept() == false); - CAPTURE(s3); + CAPTURE(s3) CHECK(json::parser(nlohmann::detail::input_adapter(std::string(s3.c_str()))).accept() == false); - CAPTURE(s4); + CAPTURE(s4) CHECK(json::parser(nlohmann::detail::input_adapter(std::string(s4.c_str()))).accept() == false); } } diff --git a/test/src/unit-comparison.cpp b/test/src/unit-comparison.cpp index 5c07a7ea..e729d1f2 100644 --- a/test/src/unit-comparison.cpp +++ b/test/src/unit-comparison.cpp @@ -74,8 +74,8 @@ TEST_CASE("lexicographical comparison operators") { for (size_t j = 0; j < j_types.size(); ++j) { - CAPTURE(i); - CAPTURE(j); + CAPTURE(i) + CAPTURE(j) // check precomputed values CHECK(operator<(j_types[i], j_types[j]) == expected[i][j]); CHECK(f(j_types[i], j_types[j]) == expected[i][j]); @@ -124,10 +124,10 @@ TEST_CASE("lexicographical comparison operators") { for (size_t j = 0; j < j_values.size(); ++j) { - CAPTURE(i); - CAPTURE(j); - CAPTURE(j_values[i]); - CAPTURE(j_values[j]); + CAPTURE(i) + CAPTURE(j) + CAPTURE(j_values[i]) + CAPTURE(j_values[j]) // check precomputed values CHECK( (j_values[i] == j_values[j]) == expected[i][j] ); } @@ -154,8 +154,8 @@ TEST_CASE("lexicographical comparison operators") { for (size_t j = 0; j < j_values.size(); ++j) { - CAPTURE(i); - CAPTURE(j); + CAPTURE(i) + CAPTURE(j) // check definition CHECK( (j_values[i] != j_values[j]) == not(j_values[i] == j_values[j]) ); } @@ -195,10 +195,10 @@ TEST_CASE("lexicographical comparison operators") { for (size_t j = 0; j < j_values.size(); ++j) { - CAPTURE(i); - CAPTURE(j); - CAPTURE(j_values[i]); - CAPTURE(j_values[j]); + CAPTURE(i) + CAPTURE(j) + CAPTURE(j_values[i]) + CAPTURE(j_values[j]) // check precomputed values CHECK( (j_values[i] < j_values[j]) == expected[i][j] ); } @@ -208,7 +208,7 @@ TEST_CASE("lexicographical comparison operators") json j_discarded(json::value_t::discarded); for (size_t i = 0; i < j_values.size(); ++i) { - CAPTURE(i); + CAPTURE(i) CHECK( (j_values[i] < j_discarded) == false); CHECK( (j_discarded < j_values[i]) == false); CHECK( (j_discarded < j_discarded) == false); @@ -221,8 +221,8 @@ TEST_CASE("lexicographical comparison operators") { for (size_t j = 0; j < j_values.size(); ++j) { - CAPTURE(i); - CAPTURE(j); + CAPTURE(i) + CAPTURE(j) // check definition CHECK( (j_values[i] <= j_values[j]) == not(j_values[j] < j_values[i]) ); } @@ -235,8 +235,8 @@ TEST_CASE("lexicographical comparison operators") { for (size_t j = 0; j < j_values.size(); ++j) { - CAPTURE(i); - CAPTURE(j); + CAPTURE(i) + CAPTURE(j) // check definition CHECK( (j_values[i] > j_values[j]) == (j_values[j] < j_values[i]) ); } @@ -249,8 +249,8 @@ TEST_CASE("lexicographical comparison operators") { for (size_t j = 0; j < j_values.size(); ++j) { - CAPTURE(i); - CAPTURE(j); + CAPTURE(i) + CAPTURE(j) // check definition CHECK( (j_values[i] >= j_values[j]) == not(j_values[i] < j_values[j]) ); } diff --git a/test/src/unit-deserialization.cpp b/test/src/unit-deserialization.cpp index 29e1454e..f92241ff 100644 --- a/test/src/unit-deserialization.cpp +++ b/test/src/unit-deserialization.cpp @@ -895,9 +895,9 @@ TEST_CASE("deserialization") for (int i2 = -1; i2 < 2; ++i2) { // debug output for the variations - CAPTURE(i0); - CAPTURE(i1); - CAPTURE(i2); + CAPTURE(i0) + CAPTURE(i1) + CAPTURE(i2) std::string s = ""; s.push_back(static_cast(bom[0] + i0)); diff --git a/test/src/unit-json_patch.cpp b/test/src/unit-json_patch.cpp index 1b407db0..b72f1148 100644 --- a/test/src/unit-json_patch.cpp +++ b/test/src/unit-json_patch.cpp @@ -1262,7 +1262,7 @@ TEST_CASE("JSON patch") "test/data/json-patch-tests/tests.json" }) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); json suite = json::parse(f); diff --git a/test/src/unit-msgpack.cpp b/test/src/unit-msgpack.cpp index 3dfee8a4..544ed224 100644 --- a/test/src/unit-msgpack.cpp +++ b/test/src/unit-msgpack.cpp @@ -163,7 +163,7 @@ TEST_CASE("MessagePack") { for (auto i = -32; i <= -1; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -193,7 +193,7 @@ TEST_CASE("MessagePack") { for (size_t i = 0; i <= 127; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -224,7 +224,7 @@ TEST_CASE("MessagePack") { for (size_t i = 128; i <= 255; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -258,7 +258,7 @@ TEST_CASE("MessagePack") { for (size_t i = 256; i <= 65535; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -296,7 +296,7 @@ TEST_CASE("MessagePack") 65536u, 77777u, 1048576u, 4294967295u }) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -339,7 +339,7 @@ TEST_CASE("MessagePack") 4294967296lu, 9223372036854775807lu }) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -387,7 +387,7 @@ TEST_CASE("MessagePack") { for (auto i = -128; i <= -33; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -435,7 +435,7 @@ TEST_CASE("MessagePack") { for (int16_t i = -32768; i <= -129; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -475,7 +475,7 @@ TEST_CASE("MessagePack") numbers.push_back(-2147483648ll); for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -517,7 +517,7 @@ TEST_CASE("MessagePack") numbers.push_back(-2147483649ll); for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -567,7 +567,7 @@ TEST_CASE("MessagePack") { for (size_t i = 0; i <= 127; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -597,7 +597,7 @@ TEST_CASE("MessagePack") { for (size_t i = 128; i <= 255; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -630,7 +630,7 @@ TEST_CASE("MessagePack") { for (size_t i = 256; i <= 65535; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -667,7 +667,7 @@ TEST_CASE("MessagePack") 65536u, 77777u, 1048576u, 4294967295u }) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -709,7 +709,7 @@ TEST_CASE("MessagePack") 4294967296lu, 18446744073709551615lu }) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -789,7 +789,7 @@ TEST_CASE("MessagePack") for (size_t N = 0; N < first_bytes.size(); ++N) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -826,7 +826,7 @@ TEST_CASE("MessagePack") { for (size_t N = 32; N <= 255; ++N) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -861,7 +861,7 @@ TEST_CASE("MessagePack") 256u, 999u, 1025u, 3333u, 2048u, 65535u }) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -894,7 +894,7 @@ TEST_CASE("MessagePack") 65536u, 77777u, 1048576u }) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -1003,7 +1003,7 @@ TEST_CASE("MessagePack") CHECK(result.size() == expected.size()); for (size_t i = 0; i < expected.size(); ++i) { - CAPTURE(i); + CAPTURE(i) CHECK(result[i] == expected[i]); } @@ -1517,7 +1517,7 @@ TEST_CASE("MessagePack roundtrips", "[hide]") "test/data/nst_json_testsuite/test_parsing/y_structure_whitespace_array.json" }) { - CAPTURE(filename); + CAPTURE(filename) SECTION(filename + ": std::vector") { diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 1db43f3d..8a94dff9 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -656,7 +656,7 @@ TEST_CASE("regression tests") "test/data/regression/working_file.json" }) { - CAPTURE(filename); + CAPTURE(filename) json j; std::ifstream f(filename); CHECK_NOTHROW(f >> j); @@ -672,7 +672,7 @@ TEST_CASE("regression tests") "test/data/regression/unsigned_ints.json" }) { - CAPTURE(filename); + CAPTURE(filename) json j; std::ifstream f(filename); CHECK_NOTHROW(f >> j); @@ -697,7 +697,7 @@ TEST_CASE("regression tests") { auto check_roundtrip = [](double number) { - CAPTURE(number); + CAPTURE(number) json j = number; CHECK(j.is_number_float()); @@ -900,7 +900,7 @@ TEST_CASE("regression tests") size_t i = 0; while (stream.peek() != EOF) { - CAPTURE(i); + CAPTURE(i) CHECK_NOTHROW(stream >> val); CHECK(i < 2); @@ -1109,12 +1109,12 @@ TEST_CASE("regression tests") CHECK_FALSE((json(v) != v));\ CHECK_FALSE((v != json(v))); - CHECK_TYPE(nullptr); - CHECK_TYPE(0); - CHECK_TYPE(0u); - CHECK_TYPE(0L); - CHECK_TYPE(0.0); - CHECK_TYPE(""); + CHECK_TYPE(nullptr) + CHECK_TYPE(0) + CHECK_TYPE(0u) + CHECK_TYPE(0L) + CHECK_TYPE(0.0) + CHECK_TYPE("") #undef CHECK_TYPE } diff --git a/test/src/unit-testsuites.cpp b/test/src/unit-testsuites.cpp index e30aeee5..f930c974 100644 --- a/test/src/unit-testsuites.cpp +++ b/test/src/unit-testsuites.cpp @@ -77,7 +77,7 @@ TEST_CASE("compliance tests from json.org") "test/data/json_tests/fail33.json" }) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); CHECK_THROWS_AS(json::parse(f), json::parse_error&); } @@ -95,7 +95,7 @@ TEST_CASE("compliance tests from json.org") "test/data/json_tests/fail10.json", }) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); json j; CHECK_NOTHROW(f >> j); @@ -111,7 +111,7 @@ TEST_CASE("compliance tests from json.org") "test/data/json_tests/pass3.json" }) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); json j; CHECK_NOTHROW(f >> j); @@ -127,8 +127,8 @@ TEST_CASE("compliance tests from nativejson-benchmark") { auto TEST_DOUBLE = [](const std::string & json_string, const double expected) { - CAPTURE(json_string); - CAPTURE(expected); + CAPTURE(json_string) + CAPTURE(expected) CHECK(json::parse(json_string)[0].get() == Approx(expected)); }; @@ -263,8 +263,8 @@ TEST_CASE("compliance tests from nativejson-benchmark") { auto TEST_STRING = [](const std::string & json_string, const std::string & expected) { - CAPTURE(json_string); - CAPTURE(expected); + CAPTURE(json_string) + CAPTURE(expected) CHECK(json::parse(json_string)[0].get() == expected); }; @@ -319,12 +319,12 @@ TEST_CASE("compliance tests from nativejson-benchmark") //"test/data/json_roundtrip/roundtrip32.json" // same as roundtrip31 }) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); std::string json_string( (std::istreambuf_iterator(f) ), (std::istreambuf_iterator()) ); - CAPTURE(json_string); + CAPTURE(json_string) json j = json::parse(json_string); CHECK(j.dump() == json_string); } @@ -600,7 +600,7 @@ TEST_CASE("nst's JSONTestSuite") } ) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); json j; CHECK_NOTHROW(f >> j); @@ -809,7 +809,7 @@ TEST_CASE("nst's JSONTestSuite") } ) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); CHECK_THROWS_AS(json::parse(f), json::parse_error&); } @@ -841,7 +841,7 @@ TEST_CASE("nst's JSONTestSuite") } ) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); json j; CHECK_NOTHROW(f >> j); @@ -864,7 +864,7 @@ TEST_CASE("nst's JSONTestSuite") } ) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); json j; CHECK_NOTHROW(f >> j); @@ -884,7 +884,7 @@ TEST_CASE("nst's JSONTestSuite") } ) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); json j; CHECK_THROWS_AS(f >> j, json::out_of_range&); @@ -911,7 +911,7 @@ TEST_CASE("nst's JSONTestSuite") } ) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); json j; CHECK_THROWS_AS(f >> j, json::parse_error&); @@ -1026,7 +1026,7 @@ TEST_CASE("nst's JSONTestSuite (2)") } ) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); CHECK_NOTHROW(json::parse(f)); std::ifstream f2(filename); @@ -1227,7 +1227,7 @@ TEST_CASE("nst's JSONTestSuite (2)") } ) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); CHECK_THROWS_AS(json::parse(f), json::parse_error&); std::ifstream f2(filename); @@ -1244,7 +1244,7 @@ TEST_CASE("nst's JSONTestSuite (2)") } ) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); CHECK(not json::accept(f)); } @@ -1292,7 +1292,7 @@ TEST_CASE("nst's JSONTestSuite (2)") } ) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); CHECK_NOTHROW(json::parse(f)); std::ifstream f2(filename); @@ -1342,7 +1342,7 @@ TEST_CASE("nst's JSONTestSuite (2)") } ) { - CAPTURE(filename); + CAPTURE(filename) std::ifstream f(filename); CHECK_THROWS_AS(json::parse(f), json::exception&); // could be parse_error or out_of_range std::ifstream f2(filename); @@ -1399,7 +1399,7 @@ TEST_CASE("Big List of Naughty Strings") } // check roundtrip - CAPTURE(line); + CAPTURE(line) json j = json::parse(line); CHECK(j.dump() == line); } diff --git a/test/src/unit-to_chars.cpp b/test/src/unit-to_chars.cpp index 223d9c22..fd2ee121 100644 --- a/test/src/unit-to_chars.cpp +++ b/test/src/unit-to_chars.cpp @@ -146,9 +146,9 @@ TEST_CASE("digit gen") { auto check_float = [](float number, const std::string & digits, int expected_exponent) { - CAPTURE(number); - CAPTURE(digits); - CAPTURE(expected_exponent); + CAPTURE(number) + CAPTURE(digits) + CAPTURE(expected_exponent) char buf[32]; int len = 0; @@ -210,9 +210,9 @@ TEST_CASE("digit gen") { auto check_double = [](double number, const std::string & digits, int expected_exponent) { - CAPTURE(number); - CAPTURE(digits); - CAPTURE(expected_exponent); + CAPTURE(number) + CAPTURE(digits) + CAPTURE(expected_exponent) char buf[32]; int len = 0; diff --git a/test/src/unit-ubjson.cpp b/test/src/unit-ubjson.cpp index 6760ae6c..6279a5d3 100644 --- a/test/src/unit-ubjson.cpp +++ b/test/src/unit-ubjson.cpp @@ -175,7 +175,7 @@ TEST_CASE("UBJSON") numbers.push_back(-2147483649ll); for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -230,7 +230,7 @@ TEST_CASE("UBJSON") numbers.push_back(-2147483647 - 1); // https://stackoverflow.com/a/29356002/266378 for (auto i : numbers) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -269,7 +269,7 @@ TEST_CASE("UBJSON") { for (int32_t i = -32768; i <= -129; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -323,7 +323,7 @@ TEST_CASE("UBJSON") { for (auto i = -128; i <= -1; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -355,7 +355,7 @@ TEST_CASE("UBJSON") { for (size_t i = 0; i <= 127; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -388,7 +388,7 @@ TEST_CASE("UBJSON") { for (size_t i = 128; i <= 255; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -421,7 +421,7 @@ TEST_CASE("UBJSON") { for (size_t i = 256; i <= 32767; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -459,7 +459,7 @@ TEST_CASE("UBJSON") 65536u, 77777u, 1048576u }) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -500,7 +500,7 @@ TEST_CASE("UBJSON") std::vector v = {2147483648ul, 9223372036854775807ul}; for (uint64_t i : v) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = -1; @@ -551,7 +551,7 @@ TEST_CASE("UBJSON") { for (size_t i = 0; i <= 127; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -584,7 +584,7 @@ TEST_CASE("UBJSON") { for (size_t i = 128; i <= 255; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -617,7 +617,7 @@ TEST_CASE("UBJSON") { for (size_t i = 256; i <= 32767; ++i) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -654,7 +654,7 @@ TEST_CASE("UBJSON") 65536u, 77777u, 1048576u }) { - CAPTURE(i); + CAPTURE(i) // create JSON value with unsigned integer number json j = i; @@ -694,7 +694,7 @@ TEST_CASE("UBJSON") std::vector v = {2147483648ul, 9223372036854775807ul}; for (uint64_t i : v) { - CAPTURE(i); + CAPTURE(i) // create JSON value with integer number json j = i; @@ -765,7 +765,7 @@ TEST_CASE("UBJSON") { for (size_t N = 0; N <= 127; ++N) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -801,7 +801,7 @@ TEST_CASE("UBJSON") { for (size_t N = 128; N <= 255; ++N) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -837,7 +837,7 @@ TEST_CASE("UBJSON") 256u, 999u, 1025u, 3333u, 2048u, 32767u }) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -871,7 +871,7 @@ TEST_CASE("UBJSON") 65536u, 77777u, 1048576u }) { - CAPTURE(N); + CAPTURE(N) // create JSON value with string containing of N * 'x' const auto s = std::string(N, 'x'); @@ -2124,7 +2124,7 @@ TEST_CASE("all UBJSON first bytes", "[!throws]") for (auto i = 0; i < 256; ++i) { const auto byte = static_cast(i); - CAPTURE(byte); + CAPTURE(byte) try { @@ -2134,7 +2134,7 @@ TEST_CASE("all UBJSON first bytes", "[!throws]") { // check that parse_error.112 is only thrown if the // first byte is not in the supported set - CAPTURE(e.what()); + CAPTURE(e.what()) if (std::find(supported.begin(), supported.end(), byte) == supported.end()) { CHECK(e.id == 112); @@ -2197,7 +2197,7 @@ TEST_CASE("UBJSON roundtrips", "[hide]") "test/data/json_tests/pass3.json" }) { - CAPTURE(filename); + CAPTURE(filename) SECTION(filename + ": std::vector") { diff --git a/test/src/unit-unicode.cpp b/test/src/unit-unicode.cpp index 95d62178..57c3c505 100644 --- a/test/src/unit-unicode.cpp +++ b/test/src/unit-unicode.cpp @@ -45,10 +45,10 @@ void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 { std::string json_string; - CAPTURE(byte1); - CAPTURE(byte2); - CAPTURE(byte3); - CAPTURE(byte4); + CAPTURE(byte1) + CAPTURE(byte2) + CAPTURE(byte3) + CAPTURE(byte4) json_string += std::string(1, static_cast(byte1)); @@ -67,7 +67,7 @@ void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 json_string += std::string(1, static_cast(byte4)); } - CAPTURE(json_string); + CAPTURE(json_string) // store the string in a JSON value json j = json_string; @@ -125,30 +125,30 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte std::string json_string = "\""; - CAPTURE(byte1); + CAPTURE(byte1) json_string += std::string(1, static_cast(byte1)); if (byte2 != -1) { - CAPTURE(byte2); + CAPTURE(byte2) json_string += std::string(1, static_cast(byte2)); } if (byte3 != -1) { - CAPTURE(byte3); + CAPTURE(byte3) json_string += std::string(1, static_cast(byte3)); } if (byte4 != -1) { - CAPTURE(byte4); + CAPTURE(byte4) json_string += std::string(1, static_cast(byte4)); } json_string += "\""; - CAPTURE(json_string); + CAPTURE(json_string) if (success_expected) { @@ -1041,7 +1041,7 @@ TEST_CASE("Unicode", "[hide]") } json_text += "\""; - CAPTURE(json_text); + CAPTURE(json_text) CHECK_NOTHROW(json::parse(json_text)); } } @@ -1090,7 +1090,7 @@ TEST_CASE("Unicode", "[hide]") for (std::size_t cp = 0xD800u; cp <= 0xDBFFu; ++cp) { std::string json_text = "\"" + codepoint_to_unicode(cp) + "\""; - CAPTURE(json_text); + CAPTURE(json_text) CHECK_THROWS_AS(json::parse(json_text), json::parse_error&); } } @@ -1109,7 +1109,7 @@ TEST_CASE("Unicode", "[hide]") } std::string json_text = "\"" + codepoint_to_unicode(cp1) + codepoint_to_unicode(cp2) + "\""; - CAPTURE(json_text); + CAPTURE(json_text) CHECK_THROWS_AS(json::parse(json_text), json::parse_error&); } } @@ -1122,7 +1122,7 @@ TEST_CASE("Unicode", "[hide]") for (std::size_t cp = 0xDC00u; cp <= 0xDFFFu; ++cp) { std::string json_text = "\"" + codepoint_to_unicode(cp) + "\""; - CAPTURE(json_text); + CAPTURE(json_text) CHECK_THROWS_AS(json::parse(json_text), json::parse_error&); } } @@ -1203,7 +1203,7 @@ void roundtrip(bool success_expected, const std::string& s); void roundtrip(bool success_expected, const std::string& s) { - CAPTURE(s); + CAPTURE(s) // create JSON string value json j = s;