diff --git a/tests/src/unit-bjdata.cpp b/tests/src/unit-bjdata.cpp index 41b78742b..091a92416 100644 --- a/tests/src/unit-bjdata.cpp +++ b/tests/src/unit-bjdata.cpp @@ -119,9 +119,9 @@ TEST_CASE_TEMPLATE_DEFINE("value_in_range_of trait", T, value_in_range_of_test) constexpr bool max_in_range = T::max_in_range; type val_min = std::numeric_limits::min(); - type val_min2 = val_min + 1; + type const val_min2 = val_min + 1; type val_max = std::numeric_limits::max(); - type val_max2 = val_max - 1; + type const val_max2 = val_max - 1; REQUIRE(CHAR_BIT == 8); @@ -209,10 +209,10 @@ TEST_CASE("BJData") { SECTION("binary_reader BJData LUT arrays are sorted") { - std::vector data; + std::vector const data; auto ia = nlohmann::detail::input_adapter(data); // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - nlohmann::detail::binary_reader br{std::move(ia), json::input_format_t::bjdata}; + nlohmann::detail::binary_reader const br{std::move(ia), json::input_format_t::bjdata}; CHECK(std::is_sorted(br.bjd_optimized_type_markers.begin(), br.bjd_optimized_type_markers.end())); CHECK(std::is_sorted(br.bjd_types_map.begin(), br.bjd_types_map.end())); @@ -223,7 +223,7 @@ TEST_CASE("BJData") SECTION("discarded") { // discarded values are not serialized - json j = json::value_t::discarded; + json const j = json::value_t::discarded; const auto result = json::to_bjdata(j); CHECK(result.empty()); } @@ -690,7 +690,7 @@ TEST_CASE("BJData") SECTION("4294967296..9223372036854775807 (int64)") { - std::vector v = {4294967296LU, 9223372036854775807LU}; + std::vector const v = {4294967296LU, 9223372036854775807LU}; for (uint64_t i : v) { CAPTURE(i) @@ -739,7 +739,7 @@ TEST_CASE("BJData") SECTION("9223372036854775808..18446744073709551615 (uint64)") { - std::vector v = {9223372036854775808ull, 18446744073709551615ull}; + std::vector const v = {9223372036854775808ull, 18446744073709551615ull}; for (uint64_t i : v) { CAPTURE(i) @@ -1010,7 +1010,7 @@ TEST_CASE("BJData") SECTION("4294967296..9223372036854775807 (int64)") { - std::vector v = {4294967296ul, 9223372036854775807ul}; + std::vector const v = {4294967296ul, 9223372036854775807ul}; for (uint64_t i : v) { CAPTURE(i) @@ -1058,7 +1058,7 @@ TEST_CASE("BJData") SECTION("9223372036854775808..18446744073709551615 (uint64)") { - std::vector v = {9223372036854775808ull, 18446744073709551615ull}; + std::vector const v = {9223372036854775808ull, 18446744073709551615ull}; for (uint64_t i : v) { CAPTURE(i) @@ -1140,7 +1140,7 @@ TEST_CASE("BJData") SECTION("no byte follows") { json _; - std::vector vec0 = {'h'}; + std::vector const vec0 = {'h'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vec0), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vec0, true, false).is_discarded()); } @@ -1148,7 +1148,7 @@ TEST_CASE("BJData") SECTION("only one byte follows") { json _; - std::vector vec1 = {'h', 0x00}; + std::vector const vec1 = {'h', 0x00}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vec1), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vec1, true, false).is_discarded()); } @@ -1161,21 +1161,21 @@ TEST_CASE("BJData") { SECTION("0 (0 00000 0000000000)") { - json j = json::from_bjdata(std::vector({'h', 0x00, 0x00})); + json const j = json::from_bjdata(std::vector({'h', 0x00, 0x00})); json::number_float_t d{j}; CHECK(d == 0.0); } SECTION("-0 (1 00000 0000000000)") { - json j = json::from_bjdata(std::vector({'h', 0x00, 0x80})); + json const j = json::from_bjdata(std::vector({'h', 0x00, 0x80})); json::number_float_t d{j}; CHECK(d == -0.0); } SECTION("2**-24 (0 00000 0000000001)") { - json j = json::from_bjdata(std::vector({'h', 0x01, 0x00})); + json const j = json::from_bjdata(std::vector({'h', 0x01, 0x00})); json::number_float_t d{j}; CHECK(d == std::pow(2.0, -24.0)); } @@ -1185,7 +1185,7 @@ TEST_CASE("BJData") { SECTION("infinity (0 11111 0000000000)") { - json j = json::from_bjdata(std::vector({'h', 0x00, 0x7c})); + json const j = json::from_bjdata(std::vector({'h', 0x00, 0x7c})); json::number_float_t d{j}; CHECK(d == std::numeric_limits::infinity()); CHECK(j.dump() == "null"); @@ -1193,7 +1193,7 @@ TEST_CASE("BJData") SECTION("-infinity (1 11111 0000000000)") { - json j = json::from_bjdata(std::vector({'h', 0x00, 0xfc})); + json const j = json::from_bjdata(std::vector({'h', 0x00, 0xfc})); json::number_float_t d{j}; CHECK(d == -std::numeric_limits::infinity()); CHECK(j.dump() == "null"); @@ -1204,21 +1204,21 @@ TEST_CASE("BJData") { SECTION("1 (0 01111 0000000000)") { - json j = json::from_bjdata(std::vector({'h', 0x00, 0x3c})); + json const j = json::from_bjdata(std::vector({'h', 0x00, 0x3c})); json::number_float_t d{j}; CHECK(d == 1); } SECTION("-2 (1 10000 0000000000)") { - json j = json::from_bjdata(std::vector({'h', 0x00, 0xc0})); + json const j = json::from_bjdata(std::vector({'h', 0x00, 0xc0})); json::number_float_t d{j}; CHECK(d == -2); } SECTION("65504 (0 11110 1111111111)") { - json j = json::from_bjdata(std::vector({'h', 0xff, 0x7b})); + json const j = json::from_bjdata(std::vector({'h', 0xff, 0x7b})); json::number_float_t d{j}; CHECK(d == 65504); } @@ -1226,16 +1226,16 @@ TEST_CASE("BJData") SECTION("infinity") { - json j = json::from_bjdata(std::vector({'h', 0x00, 0x7c})); - json::number_float_t d{j}; + json const j = json::from_bjdata(std::vector({'h', 0x00, 0x7c})); + json::number_float_t const d{j}; CHECK_FALSE(std::isfinite(d)); CHECK(j.dump() == "null"); } SECTION("NaN") { - json j = json::from_bjdata(std::vector({'h', 0x00, 0x7e })); - json::number_float_t d{j}; + json const j = json::from_bjdata(std::vector({'h', 0x00, 0x7e })); + json::number_float_t const d{j}; CHECK(std::isnan(d)); CHECK(j.dump() == "null"); } @@ -1245,7 +1245,7 @@ TEST_CASE("BJData") { SECTION("unsigned integer number") { - std::vector vec = {'H', 'i', 0x14, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'}; + std::vector const vec = {'H', 'i', 0x14, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'}; const auto j = json::from_bjdata(vec); CHECK(j.is_number_unsigned()); CHECK(j.dump() == "12345678901234567890"); @@ -1253,7 +1253,7 @@ TEST_CASE("BJData") SECTION("signed integer number") { - std::vector vec = {'H', 'i', 0x13, '-', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8'}; + std::vector const vec = {'H', 'i', 0x13, '-', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8'}; const auto j = json::from_bjdata(vec); CHECK(j.is_number_integer()); CHECK(j.dump() == "-123456789012345678"); @@ -1261,7 +1261,7 @@ TEST_CASE("BJData") SECTION("floating-point number") { - std::vector vec = {'H', 'i', 0x16, '3', '.', '1', '4', '1', '5', '9', '2', '6', '5', '3', '5', '8', '9', '7', '9', '3', '2', '3', '8', '4', '6'}; + std::vector const vec = {'H', 'i', 0x16, '3', '.', '1', '4', '1', '5', '9', '2', '6', '5', '3', '5', '8', '9', '7', '9', '3', '2', '3', '8', '4', '6'}; const auto j = json::from_bjdata(vec); CHECK(j.is_number_float()); CHECK(j.dump() == "3.141592653589793"); @@ -1270,18 +1270,18 @@ TEST_CASE("BJData") SECTION("errors") { // error while parsing length - std::vector vec0 = {'H', 'i'}; + std::vector const vec0 = {'H', 'i'}; CHECK(json::from_bjdata(vec0, true, false).is_discarded()); // error while parsing string - std::vector vec1 = {'H', 'i', '1'}; + std::vector const vec1 = {'H', 'i', '1'}; CHECK(json::from_bjdata(vec1, true, false).is_discarded()); json _; - std::vector vec2 = {'H', 'i', 2, '1', 'A', '3'}; + std::vector const vec2 = {'H', 'i', 2, '1', 'A', '3'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vec2), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing BJData high-precision number: invalid number text: 1A", json::parse_error); - std::vector vec3 = {'H', 'i', 2, '1', '.'}; + std::vector const vec3 = {'H', 'i', 2, '1', '.'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vec3), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing BJData high-precision number: invalid number text: 1.", json::parse_error); - std::vector vec4 = {'H', 2, '1', '0'}; + std::vector const vec4 = {'H', 2, '1', '0'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vec4), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing BJData size: expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x02", json::parse_error); } } @@ -1474,7 +1474,7 @@ TEST_CASE("BJData") // create JSON value with byte array containing of N * 'x' const auto s = std::vector(N, 'x'); - json j = json::binary(s); + json const j = json::binary(s); // create expected byte vector std::vector expected; @@ -1525,7 +1525,7 @@ TEST_CASE("BJData") // create JSON value with byte array containing of N * 'x' const auto s = std::vector(N, 'x'); - json j = json::binary(s); + json const j = json::binary(s); // create expected byte vector std::vector expected; @@ -1565,7 +1565,7 @@ TEST_CASE("BJData") // create JSON value with byte array containing of N * 'x' const auto s = std::vector(N, 'x'); - json j = json::binary(s); + json const j = json::binary(s); // create expected byte vector std::vector expected(N + 7, 'x'); @@ -1602,7 +1602,7 @@ TEST_CASE("BJData") // create JSON value with byte array containing of N * 'x' const auto s = std::vector(N, 'x'); - json j = json::binary(s); + json const j = json::binary(s); // create expected byte vector std::vector expected(N + 7, 'x'); @@ -1639,7 +1639,7 @@ TEST_CASE("BJData") // create JSON value with byte array containing of N * 'x' const auto s = std::vector(N, 'x'); - json j = json::binary(s); + json const j = json::binary(s); // create expected byte vector std::vector expected(N + 9, 'x'); @@ -1671,7 +1671,7 @@ TEST_CASE("BJData") { const std::size_t N = 10; const auto s = std::vector(N, 'x'); - json j = json::binary(s); + json const j = json::binary(s); SECTION("No Count No Type") { @@ -2110,7 +2110,7 @@ TEST_CASE("BJData") { SECTION("strict mode") { - std::vector vec = {'Z', 'Z'}; + std::vector const vec = {'Z', 'Z'}; SECTION("non-strict mode") { const auto result = json::from_bjdata(vec, false); @@ -2130,98 +2130,98 @@ TEST_CASE("BJData") { SECTION("start_array()") { - std::vector v = {'[', 'T', 'F', ']'}; + std::vector const v = {'[', 'T', 'F', ']'}; SaxCountdown scp(0); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("start_object()") { - std::vector v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'}; + std::vector const v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'}; SaxCountdown scp(0); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("key() in object") { - std::vector v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'}; + std::vector const v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'}; SaxCountdown scp(1); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("start_array(len)") { - std::vector v = {'[', '#', 'i', '2', 'T', 'F'}; + std::vector const v = {'[', '#', 'i', '2', 'T', 'F'}; SaxCountdown scp(0); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("start_object(len)") { - std::vector v = {'{', '#', 'i', '1', 3, 'f', 'o', 'o', 'F'}; + std::vector const v = {'{', '#', 'i', '1', 3, 'f', 'o', 'o', 'F'}; SaxCountdown scp(0); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("key() in object with length") { - std::vector v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'}; + std::vector const v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'}; SaxCountdown scp(1); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("start_array() in ndarray _ArraySize_") { - std::vector v = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 2, 1, 1, 2}; + std::vector const v = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 2, 1, 1, 2}; SaxCountdown scp(2); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("number_integer() in ndarray _ArraySize_") { - std::vector v = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 1, 1, 2}; + std::vector const v = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 1, 1, 2}; SaxCountdown scp(3); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("key() in ndarray _ArrayType_") { - std::vector v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4}; + std::vector const v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4}; SaxCountdown scp(6); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("string() in ndarray _ArrayType_") { - std::vector v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4}; + std::vector const v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4}; SaxCountdown scp(7); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("key() in ndarray _ArrayData_") { - std::vector v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4}; + std::vector const v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4}; SaxCountdown scp(8); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("string() in ndarray _ArrayData_") { - std::vector v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4}; + std::vector const v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4}; SaxCountdown scp(9); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("string() in ndarray _ArrayType_") { - std::vector v = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 3, 2, 6, 5, 4, 3, 2, 1}; + std::vector const v = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 3, 2, 6, 5, 4, 3, 2, 1}; SaxCountdown scp(11); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } SECTION("start_array() in ndarray _ArrayData_") { - std::vector v = {'[', '$', 'U', '#', '[', 'i', 2, 'i', 3, ']', 6, 5, 4, 3, 2, 1}; + std::vector const v = {'[', '$', 'U', '#', '[', 'i', 2, 'i', 3, ']', 6, 5, 4, 3, 2, 1}; SaxCountdown scp(13); CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata)); } @@ -2233,13 +2233,13 @@ TEST_CASE("BJData") { // create a single-character string for all number types std::vector s_i = {'S', 'i', 1, 'a'}; - std::vector s_U = {'S', 'U', 1, 'a'}; - std::vector s_I = {'S', 'I', 1, 0, 'a'}; - std::vector s_u = {'S', 'u', 1, 0, 'a'}; - std::vector s_l = {'S', 'l', 1, 0, 0, 0, 'a'}; - std::vector s_m = {'S', 'm', 1, 0, 0, 0, 'a'}; - std::vector s_L = {'S', 'L', 1, 0, 0, 0, 0, 0, 0, 0, 'a'}; - std::vector s_M = {'S', 'M', 1, 0, 0, 0, 0, 0, 0, 0, 'a'}; + std::vector const s_U = {'S', 'U', 1, 'a'}; + std::vector const s_I = {'S', 'I', 1, 0, 'a'}; + std::vector const s_u = {'S', 'u', 1, 0, 'a'}; + std::vector const s_l = {'S', 'l', 1, 0, 0, 0, 'a'}; + std::vector const s_m = {'S', 'm', 1, 0, 0, 0, 'a'}; + std::vector const s_L = {'S', 'L', 1, 0, 0, 0, 0, 0, 0, 0, 'a'}; + std::vector const s_M = {'S', 'M', 1, 0, 0, 0, 0, 0, 0, 0, 'a'}; // check if string is parsed correctly to "a" CHECK(json::from_bjdata(s_i) == "a"); @@ -2267,11 +2267,11 @@ TEST_CASE("BJData") SECTION("float") { // float32 - std::vector v_d = {'d', 0xd0, 0x0f, 0x49, 0x40}; + std::vector const v_d = {'d', 0xd0, 0x0f, 0x49, 0x40}; CHECK(json::from_bjdata(v_d) == 3.14159f); // float64 - std::vector v_D = {'D', 0x6e, 0x86, 0x1b, 0xf0, 0xf9, 0x21, 0x09, 0x40}; + std::vector const v_D = {'D', 0x6e, 0x86, 0x1b, 0xf0, 0xf9, 0x21, 0x09, 0x40}; CHECK(json::from_bjdata(v_D) == 3.14159); // float32 is serialized as float64 as the library does not support float32 @@ -2284,7 +2284,7 @@ TEST_CASE("BJData") SECTION("optimized version (length only)") { // create vector with two elements of the same type - std::vector v_TU = {'[', '#', 'U', 2, 'T', 'T'}; + std::vector const v_TU = {'[', '#', 'U', 2, 'T', 'T'}; std::vector v_T = {'[', '#', 'i', 2, 'T', 'T'}; std::vector v_F = {'[', '#', 'i', 2, 'F', 'F'}; std::vector v_Z = {'[', '#', 'i', 2, 'Z', 'Z'}; @@ -2298,7 +2298,7 @@ TEST_CASE("BJData") std::vector v_M = {'[', '#', 'i', 2, 'M', 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 'M', 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; std::vector v_D = {'[', '#', 'i', 2, 'D', 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40, 'D', 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40}; std::vector v_S = {'[', '#', 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'}; - std::vector v_C = {'[', '#', 'i', 2, 'C', 'a', 'C', 'a'}; + std::vector const v_C = {'[', '#', 'i', 2, 'C', 'a', 'C', 'a'}; // check if vector is parsed correctly CHECK(json::from_bjdata(v_TU) == json({true, true})); @@ -2347,7 +2347,7 @@ TEST_CASE("BJData") std::vector v_M = {'[', '$', 'M', '#', 'i', 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; std::vector v_D = {'[', '$', 'D', '#', 'i', 2, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40}; std::vector v_S = {'[', '#', 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'}; - std::vector v_C = {'[', '$', 'C', '#', 'i', 2, 'a', 'a'}; + std::vector const v_C = {'[', '$', 'C', '#', 'i', 2, 'a', 'a'}; // check if vector is parsed correctly CHECK(json::from_bjdata(v_i) == json({127, 127})); @@ -2363,7 +2363,7 @@ TEST_CASE("BJData") CHECK(json::from_bjdata(v_C) == json({"a", "a"})); // roundtrip: output should be optimized - std::vector v_empty = {'[', '#', 'i', 0}; + std::vector const v_empty = {'[', '#', 'i', 0}; CHECK(json::to_bjdata(json::from_bjdata(v_i), true, true) == v_i); CHECK(json::to_bjdata(json::from_bjdata(v_U), true, true) == v_U); CHECK(json::to_bjdata(json::from_bjdata(v_I), true, true) == v_I); @@ -2380,19 +2380,19 @@ TEST_CASE("BJData") SECTION("optimized ndarray (type and vector-size as optimized 1D array)") { // create vector with two elements of the same type - std::vector v_0 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 1, 0}; - std::vector v_1 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 1, 2, 0x7F, 0x7F}; - std::vector v_i = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0x7F, 0x7F}; - std::vector v_U = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF}; - std::vector v_I = {'[', '$', 'I', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0x7F, 0xFF, 0x7F}; - std::vector v_u = {'[', '$', 'u', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0x0F, 0xA7, 0x0F, 0xA7}; - std::vector v_l = {'[', '$', 'l', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F}; - std::vector v_m = {'[', '$', 'm', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB}; - std::vector v_L = {'[', '$', 'L', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}; - std::vector v_M = {'[', '$', 'M', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; - std::vector v_D = {'[', '$', 'D', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40}; - std::vector v_S = {'[', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'}; - std::vector v_C = {'[', '$', 'C', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 'a', 'a'}; + std::vector const v_0 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 1, 0}; + std::vector const v_1 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 1, 2, 0x7F, 0x7F}; + std::vector const v_i = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0x7F, 0x7F}; + std::vector const v_U = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF}; + std::vector const v_I = {'[', '$', 'I', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0x7F, 0xFF, 0x7F}; + std::vector const v_u = {'[', '$', 'u', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0x0F, 0xA7, 0x0F, 0xA7}; + std::vector const v_l = {'[', '$', 'l', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F}; + std::vector const v_m = {'[', '$', 'm', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB}; + std::vector const v_L = {'[', '$', 'L', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}; + std::vector const v_M = {'[', '$', 'M', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; + std::vector const v_D = {'[', '$', 'D', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40}; + std::vector const v_S = {'[', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'}; + std::vector const v_C = {'[', '$', 'C', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 'a', 'a'}; // check if vector is parsed correctly CHECK(json::from_bjdata(v_0) == json::array()); @@ -2459,20 +2459,20 @@ TEST_CASE("BJData") SECTION("optimized ndarray (type and vector-size as 1D array)") { // create vector with two elements of the same type - std::vector v_0 = {'[', '$', 'i', '#', '[', ']'}; - std::vector v_E = {'[', '$', 'i', '#', '[', 'i', 2, 'i', 0, ']'}; - std::vector v_i = {'[', '$', 'i', '#', '[', 'i', 1, 'i', 2, ']', 0x7F, 0x7F}; - std::vector v_U = {'[', '$', 'U', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF}; - std::vector v_I = {'[', '$', 'I', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0x7F, 0xFF, 0x7F}; - std::vector v_u = {'[', '$', 'u', '#', '[', 'i', 1, 'i', 2, ']', 0x0F, 0xA7, 0x0F, 0xA7}; - std::vector v_l = {'[', '$', 'l', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F}; - std::vector v_m = {'[', '$', 'm', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB}; - std::vector v_L = {'[', '$', 'L', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}; - std::vector v_M = {'[', '$', 'M', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; - std::vector v_D = {'[', '$', 'D', '#', '[', 'i', 1, 'i', 2, ']', 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40}; - std::vector v_S = {'[', '#', '[', 'i', 1, 'i', 2, ']', 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'}; - std::vector v_C = {'[', '$', 'C', '#', '[', 'i', 1, 'i', 2, ']', 'a', 'a'}; - std::vector v_R = {'[', '#', '[', 'i', 2, ']', 'i', 6, 'U', 7}; + std::vector const v_0 = {'[', '$', 'i', '#', '[', ']'}; + std::vector const v_E = {'[', '$', 'i', '#', '[', 'i', 2, 'i', 0, ']'}; + std::vector const v_i = {'[', '$', 'i', '#', '[', 'i', 1, 'i', 2, ']', 0x7F, 0x7F}; + std::vector const v_U = {'[', '$', 'U', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF}; + std::vector const v_I = {'[', '$', 'I', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0x7F, 0xFF, 0x7F}; + std::vector const v_u = {'[', '$', 'u', '#', '[', 'i', 1, 'i', 2, ']', 0x0F, 0xA7, 0x0F, 0xA7}; + std::vector const v_l = {'[', '$', 'l', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F}; + std::vector const v_m = {'[', '$', 'm', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB}; + std::vector const v_L = {'[', '$', 'L', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}; + std::vector const v_M = {'[', '$', 'M', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; + std::vector const v_D = {'[', '$', 'D', '#', '[', 'i', 1, 'i', 2, ']', 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40}; + std::vector const v_S = {'[', '#', '[', 'i', 1, 'i', 2, ']', 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'}; + std::vector const v_C = {'[', '$', 'C', '#', '[', 'i', 1, 'i', 2, ']', 'a', 'a'}; + std::vector const v_R = {'[', '#', '[', 'i', 2, ']', 'i', 6, 'U', 7}; // check if vector is parsed correctly CHECK(json::from_bjdata(v_0) == json::array()); @@ -2494,17 +2494,17 @@ TEST_CASE("BJData") SECTION("optimized ndarray (type and vector-size as size-optimized array)") { // create vector with two elements of the same type - std::vector v_i = {'[', '$', 'i', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0x7F, 0x7F}; - std::vector v_U = {'[', '$', 'U', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF}; - std::vector v_I = {'[', '$', 'I', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0x7F, 0xFF, 0x7F}; - std::vector v_u = {'[', '$', 'u', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0x0F, 0xA7, 0x0F, 0xA7}; - std::vector v_l = {'[', '$', 'l', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F}; - std::vector v_m = {'[', '$', 'm', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB}; - std::vector v_L = {'[', '$', 'L', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}; - std::vector v_M = {'[', '$', 'M', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; - std::vector v_D = {'[', '$', 'D', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40}; - std::vector v_S = {'[', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'}; - std::vector v_C = {'[', '$', 'C', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 'a', 'a'}; + std::vector const v_i = {'[', '$', 'i', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0x7F, 0x7F}; + std::vector const v_U = {'[', '$', 'U', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF}; + std::vector const v_I = {'[', '$', 'I', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0x7F, 0xFF, 0x7F}; + std::vector const v_u = {'[', '$', 'u', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0x0F, 0xA7, 0x0F, 0xA7}; + std::vector const v_l = {'[', '$', 'l', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F}; + std::vector const v_m = {'[', '$', 'm', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB}; + std::vector const v_L = {'[', '$', 'L', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}; + std::vector const v_M = {'[', '$', 'M', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; + std::vector const v_D = {'[', '$', 'D', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40}; + std::vector const v_S = {'[', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'}; + std::vector const v_C = {'[', '$', 'C', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 'a', 'a'}; // check if vector is parsed correctly CHECK(json::from_bjdata(v_i) == json({127, 127})); @@ -2546,14 +2546,14 @@ TEST_CASE("BJData") { SECTION("eof after C byte") { - std::vector v = {'C'}; + std::vector const v = {'C'}; json _; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing BJData char: unexpected end of input", json::parse_error&); } SECTION("byte out of range") { - std::vector v = {'C', 130}; + std::vector const v = {'C', 130}; json _; CHECK_THROWS_WITH(_ = json::from_bjdata(v), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing BJData char: byte after 'C' must be in range 0x00..0x7F; last byte: 0x82"); } @@ -2563,14 +2563,14 @@ TEST_CASE("BJData") { SECTION("eof after S byte") { - std::vector v = {'S'}; + std::vector const v = {'S'}; json _; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing BJData value: unexpected end of input", json::parse_error&); } SECTION("invalid byte") { - std::vector v = {'S', '1', 'a'}; + std::vector const v = {'S', '1', 'a'}; json _; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing BJData string: expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x31", json::parse_error&); } @@ -2578,9 +2578,9 @@ TEST_CASE("BJData") SECTION("parse bjdata markers in ubjson") { // create a single-character string for all number types - std::vector s_u = {'S', 'u', 1, 0, 'a'}; - std::vector s_m = {'S', 'm', 1, 0, 0, 0, 'a'}; - std::vector s_M = {'S', 'M', 1, 0, 0, 0, 0, 0, 0, 0, 'a'}; + std::vector const s_u = {'S', 'u', 1, 0, 'a'}; + std::vector const s_m = {'S', 'm', 1, 0, 0, 0, 'a'}; + std::vector const s_M = {'S', 'M', 1, 0, 0, 0, 0, 0, 0, 0, 'a'}; json _; // check if string is parsed correctly to "a" @@ -2594,25 +2594,25 @@ TEST_CASE("BJData") { SECTION("optimized array: no size following type") { - std::vector v = {'[', '$', 'i', 2}; + std::vector const v = {'[', '$', 'i', 2}; json _; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v), "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing BJData size: expected '#' after type information; last byte: 0x02", json::parse_error&); } SECTION("optimized array: negative size") { - std::vector v1 = {'[', '#', 'i', 0xF1}; - std::vector v2 = {'[', '$', 'I', '#', 'i', 0xF2}; - std::vector v3 = {'[', '$', 'I', '#', '[', 'i', 0xF4, 'i', 0x02, ']'}; - std::vector v4 = {'[', '$', 0xF6, '#', 'i', 0xF7}; - std::vector v5 = {'[', '$', 'I', '#', '[', 'i', 0xF5, 'i', 0xF1, ']'}; - std::vector v6 = {'[', '#', '[', 'i', 0xF3, 'i', 0x02, ']'}; + std::vector const v1 = {'[', '#', 'i', 0xF1}; + std::vector const v2 = {'[', '$', 'I', '#', 'i', 0xF2}; + std::vector const v3 = {'[', '$', 'I', '#', '[', 'i', 0xF4, 'i', 0x02, ']'}; + std::vector const v4 = {'[', '$', 0xF6, '#', 'i', 0xF7}; + std::vector const v5 = {'[', '$', 'I', '#', '[', 'i', 0xF5, 'i', 0xF1, ']'}; + std::vector const v6 = {'[', '#', '[', 'i', 0xF3, 'i', 0x02, ']'}; - std::vector vI = {'[', '#', 'I', 0x00, 0xF1}; - std::vector vl = {'[', '#', 'l', 0x00, 0x00, 0x00, 0xF2}; - std::vector vL = {'[', '#', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF3}; - std::vector vM = {'[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']'}; - std::vector vMX = {'[', '$', 'U', '#', '[', 'M', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 'U', 0x01, ']'}; + std::vector const vI = {'[', '#', 'I', 0x00, 0xF1}; + std::vector const vl = {'[', '#', 'l', 0x00, 0x00, 0x00, 0xF2}; + std::vector const vL = {'[', '#', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF3}; + std::vector const vM = {'[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']'}; + std::vector const vMX = {'[', '$', 'U', '#', '[', 'M', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 'U', 0x01, ']'}; json _; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v1), "[json.exception.parse_error.113] parse error at byte 4: syntax error while parsing BJData size: count in an optimized container must be positive", json::parse_error&); @@ -2659,10 +2659,10 @@ TEST_CASE("BJData") SECTION("optimized array: integer value overflow") { - std::vector vL = {'[', '#', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F}; - std::vector vM = {'[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']'}; + std::vector const vL = {'[', '#', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F}; + std::vector const vM = {'[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']'}; - json _; + json const _; #if SIZE_MAX == 0xffffffff CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vL), "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", json::out_of_range&); CHECK(json::from_bjdata(vL, true, false).is_discarded()); @@ -2677,10 +2677,10 @@ TEST_CASE("BJData") SECTION("do not accept NTFZ markers in ndarray optimized type (with count)") { json _; - std::vector v_N = {'[', '$', 'N', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2}; - std::vector v_T = {'[', '$', 'T', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2}; - std::vector v_F = {'[', '$', 'F', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2}; - std::vector v_Z = {'[', '$', 'Z', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2}; + std::vector const v_N = {'[', '$', 'N', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2}; + std::vector const v_T = {'[', '$', 'T', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2}; + std::vector const v_F = {'[', '$', 'F', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2}; + std::vector const v_Z = {'[', '$', 'Z', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v_N), "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x4E is not a permitted optimized array type", json::parse_error&); CHECK(json::from_bjdata(v_N, true, false).is_discarded()); @@ -2698,10 +2698,10 @@ TEST_CASE("BJData") SECTION("do not accept NTFZ markers in ndarray optimized type (without count)") { json _; - std::vector v_N = {'[', '$', 'N', '#', '[', 'i', 1, 'i', 2, ']'}; - std::vector v_T = {'[', '$', 'T', '#', '[', 'i', 1, 'i', 2, ']'}; - std::vector v_F = {'[', '$', 'F', '#', '[', 'i', 1, 'i', 2, ']'}; - std::vector v_Z = {'[', '$', 'Z', '#', '[', 'i', 1, 'i', 2, ']'}; + std::vector const v_N = {'[', '$', 'N', '#', '[', 'i', 1, 'i', 2, ']'}; + std::vector const v_T = {'[', '$', 'T', '#', '[', 'i', 1, 'i', 2, ']'}; + std::vector const v_F = {'[', '$', 'F', '#', '[', 'i', 1, 'i', 2, ']'}; + std::vector const v_Z = {'[', '$', 'Z', '#', '[', 'i', 1, 'i', 2, ']'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v_N), "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x4E is not a permitted optimized array type", json::parse_error&); CHECK(json::from_bjdata(v_N, true, false).is_discarded()); @@ -2719,56 +2719,56 @@ TEST_CASE("BJData") SECTION("strings") { - std::vector vS = {'S'}; + std::vector const vS = {'S'}; json _; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vS), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing BJData value: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vS, true, false).is_discarded()); - std::vector v = {'S', 'i', '2', 'a'}; + std::vector const v = {'S', 'i', '2', 'a'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing BJData string: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(v, true, false).is_discarded()); - std::vector vC = {'C'}; + std::vector const vC = {'C'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vC), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing BJData char: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vC, true, false).is_discarded()); } SECTION("sizes") { - std::vector vU = {'[', '#', 'U'}; + std::vector const vU = {'[', '#', 'U'}; json _; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vU), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vU, true, false).is_discarded()); - std::vector vi = {'[', '#', 'i'}; + std::vector const vi = {'[', '#', 'i'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vi), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vi, true, false).is_discarded()); - std::vector vI = {'[', '#', 'I'}; + std::vector const vI = {'[', '#', 'I'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vI), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vI, true, false).is_discarded()); - std::vector vu = {'[', '#', 'u'}; + std::vector const vu = {'[', '#', 'u'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vu), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vu, true, false).is_discarded()); - std::vector vl = {'[', '#', 'l'}; + std::vector const vl = {'[', '#', 'l'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vl), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vl, true, false).is_discarded()); - std::vector vm = {'[', '#', 'm'}; + std::vector const vm = {'[', '#', 'm'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vm), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vm, true, false).is_discarded()); - std::vector vL = {'[', '#', 'L'}; + std::vector const vL = {'[', '#', 'L'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vL), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vL, true, false).is_discarded()); - std::vector vM = {'[', '#', 'M'}; + std::vector const vM = {'[', '#', 'M'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vM, true, false).is_discarded()); - std::vector v0 = {'[', '#', 'T', ']'}; + std::vector const v0 = {'[', '#', 'T', ']'}; CHECK_THROWS_WITH(_ = json::from_bjdata(v0), "[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing BJData size: expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x54"); CHECK(json::from_bjdata(v0, true, false).is_discarded()); } @@ -2776,185 +2776,185 @@ TEST_CASE("BJData") SECTION("parse bjdata markers as array size in ubjson") { json _; - std::vector vu = {'[', '#', 'u'}; + std::vector const vu = {'[', '#', 'u'}; CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vu), "[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x75", json::parse_error&); CHECK(json::from_ubjson(vu, true, false).is_discarded()); - std::vector vm = {'[', '#', 'm'}; + std::vector const vm = {'[', '#', 'm'}; CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vm), "[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x6D", json::parse_error&); CHECK(json::from_ubjson(vm, true, false).is_discarded()); - std::vector vM = {'[', '#', 'M'}; + std::vector const vM = {'[', '#', 'M'}; CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vM), "[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x4D", json::parse_error&); CHECK(json::from_ubjson(vM, true, false).is_discarded()); - std::vector v0 = {'[', '#', '['}; + std::vector const v0 = {'[', '#', '['}; CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v0), "[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x5B", json::parse_error&); CHECK(json::from_ubjson(v0, true, false).is_discarded()); } SECTION("types") { - std::vector v0 = {'[', '$'}; + std::vector const v0 = {'[', '$'}; json _; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v0), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing BJData type: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(v0, true, false).is_discarded()); - std::vector vi = {'[', '$', '#'}; + std::vector const vi = {'[', '$', '#'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vi), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData value: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vi, true, false).is_discarded()); - std::vector vU = {'[', '$', 'U'}; + std::vector const vU = {'[', '$', 'U'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vU), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData value: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vU, true, false).is_discarded()); - std::vector v1 = {'[', '$', '['}; + std::vector const v1 = {'[', '$', '['}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v1), "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x5B is not a permitted optimized array type", json::parse_error&); CHECK(json::from_bjdata(v1, true, false).is_discarded()); } SECTION("arrays") { - std::vector vST = {'[', '$', 'i', '#', 'i', 2, 1}; + std::vector const vST = {'[', '$', 'i', '#', 'i', 2, 1}; json _; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vST), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vST, true, false).is_discarded()); - std::vector vS = {'[', '#', 'i', 2, 'i', 1}; + std::vector const vS = {'[', '#', 'i', 2, 'i', 1}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vS), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing BJData value: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vS, true, false).is_discarded()); - std::vector v = {'[', 'i', 2, 'i', 1}; + std::vector const v = {'[', 'i', 2, 'i', 1}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing BJData value: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(v, true, false).is_discarded()); } SECTION("ndarrays") { - std::vector vST = {'[', '$', 'i', '#', '[', '$', 'i', '#'}; + std::vector const vST = {'[', '$', 'i', '#', '[', '$', 'i', '#'}; json _; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vST), "[json.exception.parse_error.113] parse error at byte 9: syntax error while parsing BJData size: expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0xFF", json::parse_error&); CHECK(json::from_bjdata(vST, true, false).is_discarded()); - std::vector v = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1, 2}; + std::vector const v = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1, 2}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v), "[json.exception.parse_error.110] parse error at byte 13: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(v, true, false).is_discarded()); - std::vector vS0 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1}; + std::vector const vS0 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vS0), "[json.exception.parse_error.110] parse error at byte 12: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vS0, true, false).is_discarded()); - std::vector vS = {'[', '$', 'i', '#', '[', '#', 'i', 2, 1, 2, 1}; + std::vector const vS = {'[', '$', 'i', '#', '[', '#', 'i', 2, 1, 2, 1}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vS), "[json.exception.parse_error.113] parse error at byte 9: syntax error while parsing BJData size: expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x01", json::parse_error&); CHECK(json::from_bjdata(vS, true, false).is_discarded()); - std::vector vT = {'[', '$', 'i', '#', '[', 'i', 2, 'i'}; + std::vector const vT = {'[', '$', 'i', '#', '[', 'i', 2, 'i'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vT), "[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vT, true, false).is_discarded()); - std::vector vT0 = {'[', '$', 'i', '#', '[', 'i'}; + std::vector const vT0 = {'[', '$', 'i', '#', '[', 'i'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vT0), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vT0, true, false).is_discarded()); - std::vector vu = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'u', 1, 0}; + std::vector const vu = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'u', 1, 0}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vu), "[json.exception.parse_error.110] parse error at byte 12: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vu, true, false).is_discarded()); - std::vector vm = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'm', 1, 0, 0, 0}; + std::vector const vm = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'm', 1, 0, 0, 0}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vm), "[json.exception.parse_error.110] parse error at byte 14: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vm, true, false).is_discarded()); - std::vector vM = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'M', 1, 0, 0, 0, 0, 0, 0, 0}; + std::vector const vM = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'M', 1, 0, 0, 0, 0, 0, 0, 0}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), "[json.exception.parse_error.110] parse error at byte 18: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vM, true, false).is_discarded()); - std::vector vU = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 1, 2, 3, 4, 5}; + std::vector const vU = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 1, 2, 3, 4, 5}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vU), "[json.exception.parse_error.110] parse error at byte 18: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vU, true, false).is_discarded()); - std::vector vT1 = {'[', '$', 'T', '#', '[', '$', 'i', '#', 'i', 2, 2, 3}; + std::vector const vT1 = {'[', '$', 'T', '#', '[', '$', 'i', '#', 'i', 2, 2, 3}; CHECK(json::from_bjdata(vT1, true, false).is_discarded()); - std::vector vh = {'[', '$', 'h', '#', '[', '$', 'i', '#', 'i', 2, 2, 3}; + std::vector const vh = {'[', '$', 'h', '#', '[', '$', 'i', '#', 'i', 2, 2, 3}; CHECK(json::from_bjdata(vh, true, false).is_discarded()); - std::vector vR = {'[', '$', 'i', '#', '[', 'i', 1, '[', ']', ']', 1}; + std::vector const vR = {'[', '$', 'i', '#', '[', 'i', 1, '[', ']', ']', 1}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vR), "[json.exception.parse_error.113] parse error at byte 8: syntax error while parsing BJData size: ndarray dimentional vector is not allowed", json::parse_error&); CHECK(json::from_bjdata(vR, true, false).is_discarded()); - std::vector vRo = {'[', '$', 'i', '#', '[', 'i', 0, '{', '}', ']', 1}; + std::vector const vRo = {'[', '$', 'i', '#', '[', 'i', 0, '{', '}', ']', 1}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vRo), "[json.exception.parse_error.113] parse error at byte 8: syntax error while parsing BJData size: expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x7B", json::parse_error&); CHECK(json::from_bjdata(vRo, true, false).is_discarded()); - std::vector vR1 = {'[', '$', 'i', '#', '[', '[', 'i', 1, ']', ']', 1}; + std::vector const vR1 = {'[', '$', 'i', '#', '[', '[', 'i', 1, ']', ']', 1}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vR1), "[json.exception.parse_error.113] parse error at byte 6: syntax error while parsing BJData size: ndarray dimentional vector is not allowed", json::parse_error&); CHECK(json::from_bjdata(vR1, true, false).is_discarded()); - std::vector vR2 = {'[', '$', 'i', '#', '[', '#', '[', 'i', 1, ']', ']', 1}; + std::vector const vR2 = {'[', '$', 'i', '#', '[', '#', '[', 'i', 1, ']', ']', 1}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vR2), "[json.exception.parse_error.113] parse error at byte 11: syntax error while parsing BJData size: expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x5D", json::parse_error&); CHECK(json::from_bjdata(vR2, true, false).is_discarded()); - std::vector vR3 = {'[', '#', '[', 'i', '2', 'i', 2, ']'}; + std::vector const vR3 = {'[', '#', '[', 'i', '2', 'i', 2, ']'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vR3), "[json.exception.parse_error.112] parse error at byte 8: syntax error while parsing BJData size: ndarray requires both type and size", json::parse_error&); CHECK(json::from_bjdata(vR3, true, false).is_discarded()); - std::vector vR4 = {'[', '$', 'i', '#', '[', '$', 'i', '#', '[', 'i', 1, ']', 1}; + std::vector const vR4 = {'[', '$', 'i', '#', '[', '$', 'i', '#', '[', 'i', 1, ']', 1}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vR4), "[json.exception.parse_error.110] parse error at byte 14: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vR4, true, false).is_discarded()); - std::vector vR5 = {'[', '$', 'i', '#', '[', '[', '[', ']', ']', ']'}; + std::vector const vR5 = {'[', '$', 'i', '#', '[', '[', '[', ']', ']', ']'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vR5), "[json.exception.parse_error.113] parse error at byte 6: syntax error while parsing BJData size: ndarray dimentional vector is not allowed", json::parse_error&); CHECK(json::from_bjdata(vR5, true, false).is_discarded()); - std::vector vR6 = {'[', '$', 'i', '#', '[', '$', 'i', '#', '[', 'i', '2', 'i', 2, ']'}; + std::vector const vR6 = {'[', '$', 'i', '#', '[', '$', 'i', '#', '[', 'i', '2', 'i', 2, ']'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vR6), "[json.exception.parse_error.112] parse error at byte 14: syntax error while parsing BJData size: ndarray can not be recursive", json::parse_error&); CHECK(json::from_bjdata(vR6, true, false).is_discarded()); - std::vector vH = {'[', 'H', '[', '#', '[', '$', 'i', '#', '[', 'i', '2', 'i', 2, ']'}; + std::vector const vH = {'[', 'H', '[', '#', '[', '$', 'i', '#', '[', 'i', '2', 'i', 2, ']'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vH), "[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing BJData size: ndarray dimentional vector is not allowed", json::parse_error&); CHECK(json::from_bjdata(vH, true, false).is_discarded()); } SECTION("objects") { - std::vector vST = {'{', '$', 'i', '#', 'i', 2, 'i', 1, 'a', 1}; + std::vector const vST = {'{', '$', 'i', '#', 'i', 2, 'i', 1, 'a', 1}; json _; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vST), "[json.exception.parse_error.110] parse error at byte 11: syntax error while parsing BJData value: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vST, true, false).is_discarded()); - std::vector vT = {'{', '$', 'i', 'i', 1, 'a', 1}; + std::vector const vT = {'{', '$', 'i', 'i', 1, 'a', 1}; CHECK_THROWS_WITH(_ = json::from_bjdata(vT), "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing BJData size: expected '#' after type information; last byte: 0x69"); CHECK(json::from_bjdata(vT, true, false).is_discarded()); - std::vector vS = {'{', '#', 'i', 2, 'i', 1, 'a', 'i', 1}; + std::vector const vS = {'{', '#', 'i', 2, 'i', 1, 'a', 'i', 1}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vS), "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing BJData value: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vS, true, false).is_discarded()); - std::vector v = {'{', 'i', 1, 'a', 'i', 1}; + std::vector const v = {'{', 'i', 1, 'a', 'i', 1}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing BJData value: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(v, true, false).is_discarded()); - std::vector v2 = {'{', 'i', 1, 'a', 'i', 1, 'i'}; + std::vector const v2 = {'{', 'i', 1, 'a', 'i', 1, 'i'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v2), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(v2, true, false).is_discarded()); - std::vector v3 = {'{', 'i', 1, 'a'}; + std::vector const v3 = {'{', 'i', 1, 'a'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v3), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing BJData value: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(v3, true, false).is_discarded()); - std::vector vST1 = {'{', '$', 'd', '#', 'i', 2, 'i', 1, 'a'}; + std::vector const vST1 = {'{', '$', 'd', '#', 'i', 2, 'i', 1, 'a'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vST1), "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing BJData number: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vST1, true, false).is_discarded()); - std::vector vST2 = {'{', '#', 'i', 2, 'i', 1, 'a'}; + std::vector const vST2 = {'{', '#', 'i', 2, 'i', 1, 'a'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vST2), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing BJData value: unexpected end of input", json::parse_error&); CHECK(json::from_bjdata(vST2, true, false).is_discarded()); - std::vector vO = {'{', '#', '[', 'i', 2, 'i', 1, ']', 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'i', 2}; + std::vector const vO = {'{', '#', '[', 'i', 2, 'i', 1, ']', 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'i', 2}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vO), "[json.exception.parse_error.112] parse error at byte 8: syntax error while parsing BJData size: ndarray requires both type and size", json::parse_error&); CHECK(json::from_bjdata(vO, true, false).is_discarded()); - std::vector vO2 = {'{', '$', 'i', '#', '[', 'i', 2, 'i', 1, ']', 'i', 1, 'a', 1, 'i', 1, 'b', 2}; + std::vector const vO2 = {'{', '$', 'i', '#', '[', 'i', 2, 'i', 1, ']', 'i', 1, 'a', 1, 'i', 1, 'b', 2}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vO2), "[json.exception.parse_error.112] parse error at byte 10: syntax error while parsing BJData object: BJData object does not support ND-array size in optimized format", json::parse_error&); CHECK(json::from_bjdata(vO2, true, false).is_discarded()); } @@ -2966,49 +2966,49 @@ TEST_CASE("BJData") { SECTION("array of i") { - json j = {1, -1}; + json const j = {1, -1}; std::vector expected = {'[', '$', 'i', '#', 'i', 2, 1, 0xff}; CHECK(json::to_bjdata(j, true, true) == expected); } SECTION("array of U") { - json j = {200, 201}; + json const j = {200, 201}; std::vector expected = {'[', '$', 'U', '#', 'i', 2, 0xC8, 0xC9}; CHECK(json::to_bjdata(j, true, true) == expected); } SECTION("array of I") { - json j = {30000, -30000}; + json const j = {30000, -30000}; std::vector expected = {'[', '$', 'I', '#', 'i', 2, 0x30, 0x75, 0xd0, 0x8a}; CHECK(json::to_bjdata(j, true, true) == expected); } SECTION("array of u") { - json j = {50000, 50001}; + json const j = {50000, 50001}; std::vector expected = {'[', '$', 'u', '#', 'i', 2, 0x50, 0xC3, 0x51, 0xC3}; CHECK(json::to_bjdata(j, true, true) == expected); } SECTION("array of l") { - json j = {70000, -70000}; + json const j = {70000, -70000}; std::vector expected = {'[', '$', 'l', '#', 'i', 2, 0x70, 0x11, 0x01, 0x00, 0x90, 0xEE, 0xFE, 0xFF}; CHECK(json::to_bjdata(j, true, true) == expected); } SECTION("array of m") { - json j = {3147483647, 3147483648}; + json const j = {3147483647, 3147483648}; std::vector expected = {'[', '$', 'm', '#', 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0x00, 0xCA, 0x9A, 0xBB}; CHECK(json::to_bjdata(j, true, true) == expected); } SECTION("array of L") { - json j = {5000000000, -5000000000}; + json const j = {5000000000, -5000000000}; std::vector expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFA, 0xD5, 0xFE, 0xFF, 0xFF, 0xFF}; CHECK(json::to_bjdata(j, true, true) == expected); } @@ -3018,7 +3018,7 @@ TEST_CASE("BJData") { SECTION("array of i") { - json j = {1u, 2u}; + json const j = {1u, 2u}; std::vector expected = {'[', '$', 'i', '#', 'i', 2, 1, 2}; std::vector expected_size = {'[', '#', 'i', 2, 'i', 1, 'i', 2}; CHECK(json::to_bjdata(j, true, true) == expected); @@ -3027,7 +3027,7 @@ TEST_CASE("BJData") SECTION("array of U") { - json j = {200u, 201u}; + json const j = {200u, 201u}; std::vector expected = {'[', '$', 'U', '#', 'i', 2, 0xC8, 0xC9}; std::vector expected_size = {'[', '#', 'i', 2, 'U', 0xC8, 'U', 0xC9}; CHECK(json::to_bjdata(j, true, true) == expected); @@ -3036,7 +3036,7 @@ TEST_CASE("BJData") SECTION("array of I") { - json j = {30000u, 30001u}; + json const j = {30000u, 30001u}; std::vector expected = {'[', '$', 'I', '#', 'i', 2, 0x30, 0x75, 0x31, 0x75}; std::vector expected_size = {'[', '#', 'i', 2, 'I', 0x30, 0x75, 'I', 0x31, 0x75}; CHECK(json::to_bjdata(j, true, true) == expected); @@ -3045,7 +3045,7 @@ TEST_CASE("BJData") SECTION("array of u") { - json j = {50000u, 50001u}; + json const j = {50000u, 50001u}; std::vector expected = {'[', '$', 'u', '#', 'i', 2, 0x50, 0xC3, 0x51, 0xC3}; std::vector expected_size = {'[', '#', 'i', 2, 'u', 0x50, 0xC3, 'u', 0x51, 0xC3}; CHECK(json::to_bjdata(j, true, true) == expected); @@ -3054,7 +3054,7 @@ TEST_CASE("BJData") SECTION("array of l") { - json j = {70000u, 70001u}; + json const j = {70000u, 70001u}; std::vector expected = {'[', '$', 'l', '#', 'i', 2, 0x70, 0x11, 0x01, 0x00, 0x71, 0x11, 0x01, 0x00}; std::vector expected_size = {'[', '#', 'i', 2, 'l', 0x70, 0x11, 0x01, 0x00, 'l', 0x71, 0x11, 0x01, 0x00}; CHECK(json::to_bjdata(j, true, true) == expected); @@ -3063,7 +3063,7 @@ TEST_CASE("BJData") SECTION("array of m") { - json j = {3147483647u, 3147483648u}; + json const j = {3147483647u, 3147483648u}; std::vector expected = {'[', '$', 'm', '#', 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0x00, 0xCA, 0x9A, 0xBB}; std::vector expected_size = {'[', '#', 'i', 2, 'm', 0xFF, 0xC9, 0x9A, 0xBB, 'm', 0x00, 0xCA, 0x9A, 0xBB}; CHECK(json::to_bjdata(j, true, true) == expected); @@ -3072,7 +3072,7 @@ TEST_CASE("BJData") SECTION("array of L") { - json j = {5000000000u, 5000000001u}; + json const j = {5000000000u, 5000000001u}; std::vector expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00, 0x01, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00}; std::vector expected_size = {'[', '#', 'i', 2, 'L', 0x00, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00, 'L', 0x01, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00}; CHECK(json::to_bjdata(j, true, true) == expected); @@ -3081,7 +3081,7 @@ TEST_CASE("BJData") SECTION("array of M") { - json j = {10223372036854775807ull, 10223372036854775808ull}; + json const j = {10223372036854775807ull, 10223372036854775808ull}; std::vector expected = {'[', '$', 'M', '#', 'i', 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 0x00, 0x00, 0x64, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; std::vector expected_size = {'[', '#', 'i', 2, 'M', 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 'M', 0x00, 0x00, 0x64, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; CHECK(json::to_bjdata(j, true, true) == expected); @@ -3108,7 +3108,7 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") 'S', 'i', 3, 'b', 'a', 'r', 'S', 'i', 3, 'b', 'a', 'z', ']' }; - std::vector v2 = {'[', 'S', 'i', 3, 'f', 'o', 'o', 'N', + std::vector const v2 = {'[', 'S', 'i', 3, 'f', 'o', 'o', 'N', 'S', 'i', 3, 'b', 'a', 'r', 'N', 'N', 'N', 'S', 'i', 3, 'b', 'a', 'z', 'N', 'N', ']' }; @@ -3160,7 +3160,7 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") SECTION("Char Type") { json j = {{"rolecode", "a"}, {"delim", ";"}}; - std::vector v = {'{', 'i', 5, 'd', 'e', 'l', 'i', 'm', 'C', ';', 'i', 8, 'r', 'o', 'l', 'e', 'c', 'o', 'd', 'e', 'C', 'a', '}'}; + std::vector const v = {'{', 'i', 5, 'd', 'e', 'l', 'i', 'm', 'C', ';', 'i', 8, 'r', 'o', 'l', 'e', 'c', 'o', 'd', 'e', 'C', 'a', '}'}; //CHECK(json::to_bjdata(j) == v); CHECK(json::from_bjdata(v) == j); } @@ -3394,7 +3394,7 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") SECTION("Array") { json _; - std::vector v = {'[', '$', 'N', '#', 'I', 0x00, 0x02}; + std::vector const v = {'[', '$', 'N', '#', 'I', 0x00, 0x02}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v), "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x4E is not a permitted optimized array type", json::parse_error&); CHECK(json::from_bjdata(v, true, false).is_discarded()); } @@ -3402,7 +3402,7 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") SECTION("Object") { json _; - std::vector v = {'{', '$', 'Z', '#', 'i', 3, 'i', 4, 'n', 'a', 'm', 'e', 'i', 8, 'p', 'a', 's', 's', 'w', 'o', 'r', 'd', 'i', 5, 'e', 'm', 'a', 'i', 'l'}; + std::vector const v = {'{', '$', 'Z', '#', 'i', 3, 'i', 4, 'n', 'a', 'm', 'e', 'i', 8, 'p', 'a', 's', 's', 'w', 'o', 'r', 'd', 'i', 5, 'e', 'm', 'a', 'i', 'l'}; CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v), "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x5A is not a permitted optimized array type", json::parse_error&); CHECK(json::from_bjdata(v, true, false).is_discarded()); } @@ -3532,7 +3532,7 @@ TEST_CASE("BJData roundtrips" * doctest::skip()) INFO_WITH_TEMP(filename + ": output to output adapters"); // parse JSON file std::ifstream f_json(filename); - json j1 = json::parse(f_json); + json const j1 = json::parse(f_json); // parse BJData file auto packed = utils::read_binary_file(filename + ".bjdata"); diff --git a/tests/src/unit-cbor.cpp b/tests/src/unit-cbor.cpp index ffa3e92d8..084ebd3dd 100644 --- a/tests/src/unit-cbor.cpp +++ b/tests/src/unit-cbor.cpp @@ -104,7 +104,7 @@ TEST_CASE("CBOR") SECTION("discarded") { // discarded values are not serialized - json j = json::value_t::discarded; + json const j = json::value_t::discarded; const auto result = json::to_cbor(j); CHECK(result.empty()); } @@ -112,7 +112,7 @@ TEST_CASE("CBOR") SECTION("NaN") { // NaN value - json j = std::numeric_limits::quiet_NaN(); + json const j = std::numeric_limits::quiet_NaN(); std::vector expected = {0xf9, 0x7e, 0x00}; const auto result = json::to_cbor(j); CHECK(result == expected); @@ -121,7 +121,7 @@ TEST_CASE("CBOR") SECTION("Infinity") { // Infinity value - json j = std::numeric_limits::infinity(); + json const j = std::numeric_limits::infinity(); std::vector expected = {0xf9, 0x7c, 0x00}; const auto result = json::to_cbor(j); CHECK(result == expected); @@ -985,21 +985,21 @@ TEST_CASE("CBOR") { SECTION("0 (0 00000 0000000000)") { - json j = json::from_cbor(std::vector({0xf9, 0x00, 0x00})); + json const j = json::from_cbor(std::vector({0xf9, 0x00, 0x00})); json::number_float_t d{j}; CHECK(d == 0.0); } SECTION("-0 (1 00000 0000000000)") { - json j = json::from_cbor(std::vector({0xf9, 0x80, 0x00})); + json const j = json::from_cbor(std::vector({0xf9, 0x80, 0x00})); json::number_float_t d{j}; CHECK(d == -0.0); } SECTION("2**-24 (0 00000 0000000001)") { - json j = json::from_cbor(std::vector({0xf9, 0x00, 0x01})); + json const j = json::from_cbor(std::vector({0xf9, 0x00, 0x01})); json::number_float_t d{j}; CHECK(d == std::pow(2.0, -24.0)); } @@ -1009,7 +1009,7 @@ TEST_CASE("CBOR") { SECTION("infinity (0 11111 0000000000)") { - json j = json::from_cbor(std::vector({0xf9, 0x7c, 0x00})); + json const j = json::from_cbor(std::vector({0xf9, 0x7c, 0x00})); json::number_float_t d{j}; CHECK(d == std::numeric_limits::infinity()); CHECK(j.dump() == "null"); @@ -1017,7 +1017,7 @@ TEST_CASE("CBOR") SECTION("-infinity (1 11111 0000000000)") { - json j = json::from_cbor(std::vector({0xf9, 0xfc, 0x00})); + json const j = json::from_cbor(std::vector({0xf9, 0xfc, 0x00})); json::number_float_t d{j}; CHECK(d == -std::numeric_limits::infinity()); CHECK(j.dump() == "null"); @@ -1028,21 +1028,21 @@ TEST_CASE("CBOR") { SECTION("1 (0 01111 0000000000)") { - json j = json::from_cbor(std::vector({0xf9, 0x3c, 0x00})); + json const j = json::from_cbor(std::vector({0xf9, 0x3c, 0x00})); json::number_float_t d{j}; CHECK(d == 1); } SECTION("-2 (1 10000 0000000000)") { - json j = json::from_cbor(std::vector({0xf9, 0xc0, 0x00})); + json const j = json::from_cbor(std::vector({0xf9, 0xc0, 0x00})); json::number_float_t d{j}; CHECK(d == -2); } SECTION("65504 (0 11110 1111111111)") { - json j = json::from_cbor(std::vector({0xf9, 0x7b, 0xff})); + json const j = json::from_cbor(std::vector({0xf9, 0x7b, 0xff})); json::number_float_t d{j}; CHECK(d == 65504); } @@ -1050,16 +1050,16 @@ TEST_CASE("CBOR") SECTION("infinity") { - json j = json::from_cbor(std::vector({0xf9, 0x7c, 0x00})); - json::number_float_t d{j}; + json const j = json::from_cbor(std::vector({0xf9, 0x7c, 0x00})); + json::number_float_t const d{j}; CHECK(!std::isfinite(d)); CHECK(j.dump() == "null"); } SECTION("NaN") { - json j = json::from_cbor(std::vector({0xf9, 0x7e, 0x00})); - json::number_float_t d{j}; + json const j = json::from_cbor(std::vector({0xf9, 0x7e, 0x00})); + json::number_float_t const d{j}; CHECK(std::isnan(d)); CHECK(j.dump() == "null"); } @@ -1553,7 +1553,7 @@ TEST_CASE("CBOR") SECTION("indefinite size") { - std::vector input = {0x5F, 0x44, 0xaa, 0xbb, 0xcc, 0xdd, 0x43, 0xee, 0xff, 0x99, 0xFF}; + std::vector const input = {0x5F, 0x44, 0xaa, 0xbb, 0xcc, 0xdd, 0x43, 0xee, 0xff, 0x99, 0xFF}; auto j = json::from_cbor(input); CHECK(j.is_binary()); auto k = json::binary({0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x99}); @@ -1564,7 +1564,7 @@ TEST_CASE("CBOR") SECTION("binary in array") { // array with three empty byte strings - std::vector input = {0x83, 0x40, 0x40, 0x40}; + std::vector const input = {0x83, 0x40, 0x40, 0x40}; json _; CHECK_NOTHROW(_ = json::from_cbor(input)); } @@ -1572,7 +1572,7 @@ TEST_CASE("CBOR") SECTION("binary in object") { // object mapping "foo" to empty byte string - std::vector input = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0x40}; + std::vector const input = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0x40}; json _; CHECK_NOTHROW(_ = json::from_cbor(input)); } @@ -1580,7 +1580,7 @@ TEST_CASE("CBOR") SECTION("SAX callback with binary") { // object mapping "foo" to byte string - std::vector input = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0x41, 0x00}; + std::vector const input = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0x41, 0x00}; // callback to set binary_seen to true if a binary value was seen bool binary_seen = false; @@ -1606,7 +1606,7 @@ TEST_CASE("CBOR") { SECTION("0x5b (byte array)") { - std::vector given = {0x5b, 0x00, 0x00, 0x00, 0x00, + std::vector const given = {0x5b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x61 }; json j = json::from_cbor(given); @@ -1615,7 +1615,7 @@ TEST_CASE("CBOR") SECTION("0x7b (string)") { - std::vector given = {0x7b, 0x00, 0x00, 0x00, 0x00, + std::vector const given = {0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x61 }; json j = json::from_cbor(given); @@ -1624,7 +1624,7 @@ TEST_CASE("CBOR") SECTION("0x9b (array)") { - std::vector given = {0x9b, 0x00, 0x00, 0x00, 0x00, + std::vector const given = {0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf4 }; json j = json::from_cbor(given); @@ -1633,7 +1633,7 @@ TEST_CASE("CBOR") SECTION("0xbb (map)") { - std::vector given = {0xbb, 0x00, 0x00, 0x00, 0x00, + std::vector const given = {0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x60, 0xf4 }; json j = json::from_cbor(given); @@ -1778,7 +1778,7 @@ TEST_CASE("CBOR") SECTION("strict mode") { - std::vector vec = {0xf6, 0xf6}; + std::vector const vec = {0xf6, 0xf6}; SECTION("non-strict mode") { const auto result = json::from_cbor(vec, false); @@ -1799,21 +1799,21 @@ TEST_CASE("CBOR") { SECTION("start_array(len)") { - std::vector v = {0x83, 0x01, 0x02, 0x03}; + std::vector const v = {0x83, 0x01, 0x02, 0x03}; SaxCountdown scp(0); CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor)); } SECTION("start_object(len)") { - std::vector v = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4}; + std::vector const v = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4}; SaxCountdown scp(0); CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor)); } SECTION("key()") { - std::vector v = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4}; + std::vector const v = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4}; SaxCountdown scp(1); CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor)); } @@ -1825,7 +1825,7 @@ TEST_CASE("single CBOR roundtrip") { SECTION("sample.json") { - std::string filename = TEST_DATA_DIRECTORY "/json_testsuite/sample.json"; + std::string const filename = TEST_DATA_DIRECTORY "/json_testsuite/sample.json"; // parse JSON file std::ifstream f_json(filename); @@ -1910,7 +1910,7 @@ TEST_CASE("CBOR regressions") try { // step 2: round trip - std::vector vec2 = json::to_cbor(j1); + std::vector const vec2 = json::to_cbor(j1); // parse serialization json j2 = json::from_cbor(vec2); @@ -2151,7 +2151,7 @@ TEST_CASE("CBOR roundtrips" * doctest::skip()) INFO_WITH_TEMP(filename + ": output to output adapters"); // parse JSON file std::ifstream f_json(filename); - json j1 = json::parse(f_json); + json const j1 = json::parse(f_json); // parse CBOR file auto packed = utils::read_binary_file(filename + ".cbor"); diff --git a/tests/src/unit-class_const_iterator.cpp b/tests/src/unit-class_const_iterator.cpp index 3c5ba053f..290ab0b2d 100644 --- a/tests/src/unit-class_const_iterator.cpp +++ b/tests/src/unit-class_const_iterator.cpp @@ -20,27 +20,27 @@ TEST_CASE("const_iterator class") { SECTION("null") { - json j(json::value_t::null); - json::const_iterator it(&j); + json const j(json::value_t::null); + json::const_iterator const it(&j); } SECTION("object") { - json j(json::value_t::object); - json::const_iterator it(&j); + json const j(json::value_t::object); + json::const_iterator const it(&j); } SECTION("array") { - json j(json::value_t::array); - json::const_iterator it(&j); + json const j(json::value_t::array); + json::const_iterator const it(&j); } } SECTION("copy assignment") { - json j(json::value_t::null); - json::const_iterator it(&j); + json const j(json::value_t::null); + json::const_iterator const it(&j); json::const_iterator it2(&j); it2 = it; } @@ -50,14 +50,14 @@ TEST_CASE("const_iterator class") SECTION("create from uninitialized iterator") { const json::iterator it {}; - json::const_iterator cit(it); + json::const_iterator const cit(it); } SECTION("create from initialized iterator") { json j; const json::iterator it = j.begin(); - json::const_iterator cit(it); + json::const_iterator const cit(it); } } } @@ -68,7 +68,7 @@ TEST_CASE("const_iterator class") { SECTION("null") { - json j(json::value_t::null); + json const j(json::value_t::null); json::const_iterator it(&j); it.set_begin(); CHECK((it == j.cbegin())); @@ -76,7 +76,7 @@ TEST_CASE("const_iterator class") SECTION("object") { - json j(json::value_t::object); + json const j(json::value_t::object); json::const_iterator it(&j); it.set_begin(); CHECK((it == j.cbegin())); @@ -84,7 +84,7 @@ TEST_CASE("const_iterator class") SECTION("array") { - json j(json::value_t::array); + json const j(json::value_t::array); json::const_iterator it(&j); it.set_begin(); CHECK((it == j.cbegin())); @@ -95,7 +95,7 @@ TEST_CASE("const_iterator class") { SECTION("null") { - json j(json::value_t::null); + json const j(json::value_t::null); json::const_iterator it(&j); it.set_end(); CHECK((it == j.cend())); @@ -103,7 +103,7 @@ TEST_CASE("const_iterator class") SECTION("object") { - json j(json::value_t::object); + json const j(json::value_t::object); json::const_iterator it(&j); it.set_end(); CHECK((it == j.cend())); @@ -111,7 +111,7 @@ TEST_CASE("const_iterator class") SECTION("array") { - json j(json::value_t::array); + json const j(json::value_t::array); json::const_iterator it(&j); it.set_end(); CHECK((it == j.cend())); @@ -125,14 +125,14 @@ TEST_CASE("const_iterator class") { SECTION("null") { - json j(json::value_t::null); - json::const_iterator it = j.cbegin(); + json const j(json::value_t::null); + json::const_iterator const it = j.cbegin(); CHECK_THROWS_WITH_AS(*it, "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&); } SECTION("number") { - json j(17); + json const j(17); json::const_iterator it = j.cbegin(); CHECK(*it == json(17)); it = j.cend(); @@ -141,15 +141,15 @@ TEST_CASE("const_iterator class") SECTION("object") { - json j({{"foo", "bar"}}); - json::const_iterator it = j.cbegin(); + json const j({{"foo", "bar"}}); + json::const_iterator const it = j.cbegin(); CHECK(*it == json("bar")); } SECTION("array") { - json j({1, 2, 3, 4}); - json::const_iterator it = j.cbegin(); + json const j({1, 2, 3, 4}); + json::const_iterator const it = j.cbegin(); CHECK(*it == json(1)); } } @@ -158,14 +158,14 @@ TEST_CASE("const_iterator class") { SECTION("null") { - json j(json::value_t::null); - json::const_iterator it = j.cbegin(); + json const j(json::value_t::null); + json::const_iterator const it = j.cbegin(); CHECK_THROWS_WITH_AS(std::string(it->type_name()), "[json.exception.invalid_iterator.214] cannot get value", json::invalid_iterator&); } SECTION("number") { - json j(17); + json const j(17); json::const_iterator it = j.cbegin(); CHECK(std::string(it->type_name()) == "number"); it = j.cend(); @@ -174,15 +174,15 @@ TEST_CASE("const_iterator class") SECTION("object") { - json j({{"foo", "bar"}}); - json::const_iterator it = j.cbegin(); + json const j({{"foo", "bar"}}); + json::const_iterator const it = j.cbegin(); CHECK(std::string(it->type_name()) == "string"); } SECTION("array") { - json j({1, 2, 3, 4}); - json::const_iterator it = j.cbegin(); + json const j({1, 2, 3, 4}); + json::const_iterator const it = j.cbegin(); CHECK(std::string(it->type_name()) == "number"); } } @@ -194,7 +194,7 @@ TEST_CASE("const_iterator class") { SECTION("null") { - json j(json::value_t::null); + json const j(json::value_t::null); json::const_iterator it = j.cbegin(); CHECK((it.m_it.primitive_iterator.m_it == 1)); it++; @@ -203,7 +203,7 @@ TEST_CASE("const_iterator class") SECTION("number") { - json j(17); + json const j(17); json::const_iterator it = j.cbegin(); CHECK((it.m_it.primitive_iterator.m_it == 0)); it++; @@ -214,7 +214,7 @@ TEST_CASE("const_iterator class") SECTION("object") { - json j({{"foo", "bar"}}); + json const j({{"foo", "bar"}}); json::const_iterator it = j.cbegin(); CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin())); it++; @@ -223,7 +223,7 @@ TEST_CASE("const_iterator class") SECTION("array") { - json j({1, 2, 3, 4}); + json const j({1, 2, 3, 4}); json::const_iterator it = j.cbegin(); CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin())); it++; @@ -245,7 +245,7 @@ TEST_CASE("const_iterator class") { SECTION("null") { - json j(json::value_t::null); + json const j(json::value_t::null); json::const_iterator it = j.cbegin(); CHECK((it.m_it.primitive_iterator.m_it == 1)); ++it; @@ -254,7 +254,7 @@ TEST_CASE("const_iterator class") SECTION("number") { - json j(17); + json const j(17); json::const_iterator it = j.cbegin(); CHECK((it.m_it.primitive_iterator.m_it == 0)); ++it; @@ -265,7 +265,7 @@ TEST_CASE("const_iterator class") SECTION("object") { - json j({{"foo", "bar"}}); + json const j({{"foo", "bar"}}); json::const_iterator it = j.cbegin(); CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin())); ++it; @@ -274,7 +274,7 @@ TEST_CASE("const_iterator class") SECTION("array") { - json j({1, 2, 3, 4}); + json const j({1, 2, 3, 4}); json::const_iterator it = j.cbegin(); CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin())); ++it; @@ -296,14 +296,14 @@ TEST_CASE("const_iterator class") { SECTION("null") { - json j(json::value_t::null); - json::const_iterator it = j.cend(); + json const j(json::value_t::null); + json::const_iterator const it = j.cend(); CHECK((it.m_it.primitive_iterator.m_it == 1)); } SECTION("number") { - json j(17); + json const j(17); json::const_iterator it = j.cend(); CHECK((it.m_it.primitive_iterator.m_it == 1)); it--; @@ -314,7 +314,7 @@ TEST_CASE("const_iterator class") SECTION("object") { - json j({{"foo", "bar"}}); + json const j({{"foo", "bar"}}); json::const_iterator it = j.cend(); CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end())); it--; @@ -323,7 +323,7 @@ TEST_CASE("const_iterator class") SECTION("array") { - json j({1, 2, 3, 4}); + json const j({1, 2, 3, 4}); json::const_iterator it = j.cend(); CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end())); it--; @@ -345,14 +345,14 @@ TEST_CASE("const_iterator class") { SECTION("null") { - json j(json::value_t::null); - json::const_iterator it = j.cend(); + json const j(json::value_t::null); + json::const_iterator const it = j.cend(); CHECK((it.m_it.primitive_iterator.m_it == 1)); } SECTION("number") { - json j(17); + json const j(17); json::const_iterator it = j.cend(); CHECK((it.m_it.primitive_iterator.m_it == 1)); --it; @@ -363,7 +363,7 @@ TEST_CASE("const_iterator class") SECTION("object") { - json j({{"foo", "bar"}}); + json const j({{"foo", "bar"}}); json::const_iterator it = j.cend(); CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end())); --it; @@ -372,7 +372,7 @@ TEST_CASE("const_iterator class") SECTION("array") { - json j({1, 2, 3, 4}); + json const j({1, 2, 3, 4}); json::const_iterator it = j.cend(); CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end())); --it; diff --git a/tests/src/unit-conversions.cpp b/tests/src/unit-conversions.cpp index 24d89e11a..59c023b7a 100644 --- a/tests/src/unit-conversions.cpp +++ b/tests/src/unit-conversions.cpp @@ -47,7 +47,7 @@ TEST_CASE("value conversion") SECTION("json::object_t") { - json::object_t o = j.get(); + json::object_t const const o = j.get(); CHECK(json(o) == j); } @@ -410,7 +410,7 @@ TEST_CASE("value conversion") #if defined(JSON_HAS_CPP_17) SECTION("std::string_view") { - std::string_view s = j.get(); + std::string_view const s = j.get(); CHECK(json(s) == j); } #endif @@ -482,7 +482,7 @@ TEST_CASE("value conversion") #if defined(JSON_HAS_CPP_17) SECTION("std::string_view") { - std::string s = "previous value"; + std::string const s = "previous value"; std::string_view sv = s; j.get_to(sv); CHECK(json(sv) == j); @@ -529,7 +529,7 @@ TEST_CASE("value conversion") #if defined(JSON_HAS_CPP_17) SECTION("std::string_view") { - std::string_view s = j.get(); + std::string_view const s = j.get(); CHECK(json(s) == j); } #endif @@ -857,9 +857,9 @@ TEST_CASE("value conversion") #if JSON_USE_IMPLICIT_CONVERSIONS SECTION("get an integer number (implicit)") { - json::number_integer_t n_reference{42}; + json::number_integer_t const n_reference{42}; json j(n_reference); - json::number_unsigned_t n_unsigned_reference{42u}; + json::number_unsigned_t const n_unsigned_reference{42u}; json j_unsigned(n_unsigned_reference); SECTION("number_integer_t") @@ -876,193 +876,193 @@ TEST_CASE("value conversion") SECTION("short") { - short n = j; + short const n = j; CHECK(json(n) == j); } SECTION("unsigned short") { - unsigned short n = j_unsigned; + unsigned short const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("int") { - int n = j; + int const n = j; CHECK(json(n) == j); } SECTION("unsigned int") { - unsigned int n = j_unsigned; + unsigned int const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("long") { - long n = j; + long const n = j; CHECK(json(n) == j); } SECTION("unsigned long") { - unsigned long n = j_unsigned; + unsigned long const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("long long") { - long long n = j; + long long const n = j; CHECK(json(n) == j); } SECTION("unsigned long long") { - unsigned long long n = j_unsigned; + unsigned long long const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("int8_t") { - int8_t n = j; + int8_t const n = j; CHECK(json(n) == j); } SECTION("int16_t") { - int16_t n = j; + int16_t const n = j; CHECK(json(n) == j); } SECTION("int32_t") { - int32_t n = j; + int32_t const n = j; CHECK(json(n) == j); } SECTION("int64_t") { - int64_t n = j; + int64_t const n = j; CHECK(json(n) == j); } SECTION("int8_fast_t") { - int_fast8_t n = j; + int_fast8_t const n = j; CHECK(json(n) == j); } SECTION("int16_fast_t") { - int_fast16_t n = j; + int_fast16_t const n = j; CHECK(json(n) == j); } SECTION("int32_fast_t") { - int_fast32_t n = j; + int_fast32_t const n = j; CHECK(json(n) == j); } SECTION("int64_fast_t") { - int_fast64_t n = j; + int_fast64_t const n = j; CHECK(json(n) == j); } SECTION("int8_least_t") { - int_least8_t n = j; + int_least8_t const n = j; CHECK(json(n) == j); } SECTION("int16_least_t") { - int_least16_t n = j; + int_least16_t const n = j; CHECK(json(n) == j); } SECTION("int32_least_t") { - int_least32_t n = j; + int_least32_t const n = j; CHECK(json(n) == j); } SECTION("int64_least_t") { - int_least64_t n = j; + int_least64_t const n = j; CHECK(json(n) == j); } SECTION("uint8_t") { - uint8_t n = j_unsigned; + uint8_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("uint16_t") { - uint16_t n = j_unsigned; + uint16_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("uint32_t") { - uint32_t n = j_unsigned; + uint32_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("uint64_t") { - uint64_t n = j_unsigned; + uint64_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("uint8_fast_t") { - uint_fast8_t n = j_unsigned; + uint_fast8_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("uint16_fast_t") { - uint_fast16_t n = j_unsigned; + uint_fast16_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("uint32_fast_t") { - uint_fast32_t n = j_unsigned; + uint_fast32_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("uint64_fast_t") { - uint_fast64_t n = j_unsigned; + uint_fast64_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("uint8_least_t") { - uint_least8_t n = j_unsigned; + uint_least8_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("uint16_least_t") { - uint_least16_t n = j_unsigned; + uint_least16_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("uint32_least_t") { - uint_least32_t n = j_unsigned; + uint_least32_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } SECTION("uint64_least_t") { - uint_least64_t n = j_unsigned; + uint_least64_t const n = j_unsigned; CHECK(json(n) == j_unsigned); } } @@ -1070,8 +1070,8 @@ TEST_CASE("value conversion") SECTION("get a floating-point number (explicit)") { - json::number_float_t n_reference{42.23}; - json j(n_reference); + json::number_float_t const n_reference{42.23}; + json const j(n_reference); SECTION("number_float_t") { @@ -1120,24 +1120,24 @@ TEST_CASE("value conversion") #if JSON_USE_IMPLICIT_CONVERSIONS SECTION("get a floating-point number (implicit)") { - json::number_float_t n_reference{42.23}; - json j(n_reference); + json::number_float_t const n_reference{42.23}; + json const j(n_reference); SECTION("number_float_t") { - json::number_float_t n = j; + json::number_float_t const n = j; CHECK(json(n).m_value.number_float == Approx(j.m_value.number_float)); } SECTION("float") { - float n = j; + float const n = j; CHECK(json(n).m_value.number_float == Approx(j.m_value.number_float)); } SECTION("double") { - double n = j; + double const n = j; CHECK(json(n).m_value.number_float == Approx(j.m_value.number_float)); } } @@ -1145,12 +1145,12 @@ TEST_CASE("value conversion") SECTION("get a binary value (explicit)") { - json::binary_t n_reference{{1, 2, 3}}; + json::binary_t const n_reference{{1, 2, 3}}; json j(n_reference); SECTION("binary_t") { - json::binary_t b = j.get(); + json::binary_t const b = j.get(); CHECK(*json(b).m_value.binary == *j.m_value.binary); } @@ -1252,12 +1252,12 @@ TEST_CASE("value conversion") #if JSON_USE_IMPLICIT_CONVERSIONS SECTION("get a binary value (implicit)") { - json::binary_t n_reference{{1, 2, 3}}; - json j(n_reference); + json::binary_t const n_reference{{1, 2, 3}}; + json const j(n_reference); SECTION("binary_t") { - json::binary_t b = j; + json::binary_t const b = j; CHECK(*json(b).m_value.binary == *j.m_value.binary); } } @@ -1276,11 +1276,11 @@ TEST_CASE("value conversion") { SECTION("object-like STL containers") { - json j1 = {{"one", 1}, {"two", 2}, {"three", 3}}; - json j2 = {{"one", 1u}, {"two", 2u}, {"three", 3u}}; - json j3 = {{"one", 1.1}, {"two", 2.2}, {"three", 3.3}}; - json j4 = {{"one", true}, {"two", false}, {"three", true}}; - json j5 = {{"one", "eins"}, {"two", "zwei"}, {"three", "drei"}}; + json const j1 = {{"one", 1}, {"two", 2}, {"three", 3}}; + json const j2 = {{"one", 1u}, {"two", 2u}, {"three", 3u}}; + json const j3 = {{"one", 1.1}, {"two", 2.2}, {"three", 3.3}}; + json const j4 = {{"one", true}, {"two", false}, {"three", true}}; + json const j5 = {{"one", "eins"}, {"two", "zwei"}, {"three", "drei"}}; SECTION("std::map") { @@ -1331,11 +1331,11 @@ TEST_CASE("value conversion") SECTION("array-like STL containers") { - json j1 = {1, 2, 3, 4}; - json j2 = {1u, 2u, 3u, 4u}; - json j3 = {1.2, 2.3, 3.4, 4.5}; - json j4 = {true, false, true}; - json j5 = {"one", "two", "three"}; + json const j1 = {1, 2, 3, 4}; + json const j2 = {1u, 2u, 3u, 4u}; + json const j3 = {1.2, 2.3, 3.4, 4.5}; + json const j4 = {true, false, true}; + json const j5 = {"one", "two", "three"}; SECTION("std::list") { @@ -1427,13 +1427,13 @@ TEST_CASE("value conversion") SECTION("std::map (array of pairs)") { std::map m{{0, 1}, {1, 2}, {2, 3}}; - json j6 = m; + json const j6 = m; auto m2 = j6.get>(); CHECK(m == m2); - json j7 = {0, 1, 2, 3}; - json j8 = 2; + json const j7 = {0, 1, 2, 3}; + json const j8 = 2; CHECK_THROWS_WITH_AS((j7.get>()), "[json.exception.type_error.302] type must be array, " "but is number", json::type_error&); @@ -1443,7 +1443,7 @@ TEST_CASE("value conversion") SECTION("superfluous entries") { - json j9 = {{0, 1, 2}, {1, 2, 3}, {2, 3, 4}}; + json const j9 = {{0, 1, 2}, {1, 2, 3}, {2, 3, 4}}; m2 = j9.get>(); CHECK(m == m2); } @@ -1452,13 +1452,13 @@ TEST_CASE("value conversion") SECTION("std::unordered_map (array of pairs)") { std::unordered_map m{{0, 1}, {1, 2}, {2, 3}}; - json j6 = m; + json const j6 = m; auto m2 = j6.get>(); CHECK(m == m2); - json j7 = {0, 1, 2, 3}; - json j8 = 2; + json const j7 = {0, 1, 2, 3}; + json const j8 = 2; CHECK_THROWS_WITH_AS((j7.get>()), "[json.exception.type_error.302] type must be array, " "but is number", json::type_error&); @@ -1468,7 +1468,7 @@ TEST_CASE("value conversion") SECTION("superfluous entries") { - json j9{{0, 1, 2}, {1, 2, 3}, {2, 3, 4}}; + json const j9{{0, 1, 2}, {1, 2, 3}, {2, 3, 4}}; m2 = j9.get>(); CHECK(m == m2); } diff --git a/tests/src/unit-element_access2.cpp b/tests/src/unit-element_access2.cpp index 165b24b46..db20a02b1 100644 --- a/tests/src/unit-element_access2.cpp +++ b/tests/src/unit-element_access2.cpp @@ -469,7 +469,7 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j } #ifdef JSON_HAS_CPP_17 { - std::string_view key = "key"; + std::string_view const key = "key"; Json j_null; CHECK(j_null.is_null()); j_null[key] = 1; @@ -833,13 +833,13 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { { Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - typename Json::iterator it2 = jobject.erase(jobject.begin()); + typename Json::iterator const it2 = jobject.erase(jobject.begin()); CHECK(jobject == Json({{"b", 1}, {"c", 17u}})); CHECK(*it2 == Json(1)); } { Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - typename Json::const_iterator it2 = jobject.erase(jobject.cbegin()); + typename Json::const_iterator const it2 = jobject.erase(jobject.cbegin()); CHECK(jobject == Json({{"b", 1}, {"c", 17u}})); CHECK(*it2 == Json(1)); } @@ -865,13 +865,13 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { { Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - typename Json::iterator it2 = jobject.erase(jobject.begin(), jobject.begin()); + typename Json::iterator const it2 = jobject.erase(jobject.begin(), jobject.begin()); CHECK(jobject == Json({{"a", "a"}, {"b", 1}, {"c", 17u}})); CHECK(*it2 == Json("a")); } { Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - typename Json::const_iterator it2 = jobject.erase(jobject.cbegin(), jobject.cbegin()); + typename Json::const_iterator const it2 = jobject.erase(jobject.cbegin(), jobject.cbegin()); CHECK(jobject == Json({{"a", "a"}, {"b", 1}, {"c", 17u}})); CHECK(*it2 == Json("a")); } @@ -881,15 +881,15 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { { Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - typename Json::iterator it = jobject.find("b"); - typename Json::iterator it2 = jobject.erase(it); + typename Json::iterator const it = jobject.find("b"); + typename Json::iterator const it2 = jobject.erase(it); CHECK(jobject == Json({{"a", "a"}, {"c", 17u}})); CHECK(*it2 == Json(17)); } { Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - typename Json::const_iterator it = jobject.find("b"); - typename Json::const_iterator it2 = jobject.erase(it); + typename Json::const_iterator const it = jobject.find("b"); + typename Json::const_iterator const it2 = jobject.erase(it); CHECK(jobject == Json({{"a", "a"}, {"c", 17u}})); CHECK(*it2 == Json(17)); } @@ -899,13 +899,13 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { { Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}}; - typename Json::iterator it2 = jobject.erase(jobject.find("b"), jobject.find("e")); + typename Json::iterator const it2 = jobject.erase(jobject.find("b"), jobject.find("e")); CHECK(jobject == Json({{"a", "a"}, {"e", true}})); CHECK(*it2 == Json(true)); } { Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}}; - typename Json::const_iterator it2 = jobject.erase(jobject.find("b"), jobject.find("e")); + typename Json::const_iterator const it2 = jobject.erase(jobject.find("b"), jobject.find("e")); CHECK(jobject == Json({{"a", "a"}, {"e", true}})); CHECK(*it2 == Json(true)); } @@ -1509,7 +1509,7 @@ TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann const char* cpstr = "default"; const char castr[] = "default"; // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) - string_t str = "default"; + string_t const str = "default"; number_integer_t integer = 69; std::size_t size = 69; @@ -1592,9 +1592,9 @@ TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann SECTION("string_t/object_t::key_type key") { - string_t key = "foo"; - string_t key2 = "baz"; - string_t key_notfound = "bar"; + string_t const key = "foo"; + string_t const key2 = "baz"; + string_t const key_notfound = "bar"; CHECK(j.value(key, "default") == "bar"); CHECK(j.value(key, cpstr) == "bar"); @@ -1618,9 +1618,9 @@ TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann #ifdef JSON_HAS_CPP_17 SECTION("std::string_view key") { - std::string_view key = "foo"; - std::string_view key2 = "baz"; - std::string_view key_notfound = "bar"; + std::string_view const key = "foo"; + std::string_view const key2 = "baz"; + std::string_view const key_notfound = "bar"; CHECK(j.value(key, "default") == "bar"); CHECK(j.value(key, cpstr) == "bar"); @@ -1730,9 +1730,9 @@ TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann SECTION("string_t/object_t::key_type key") { - string_t key = "foo"; - string_t key2 = "baz"; - string_t key_notfound = "bar"; + string_t const key = "foo"; + string_t const key2 = "baz"; + string_t const key_notfound = "bar"; CHECK(j.template value(key, "default") == "bar"); CHECK(j.template value(key, cpstr) == "bar"); @@ -1756,9 +1756,9 @@ TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann #ifdef JSON_HAS_CPP_17 SECTION("std::string_view key") { - std::string_view key = "foo"; - std::string_view key2 = "baz"; - std::string_view key_notfound = "bar"; + std::string_view const key = "foo"; + std::string_view const key2 = "baz"; + std::string_view const key_notfound = "bar"; CHECK(j.template value(key, "default") == "bar"); CHECK(j.template value(key, cpstr) == "bar");