diff --git a/.clang-format b/.clang-format index 64ee00f458..a7fdf1a558 100644 --- a/.clang-format +++ b/.clang-format @@ -29,7 +29,7 @@ BraceWrapping: AfterControlStatement: Always AfterEnum: true AfterFunction: true - AfterNamespace: false + AfterNamespace: true AfterStruct: true AfterUnion: true AfterExternBlock: false @@ -43,13 +43,12 @@ BraceWrapping: BreakBeforeTernaryOperators: true BreakConstructorInitializers: BeforeComma BreakStringLiterals: false -ColumnLimit: 0 +ColumnLimit: 160 CompactNamespaces: false ConstructorInitializerIndentWidth: 2 Cpp11BracedListStyle: true PointerAlignment: Left FixNamespaceComments: true -IncludeBlocks: Preserve #IndentCaseBlocks: false IndentCaseLabels: true IndentGotoLabels: false @@ -59,7 +58,6 @@ KeepEmptyLinesAtTheStartOfBlocks: false MaxEmptyLinesToKeep: 1 NamespaceIndentation: None ReflowComments: false -SortIncludes: CaseSensitive SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false @@ -81,3 +79,16 @@ SpacesInSquareBrackets: false Standard: Latest TabWidth: 4 UseTab: Never + +# what to do with include blocks +SortIncludes: true +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^".*"' + Priority: 1 + - Regex: '<[^\/]+>' + Priority: 2 + - Regex: '^<(nlohmann)\/-*' + Priority: 3 + - Regex: '.*' + Priority: 4 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 35fb9573cc..acf2e23ee4 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -43,12 +43,14 @@ jobs: ci_static_analysis: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.4.0 + container: silkeh/clang:dev strategy: matrix: target: [ci_cppcheck, ci_test_valgrind, ci_test_amalgamation, ci_test_single_header, ci_single_binaries, ci_infer] steps: - uses: actions/checkout@v3 + - name: Get latest CMake and ninja + uses: lukka/get-cmake@v3.27.7 - name: Run CMake run: cmake -S . -B build -DJSON_CI=On - name: Build diff --git a/include/nlohmann/adl_serializer.hpp b/include/nlohmann/adl_serializer.hpp index 7bea4c47c3..95b0722e78 100644 --- a/include/nlohmann/adl_serializer.hpp +++ b/include/nlohmann/adl_serializer.hpp @@ -24,8 +24,7 @@ struct adl_serializer /// @brief convert a JSON value to any value type /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ template - static auto from_json(BasicJsonType&& j, TargetType& val) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), val))) + static auto from_json(BasicJsonType&& j, TargetType& val) noexcept(noexcept(::nlohmann::from_json(std::forward(j), val))) -> decltype(::nlohmann::from_json(std::forward(j), val), void()) { ::nlohmann::from_json(std::forward(j), val); @@ -34,8 +33,7 @@ struct adl_serializer /// @brief convert a JSON value to any value type /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ template - static auto from_json(BasicJsonType&& j) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag{}))) + static auto from_json(BasicJsonType&& j) noexcept(noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag{}))) -> decltype(::nlohmann::from_json(std::forward(j), detail::identity_tag{})) { return ::nlohmann::from_json(std::forward(j), detail::identity_tag{}); @@ -44,8 +42,7 @@ struct adl_serializer /// @brief convert any value type to a JSON value /// @sa https://json.nlohmann.me/api/adl_serializer/to_json/ template - static auto to_json(BasicJsonType& j, TargetType&& val) noexcept( - noexcept(::nlohmann::to_json(j, std::forward(val)))) + static auto to_json(BasicJsonType& j, TargetType&& val) noexcept(noexcept(::nlohmann::to_json(j, std::forward(val)))) -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) { ::nlohmann::to_json(j, std::forward(val)); diff --git a/include/nlohmann/detail/abi_macros.hpp b/include/nlohmann/detail/abi_macros.hpp index ed31cd1ebf..3e560bc455 100644 --- a/include/nlohmann/detail/abi_macros.hpp +++ b/include/nlohmann/detail/abi_macros.hpp @@ -48,51 +48,39 @@ // Construct the namespace ABI tags component #define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi##a##b -#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ - NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) +#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) -#define NLOHMANN_JSON_ABI_TAGS \ - NLOHMANN_JSON_ABI_TAGS_CONCAT( \ - NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ - NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) +#define NLOHMANN_JSON_ABI_TAGS NLOHMANN_JSON_ABI_TAGS_CONCAT(NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) // Construct the namespace version component -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ - _v##major##_##minor##_##patch -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) _v##major##_##minor##_##patch +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) #if NLOHMANN_JSON_NAMESPACE_NO_VERSION #define NLOHMANN_JSON_NAMESPACE_VERSION #else - #define NLOHMANN_JSON_NAMESPACE_VERSION \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ - NLOHMANN_JSON_VERSION_MINOR, \ - NLOHMANN_JSON_VERSION_PATCH) + #define NLOHMANN_JSON_NAMESPACE_VERSION \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH) #endif // Combine namespace components #define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a##b -#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ - NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) +#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) #ifndef NLOHMANN_JSON_NAMESPACE - #define NLOHMANN_JSON_NAMESPACE \ - nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) + #define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT(NLOHMANN_JSON_ABI_TAGS, NLOHMANN_JSON_NAMESPACE_VERSION) #endif #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN - #define NLOHMANN_JSON_NAMESPACE_BEGIN \ - namespace nlohmann { \ - inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) { + #define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { \ + inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT(NLOHMANN_JSON_ABI_TAGS, NLOHMANN_JSON_NAMESPACE_VERSION) \ + { #endif #ifndef NLOHMANN_JSON_NAMESPACE_END - #define NLOHMANN_JSON_NAMESPACE_END \ - } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ + #define NLOHMANN_JSON_NAMESPACE_END \ + } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ } // namespace nlohmann #endif diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index bbfd63c9ed..d3af3b9686 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -30,7 +30,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n) @@ -43,7 +44,9 @@ inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n) } // overloads for basic_json template parameters -template::value && !std::is_same::value, int> = 0> +template::value && !std::is_same::value, int> = 0> void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) { switch (static_cast(j)) @@ -96,12 +99,12 @@ inline void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s = *j.template get_ptr(); } -template< - typename BasicJsonType, - typename StringType, - enable_if_t< - std::is_assignable::value && is_detected_exact::value && !std::is_same::value && !is_json_ref::value, - int> = 0> +template::value && + is_detected_exact::value && + !std::is_same::value && !is_json_ref::value, + int> = 0> inline void from_json(const BasicJsonType& j, StringType& s) { if (JSON_HEDLEY_UNLIKELY(!j.is_string())) @@ -185,8 +188,7 @@ inline void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType: } template -auto from_json_array_impl(const BasicJsonType& j, std::array& arr, priority_tag<2> /*unused*/) - -> decltype(j.template get(), void()) +auto from_json_array_impl(const BasicJsonType& j, std::array& arr, priority_tag<2> /*unused*/) -> decltype(j.template get(), void()) { for (std::size_t i = 0; i < N; ++i) { @@ -194,11 +196,11 @@ auto from_json_array_impl(const BasicJsonType& j, std::array& arr, priorit } } -template::value, int> = 0> +template::value, int> = 0> auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/) - -> decltype(arr.reserve(std::declval()), - j.template get(), - void()) + -> decltype(arr.reserve(std::declval()), j.template get(), void()) { using std::end; @@ -212,29 +214,31 @@ auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, p arr = std::move(ret); } -template::value, int> = 0> +template::value, int> = 0> inline void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<0> /*unused*/) { using std::end; ConstructibleArrayType ret; - std::transform( - j.begin(), - j.end(), - std::inserter(ret, end(ret)), - [](const BasicJsonType& i) { - // get() returns *this, this won't call a from_json - // method when value_type is BasicJsonType - return i.template get(); - }); + std::transform(j.begin(), j.end(), std::inserter(ret, end(ret)), [](const BasicJsonType& i) { + // get() returns *this, this won't call a from_json + // method when value_type is BasicJsonType + return i.template get(); + }); arr = std::move(ret); } -template::value && !is_constructible_object_type::value && !is_constructible_string_type::value && !std::is_same::value && !is_basic_json::value, int> = 0> +template::value && + !is_constructible_object_type::value && + !is_constructible_string_type::value && + !std::is_same::value && !is_basic_json::value, + int> = 0> auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) - -> decltype(from_json_array_impl(j, arr, priority_tag<3>{}), - j.template get(), - void()) + -> decltype(from_json_array_impl(j, arr, priority_tag<3>{}), j.template get(), void()) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { @@ -245,9 +249,8 @@ auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) } template -std::array from_json_inplace_array_impl(BasicJsonType&& j, - identity_tag> /*unused*/, - index_sequence /*unused*/) +std::array +from_json_inplace_array_impl(BasicJsonType&& j, identity_tag> /*unused*/, index_sequence /*unused*/) { return {{std::forward(j).at(Idx).template get()...}}; } @@ -275,7 +278,9 @@ inline void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin = *j.template get_ptr(); } -template::value, int> = 0> +template::value, int> = 0> inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { if (JSON_HEDLEY_UNLIKELY(!j.is_object())) @@ -286,13 +291,9 @@ inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) ConstructibleObjectType ret; const auto* inner_object = j.template get_ptr(); using value_type = typename ConstructibleObjectType::value_type; - std::transform( - inner_object->begin(), - inner_object->end(), - std::inserter(ret, ret.begin()), - [](typename BasicJsonType::object_t::value_type const& p) { - return value_type(p.first, p.second.template get()); - }); + std::transform(inner_object->begin(), inner_object->end(), std::inserter(ret, ret.begin()), [](typename BasicJsonType::object_t::value_type const& p) { + return value_type(p.first, p.second.template get()); + }); obj = std::move(ret); } @@ -300,7 +301,13 @@ inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) // (BooleanType, etc..); note: Is it really necessary to provide explicit // overloads for boolean_t etc. in case of a custom BooleanType which is not // an arithmetic type? -template::value && !std::is_same::value && !std::is_same::value && !std::is_same::value && !std::is_same::value, int> = 0> +template::value && !std::is_same::value && + !std::is_same::value && + !std::is_same::value && + !std::is_same::value, + int> = 0> inline void from_json(const BasicJsonType& j, ArithmeticType& val) { switch (static_cast(j)) @@ -346,8 +353,7 @@ std::tuple from_json_tuple_impl_base(BasicJsonType&& j, index_sequence< template std::pair from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<0> /*unused*/) { - return {std::forward(j).at(0).template get(), - std::forward(j).at(1).template get()}; + return {std::forward(j).at(0).template get(), std::forward(j).at(1).template get()}; } template @@ -380,7 +386,12 @@ auto from_json(BasicJsonType&& j, TupleRelated&& t) return from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3>{}); } -template::value>> +template::value>> inline void from_json(const BasicJsonType& j, std::map& m) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) @@ -398,7 +409,13 @@ inline void from_json(const BasicJsonType& j, std::map::value>> +template::value>> inline void from_json(const BasicJsonType& j, std::unordered_map& m) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) @@ -431,9 +448,8 @@ inline void from_json(const BasicJsonType& j, std_fs::path& p) struct from_json_fn { template - auto operator()(const BasicJsonType& j, T&& val) const - noexcept(noexcept(from_json(j, std::forward(val)))) - -> decltype(from_json(j, std::forward(val))) + auto operator()(const BasicJsonType& j, T&& val) const noexcept(noexcept(from_json(j, std::forward(val)))) + -> decltype(from_json(j, std::forward(val))) { return from_json(j, std::forward(val)); } diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp index 51f2b4a88d..f1dabf4871 100644 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ b/include/nlohmann/detail/conversions/to_chars.hpp @@ -19,7 +19,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /*! @brief implements the Grisu2 algorithm for binary to decimal floating-point @@ -40,7 +41,8 @@ For a detailed description of the algorithm see: Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language Design and Implementation, PLDI 1996 */ -namespace dtoa_impl { +namespace dtoa_impl +{ template Target reinterpret_bits(const Source source) @@ -199,8 +201,7 @@ boundaries compute_boundaries(FloatType value) // If v is normalized: // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1)) - static_assert(std::numeric_limits::is_iec559, - "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); + static_assert(std::numeric_limits::is_iec559, "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); constexpr int kPrecision = std::numeric_limits::digits; // = p (includes the hidden bit) constexpr int kBias = std::numeric_limits::max_exponent - 1 + (kPrecision - 1); @@ -214,9 +215,7 @@ boundaries compute_boundaries(FloatType value) const std::uint64_t F = bits & (kHiddenBit - 1); const bool is_denormal = E == 0; - const diyfp v = is_denormal - ? diyfp(F, kMinExp) - : diyfp(F + kHiddenBit, static_cast(E) - kBias); + const diyfp v = is_denormal ? diyfp(F, kMinExp) : diyfp(F + kHiddenBit, static_cast(E) - kBias); // Compute the boundaries m- and m+ of the floating-point value // v = f * 2^e. @@ -241,9 +240,8 @@ boundaries compute_boundaries(FloatType value) const bool lower_boundary_is_closer = F == 0 && E > 1; const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1); - const diyfp m_minus = lower_boundary_is_closer - ? diyfp(4 * v.f - 1, v.e - 2) // (B) - : diyfp(2 * v.f - 1, v.e - 1); // (A) + const diyfp m_minus = lower_boundary_is_closer ? diyfp(4 * v.f - 1, v.e - 2) // (B) + : diyfp(2 * v.f - 1, v.e - 1); // (A) // Determine the normalized w+ = m+. const diyfp w_plus = diyfp::normalize(m_plus); @@ -381,89 +379,28 @@ inline cached_power get_cached_power_for_binary_exponent(int e) constexpr int kCachedPowersMinDecExp = -300; constexpr int kCachedPowersDecStep = 8; - static constexpr std::array kCachedPowers = - { - { - {0xAB70FE17C79AC6CA, -1060, -300}, - {0xFF77B1FCBEBCDC4F, -1034, -292}, - {0xBE5691EF416BD60C, -1007, -284}, - {0x8DD01FAD907FFC3C, -980, -276}, - {0xD3515C2831559A83, -954, -268}, - {0x9D71AC8FADA6C9B5, -927, -260}, - {0xEA9C227723EE8BCB, -901, -252}, - {0xAECC49914078536D, -874, -244}, - {0x823C12795DB6CE57, -847, -236}, - {0xC21094364DFB5637, -821, -228}, - {0x9096EA6F3848984F, -794, -220}, - {0xD77485CB25823AC7, -768, -212}, - {0xA086CFCD97BF97F4, -741, -204}, - {0xEF340A98172AACE5, -715, -196}, - {0xB23867FB2A35B28E, -688, -188}, - {0x84C8D4DFD2C63F3B, -661, -180}, - {0xC5DD44271AD3CDBA, -635, -172}, - {0x936B9FCEBB25C996, -608, -164}, - {0xDBAC6C247D62A584, -582, -156}, - {0xA3AB66580D5FDAF6, -555, -148}, - {0xF3E2F893DEC3F126, -529, -140}, - {0xB5B5ADA8AAFF80B8, -502, -132}, - {0x87625F056C7C4A8B, -475, -124}, - {0xC9BCFF6034C13053, -449, -116}, - {0x964E858C91BA2655, -422, -108}, - {0xDFF9772470297EBD, -396, -100}, - {0xA6DFBD9FB8E5B88F, -369, -92}, - {0xF8A95FCF88747D94, -343, -84}, - {0xB94470938FA89BCF, -316, -76}, - {0x8A08F0F8BF0F156B, -289, -68}, - {0xCDB02555653131B6, -263, -60}, - {0x993FE2C6D07B7FAC, -236, -52}, - {0xE45C10C42A2B3B06, -210, -44}, - {0xAA242499697392D3, -183, -36}, - {0xFD87B5F28300CA0E, -157, -28}, - {0xBCE5086492111AEB, -130, -20}, - {0x8CBCCC096F5088CC, -103, -12}, - {0xD1B71758E219652C, -77, -4}, - {0x9C40000000000000, -50, 4}, - {0xE8D4A51000000000, -24, 12}, - {0xAD78EBC5AC620000, 3, 20}, - {0x813F3978F8940984, 30, 28}, - {0xC097CE7BC90715B3, 56, 36}, - {0x8F7E32CE7BEA5C70, 83, 44}, - {0xD5D238A4ABE98068, 109, 52}, - {0x9F4F2726179A2245, 136, 60}, - {0xED63A231D4C4FB27, 162, 68}, - {0xB0DE65388CC8ADA8, 189, 76}, - {0x83C7088E1AAB65DB, 216, 84}, - {0xC45D1DF942711D9A, 242, 92}, - {0x924D692CA61BE758, 269, 100}, - {0xDA01EE641A708DEA, 295, 108}, - {0xA26DA3999AEF774A, 322, 116}, - {0xF209787BB47D6B85, 348, 124}, - {0xB454E4A179DD1877, 375, 132}, - {0x865B86925B9BC5C2, 402, 140}, - {0xC83553C5C8965D3D, 428, 148}, - {0x952AB45CFA97A0B3, 455, 156}, - {0xDE469FBD99A05FE3, 481, 164}, - {0xA59BC234DB398C25, 508, 172}, - {0xF6C69A72A3989F5C, 534, 180}, - {0xB7DCBF5354E9BECE, 561, 188}, - {0x88FCF317F22241E2, 588, 196}, - {0xCC20CE9BD35C78A5, 614, 204}, - {0x98165AF37B2153DF, 641, 212}, - {0xE2A0B5DC971F303A, 667, 220}, - {0xA8D9D1535CE3B396, 694, 228}, - {0xFB9B7CD9A4A7443C, 720, 236}, - {0xBB764C4CA7A44410, 747, 244}, - {0x8BAB8EEFB6409C1A, 774, 252}, - {0xD01FEF10A657842C, 800, 260}, - {0x9B10A4E5E9913129, 827, 268}, - {0xE7109BFBA19C0C9D, 853, 276}, - {0xAC2820D9623BF429, 880, 284}, - {0x80444B5E7AA7CF85, 907, 292}, - {0xBF21E44003ACDD2D, 933, 300}, - {0x8E679C2F5E44FF8F, 960, 308}, - {0xD433179D9C8CB841, 986, 316}, - {0x9E19DB92B4E31BA9, 1013, 324}, - }}; + static constexpr std::array kCachedPowers = {{ + {0xAB70FE17C79AC6CA, -1060, -300}, {0xFF77B1FCBEBCDC4F, -1034, -292}, {0xBE5691EF416BD60C, -1007, -284}, {0x8DD01FAD907FFC3C, -980, -276}, + {0xD3515C2831559A83, -954, -268}, {0x9D71AC8FADA6C9B5, -927, -260}, {0xEA9C227723EE8BCB, -901, -252}, {0xAECC49914078536D, -874, -244}, + {0x823C12795DB6CE57, -847, -236}, {0xC21094364DFB5637, -821, -228}, {0x9096EA6F3848984F, -794, -220}, {0xD77485CB25823AC7, -768, -212}, + {0xA086CFCD97BF97F4, -741, -204}, {0xEF340A98172AACE5, -715, -196}, {0xB23867FB2A35B28E, -688, -188}, {0x84C8D4DFD2C63F3B, -661, -180}, + {0xC5DD44271AD3CDBA, -635, -172}, {0x936B9FCEBB25C996, -608, -164}, {0xDBAC6C247D62A584, -582, -156}, {0xA3AB66580D5FDAF6, -555, -148}, + {0xF3E2F893DEC3F126, -529, -140}, {0xB5B5ADA8AAFF80B8, -502, -132}, {0x87625F056C7C4A8B, -475, -124}, {0xC9BCFF6034C13053, -449, -116}, + {0x964E858C91BA2655, -422, -108}, {0xDFF9772470297EBD, -396, -100}, {0xA6DFBD9FB8E5B88F, -369, -92}, {0xF8A95FCF88747D94, -343, -84}, + {0xB94470938FA89BCF, -316, -76}, {0x8A08F0F8BF0F156B, -289, -68}, {0xCDB02555653131B6, -263, -60}, {0x993FE2C6D07B7FAC, -236, -52}, + {0xE45C10C42A2B3B06, -210, -44}, {0xAA242499697392D3, -183, -36}, {0xFD87B5F28300CA0E, -157, -28}, {0xBCE5086492111AEB, -130, -20}, + {0x8CBCCC096F5088CC, -103, -12}, {0xD1B71758E219652C, -77, -4}, {0x9C40000000000000, -50, 4}, {0xE8D4A51000000000, -24, 12}, + {0xAD78EBC5AC620000, 3, 20}, {0x813F3978F8940984, 30, 28}, {0xC097CE7BC90715B3, 56, 36}, {0x8F7E32CE7BEA5C70, 83, 44}, + {0xD5D238A4ABE98068, 109, 52}, {0x9F4F2726179A2245, 136, 60}, {0xED63A231D4C4FB27, 162, 68}, {0xB0DE65388CC8ADA8, 189, 76}, + {0x83C7088E1AAB65DB, 216, 84}, {0xC45D1DF942711D9A, 242, 92}, {0x924D692CA61BE758, 269, 100}, {0xDA01EE641A708DEA, 295, 108}, + {0xA26DA3999AEF774A, 322, 116}, {0xF209787BB47D6B85, 348, 124}, {0xB454E4A179DD1877, 375, 132}, {0x865B86925B9BC5C2, 402, 140}, + {0xC83553C5C8965D3D, 428, 148}, {0x952AB45CFA97A0B3, 455, 156}, {0xDE469FBD99A05FE3, 481, 164}, {0xA59BC234DB398C25, 508, 172}, + {0xF6C69A72A3989F5C, 534, 180}, {0xB7DCBF5354E9BECE, 561, 188}, {0x88FCF317F22241E2, 588, 196}, {0xCC20CE9BD35C78A5, 614, 204}, + {0x98165AF37B2153DF, 641, 212}, {0xE2A0B5DC971F303A, 667, 220}, {0xA8D9D1535CE3B396, 694, 228}, {0xFB9B7CD9A4A7443C, 720, 236}, + {0xBB764C4CA7A44410, 747, 244}, {0x8BAB8EEFB6409C1A, 774, 252}, {0xD01FEF10A657842C, 800, 260}, {0x9B10A4E5E9913129, 827, 268}, + {0xE7109BFBA19C0C9D, 853, 276}, {0xAC2820D9623BF429, 880, 284}, {0x80444B5E7AA7CF85, 907, 292}, {0xBF21E44003ACDD2D, 933, 300}, + {0x8E679C2F5E44FF8F, 960, 308}, {0xD433179D9C8CB841, 986, 316}, {0x9E19DB92B4E31BA9, 1013, 324}, + }}; // This computation gives exactly the same results for k as // k = ceil((kAlpha - e - 1) * 0.30102999566398114) @@ -882,8 +819,7 @@ template JSON_HEDLEY_NON_NULL(1) void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) { - static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, - "internal error: not enough precision"); + static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, "internal error: not enough precision"); JSON_ASSERT(std::isfinite(value)); JSON_ASSERT(value > 0); @@ -1055,8 +991,7 @@ format. Returns an iterator pointing past-the-end of the decimal representation. */ template JSON_HEDLEY_NON_NULL(1, 2) -JSON_HEDLEY_RETURNS_NON_NULL - char* to_chars(char* first, const char* last, FloatType value) +JSON_HEDLEY_RETURNS_NON_NULL char* to_chars(char* first, const char* last, FloatType value) { static_cast(last); // maybe unused - fix warning JSON_ASSERT(std::isfinite(value)); diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index 1efce1a783..4fd3d860ac 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -25,7 +25,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ ////////////////// // constructors // @@ -75,7 +76,9 @@ struct external_constructor j.assert_invariant(); } - template::value, int> = 0> + template::value, int> = 0> static void construct(BasicJsonType& j, const CompatibleStringType& str) { j.m_data.m_value.destroy(j.m_data.m_type); @@ -169,7 +172,9 @@ struct external_constructor j.assert_invariant(); } - template::value, int> = 0> + template::value, int> = 0> static void construct(BasicJsonType& j, const CompatibleArrayType& arr) { using std::begin; @@ -236,7 +241,9 @@ struct external_constructor j.assert_invariant(); } - template::value, int> = 0> + template::value, int> = 0> static void construct(BasicJsonType& j, const CompatibleObjectType& obj) { using std::begin; @@ -260,13 +267,22 @@ inline void to_json(BasicJsonType& j, T b) noexcept external_constructor::construct(j, b); } -template::reference, BoolRef>::value && !std::is_same::reference, typename BasicJsonType::boolean_t&>::value) || (std::is_same::const_reference, BoolRef>::value && !std::is_same::const_reference>, typename BasicJsonType::boolean_t>::value)) && std::is_convertible::value, int> = 0> +template::reference, BoolRef>::value && + !std::is_same::reference, typename BasicJsonType::boolean_t&>::value) || + (std::is_same::const_reference, BoolRef>::value && + !std::is_same::const_reference>, typename BasicJsonType::boolean_t>::value)) && + std::is_convertible::value, + int> = 0> inline void to_json(BasicJsonType& j, const BoolRef& b) noexcept { external_constructor::construct(j, static_cast(b)); } -template::value, int> = 0> +template::value, int> = 0> inline void to_json(BasicJsonType& j, const CompatibleString& s) { external_constructor::construct(j, s); @@ -284,13 +300,17 @@ inline void to_json(BasicJsonType& j, FloatType val) noexcept external_constructor::construct(j, static_cast(val)); } -template::value, int> = 0> +template::value, int> = 0> inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept { external_constructor::construct(j, static_cast(val)); } -template::value, int> = 0> +template::value, int> = 0> inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept { external_constructor::construct(j, static_cast(val)); @@ -311,7 +331,13 @@ inline void to_json(BasicJsonType& j, const std::vector& e) external_constructor::construct(j, e); } -template::value && !is_compatible_object_type::value && !is_compatible_string_type::value && !std::is_same::value && !is_basic_json::value, int> = 0> +template< + typename BasicJsonType, + typename CompatibleArrayType, + enable_if_t::value && !is_compatible_object_type::value && + !is_compatible_string_type::value && + !std::is_same::value && !is_basic_json::value, + int> = 0> inline void to_json(BasicJsonType& j, const CompatibleArrayType& arr) { external_constructor::construct(j, arr); @@ -335,7 +361,9 @@ inline void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) external_constructor::construct(j, std::move(arr)); } -template::value && !is_basic_json::value, int> = 0> +template::value && !is_basic_json::value, int> = 0> inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj) { external_constructor::construct(j, obj); @@ -347,19 +375,21 @@ inline void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) external_constructor::construct(j, std::move(obj)); } -template< - typename BasicJsonType, - typename T, - std::size_t N, - enable_if_t::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - int> = 0> +template::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) + int> = 0> inline void to_json(BasicJsonType& j, const T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) { external_constructor::construct(j, arr); } -template::value && std::is_constructible::value, int> = 0> +template::value && std::is_constructible::value, int> = 0> inline void to_json(BasicJsonType& j, const std::pair& p) { j = {p.first, p.second}; @@ -395,8 +425,7 @@ inline void to_json(BasicJsonType& j, const std_fs::path& p) struct to_json_fn { template - auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) - -> decltype(to_json(j, std::forward(val)), void()) + auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) -> decltype(to_json(j, std::forward(val)), void()) { return to_json(j, std::forward(val)); } diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index 430b9acba3..ac4014b671 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -26,7 +26,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ //////////////// // exceptions // @@ -155,7 +156,12 @@ class parse_error : public exception template::value, int> = 0> static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, BasicJsonContext context) { - const std::string w = concat(exception::name("parse_error", id_), "parse error", (byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""), ": ", exception::diagnostics(context), what_arg); + const std::string w = concat(exception::name("parse_error", id_), + "parse error", + (byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""), + ": ", + exception::diagnostics(context), + what_arg); return {id_, byte_, w.c_str()}; } diff --git a/include/nlohmann/detail/hash.hpp b/include/nlohmann/detail/hash.hpp index 64bff1cc31..2d405110b0 100644 --- a/include/nlohmann/detail/hash.hpp +++ b/include/nlohmann/detail/hash.hpp @@ -16,7 +16,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ // boost::hash_combine inline std::size_t combine(std::size_t seed, std::size_t h) noexcept diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index e2509d5968..4d7316f6d6 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -32,7 +32,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /// how to treat CBOR tags enum class cbor_tag_handler_t @@ -102,10 +103,7 @@ class binary_reader @return whether parsing was successful */ JSON_HEDLEY_NON_NULL(3) - bool sax_parse(const input_format_t format, - json_sax_t* sax_, - const bool strict = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + bool sax_parse(const input_format_t format, json_sax_t* sax_, const bool strict = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) { sax = sax_; bool result = false; @@ -148,7 +146,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(current != char_traits::eof())) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(110, + chars_read, + exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), + nullptr)); } } @@ -224,7 +228,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(len < 1)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), + nullptr)); } return get_string(input_format_t::bson, len - static_cast(1), result) && get() != char_traits::eof(); @@ -245,7 +255,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(len < 0)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, concat("byte array length cannot be negative, is ", std::to_string(len)), "binary"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format_t::bson, concat("byte array length cannot be negative, is ", std::to_string(len)), "binary"), + nullptr)); } // All BSON binary values have a subtype @@ -266,8 +282,7 @@ class binary_reader Unsupported BSON record type 0x... @return whether a valid BSON-object/array was passed to the SAX parser */ - bool parse_bson_element_internal(const char_int_type element_type, - const std::size_t element_type_parse_position) + bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position) { switch (element_type) { @@ -326,9 +341,14 @@ class binary_reader default: // anything else not supported (yet) { std::array cr{{}}; - static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast((std::snprintf)(cr.data(), + cr.size(), + "%.2hhX", + static_cast(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) const std::string cr_str{cr.data()}; - return sax->parse_error(element_type_parse_position, cr_str, parse_error::create(114, element_type_parse_position, concat("Unsupported BSON record type 0x", cr_str), nullptr)); + return sax->parse_error(element_type_parse_position, + cr_str, + parse_error::create(114, element_type_parse_position, concat("Unsupported BSON record type 0x", cr_str), nullptr)); } } } @@ -413,8 +433,7 @@ class binary_reader @return whether a valid CBOR value was passed to the SAX parser */ - bool parse_cbor_internal(const bool get_char, - const cbor_tag_handler_t tag_handler) + bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler) { switch (get_char ? get() : current) { @@ -521,7 +540,8 @@ class binary_reader case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) { std::uint64_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - static_cast(number)); + return get_number(input_format_t::cbor, number) && + sax->number_integer(static_cast(-1) - static_cast(number)); } // Binary data (0x00..0x17 bytes follow) @@ -619,9 +639,7 @@ class binary_reader case 0x95: case 0x96: case 0x97: - return get_cbor_array( - conditional_static_cast(static_cast(current) & 0x1Fu), - tag_handler); + return get_cbor_array(conditional_static_cast(static_cast(current) & 0x1Fu), tag_handler); case 0x98: // array (one-byte uint8_t for n follows) { @@ -729,7 +747,12 @@ class binary_reader case cbor_tag_handler_t::error: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); + return sax->parse_error(chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), + nullptr)); } case cbor_tag_handler_t::ignore: @@ -858,17 +881,12 @@ class binary_reader case 0: return std::ldexp(mant, -24); case 31: - return (mant == 0) - ? std::numeric_limits::infinity() - : std::numeric_limits::quiet_NaN(); + return (mant == 0) ? std::numeric_limits::infinity() : std::numeric_limits::quiet_NaN(); default: return std::ldexp(mant + 1024, exp - 25); } }(); - return sax->number_float((half & 0x8000u) != 0 - ? static_cast(-val) - : static_cast(val), - ""); + return sax->number_float((half & 0x8000u) != 0 ? static_cast(-val) : static_cast(val), ""); } case 0xFA: // Single-Precision Float (four-byte IEEE 754) @@ -886,7 +904,10 @@ class binary_reader default: // anything else (0xFF is handled inside the other types) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); } } } @@ -981,7 +1002,16 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, concat("expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token), "string"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create( + 113, + chars_read, + exception_message(input_format_t::cbor, + concat("expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token), + "string"), + nullptr)); } } } @@ -1038,29 +1068,25 @@ class binary_reader case 0x58: // Binary data (one-byte uint8_t for n follows) { std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } case 0x59: // Binary data (two-byte uint16_t for n follow) { std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } case 0x5A: // Binary data (four-byte uint32_t for n follow) { std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } case 0x5B: // Binary data (eight-byte uint64_t for n follow) { std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } case 0x5F: // Binary data (indefinite length) @@ -1080,7 +1106,16 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, concat("expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token), "binary"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create( + 113, + chars_read, + exception_message(input_format_t::cbor, + concat("expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token), + "binary"), + nullptr)); } } } @@ -1091,8 +1126,7 @@ class binary_reader @param[in] tag_handler how CBOR tags should be treated @return whether array creation completed */ - bool get_cbor_array(const std::size_t len, - const cbor_tag_handler_t tag_handler) + bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler) { if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) { @@ -1129,8 +1163,7 @@ class binary_reader @param[in] tag_handler how CBOR tags should be treated @return whether object creation completed */ - bool get_cbor_object(const std::size_t len, - const cbor_tag_handler_t tag_handler) + bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler) { if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) { @@ -1550,7 +1583,10 @@ class binary_reader default: // anything else { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, concat("invalid byte: 0x", last_token), "value"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, concat("invalid byte: 0x", last_token), "value"), nullptr)); } } } @@ -1632,7 +1668,15 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, concat("expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token), "string"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(113, + chars_read, + exception_message(input_format_t::msgpack, + concat("expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token), + "string"), + nullptr)); } } } @@ -1660,92 +1704,73 @@ class binary_reader case 0xC4: // bin 8 { std::uint8_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); + return get_number(input_format_t::msgpack, len) && get_binary(input_format_t::msgpack, len, result); } case 0xC5: // bin 16 { std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); + return get_number(input_format_t::msgpack, len) && get_binary(input_format_t::msgpack, len, result); } case 0xC6: // bin 32 { std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); + return get_number(input_format_t::msgpack, len) && get_binary(input_format_t::msgpack, len, result); } case 0xC7: // ext 8 { std::uint8_t len{}; std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, len) && get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && assign_and_return_true(subtype); } case 0xC8: // ext 16 { std::uint16_t len{}; std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, len) && get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && assign_and_return_true(subtype); } case 0xC9: // ext 32 { std::uint32_t len{}; std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, len) && get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && assign_and_return_true(subtype); } case 0xD4: // fixext 1 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 1, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 1, result) && assign_and_return_true(subtype); } case 0xD5: // fixext 2 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 2, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 2, result) && assign_and_return_true(subtype); } case 0xD6: // fixext 4 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 4, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 4, result) && assign_and_return_true(subtype); } case 0xD7: // fixext 8 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 8, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 8, result) && assign_and_return_true(subtype); } case 0xD8: // fixext 16 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 16, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 16, result) && assign_and_return_true(subtype); } default: // LCOV_EXCL_LINE @@ -2024,7 +2049,12 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } result = static_cast(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char return true; @@ -2039,7 +2069,12 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } result = static_cast(number); return true; @@ -2054,7 +2089,12 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } result = static_cast(number); return true; @@ -2069,11 +2109,18 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } if (!value_in_range_of(number)) { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "integer value overflow", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + out_of_range::create(408, exception_message(input_format, "integer value overflow", "size"), nullptr)); } result = static_cast(number); return true; @@ -2122,7 +2169,9 @@ class binary_reader } if (!value_in_range_of(number)) { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "integer value overflow", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + out_of_range::create(408, exception_message(input_format, "integer value overflow", "size"), nullptr)); } result = detail::conditional_static_cast(number); return true; @@ -2136,7 +2185,10 @@ class binary_reader } if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr)); } std::vector dim; if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim))) @@ -2168,9 +2220,14 @@ class binary_reader for (auto i : dim) { result *= i; - if (result == 0 || result == npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be npos as it is used to initialize size in get_ubjson_size_type() + if (result == 0 || + result == + npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be npos as it is used to initialize size in get_ubjson_size_type() { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(static_cast(i)))) { @@ -2223,10 +2280,17 @@ class binary_reader if (current == '$') { result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (input_format == input_format_t::bjdata && JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second))) + if (input_format == input_format_t::bjdata && + JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second))) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, concat("marker 0x", last_token, " is not a permitted optimized array type"), "type"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format, concat("marker 0x", last_token, " is not a permitted optimized array type"), "type"), + nullptr)); } if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "type"))) @@ -2242,7 +2306,13 @@ class binary_reader return false; } auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), + nullptr)); } const bool is_error = get_ubjson_size_value(result.first, is_ndarray); @@ -2250,7 +2320,10 @@ class binary_reader { if (inside_ndarray) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, exception_message(input_format, "ndarray can not be recursive", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(112, chars_read, exception_message(input_format, "ndarray can not be recursive", "size"), nullptr)); } result.second |= (1 << 8); // use bit 8 to indicate ndarray, all UBJSON and BJData markers should be ASCII letters } @@ -2262,7 +2335,10 @@ class binary_reader const bool is_error = get_ubjson_size_value(result.first, is_ndarray); if (input_format == input_format_t::bjdata && is_ndarray) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, exception_message(input_format, "ndarray requires both type and size", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(112, chars_read, exception_message(input_format, "ndarray requires both type and size", "size"), nullptr)); } return is_error; } @@ -2388,17 +2464,12 @@ class binary_reader case 0: return std::ldexp(mant, -24); case 31: - return (mant == 0) - ? std::numeric_limits::infinity() - : std::numeric_limits::quiet_NaN(); + return (mant == 0) ? std::numeric_limits::infinity() : std::numeric_limits::quiet_NaN(); default: return std::ldexp(mant + 1024, exp - 25); } }(); - return sax->number_float((half & 0x8000u) != 0 - ? static_cast(-val) - : static_cast(val), - ""); + return sax->number_float((half & 0x8000u) != 0 ? static_cast(-val) : static_cast(val), ""); } case 'd': @@ -2428,7 +2499,14 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(current > 127)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, concat("byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token), "char"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create( + 113, + chars_read, + exception_message(input_format, concat("byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token), "char"), + nullptr)); } string_t s(1, static_cast(current)); return sax->string(s); @@ -2450,7 +2528,9 @@ class binary_reader break; } auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "value"), nullptr)); + return sax->parse_error(chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "value"), nullptr)); } /*! @@ -2477,7 +2557,10 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(it == bjd_types_map.end() || it->first != size_and_type.second)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr)); } string_t type = it->second; // sax->string() takes a reference @@ -2574,7 +2657,13 @@ class binary_reader if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, "BJData object does not support ND-array size in optimized format", "object"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format, "BJData object does not support ND-array size in optimized format", "object"), + nullptr)); } string_t key; @@ -2678,7 +2767,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input)) { - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); + return sax->parse_error( + chars_read, + number_string, + parse_error::create(115, + chars_read, + exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), + nullptr)); } switch (result_number) @@ -2704,7 +2799,14 @@ class binary_reader case token_type::end_of_input: case token_type::literal_or_value: default: - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); + return sax->parse_error( + chars_read, + number_string, + parse_error::create( + 115, + chars_read, + exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), + nullptr)); } } @@ -2799,9 +2901,7 @@ class binary_reader the input before we run out of string memory. */ template - bool get_string(const input_format_t format, - const NumberType len, - string_t& result) + bool get_string(const input_format_t format, const NumberType len, string_t& result) { bool success = true; for (NumberType i = 0; i < len; i++) @@ -2832,9 +2932,7 @@ class binary_reader the input before we run out of memory. */ template - bool get_binary(const input_format_t format, - const NumberType len, - binary_t& result) + bool get_binary(const input_format_t format, const NumberType len, binary_t& result) { bool success = true; for (NumberType i = 0; i < len; i++) @@ -2860,7 +2958,9 @@ class binary_reader { if (JSON_HEDLEY_UNLIKELY(current == char_traits::eof())) { - return sax->parse_error(chars_read, "", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr)); + return sax->parse_error(chars_read, + "", + parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr)); } return true; } @@ -2871,7 +2971,8 @@ class binary_reader std::string get_token_string() const { std::array cr{{}}; - static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast( + (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) return std::string{cr.data()}; } @@ -2881,9 +2982,7 @@ class binary_reader @param[in] context further context information @return a message string to use in the parse_error exceptions */ - std::string exception_message(const input_format_t format, - const std::string& detail, - const std::string& context) const + std::string exception_message(const input_format_t format, const std::string& detail, const std::string& context) const { std::string error_msg = "syntax error while parsing "; @@ -2939,33 +3038,29 @@ class binary_reader json_sax_t* sax = nullptr; // excluded markers in bjdata optimized type -#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \ - make_array('F', 'H', 'N', 'S', 'T', 'Z', '[', '{') - -#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \ - make_array( \ - bjd_type{'C', "char"}, \ - bjd_type{'D', "double"}, \ - bjd_type{'I', "int16"}, \ - bjd_type{'L', "int64"}, \ - bjd_type{'M', "uint64"}, \ - bjd_type{'U', "uint8"}, \ - bjd_type{'d', "single"}, \ - bjd_type{'i', "int8"}, \ - bjd_type{'l', "int32"}, \ - bjd_type{'m', "uint32"}, \ - bjd_type{'u', "uint16"}) +#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ make_array('F', 'H', 'N', 'S', 'T', 'Z', '[', '{') + +#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \ + make_array(bjd_type{'C', "char"}, \ + bjd_type{'D', "double"}, \ + bjd_type{'I', "int16"}, \ + bjd_type{'L', "int64"}, \ + bjd_type{'M', "uint64"}, \ + bjd_type{'U', "uint8"}, \ + bjd_type{'d', "single"}, \ + bjd_type{'i', "int8"}, \ + bjd_type{'l', "int32"}, \ + bjd_type{'m', "uint32"}, \ + bjd_type{'u', "uint16"}) JSON_PRIVATE_UNLESS_TESTED : // lookup tables // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) - const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers = - JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_; + const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers = JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_; using bjd_type = std::pair; // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) - const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) bjd_types_map = - JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_; + const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) bjd_types_map = JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_; #undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ #undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 769775d460..ae38ce4658 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -28,7 +28,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /// the supported input formats enum class input_format_t @@ -187,10 +188,8 @@ template struct wide_string_input_helper { // UTF-32 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) + static void + fill_buffer(BaseInputAdapter& input, std::array::int_type, 4>& utf8_bytes, size_t& utf8_bytes_index, size_t& utf8_bytes_filled) { utf8_bytes_index = 0; @@ -245,10 +244,8 @@ template struct wide_string_input_helper { // UTF-16 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) + static void + fill_buffer(BaseInputAdapter& input, std::array::int_type, 4>& utf8_bytes, size_t& utf8_bytes_index, size_t& utf8_bytes_filled) { utf8_bytes_index = 0; @@ -398,7 +395,8 @@ typename iterator_input_adapter_factory::adapter_type input_adapte // Enables ADL on begin(container) and end(container) // Encloses the using declarations in namespace for not to leak them to outside scope -namespace container_input_adapter_factory_impl { +namespace container_input_adapter_factory_impl +{ using std::begin; using std::end; @@ -408,8 +406,7 @@ struct container_input_adapter_factory {}; template -struct container_input_adapter_factory()), end(std::declval()))>> +struct container_input_adapter_factory()), end(std::declval()))>> { using adapter_type = decltype(input_adapter(begin(std::declval()), end(std::declval()))); @@ -448,13 +445,11 @@ inline input_stream_adapter input_adapter(std::istream&& stream) using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval(), std::declval())); // Null-delimited strings, and the like. -template::value && - !std::is_array::value && - std::is_integral::type>::value && - sizeof(typename std::remove_pointer::type) == 1, - int>::type = 0> +template< + typename CharT, + typename std::enable_if::value && !std::is_array::value && + std::is_integral::type>::value && sizeof(typename std::remove_pointer::type) == 1, + int>::type = 0> contiguous_bytes_input_adapter input_adapter(CharT b) { auto length = std::strlen(reinterpret_cast(b)); @@ -463,7 +458,8 @@ contiguous_bytes_input_adapter input_adapter(CharT b) } template -auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) +auto input_adapter(T (&array)[N]) + -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) { return input_adapter(array, array + N); } @@ -475,19 +471,16 @@ class span_input_adapter { public: template::value && - std::is_integral::type>::value && - sizeof(typename std::remove_pointer::type) == 1, - int>::type = 0> + typename std::enable_if::value && std::is_integral::type>::value && + sizeof(typename std::remove_pointer::type) == 1, + int>::type = 0> span_input_adapter(CharT b, std::size_t l) : ia(reinterpret_cast(b), reinterpret_cast(b) + l) {} - template::iterator_category, std::random_access_iterator_tag>::value, - int>::type = 0> + template< + class IteratorType, + typename std::enable_if::iterator_category, std::random_access_iterator_tag>::value, int>::type = 0> span_input_adapter(IteratorType first, IteratorType last) : ia(input_adapter(first, last)) {} diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index 90b2ac90b4..864f4a167b 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -130,9 +130,7 @@ struct json_sax @param[in] ex an exception object describing the error @return whether parsing should proceed (must return false) */ - virtual bool parse_error(std::size_t position, - const std::string& last_token, - const detail::exception& ex) = 0; + virtual bool parse_error(std::size_t position, const std::string& last_token, const detail::exception& ex) = 0; json_sax() = default; json_sax(const json_sax&) = default; @@ -142,7 +140,8 @@ struct json_sax virtual ~json_sax() = default; }; -namespace detail { +namespace detail +{ /*! @brief SAX implementation to create a JSON value from SAX events @@ -304,9 +303,7 @@ class json_sax_dom_parser object to which we can add elements */ template - JSON_HEDLEY_RETURNS_NON_NULL - BasicJsonType* - handle_value(Value&& v) + JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType* handle_value(Value&& v) { if (ref_stack.empty()) { @@ -352,9 +349,7 @@ class json_sax_dom_callback_parser using parser_callback_t = typename BasicJsonType::parser_callback_t; using parse_event_t = typename BasicJsonType::parse_event_t; - json_sax_dom_callback_parser(BasicJsonType& r, - const parser_callback_t cb, - const bool allow_exceptions_ = true) + json_sax_dom_callback_parser(BasicJsonType& r, const parser_callback_t cb, const bool allow_exceptions_ = true) : root(r) , callback(cb) , allow_exceptions(allow_exceptions_) diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 6fabf35259..a132e2c984 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -24,7 +24,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /////////// // lexer // @@ -1184,8 +1185,7 @@ class lexer : public lexer_base default: { - error_message = - "invalid number; expected '+', '-', or digit after exponent"; + error_message = "invalid number; expected '+', '-', or digit after exponent"; return token_type::parse_error; } } @@ -1454,7 +1454,8 @@ class lexer : public lexer_base { // escape control characters std::array cs{{}}; - static_cast((std::snprintf)(cs.data(), cs.size(), "", static_cast(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast(( + std::snprintf)(cs.data(), cs.size(), "", static_cast(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) result += cs.data(); } else @@ -1547,17 +1548,23 @@ class lexer : public lexer_base // literals case 't': { - std::array true_literal = {{static_cast('t'), static_cast('r'), static_cast('u'), static_cast('e')}}; + std::array true_literal = { + {static_cast('t'), static_cast('r'), static_cast('u'), static_cast('e')}}; return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); } case 'f': { - std::array false_literal = {{static_cast('f'), static_cast('a'), static_cast('l'), static_cast('s'), static_cast('e')}}; + std::array false_literal = {{static_cast('f'), + static_cast('a'), + static_cast('l'), + static_cast('s'), + static_cast('e')}}; return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); } case 'n': { - std::array null_literal = {{static_cast('n'), static_cast('u'), static_cast('l'), static_cast('l')}}; + std::array null_literal = { + {static_cast('n'), static_cast('u'), static_cast('l'), static_cast('l')}}; return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); } diff --git a/include/nlohmann/detail/input/parser.hpp b/include/nlohmann/detail/input/parser.hpp index b90b0210bb..40893e219d 100644 --- a/include/nlohmann/detail/input/parser.hpp +++ b/include/nlohmann/detail/input/parser.hpp @@ -25,7 +25,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ //////////// // parser // //////////// @@ -47,8 +48,7 @@ enum class parse_event_t : std::uint8_t }; template -using parser_callback_t = - std::function; +using parser_callback_t = std::function; /*! @brief syntax analysis @@ -210,9 +210,10 @@ class parser // parse key if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) { @@ -222,9 +223,10 @@ class parser // parse separator (:) if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); } // remember we are now inside an object @@ -335,22 +337,28 @@ class parser case token_type::parse_error: { // using "uninitialized" to avoid "expected" message - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr)); } case token_type::end_of_input: { if (JSON_HEDLEY_UNLIKELY(m_lexer.get_position().chars_read_total == 1)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), "attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, + m_lexer.get_position(), + "attempting to parse an empty input; check that your input string or stream contains the expected JSON", + nullptr)); } - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); } case token_type::uninitialized: case token_type::end_array: @@ -360,9 +368,10 @@ class parser case token_type::literal_or_value: default: // the last token was unexpected { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); } } } @@ -419,9 +428,10 @@ class parser // parse key if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) @@ -432,9 +442,10 @@ class parser // parse separator (:) if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); } // parse values diff --git a/include/nlohmann/detail/input/position_t.hpp b/include/nlohmann/detail/input/position_t.hpp index 5bda49876d..a5e0808f40 100644 --- a/include/nlohmann/detail/input/position_t.hpp +++ b/include/nlohmann/detail/input/position_t.hpp @@ -13,7 +13,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /// struct to capture the start position of the current token struct position_t diff --git a/include/nlohmann/detail/iterators/internal_iterator.hpp b/include/nlohmann/detail/iterators/internal_iterator.hpp index b706454e68..c0db658e50 100644 --- a/include/nlohmann/detail/iterators/internal_iterator.hpp +++ b/include/nlohmann/detail/iterators/internal_iterator.hpp @@ -12,7 +12,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /*! @brief an iterator value diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index d50ca28906..bb612d7fbe 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -20,7 +20,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ // forward declare, to be able to friend it later on template @@ -48,7 +49,8 @@ template class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) { /// the iterator with BasicJsonType of different const-ness - using other_iter_impl = iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; + using other_iter_impl = + iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; /// allow basic_json to access private members friend other_iter_impl; friend BasicJsonType; @@ -58,10 +60,10 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec using object_t = typename BasicJsonType::object_t; using array_t = typename BasicJsonType::array_t; // make sure BasicJsonType is basic_json or const basic_json - static_assert(is_basic_json::type>::value, - "iter_impl only accepts (const) basic_json"); + static_assert(is_basic_json::type>::value, "iter_impl only accepts (const) basic_json"); // superficial check for the LegacyBidirectionalIterator named requirement - static_assert(std::is_base_of::value && std::is_base_of::iterator_category>::value, + static_assert(std::is_base_of::value && + std::is_base_of::iterator_category>::value, "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement."); public: @@ -77,14 +79,11 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// a type to represent differences between iterators using difference_type = typename BasicJsonType::difference_type; /// defines a pointer to the type iterated over (value_type) - using pointer = typename std::conditional::value, - typename BasicJsonType::const_pointer, - typename BasicJsonType::pointer>::type; + using pointer = + typename std::conditional::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer>::type; /// defines a reference to the type iterated over (value_type) using reference = - typename std::conditional::value, - typename BasicJsonType::const_reference, - typename BasicJsonType::reference>::type; + typename std::conditional::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference>::type; iter_impl() = default; ~iter_impl() = default; @@ -469,7 +468,8 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec @brief comparison: equal @pre The iterator is initialized; i.e. `m_object != nullptr`. */ - template::value || std::is_same::value), std::nullptr_t> = nullptr> + template::value || std::is_same::value), std::nullptr_t> = nullptr> bool operator==(const IterImpl& other) const { // if objects are not the same, the comparison is undefined @@ -505,7 +505,8 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec @brief comparison: not equal @pre The iterator is initialized; i.e. `m_object != nullptr`. */ - template::value || std::is_same::value), std::nullptr_t> = nullptr> + template::value || std::is_same::value), std::nullptr_t> = nullptr> bool operator!=(const IterImpl& other) const { return !operator==(other); diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp index 457b4efb36..090cc9ca37 100644 --- a/include/nlohmann/detail/iterators/iteration_proxy.hpp +++ b/include/nlohmann/detail/iterators/iteration_proxy.hpp @@ -23,7 +23,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template void int_to_string(string_type& target, std::size_t value) @@ -57,7 +58,8 @@ class iteration_proxy_value public: explicit iteration_proxy_value() = default; - explicit iteration_proxy_value(IteratorType it, std::size_t array_index_ = 0) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_default_constructible::value) + explicit iteration_proxy_value(IteratorType it, std::size_t array_index_ = 0) noexcept(std::is_nothrow_move_constructible::value && + std::is_nothrow_default_constructible::value) : anchor(std::move(it)) , array_index(array_index_) {} @@ -65,8 +67,12 @@ class iteration_proxy_value iteration_proxy_value(iteration_proxy_value const&) = default; iteration_proxy_value& operator=(iteration_proxy_value const&) = default; // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions - iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) - iteration_proxy_value& operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable::value && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) + iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible::value && + std::is_nothrow_move_constructible::value) = + default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) + iteration_proxy_value& operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable::value && + std::is_nothrow_move_assignable::value) = + default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) ~iteration_proxy_value() = default; /// dereference operator (needed for range-based for) @@ -206,7 +212,8 @@ NLOHMANN_JSON_NAMESPACE_END // Structured Bindings Support to the iteration_proxy_value class // For further reference see https://blog.tartanllama.xyz/structured-bindings/ // And see https://github.com/nlohmann/json/pull/1391 -namespace std { +namespace std +{ #if defined(__clang__) // Fix: https://github.com/nlohmann/json/issues/1401 @@ -222,8 +229,7 @@ template class tuple_element> // NOLINT(cert-dcl58-cpp) { public: - using type = decltype(get(std::declval< - ::nlohmann::detail::iteration_proxy_value>())); + using type = decltype(get(std::declval<::nlohmann::detail::iteration_proxy_value>())); }; #if defined(__clang__) #pragma clang diagnostic pop diff --git a/include/nlohmann/detail/iterators/iterator_traits.hpp b/include/nlohmann/detail/iterators/iterator_traits.hpp index 4fd2e9c531..6c85b0e3a9 100644 --- a/include/nlohmann/detail/iterators/iterator_traits.hpp +++ b/include/nlohmann/detail/iterators/iterator_traits.hpp @@ -15,7 +15,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template struct iterator_types @@ -37,14 +38,11 @@ struct iterator_types< // doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. template struct iterator_traits -{ -}; +{}; template -struct iterator_traits::value>> - : iterator_types -{ -}; +struct iterator_traits::value>> : iterator_types +{}; template struct iterator_traits::value>> diff --git a/include/nlohmann/detail/iterators/json_reverse_iterator.hpp b/include/nlohmann/detail/iterators/json_reverse_iterator.hpp index b61e2badd2..1a99af2f11 100644 --- a/include/nlohmann/detail/iterators/json_reverse_iterator.hpp +++ b/include/nlohmann/detail/iterators/json_reverse_iterator.hpp @@ -15,7 +15,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ ////////////////////// // reverse_iterator // diff --git a/include/nlohmann/detail/iterators/primitive_iterator.hpp b/include/nlohmann/detail/iterators/primitive_iterator.hpp index 5d6b53b5c9..4c651a2a3b 100644 --- a/include/nlohmann/detail/iterators/primitive_iterator.hpp +++ b/include/nlohmann/detail/iterators/primitive_iterator.hpp @@ -14,7 +14,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /* @brief an iterator for primitive JSON types diff --git a/include/nlohmann/detail/json_custom_base_class.hpp b/include/nlohmann/detail/json_custom_base_class.hpp index 76fd8dc3bc..4dd54cd9aa 100644 --- a/include/nlohmann/detail/json_custom_base_class.hpp +++ b/include/nlohmann/detail/json_custom_base_class.hpp @@ -13,7 +13,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /*! @brief Default base class of the @ref basic_json class. @@ -29,10 +30,7 @@ struct json_default_base {}; template -using json_base_class = typename std::conditional< - std::is_same::value, - json_default_base, - T>::type; +using json_base_class = typename std::conditional::value, json_default_base, T>::type; } // namespace detail NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp index f782d48796..5f3cde8a1e 100644 --- a/include/nlohmann/detail/json_pointer.hpp +++ b/include/nlohmann/detail/json_pointer.hpp @@ -94,9 +94,7 @@ class json_pointer /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ json_pointer& operator/=(const json_pointer& ptr) { - reference_tokens.insert(reference_tokens.end(), - ptr.reference_tokens.begin(), - ptr.reference_tokens.end()); + reference_tokens.insert(reference_tokens.end(), ptr.reference_tokens.begin(), ptr.reference_tokens.end()); return *this; } @@ -117,8 +115,7 @@ class json_pointer /// @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ - friend json_pointer operator/(const json_pointer& lhs, - const json_pointer& rhs) + friend json_pointer operator/(const json_pointer& lhs, const json_pointer& rhs) { return json_pointer(lhs) /= rhs; } @@ -355,15 +352,12 @@ class json_pointer if (ptr->is_null()) { // check if reference token is a number - const bool nums = - std::all_of(reference_token.begin(), reference_token.end(), [](const unsigned char x) { - return std::isdigit(x); - }); + const bool nums = std::all_of(reference_token.begin(), reference_token.end(), [](const unsigned char x) { + return std::isdigit(x); + }); // change value to array for numbers or "-" or to object otherwise - *ptr = (nums || reference_token == "-") - ? detail::value_t::array - : detail::value_t::object; + *ptr = (nums || reference_token == "-") ? detail::value_t::array : detail::value_t::object; } switch (ptr->type()) @@ -431,7 +425,10 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), ptr)); + JSON_THROW(detail::out_of_range::create( + 402, + detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), + ptr)); } // note: at performs range check @@ -487,7 +484,10 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" cannot be used for const access - JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), ptr)); + JSON_THROW(detail::out_of_range::create( + 402, + detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), + ptr)); } // use unchecked array access @@ -536,7 +536,10 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), ptr)); + JSON_THROW(detail::out_of_range::create( + 402, + detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), + ptr)); } // note: at performs range check @@ -666,7 +669,8 @@ class json_pointer // check if nonempty reference string begins with slash if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) { - JSON_THROW(detail::parse_error::create(107, 1, detail::concat("JSON pointer must be empty or begin with '/' - was: '", reference_string, "'"), nullptr)); + JSON_THROW( + detail::parse_error::create(107, 1, detail::concat("JSON pointer must be empty or begin with '/' - was: '", reference_string, "'"), nullptr)); } // extract the reference tokens: @@ -690,16 +694,12 @@ class json_pointer auto reference_token = reference_string.substr(start, slash - start); // check reference tokens are properly escaped - for (std::size_t pos = reference_token.find_first_of('~'); - pos != string_t::npos; - pos = reference_token.find_first_of('~', pos + 1)) + for (std::size_t pos = reference_token.find_first_of('~'); pos != string_t::npos; pos = reference_token.find_first_of('~', pos + 1)) { JSON_ASSERT(reference_token[pos] == '~'); // ~ must be followed by 0 or 1 - if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || - (reference_token[pos + 1] != '0' && - reference_token[pos + 1] != '1'))) + if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || (reference_token[pos + 1] != '0' && reference_token[pos + 1] != '1'))) { JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", nullptr)); } @@ -722,9 +722,7 @@ class json_pointer @note Empty objects or arrays are flattened to `null`. */ template - static void flatten(const string_t& reference_string, - const BasicJsonType& value, - BasicJsonType& result) + static void flatten(const string_t& reference_string, const BasicJsonType& value, BasicJsonType& result) { switch (value.type()) { @@ -740,9 +738,7 @@ class json_pointer // iterate array and use index as reference string for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i) { - flatten(detail::concat(reference_string, '/', std::to_string(i)), - value.m_data.m_value.array->operator[](i), - result); + flatten(detail::concat(reference_string, '/', std::to_string(i)), value.m_data.m_value.array->operator[](i), result); } } break; @@ -794,8 +790,7 @@ class json_pointer @throw type_error.313 if value cannot be unflattened */ template - static BasicJsonType - unflatten(const BasicJsonType& value) + static BasicJsonType unflatten(const BasicJsonType& value) { if (JSON_HEDLEY_UNLIKELY(!value.is_object())) { @@ -866,49 +861,42 @@ class json_pointer /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const json_pointer& lhs, - const json_pointer& rhs) noexcept; + friend bool operator==(const json_pointer& lhs, const json_pointer& rhs) noexcept; /// @brief compares JSON pointer and string for equality /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const json_pointer& lhs, - const StringType& rhs); + friend bool operator==(const json_pointer& lhs, const StringType& rhs); /// @brief compares string and JSON pointer for equality /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const StringType& lhs, - const json_pointer& rhs); + friend bool operator==(const StringType& lhs, const json_pointer& rhs); /// @brief compares two JSON pointers for inequality /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const json_pointer& lhs, - const json_pointer& rhs) noexcept; + friend bool operator!=(const json_pointer& lhs, const json_pointer& rhs) noexcept; /// @brief compares JSON pointer and string for inequality /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const json_pointer& lhs, - const StringType& rhs); + friend bool operator!=(const json_pointer& lhs, const StringType& rhs); /// @brief compares string and JSON pointer for inequality /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const StringType& lhs, - const json_pointer& rhs); + friend bool operator!=(const StringType& lhs, const json_pointer& rhs); /// @brief compares two JSON pointer for less-than template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator<(const json_pointer& lhs, - const json_pointer& rhs) noexcept; + friend bool operator<(const json_pointer& lhs, const json_pointer& rhs) noexcept; #endif private: @@ -919,58 +907,47 @@ class json_pointer #if !JSON_HAS_THREE_WAY_COMPARISON // functions cannot be defined inside class due to ODR violations template -inline bool operator==(const json_pointer& lhs, - const json_pointer& rhs) noexcept +inline bool operator==(const json_pointer& lhs, const json_pointer& rhs) noexcept { return lhs.reference_tokens == rhs.reference_tokens; } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) -inline bool operator==(const json_pointer& lhs, - const StringType& rhs) +inline bool operator==(const json_pointer& lhs, const StringType& rhs) { return lhs == json_pointer(rhs); } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) -inline bool operator==(const StringType& lhs, - const json_pointer& rhs) +inline bool operator==(const StringType& lhs, const json_pointer& rhs) { return json_pointer(lhs) == rhs; } template -inline bool operator!=(const json_pointer& lhs, - const json_pointer& rhs) noexcept +inline bool operator!=(const json_pointer& lhs, const json_pointer& rhs) noexcept { return !(lhs == rhs); } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) -inline bool operator!=(const json_pointer& lhs, - const StringType& rhs) +inline bool operator!=(const json_pointer& lhs, const StringType& rhs) { return !(lhs == rhs); } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) -inline bool operator!=(const StringType& lhs, - const json_pointer& rhs) +inline bool operator!=(const StringType& lhs, const json_pointer& rhs) { return !(lhs == rhs); } template -inline bool operator<(const json_pointer& lhs, - const json_pointer& rhs) noexcept +inline bool operator<(const json_pointer& lhs, const json_pointer& rhs) noexcept { return lhs.reference_tokens < rhs.reference_tokens; } diff --git a/include/nlohmann/detail/json_ref.hpp b/include/nlohmann/detail/json_ref.hpp index 7eaea97bf5..aea5e334fa 100644 --- a/include/nlohmann/detail/json_ref.hpp +++ b/include/nlohmann/detail/json_ref.hpp @@ -15,7 +15,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template class json_ref @@ -35,9 +36,7 @@ class json_ref : owned_value(init) {} - template< - class... Args, - enable_if_t::value, int> = 0> + template::value, int> = 0> json_ref(Args&&... args) : owned_value(std::forward(args)...) {} diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 2593997633..dac07dfbf4 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -8,9 +8,9 @@ #pragma once +#include // declval, pair #include #include -#include // declval, pair // This file contains all internal macro definitions (except those affecting ABI) // You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them @@ -114,7 +114,8 @@ #endif #ifndef JSON_HAS_THREE_WAY_COMPARISON - #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L + #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L && defined(__cpp_lib_three_way_comparison) && \ + __cpp_lib_three_way_comparison >= 201907L #define JSON_HAS_THREE_WAY_COMPARISON 1 #else #define JSON_HAS_THREE_WAY_COMPARISON 0 @@ -211,119 +212,196 @@ @def NLOHMANN_JSON_SERIALIZE_ENUM @since version 3.4.0 */ -#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ - template \ - inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), [e](const std::pair& ej_pair) -> bool { \ - return ej_pair.first == e; \ - }); \ - j = ((it != std::end(m)) ? it : std::begin(m))->second; \ - } \ - template \ - inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), [&j](const std::pair& ej_pair) -> bool { \ - return ej_pair.second == j; \ - }); \ - e = ((it != std::end(m)) ? it : std::begin(m))->first; \ +#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ + template \ + inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), [e](const std::pair& ej_pair) -> bool { \ + return ej_pair.first == e; \ + }); \ + j = ((it != std::end(m)) ? it : std::begin(m))->second; \ + } \ + template \ + inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), [&j](const std::pair& ej_pair) -> bool { \ + return ej_pair.second == j; \ + }); \ + e = ((it != std::end(m)) ? it : std::begin(m))->first; \ } // Ugly macros to avoid uglier copy-paste when specializing basic_json. They // may be removed in the future once the class is split. -#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ - template class ObjectType, \ - template \ - class ArrayType, \ - class StringType, \ - class BooleanType, \ - class NumberIntegerType, \ - class NumberUnsignedType, \ - class NumberFloatType, \ - template \ - class AllocatorType, \ - template \ - class JSONSerializer, \ - class BinaryType, \ +#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ + template class ObjectType, \ + template \ + class ArrayType, \ + class StringType, \ + class BooleanType, \ + class NumberIntegerType, \ + class NumberUnsignedType, \ + class NumberFloatType, \ + template \ + class AllocatorType, \ + template \ + class JSONSerializer, \ + class BinaryType, \ class CustomBaseClass> -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json +#define NLOHMANN_BASIC_JSON_TPL \ + basic_json // Macros to simplify conversion from/to types #define NLOHMANN_JSON_EXPAND(x) x -#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME, ...) NAME -#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ - NLOHMANN_JSON_PASTE64, \ - NLOHMANN_JSON_PASTE63, \ - NLOHMANN_JSON_PASTE62, \ - NLOHMANN_JSON_PASTE61, \ - NLOHMANN_JSON_PASTE60, \ - NLOHMANN_JSON_PASTE59, \ - NLOHMANN_JSON_PASTE58, \ - NLOHMANN_JSON_PASTE57, \ - NLOHMANN_JSON_PASTE56, \ - NLOHMANN_JSON_PASTE55, \ - NLOHMANN_JSON_PASTE54, \ - NLOHMANN_JSON_PASTE53, \ - NLOHMANN_JSON_PASTE52, \ - NLOHMANN_JSON_PASTE51, \ - NLOHMANN_JSON_PASTE50, \ - NLOHMANN_JSON_PASTE49, \ - NLOHMANN_JSON_PASTE48, \ - NLOHMANN_JSON_PASTE47, \ - NLOHMANN_JSON_PASTE46, \ - NLOHMANN_JSON_PASTE45, \ - NLOHMANN_JSON_PASTE44, \ - NLOHMANN_JSON_PASTE43, \ - NLOHMANN_JSON_PASTE42, \ - NLOHMANN_JSON_PASTE41, \ - NLOHMANN_JSON_PASTE40, \ - NLOHMANN_JSON_PASTE39, \ - NLOHMANN_JSON_PASTE38, \ - NLOHMANN_JSON_PASTE37, \ - NLOHMANN_JSON_PASTE36, \ - NLOHMANN_JSON_PASTE35, \ - NLOHMANN_JSON_PASTE34, \ - NLOHMANN_JSON_PASTE33, \ - NLOHMANN_JSON_PASTE32, \ - NLOHMANN_JSON_PASTE31, \ - NLOHMANN_JSON_PASTE30, \ - NLOHMANN_JSON_PASTE29, \ - NLOHMANN_JSON_PASTE28, \ - NLOHMANN_JSON_PASTE27, \ - NLOHMANN_JSON_PASTE26, \ - NLOHMANN_JSON_PASTE25, \ - NLOHMANN_JSON_PASTE24, \ - NLOHMANN_JSON_PASTE23, \ - NLOHMANN_JSON_PASTE22, \ - NLOHMANN_JSON_PASTE21, \ - NLOHMANN_JSON_PASTE20, \ - NLOHMANN_JSON_PASTE19, \ - NLOHMANN_JSON_PASTE18, \ - NLOHMANN_JSON_PASTE17, \ - NLOHMANN_JSON_PASTE16, \ - NLOHMANN_JSON_PASTE15, \ - NLOHMANN_JSON_PASTE14, \ - NLOHMANN_JSON_PASTE13, \ - NLOHMANN_JSON_PASTE12, \ - NLOHMANN_JSON_PASTE11, \ - NLOHMANN_JSON_PASTE10, \ - NLOHMANN_JSON_PASTE9, \ - NLOHMANN_JSON_PASTE8, \ - NLOHMANN_JSON_PASTE7, \ - NLOHMANN_JSON_PASTE6, \ - NLOHMANN_JSON_PASTE5, \ - NLOHMANN_JSON_PASTE4, \ - NLOHMANN_JSON_PASTE3, \ - NLOHMANN_JSON_PASTE2, \ - NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) +#define NLOHMANN_JSON_GET_MACRO(_1, \ + _2, \ + _3, \ + _4, \ + _5, \ + _6, \ + _7, \ + _8, \ + _9, \ + _10, \ + _11, \ + _12, \ + _13, \ + _14, \ + _15, \ + _16, \ + _17, \ + _18, \ + _19, \ + _20, \ + _21, \ + _22, \ + _23, \ + _24, \ + _25, \ + _26, \ + _27, \ + _28, \ + _29, \ + _30, \ + _31, \ + _32, \ + _33, \ + _34, \ + _35, \ + _36, \ + _37, \ + _38, \ + _39, \ + _40, \ + _41, \ + _42, \ + _43, \ + _44, \ + _45, \ + _46, \ + _47, \ + _48, \ + _49, \ + _50, \ + _51, \ + _52, \ + _53, \ + _54, \ + _55, \ + _56, \ + _57, \ + _58, \ + _59, \ + _60, \ + _61, \ + _62, \ + _63, \ + _64, \ + NAME, \ + ...) \ + NAME +#define NLOHMANN_JSON_PASTE(...) \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ + NLOHMANN_JSON_PASTE64, \ + NLOHMANN_JSON_PASTE63, \ + NLOHMANN_JSON_PASTE62, \ + NLOHMANN_JSON_PASTE61, \ + NLOHMANN_JSON_PASTE60, \ + NLOHMANN_JSON_PASTE59, \ + NLOHMANN_JSON_PASTE58, \ + NLOHMANN_JSON_PASTE57, \ + NLOHMANN_JSON_PASTE56, \ + NLOHMANN_JSON_PASTE55, \ + NLOHMANN_JSON_PASTE54, \ + NLOHMANN_JSON_PASTE53, \ + NLOHMANN_JSON_PASTE52, \ + NLOHMANN_JSON_PASTE51, \ + NLOHMANN_JSON_PASTE50, \ + NLOHMANN_JSON_PASTE49, \ + NLOHMANN_JSON_PASTE48, \ + NLOHMANN_JSON_PASTE47, \ + NLOHMANN_JSON_PASTE46, \ + NLOHMANN_JSON_PASTE45, \ + NLOHMANN_JSON_PASTE44, \ + NLOHMANN_JSON_PASTE43, \ + NLOHMANN_JSON_PASTE42, \ + NLOHMANN_JSON_PASTE41, \ + NLOHMANN_JSON_PASTE40, \ + NLOHMANN_JSON_PASTE39, \ + NLOHMANN_JSON_PASTE38, \ + NLOHMANN_JSON_PASTE37, \ + NLOHMANN_JSON_PASTE36, \ + NLOHMANN_JSON_PASTE35, \ + NLOHMANN_JSON_PASTE34, \ + NLOHMANN_JSON_PASTE33, \ + NLOHMANN_JSON_PASTE32, \ + NLOHMANN_JSON_PASTE31, \ + NLOHMANN_JSON_PASTE30, \ + NLOHMANN_JSON_PASTE29, \ + NLOHMANN_JSON_PASTE28, \ + NLOHMANN_JSON_PASTE27, \ + NLOHMANN_JSON_PASTE26, \ + NLOHMANN_JSON_PASTE25, \ + NLOHMANN_JSON_PASTE24, \ + NLOHMANN_JSON_PASTE23, \ + NLOHMANN_JSON_PASTE22, \ + NLOHMANN_JSON_PASTE21, \ + NLOHMANN_JSON_PASTE20, \ + NLOHMANN_JSON_PASTE19, \ + NLOHMANN_JSON_PASTE18, \ + NLOHMANN_JSON_PASTE17, \ + NLOHMANN_JSON_PASTE16, \ + NLOHMANN_JSON_PASTE15, \ + NLOHMANN_JSON_PASTE14, \ + NLOHMANN_JSON_PASTE13, \ + NLOHMANN_JSON_PASTE12, \ + NLOHMANN_JSON_PASTE11, \ + NLOHMANN_JSON_PASTE10, \ + NLOHMANN_JSON_PASTE9, \ + NLOHMANN_JSON_PASTE8, \ + NLOHMANN_JSON_PASTE7, \ + NLOHMANN_JSON_PASTE6, \ + NLOHMANN_JSON_PASTE5, \ + NLOHMANN_JSON_PASTE4, \ + NLOHMANN_JSON_PASTE3, \ + NLOHMANN_JSON_PASTE2, \ + NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) #define NLOHMANN_JSON_PASTE2(func, v1) func(v1) #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) @@ -332,61 +410,3397 @@ #define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) #define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) #define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) -#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) -#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) -#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) -#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) -#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) -#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) -#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) -#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) -#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) -#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) -#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) -#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) -#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) -#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) -#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) -#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) -#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) -#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) -#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) -#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) -#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) -#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) -#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) -#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) -#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) -#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) -#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) -#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) -#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) -#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) -#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) -#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) -#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) -#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) -#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) -#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) -#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) -#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) -#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) -#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) -#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) -#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) -#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) -#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) -#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) -#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) -#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) -#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) -#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) +#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) +#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) +#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) +#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) +#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) +#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) +#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) +#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) +#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) +#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) +#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) +#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) +#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) +#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) +#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) +#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) +#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) +#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) +#define NLOHMANN_JSON_PASTE28(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) +#define NLOHMANN_JSON_PASTE29(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) +#define NLOHMANN_JSON_PASTE30(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE29(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29) +#define NLOHMANN_JSON_PASTE31(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE30(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30) +#define NLOHMANN_JSON_PASTE32(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE31(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31) +#define NLOHMANN_JSON_PASTE33(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE32(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32) +#define NLOHMANN_JSON_PASTE34(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE33(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33) +#define NLOHMANN_JSON_PASTE35(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE34(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34) +#define NLOHMANN_JSON_PASTE36(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE35(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35) +#define NLOHMANN_JSON_PASTE37(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE36(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36) +#define NLOHMANN_JSON_PASTE38(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE37(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37) +#define NLOHMANN_JSON_PASTE39(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE38(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38) +#define NLOHMANN_JSON_PASTE40(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE39(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39) +#define NLOHMANN_JSON_PASTE41(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE40(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40) +#define NLOHMANN_JSON_PASTE42(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE41(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41) +#define NLOHMANN_JSON_PASTE43(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE42(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42) +#define NLOHMANN_JSON_PASTE44(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE43(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43) +#define NLOHMANN_JSON_PASTE45(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE44(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44) +#define NLOHMANN_JSON_PASTE46(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE45(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45) +#define NLOHMANN_JSON_PASTE47(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE46(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46) +#define NLOHMANN_JSON_PASTE48(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE47(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47) +#define NLOHMANN_JSON_PASTE49(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE48(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48) +#define NLOHMANN_JSON_PASTE50(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE49(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49) +#define NLOHMANN_JSON_PASTE51(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE50(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50) +#define NLOHMANN_JSON_PASTE52(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE51(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51) +#define NLOHMANN_JSON_PASTE53(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE52(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52) +#define NLOHMANN_JSON_PASTE54(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE53(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53) +#define NLOHMANN_JSON_PASTE55(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE54(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54) +#define NLOHMANN_JSON_PASTE56(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE55(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55) +#define NLOHMANN_JSON_PASTE57(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE56(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56) +#define NLOHMANN_JSON_PASTE58(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE57(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57) +#define NLOHMANN_JSON_PASTE59(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE58(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58) +#define NLOHMANN_JSON_PASTE60(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE59(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59) +#define NLOHMANN_JSON_PASTE61(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE60(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60) +#define NLOHMANN_JSON_PASTE62(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE61(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61) +#define NLOHMANN_JSON_PASTE63(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE62(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62) +#define NLOHMANN_JSON_PASTE64(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62, \ + v63) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE63(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62, \ + v63) #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); @@ -397,31 +3811,31 @@ @def NLOHMANN_DEFINE_TYPE_INTRUSIVE @since version 3.9.0 */ -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ - } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \ } -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ - } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ - { \ - const Type nlohmann_json_default_obj{}; \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + const Type nlohmann_json_default_obj{}; \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) \ } -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ } /*! @@ -429,31 +3843,31 @@ @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE @since version 3.9.0 */ -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ - } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \ } -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ } -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ - } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ - { \ - const Type nlohmann_json_default_obj{}; \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + const Type nlohmann_json_default_obj{}; \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) \ } // inspired from https://stackoverflow.com/a/26745591 @@ -462,37 +3876,36 @@ // // it allows using the detected idiom to retrieve the return type // of such an expression -#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ - namespace detail { \ - using std::std_name; \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - } \ - \ - namespace detail2 { \ - struct std_name##_tag \ - { \ - }; \ - \ - template \ - std_name##_tag std_name(T&&...); \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - \ - template \ - struct would_call_std_##std_name \ - { \ - static constexpr auto const value = ::nlohmann::detail:: \ - is_detected_exact::value; \ - }; \ - } /* namespace detail2 */ \ - \ - template \ - struct would_call_std_##std_name : detail2::would_call_std_##std_name \ - { \ - } +#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ + namespace detail \ + { \ + using std::std_name; \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + } \ + \ + namespace detail2 \ + { \ + struct std_name##_tag \ + {}; \ + \ + template \ + std_name##_tag std_name(T&&...); \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + \ + template \ + struct would_call_std_##std_name \ + { \ + static constexpr auto const value = ::nlohmann::detail::is_detected_exact::value; \ + }; \ + } /* namespace detail2 */ \ + \ + template \ + struct would_call_std_##std_name : detail2::would_call_std_##std_name \ + {} #ifndef JSON_USE_IMPLICIT_CONVERSIONS #define JSON_USE_IMPLICIT_CONVERSIONS 1 diff --git a/include/nlohmann/detail/meta/cpp_future.hpp b/include/nlohmann/detail/meta/cpp_future.hpp index a5687bccdb..57e8430348 100644 --- a/include/nlohmann/detail/meta/cpp_future.hpp +++ b/include/nlohmann/detail/meta/cpp_future.hpp @@ -17,7 +17,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template using uncvref_t = typename std::remove_cv::type>::type; @@ -78,7 +79,8 @@ struct integer_sequence template using index_sequence = integer_sequence; -namespace utility_internal { +namespace utility_internal +{ template struct Extend; @@ -101,8 +103,7 @@ struct Extend, SeqSize, 1> template struct Gen { - using type = - typename Extend::type, N / 2, N % 2>::type; + using type = typename Extend::type, N / 2, N % 2>::type; }; template diff --git a/include/nlohmann/detail/meta/detected.hpp b/include/nlohmann/detail/meta/detected.hpp index ba048a027d..64882ac399 100644 --- a/include/nlohmann/detail/meta/detected.hpp +++ b/include/nlohmann/detail/meta/detected.hpp @@ -13,7 +13,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ // https://en.cppreference.com/w/cpp/experimental/is_detected struct nonesuch @@ -26,11 +27,7 @@ struct nonesuch void operator=(nonesuch&&) = delete; }; -template - class Op, - class... Args> +template class Op, class... Args> struct detector { using value_t = std::false_type; @@ -64,8 +61,7 @@ template class Op, class... Args> using is_detected_exact = std::is_same>; template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; +using is_detected_convertible = std::is_convertible, To>; } // namespace detail NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/identity_tag.hpp b/include/nlohmann/detail/meta/identity_tag.hpp index 1933065144..963a94bff4 100644 --- a/include/nlohmann/detail/meta/identity_tag.hpp +++ b/include/nlohmann/detail/meta/identity_tag.hpp @@ -11,7 +11,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ // dispatching helper struct template diff --git a/include/nlohmann/detail/meta/is_sax.hpp b/include/nlohmann/detail/meta/is_sax.hpp index e7f1e827e8..9250170e66 100644 --- a/include/nlohmann/detail/meta/is_sax.hpp +++ b/include/nlohmann/detail/meta/is_sax.hpp @@ -17,66 +17,54 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template using null_function_t = decltype(std::declval().null()); template -using boolean_function_t = - decltype(std::declval().boolean(std::declval())); +using boolean_function_t = decltype(std::declval().boolean(std::declval())); template -using number_integer_function_t = - decltype(std::declval().number_integer(std::declval())); +using number_integer_function_t = decltype(std::declval().number_integer(std::declval())); template -using number_unsigned_function_t = - decltype(std::declval().number_unsigned(std::declval())); +using number_unsigned_function_t = decltype(std::declval().number_unsigned(std::declval())); template -using number_float_function_t = decltype(std::declval().number_float( - std::declval(), - std::declval())); +using number_float_function_t = decltype(std::declval().number_float(std::declval(), std::declval())); template -using string_function_t = - decltype(std::declval().string(std::declval())); +using string_function_t = decltype(std::declval().string(std::declval())); template -using binary_function_t = - decltype(std::declval().binary(std::declval())); +using binary_function_t = decltype(std::declval().binary(std::declval())); template -using start_object_function_t = - decltype(std::declval().start_object(std::declval())); +using start_object_function_t = decltype(std::declval().start_object(std::declval())); template -using key_function_t = - decltype(std::declval().key(std::declval())); +using key_function_t = decltype(std::declval().key(std::declval())); template using end_object_function_t = decltype(std::declval().end_object()); template -using start_array_function_t = - decltype(std::declval().start_array(std::declval())); +using start_array_function_t = decltype(std::declval().start_array(std::declval())); template using end_array_function_t = decltype(std::declval().end_array()); template -using parse_error_function_t = decltype(std::declval().parse_error( - std::declval(), - std::declval(), - std::declval())); +using parse_error_function_t = + decltype(std::declval().parse_error(std::declval(), std::declval(), std::declval())); template struct is_sax { private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); + static_assert(is_basic_json::value, "BasicJsonType must be of type basic_json<...>"); using number_integer_t = typename BasicJsonType::number_integer_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t; @@ -87,27 +75,21 @@ struct is_sax public: static constexpr bool value = - is_detected_exact::value && - is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value; + is_detected_exact::value && is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value; }; template struct is_sax_static_asserts { private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); + static_assert(is_basic_json::value, "BasicJsonType must be of type basic_json<...>"); using number_integer_t = typename BasicJsonType::number_integer_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t; @@ -117,40 +99,25 @@ struct is_sax_static_asserts using exception_t = typename BasicJsonType::exception; public: - static_assert(is_detected_exact::value, - "Missing/invalid function: bool null()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_integer(number_integer_t)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool null()"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool boolean(bool)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool boolean(bool)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool number_integer(number_integer_t)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); static_assert(is_detected_exact::value, "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool string(string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool binary(binary_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_object(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool key(string_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_object()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_array(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_array()"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool parse_error(std::size_t, const " - "std::string&, const exception&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool string(string_t&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool binary(binary_t&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool start_object(std::size_t)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool key(string_t&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool end_object()"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool start_array(std::size_t)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool end_array()"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool parse_error(std::size_t, const " + "std::string&, const exception&)"); }; } // namespace detail diff --git a/include/nlohmann/detail/meta/std_fs.hpp b/include/nlohmann/detail/meta/std_fs.hpp index eb11dc982e..1d40745f49 100644 --- a/include/nlohmann/detail/meta/std_fs.hpp +++ b/include/nlohmann/detail/meta/std_fs.hpp @@ -13,14 +13,16 @@ #if JSON_HAS_EXPERIMENTAL_FILESYSTEM #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ namespace std_fs = std::experimental::filesystem; } // namespace detail NLOHMANN_JSON_NAMESPACE_END #elif JSON_HAS_FILESYSTEM #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ namespace std_fs = std::filesystem; } // namespace detail NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index bb71c5b08c..cbd9c1c4c2 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -31,7 +31,8 @@ implementations of some @ref basic_json methods, and meta-programming helpers. @since version 2.1.0 */ -namespace detail { +namespace detail +{ ///////////// // helpers // @@ -58,8 +59,10 @@ struct is_basic_json : std::true_type // true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t // false_type otherwise template -struct is_basic_json_context : std::integral_constant::type>::type>::value || std::is_same::value> +struct is_basic_json_context + : std::integral_constant::type>::type>::value || + std::is_same::value> {}; ////////////////////// @@ -131,8 +134,7 @@ struct has_from_json::value>> { using serializer = typename BasicJsonType::template json_serializer; - static constexpr bool value = - is_detected_exact::value; + static constexpr bool value = is_detected_exact::value; }; // This trait checks if JSONSerializer::from_json(json const&) exists @@ -146,8 +148,7 @@ struct has_non_default_from_json { using serializer = typename BasicJsonType::template json_serializer; - static constexpr bool value = - is_detected_exact::value; + static constexpr bool value = is_detected_exact::value; }; // This trait checks if BasicJsonType::json_serializer::to_json exists @@ -161,8 +162,7 @@ struct has_to_json::value>> { using serializer = typename BasicJsonType::template json_serializer; - static constexpr bool value = - is_detected_exact::value; + static constexpr bool value = is_detected_exact::value; }; template @@ -178,9 +178,7 @@ struct actual_object_comparator { using object_t = typename BasicJsonType::object_t; using object_comparator_t = typename BasicJsonType::default_object_comparator_t; - using type = typename std::conditional::value, - typename object_t::key_compare, - object_comparator_t>::type; + using type = typename std::conditional::value, typename object_t::key_compare, object_comparator_t>::type; }; template @@ -255,8 +253,7 @@ template struct conjunction : B {}; template -struct conjunction - : std::conditional(B::value), conjunction, B>::type +struct conjunction : std::conditional(B::value), conjunction, B>::type {}; // https://en.cppreference.com/w/cpp/types/negation @@ -272,23 +269,19 @@ struct is_default_constructible : std::is_default_constructible {}; template -struct is_default_constructible> - : conjunction, is_default_constructible> +struct is_default_constructible> : conjunction, is_default_constructible> {}; template -struct is_default_constructible> - : conjunction, is_default_constructible> +struct is_default_constructible> : conjunction, is_default_constructible> {}; template -struct is_default_constructible> - : conjunction...> +struct is_default_constructible> : conjunction...> {}; template -struct is_default_constructible> - : conjunction...> +struct is_default_constructible> : conjunction...> {}; template @@ -322,12 +315,9 @@ struct is_iterator_traits> using traits = iterator_traits; public: - static constexpr auto value = - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value; + static constexpr auto value = is_detected::value && is_detected::value && + is_detected::value && is_detected::value && + is_detected::value; }; template @@ -342,8 +332,7 @@ struct is_range // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator // and https://en.cppreference.com/w/cpp/iterator/sentinel_for // but reimplementing these would be too much work, as a lot of other concepts are used underneath - static constexpr auto is_iterator_begin = - is_iterator_traits>::value; + static constexpr auto is_iterator_begin = is_iterator_traits>::value; public: static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; @@ -375,22 +364,17 @@ template struct is_compatible_object_type_impl< BasicJsonType, CompatibleObjectType, - enable_if_t::value && - is_detected::value>> + enable_if_t::value && is_detected::value>> { using object_t = typename BasicJsonType::object_t; // macOS's is_constructible does not play well with nonesuch... - static constexpr bool value = - is_constructible::value && - is_constructible::value; + static constexpr bool value = is_constructible::value && + is_constructible::value; }; template -struct is_compatible_object_type - : is_compatible_object_type_impl +struct is_compatible_object_type : is_compatible_object_type_impl {}; template @@ -401,38 +385,26 @@ template struct is_constructible_object_type_impl< BasicJsonType, ConstructibleObjectType, - enable_if_t::value && - is_detected::value>> + enable_if_t::value && is_detected::value>> { using object_t = typename BasicJsonType::object_t; - static constexpr bool value = - (is_default_constructible::value && - (std::is_move_assignable::value || - std::is_copy_assignable::value) && - (is_constructible::value && - std::is_same< - typename object_t::mapped_type, - typename ConstructibleObjectType::mapped_type>::value)) || - (has_from_json::value || - has_non_default_from_json< - BasicJsonType, - typename ConstructibleObjectType::mapped_type>::value); + static constexpr bool value = (is_default_constructible::value && + (std::is_move_assignable::value || std::is_copy_assignable::value) && + (is_constructible::value && + std::is_same::value)) || + (has_from_json::value || + has_non_default_from_json::value); }; template -struct is_constructible_object_type - : is_constructible_object_type_impl +struct is_constructible_object_type : is_constructible_object_type_impl {}; template struct is_compatible_string_type { - static constexpr auto value = - is_constructible::value; + static constexpr auto value = is_constructible::value; }; template @@ -445,12 +417,8 @@ struct is_constructible_string_type using laundered_type = ConstructibleStringType; #endif - static constexpr auto value = - conjunction< - is_constructible, - is_detected_exact>::value; + static constexpr auto value = conjunction, + is_detected_exact>::value; }; template @@ -458,24 +426,19 @@ struct is_compatible_array_type_impl : std::false_type {}; template -struct is_compatible_array_type_impl< - BasicJsonType, - CompatibleArrayType, - enable_if_t< - is_detected::value && - is_iterator_traits>>::value && - // special case for types like std::filesystem::path whose iterator's value_type are themselves - // c.f. https://github.com/nlohmann/json/pull/3073 - !std::is_same>::value>> -{ - static constexpr bool value = - is_constructible>::value; +struct is_compatible_array_type_impl::value && + is_iterator_traits>>::value && + // special case for types like std::filesystem::path whose iterator's value_type are themselves + // c.f. https://github.com/nlohmann/json/pull/3073 + !std::is_same>::value>> +{ + static constexpr bool value = is_constructible>::value; }; template -struct is_compatible_array_type - : is_compatible_array_type_impl +struct is_compatible_array_type : is_compatible_array_type_impl {}; template @@ -483,48 +446,34 @@ struct is_constructible_array_type_impl : std::false_type {}; template -struct is_constructible_array_type_impl< - BasicJsonType, - ConstructibleArrayType, - enable_if_t::value>> - : std::true_type +struct is_constructible_array_type_impl::value>> : std::true_type {}; template struct is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, - enable_if_t::value && - !is_compatible_string_type::value && - is_default_constructible::value && - (std::is_move_assignable::value || - std::is_copy_assignable::value) && + enable_if_t::value && + !is_compatible_string_type::value && is_default_constructible::value && + (std::is_move_assignable::value || std::is_copy_assignable::value) && is_detected::value && is_iterator_traits>>::value && is_detected::value && // special case for types like std::filesystem::path whose iterator's value_type are themselves // c.f. https://github.com/nlohmann/json/pull/3073 !std::is_same>::value && - is_complete_type< - detected_t>::value>> + is_complete_type>::value>> { using value_type = range_value_t; - static constexpr bool value = - std::is_same::value || - has_from_json::value || - has_non_default_from_json< - BasicJsonType, - value_type>::value; + static constexpr bool value = std::is_same::value || + has_from_json::value || has_non_default_from_json::value; }; template -struct is_constructible_array_type - : is_constructible_array_type_impl +struct is_constructible_array_type : is_constructible_array_type_impl {}; template @@ -532,28 +481,21 @@ struct is_compatible_integer_type_impl : std::false_type {}; template -struct is_compatible_integer_type_impl< - RealIntegerType, - CompatibleNumberIntegerType, - enable_if_t::value && - std::is_integral::value && - !std::is_same::value>> +struct is_compatible_integer_type_impl::value && std::is_integral::value && + !std::is_same::value>> { // is there an assert somewhere on overflows? using RealLimits = std::numeric_limits; using CompatibleLimits = std::numeric_limits; - static constexpr auto value = - is_constructible::value && - CompatibleLimits::is_integer && - RealLimits::is_signed == CompatibleLimits::is_signed; + static constexpr auto value = is_constructible::value && CompatibleLimits::is_integer && + RealLimits::is_signed == CompatibleLimits::is_signed; }; template -struct is_compatible_integer_type - : is_compatible_integer_type_impl +struct is_compatible_integer_type : is_compatible_integer_type_impl {}; template @@ -561,18 +503,13 @@ struct is_compatible_type_impl : std::false_type {}; template -struct is_compatible_type_impl< - BasicJsonType, - CompatibleType, - enable_if_t::value>> +struct is_compatible_type_impl::value>> { - static constexpr bool value = - has_to_json::value; + static constexpr bool value = has_to_json::value; }; template -struct is_compatible_type - : is_compatible_type_impl +struct is_compatible_type : is_compatible_type_impl {}; template @@ -613,7 +550,12 @@ struct is_comparable : std::false_type {}; template -struct is_comparable()(std::declval(), std::declval())), decltype(std::declval()(std::declval(), std::declval()))>> : std::true_type +struct is_comparable< + Compare, + A, + B, + void_t()(std::declval(), std::declval())), decltype(std::declval()(std::declval(), std::declval()))>> + : std::true_type {}; template @@ -621,11 +563,18 @@ using detect_is_transparent = typename T::is_transparent; // type trait to check if KeyType can be used as object key (without a BasicJsonType) // see is_usable_as_basic_json_key_type below -template> -using is_usable_as_key_type = typename std::conditional< - is_comparable::value && !(ExcludeObjectKeyType && std::is_same::value) && (!RequireTransparentComparator || is_detected::value) && !is_json_pointer::value, - std::true_type, - std::false_type>::type; +template> +using is_usable_as_key_type = + typename std::conditional::value && + !(ExcludeObjectKeyType && std::is_same::value) && + (!RequireTransparentComparator || is_detected::value) && !is_json_pointer::value, + std::true_type, + std::false_type>::type; // type trait to check if KeyType can be used as object key // true if: @@ -633,29 +582,27 @@ using is_usable_as_key_type = typename std::conditional< // - if ExcludeObjectKeyType is true, KeyType is not BasicJsonType::object_t::key_type // - the comparator is transparent or RequireTransparentComparator is false // - KeyType is not a JSON iterator or json_pointer -template> -using is_usable_as_basic_json_key_type = typename std::conditional< - is_usable_as_key_type::value && - !is_json_iterator_of::value, - std::true_type, - std::false_type>::type; +template> +using is_usable_as_basic_json_key_type = typename std::conditional::value && + !is_json_iterator_of::value, + std::true_type, + std::false_type>::type; template using detect_erase_with_key_type = decltype(std::declval().erase(std::declval())); // type trait to check if object_t has an erase() member functions accepting KeyType template -using has_erase_with_key_type = typename std::conditional< - is_detected< - detect_erase_with_key_type, - typename BasicJsonType::object_t, - KeyType>::value, - std::true_type, - std::false_type>::type; +using has_erase_with_key_type = + typename std::conditional::value, std::true_type, std::false_type>::type; // a naive helper to check if a type is an ordered_map (exploits the fact that // ordered_map inherits capacity() from std::vector) @@ -704,12 +651,12 @@ using all_unsigned = conjunction...>; // there's a disjunction trait in another PR; replace when merged template -using same_sign = std::integral_constant::value || all_unsigned::value>; +using same_sign = std::integral_constant::value || all_unsigned::value>; template -using never_out_of_range = std::integral_constant::value && (sizeof(T) < sizeof(OfType))) || (same_sign::value && sizeof(OfType) == sizeof(T))>; +using never_out_of_range = + std::integral_constant::value && (sizeof(T) < sizeof(OfType))) || (same_sign::value && sizeof(OfType) == sizeof(T))>; template::value, bool TSigned = std::is_signed::value> struct value_in_range_of_impl2; @@ -750,11 +697,15 @@ struct value_in_range_of_impl2 static constexpr bool test(T val) { using CommonType = typename std::common_type::type; - return static_cast(val) >= static_cast((std::numeric_limits::min)()) && static_cast(val) <= static_cast((std::numeric_limits::max)()); + return static_cast(val) >= static_cast((std::numeric_limits::min)()) && + static_cast(val) <= static_cast((std::numeric_limits::max)()); } }; -template::value, typename = detail::enable_if_t::value>> +template::value, + typename = detail::enable_if_t::value>> struct value_in_range_of_impl1; template @@ -788,7 +739,8 @@ using bool_constant = std::integral_constant; // is_c_string /////////////////////////////////////////////////////////////////////////////// -namespace impl { +namespace impl +{ template inline constexpr bool is_c_string() @@ -814,7 +766,8 @@ using is_c_string_uncvref = is_c_string>; // is_transparent /////////////////////////////////////////////////////////////////////////////// -namespace impl { +namespace impl +{ template inline constexpr bool is_transparent() diff --git a/include/nlohmann/detail/meta/void_t.hpp b/include/nlohmann/detail/meta/void_t.hpp index 795edaad35..23fe073039 100644 --- a/include/nlohmann/detail/meta/void_t.hpp +++ b/include/nlohmann/detail/meta/void_t.hpp @@ -11,7 +11,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template struct make_void diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index e10c353ddd..8c0137e2fc 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -25,7 +25,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /////////////////// // binary writer // @@ -98,9 +99,7 @@ class binary_writer case value_t::boolean: { - oa->write_character(j.m_data.m_value.boolean - ? to_char_type(0xF5) - : to_char_type(0xF4)); + oa->write_character(j.m_data.m_value.boolean ? to_char_type(0xF5) : to_char_type(0xF4)); break; } @@ -253,9 +252,7 @@ class binary_writer // LCOV_EXCL_STOP // step 2: write the string - oa->write_characters( - reinterpret_cast(j.m_data.m_value.string->c_str()), - j.m_data.m_value.string->size()); + oa->write_characters(reinterpret_cast(j.m_data.m_value.string->c_str()), j.m_data.m_value.string->size()); break; } @@ -354,9 +351,7 @@ class binary_writer // LCOV_EXCL_STOP // step 2: write each element - oa->write_characters( - reinterpret_cast(j.m_data.m_value.binary->data()), - N); + oa->write_characters(reinterpret_cast(j.m_data.m_value.binary->data()), N); break; } @@ -422,9 +417,7 @@ class binary_writer case value_t::boolean: // true and false { - oa->write_character(j.m_data.m_value.boolean - ? to_char_type(0xC3) - : to_char_type(0xC2)); + oa->write_character(j.m_data.m_value.boolean ? to_char_type(0xC3) : to_char_type(0xC2)); break; } @@ -573,9 +566,7 @@ class binary_writer } // step 2: write the string - oa->write_characters( - reinterpret_cast(j.m_data.m_value.string->c_str()), - j.m_data.m_value.string->size()); + oa->write_characters(reinterpret_cast(j.m_data.m_value.string->c_str()), j.m_data.m_value.string->size()); break; } @@ -660,18 +651,16 @@ class binary_writer } else if (N <= (std::numeric_limits::max)()) { - const std::uint8_t output_type = use_ext - ? 0xC8 // ext 16 - : 0xC5; // bin 16 + const std::uint8_t output_type = use_ext ? 0xC8 // ext 16 + : 0xC5; // bin 16 oa->write_character(to_char_type(output_type)); write_number(static_cast(N)); } else if (N <= (std::numeric_limits::max)()) { - const std::uint8_t output_type = use_ext - ? 0xC9 // ext 32 - : 0xC6; // bin 32 + const std::uint8_t output_type = use_ext ? 0xC9 // ext 32 + : 0xC6; // bin 32 oa->write_character(to_char_type(output_type)); write_number(static_cast(N)); @@ -684,9 +673,7 @@ class binary_writer } // step 2: write the byte string - oa->write_characters( - reinterpret_cast(j.m_data.m_value.binary->data()), - N); + oa->write_characters(reinterpret_cast(j.m_data.m_value.binary->data()), N); break; } @@ -752,9 +739,7 @@ class binary_writer { if (add_prefix) { - oa->write_character(j.m_data.m_value.boolean - ? to_char_type('T') - : to_char_type('F')); + oa->write_character(j.m_data.m_value.boolean ? to_char_type('T') : to_char_type('F')); } break; } @@ -784,9 +769,7 @@ class binary_writer oa->write_character(to_char_type('S')); } write_number_with_ubjson_prefix(j.m_data.m_value.string->size(), true, use_bjdata); - oa->write_characters( - reinterpret_cast(j.m_data.m_value.string->c_str()), - j.m_data.m_value.string->size()); + oa->write_characters(reinterpret_cast(j.m_data.m_value.string->c_str()), j.m_data.m_value.string->size()); break; } @@ -857,9 +840,7 @@ class binary_writer if (use_type) { - oa->write_characters( - reinterpret_cast(j.m_data.m_value.binary->data()), - j.m_data.m_value.binary->size()); + oa->write_characters(reinterpret_cast(j.m_data.m_value.binary->data()), j.m_data.m_value.binary->size()); } else { @@ -880,9 +861,13 @@ class binary_writer case value_t::object: { - if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find("_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find("_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find("_ArrayData_") != j.m_data.m_value.object->end()) + if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find("_ArrayType_") != j.m_data.m_value.object->end() && + j.m_data.m_value.object->find("_ArraySize_") != j.m_data.m_value.object->end() && + j.m_data.m_value.object->find("_ArrayData_") != j.m_data.m_value.object->end()) { - if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type)) // decode bjdata ndarray in the JData format (https://github.com/NeuroJSON/jdata) + if (!write_bjdata_ndarray(*j.m_data.m_value.object, + use_count, + use_type)) // decode bjdata ndarray in the JData format (https://github.com/NeuroJSON/jdata) { break; } @@ -921,9 +906,7 @@ class binary_writer for (const auto& el : *j.m_data.m_value.object) { write_number_with_ubjson_prefix(el.first.size(), true, use_bjdata); - oa->write_characters( - reinterpret_cast(el.first.c_str()), - el.first.size()); + oa->write_characters(reinterpret_cast(el.first.c_str()), el.first.size()); write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata); } @@ -965,20 +948,16 @@ class binary_writer /*! @brief Writes the given @a element_type and @a name to the output adapter */ - void write_bson_entry_header(const string_t& name, - const std::uint8_t element_type) + void write_bson_entry_header(const string_t& name, const std::uint8_t element_type) { oa->write_character(to_char_type(element_type)); // boolean - oa->write_characters( - reinterpret_cast(name.c_str()), - name.size() + 1u); + oa->write_characters(reinterpret_cast(name.c_str()), name.size() + 1u); } /*! @brief Writes a BSON element with key @a name and boolean value @a value */ - void write_bson_boolean(const string_t& name, - const bool value) + void write_bson_boolean(const string_t& name, const bool value) { write_bson_entry_header(name, 0x08); oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00)); @@ -987,8 +966,7 @@ class binary_writer /*! @brief Writes a BSON element with key @a name and double value @a value */ - void write_bson_double(const string_t& name, - const double value) + void write_bson_double(const string_t& name, const double value) { write_bson_entry_header(name, 0x01); write_number(value, true); @@ -1005,15 +983,12 @@ class binary_writer /*! @brief Writes a BSON element with key @a name and string value @a value */ - void write_bson_string(const string_t& name, - const string_t& value) + void write_bson_string(const string_t& name, const string_t& value) { write_bson_entry_header(name, 0x02); write_number(static_cast(value.size() + 1ul), true); - oa->write_characters( - reinterpret_cast(value.c_str()), - value.size() + 1); + oa->write_characters(reinterpret_cast(value.c_str()), value.size() + 1); } /*! @@ -1029,16 +1004,14 @@ class binary_writer */ static std::size_t calc_bson_integer_size(const std::int64_t value) { - return (std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)() - ? sizeof(std::int32_t) - : sizeof(std::int64_t); + return (std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)() ? sizeof(std::int32_t) + : sizeof(std::int64_t); } /*! @brief Writes a BSON element with key @a name and integer @a value */ - void write_bson_integer(const string_t& name, - const std::int64_t value) + void write_bson_integer(const string_t& name, const std::int64_t value) { if ((std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)()) { @@ -1057,16 +1030,13 @@ class binary_writer */ static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept { - return (value <= static_cast((std::numeric_limits::max)())) - ? sizeof(std::int32_t) - : sizeof(std::int64_t); + return (value <= static_cast((std::numeric_limits::max)())) ? sizeof(std::int32_t) : sizeof(std::int64_t); } /*! @brief Writes a BSON element with key @a name and unsigned @a value */ - void write_bson_unsigned(const string_t& name, - const BasicJsonType& j) + void write_bson_unsigned(const string_t& name, const BasicJsonType& j) { if (j.m_data.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { @@ -1080,15 +1050,17 @@ class binary_writer } else { - JSON_THROW(out_of_range::create(407, concat("integer number ", std::to_string(j.m_data.m_value.number_unsigned), " cannot be represented by BSON as it does not fit int64"), &j)); + JSON_THROW(out_of_range::create( + 407, + concat("integer number ", std::to_string(j.m_data.m_value.number_unsigned), " cannot be represented by BSON as it does not fit int64"), + &j)); } } /*! @brief Writes a BSON element with key @a name and object @a value */ - void write_bson_object_entry(const string_t& name, - const typename BasicJsonType::object_t& value) + void write_bson_object_entry(const string_t& name, const typename BasicJsonType::object_t& value) { write_bson_entry_header(name, 0x03); // object write_bson_object(value); @@ -1101,9 +1073,12 @@ class binary_writer { std::size_t array_index = 0ul; - const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), static_cast(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type& el) { - return result + calc_bson_element_size(std::to_string(array_index++), el); - }); + const std::size_t embedded_document_size = std::accumulate(std::begin(value), + std::end(value), + static_cast(0), + [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type& el) { + return result + calc_bson_element_size(std::to_string(array_index++), el); + }); return sizeof(std::int32_t) + embedded_document_size + 1ul; } @@ -1119,8 +1094,7 @@ class binary_writer /*! @brief Writes a BSON element with key @a name and array @a value */ - void write_bson_array(const string_t& name, - const typename BasicJsonType::array_t& value) + void write_bson_array(const string_t& name, const typename BasicJsonType::array_t& value) { write_bson_entry_header(name, 0x04); // array write_number(static_cast(calc_bson_array_size(value)), true); @@ -1138,8 +1112,7 @@ class binary_writer /*! @brief Writes a BSON element with key @a name and binary value @a value */ - void write_bson_binary(const string_t& name, - const binary_t& value) + void write_bson_binary(const string_t& name, const binary_t& value) { write_bson_entry_header(name, 0x05); @@ -1153,8 +1126,7 @@ class binary_writer @brief Calculates the size necessary to serialize the JSON value @a j with its @a name @return The calculated size for the BSON document entry for @a j with the given @a name. */ - static std::size_t calc_bson_element_size(const string_t& name, - const BasicJsonType& j) + static std::size_t calc_bson_element_size(const string_t& name, const BasicJsonType& j) { const auto header_size = calc_bson_entry_header_size(name, j); switch (j.type()) @@ -1201,8 +1173,7 @@ class binary_writer @param name The name to associate with the JSON entity @a j within the current BSON document */ - void write_bson_element(const string_t& name, - const BasicJsonType& j) + void write_bson_element(const string_t& name, const BasicJsonType& j) { switch (j.type()) { @@ -1250,9 +1221,10 @@ class binary_writer */ static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value) { - const std::size_t document_size = std::accumulate(value.begin(), value.end(), static_cast(0), [](size_t result, const typename BasicJsonType::object_t::value_type& el) { - return result += calc_bson_element_size(el.first, el.second); - }); + const std::size_t document_size = + std::accumulate(value.begin(), value.end(), static_cast(0), [](size_t result, const typename BasicJsonType::object_t::value_type& el) { + return result += calc_bson_element_size(el.first, el.second); + }); return sizeof(std::int32_t) + document_size + 1ul; } @@ -1307,9 +1279,7 @@ class binary_writer // UBJSON: write number (floating point) template::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix, - const bool use_bjdata) + void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata) { if (add_prefix) { @@ -1320,9 +1290,7 @@ class binary_writer // UBJSON: write number (unsigned integer) template::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix, - const bool use_bjdata) + void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata) { if (n <= static_cast((std::numeric_limits::max)())) { @@ -1406,9 +1374,7 @@ class binary_writer // UBJSON: write number (signed integer) template::value && !std::is_floating_point::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix, - const bool use_bjdata) + void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata) { if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) { @@ -1418,7 +1384,8 @@ class binary_writer } write_number(static_cast(n), use_bjdata); } - else if (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)())) + else if (static_cast((std::numeric_limits::min)()) <= n && + n <= static_cast((std::numeric_limits::max)())) { if (add_prefix) { @@ -1434,7 +1401,8 @@ class binary_writer } write_number(static_cast(n), use_bjdata); } - else if (use_bjdata && (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) + else if (use_bjdata && (static_cast((std::numeric_limits::min)()) <= n && + n <= static_cast((std::numeric_limits::max)()))) { if (add_prefix) { @@ -1450,7 +1418,8 @@ class binary_writer } write_number(static_cast(n), use_bjdata); } - else if (use_bjdata && (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) + else if (use_bjdata && (static_cast((std::numeric_limits::min)()) <= n && + n <= static_cast((std::numeric_limits::max)()))) { if (add_prefix) { @@ -1499,31 +1468,38 @@ class binary_writer case value_t::number_integer: { - if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) + if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) { return 'i'; } - if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) + if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) { return 'U'; } - if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) + if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) { return 'I'; } - if (use_bjdata && ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)())) + if (use_bjdata && ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)())) { return 'u'; } - if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) + if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) { return 'l'; } - if (use_bjdata && ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)())) + if (use_bjdata && ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)())) { return 'm'; } - if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) + if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) { return 'L'; } @@ -1603,7 +1579,17 @@ class binary_writer */ bool write_bjdata_ndarray(const typename BasicJsonType::object_t& value, const bool use_count, const bool use_type) { - std::map bjdtype = {{"uint8", 'U'}, {"int8", 'i'}, {"uint16", 'u'}, {"int16", 'I'}, {"uint32", 'm'}, {"int32", 'l'}, {"uint64", 'M'}, {"int64", 'L'}, {"single", 'd'}, {"double", 'D'}, {"char", 'C'}}; + std::map bjdtype = {{"uint8", 'U'}, + {"int8", 'i'}, + {"uint16", 'u'}, + {"int16", 'I'}, + {"uint32", 'm'}, + {"int32", 'l'}, + {"uint64", 'M'}, + {"int64", 'L'}, + {"single", 'd'}, + {"double", 'D'}, + {"char", 'C'}}; string_t key = "_ArrayType_"; auto it = bjdtype.find(static_cast(value.at(key))); @@ -1752,16 +1738,13 @@ class binary_writer static_cast(n) <= static_cast((std::numeric_limits::max)()) && static_cast(static_cast(n)) == static_cast(n)) { - oa->write_character(format == detail::input_format_t::cbor - ? get_cbor_float_prefix(static_cast(n)) - : get_msgpack_float_prefix(static_cast(n))); + oa->write_character(format == detail::input_format_t::cbor ? get_cbor_float_prefix(static_cast(n)) + : get_msgpack_float_prefix(static_cast(n))); write_number(static_cast(n)); } else { - oa->write_character(format == detail::input_format_t::cbor - ? get_cbor_float_prefix(n) - : get_msgpack_float_prefix(n)); + oa->write_character(format == detail::input_format_t::cbor ? get_cbor_float_prefix(n) : get_msgpack_float_prefix(n)); write_number(n); } #ifdef __GNUC__ @@ -1774,15 +1757,13 @@ class binary_writer // between uint8_t and CharType. In case CharType is not unsigned, // such a conversion is required to allow values greater than 128. // See for a discussion. - template::value && std::is_signed::value>* = nullptr> + template::value && std::is_signed::value>* = nullptr> static constexpr CharType to_char_type(std::uint8_t x) noexcept { return *reinterpret_cast(&x); } - template::value && std::is_unsigned::value>* = nullptr> + template::value && std::is_unsigned::value>* = nullptr> static CharType to_char_type(std::uint8_t x) noexcept { static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t"); @@ -1792,14 +1773,16 @@ class binary_writer return result; } - template::value>* = nullptr> + template::value>* = nullptr> static constexpr CharType to_char_type(std::uint8_t x) noexcept { return x; } - template::value && std::is_signed::value && std::is_same::type>::value>* = nullptr> + template::value && std::is_signed::value && std::is_same::type>::value>* = + nullptr> static constexpr CharType to_char_type(InputCharType x) noexcept { return x; diff --git a/include/nlohmann/detail/output/output_adapters.hpp b/include/nlohmann/detail/output/output_adapters.hpp index 9fde874f8e..ab76924160 100644 --- a/include/nlohmann/detail/output/output_adapters.hpp +++ b/include/nlohmann/detail/output/output_adapters.hpp @@ -23,7 +23,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /// abstract output adapter interface template diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index f389b04722..d7ac8d78bc 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -32,7 +32,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /////////////////// // serialization // @@ -102,11 +103,7 @@ class serializer @param[in] indent_step the indent level @param[in] current_indent the current indent level (only used internally) */ - void dump(const BasicJsonType& val, - const bool pretty_print, - const bool ensure_ascii, - const unsigned int indent_step, - const unsigned int current_indent = 0) + void dump(const BasicJsonType& val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent = 0) { switch (val.m_data.m_type) { @@ -203,9 +200,7 @@ class serializer } // first n-1 elements - for (auto i = val.m_data.m_value.array->cbegin(); - i != val.m_data.m_value.array->cend() - 1; - ++i) + for (auto i = val.m_data.m_value.array->cbegin(); i != val.m_data.m_value.array->cend() - 1; ++i) { o->write_characters(indent_string.c_str(), new_indent); dump(*i, true, ensure_ascii, indent_step, new_indent); @@ -226,9 +221,7 @@ class serializer o->write_character('['); // first n-1 elements - for (auto i = val.m_data.m_value.array->cbegin(); - i != val.m_data.m_value.array->cend() - 1; - ++i) + for (auto i = val.m_data.m_value.array->cbegin(); i != val.m_data.m_value.array->cend() - 1; ++i) { dump(*i, false, ensure_ascii, indent_step, current_indent); o->write_character(','); @@ -271,9 +264,7 @@ class serializer if (!val.m_data.m_value.binary->empty()) { - for (auto i = val.m_data.m_value.binary->cbegin(); - i != val.m_data.m_value.binary->cend() - 1; - ++i) + for (auto i = val.m_data.m_value.binary->cbegin(); i != val.m_data.m_value.binary->cend() - 1; ++i) { dump_integer(*i); o->write_characters(", ", 2); @@ -303,9 +294,7 @@ class serializer if (!val.m_data.m_value.binary->empty()) { - for (auto i = val.m_data.m_value.binary->cbegin(); - i != val.m_data.m_value.binary->cend() - 1; - ++i) + for (auto i = val.m_data.m_value.binary->cbegin(); i != val.m_data.m_value.binary->cend() - 1; ++i) { dump_integer(*i); o->write_character(','); @@ -475,7 +464,11 @@ class serializer else { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - static_cast((std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x", static_cast(0xD7C0u + (codepoint >> 10u)), static_cast(0xDC00u + (codepoint & 0x3FFu)))); + static_cast((std::snprintf)(string_buffer.data() + bytes, + 13, + "\\u%04x\\u%04x", + static_cast(0xD7C0u + (codepoint >> 10u)), + static_cast(0xDC00u + (codepoint & 0x3FFu)))); bytes += 12; } } @@ -510,7 +503,8 @@ class serializer { case error_handler_t::strict: { - JSON_THROW(type_error::create(316, concat("invalid UTF-8 byte at index ", std::to_string(i), ": 0x", hex_bytes(byte | 0)), nullptr)); + JSON_THROW( + type_error::create(316, concat("invalid UTF-8 byte at index ", std::to_string(i), ": 0x", hex_bytes(byte | 0)), nullptr)); } case error_handler_t::ignore: @@ -602,7 +596,8 @@ class serializer { case error_handler_t::strict: { - JSON_THROW(type_error::create(316, concat("incomplete UTF-8 string; last byte: 0x", hex_bytes(static_cast(s.back() | 0))), nullptr)); + JSON_THROW( + type_error::create(316, concat("incomplete UTF-8 string; last byte: 0x", hex_bytes(static_cast(s.back() | 0))), nullptr)); } case error_handler_t::ignore: @@ -705,112 +700,24 @@ class serializer @param[in] x integer number (signed or unsigned) to dump @tparam NumberType either @a number_integer_t or @a number_unsigned_t */ - template::value || std::is_same::value || std::is_same::value || std::is_same::value, int> = 0> + template::value || std::is_same::value || + std::is_same::value || std::is_same::value, + int> = 0> void dump_integer(NumberType x) { - static constexpr std::array, 100> digits_to_99{ - { - {{'0', '0'}}, - {{'0', '1'}}, - {{'0', '2'}}, - {{'0', '3'}}, - {{'0', '4'}}, - {{'0', '5'}}, - {{'0', '6'}}, - {{'0', '7'}}, - {{'0', '8'}}, - {{'0', '9'}}, - {{'1', '0'}}, - {{'1', '1'}}, - {{'1', '2'}}, - {{'1', '3'}}, - {{'1', '4'}}, - {{'1', '5'}}, - {{'1', '6'}}, - {{'1', '7'}}, - {{'1', '8'}}, - {{'1', '9'}}, - {{'2', '0'}}, - {{'2', '1'}}, - {{'2', '2'}}, - {{'2', '3'}}, - {{'2', '4'}}, - {{'2', '5'}}, - {{'2', '6'}}, - {{'2', '7'}}, - {{'2', '8'}}, - {{'2', '9'}}, - {{'3', '0'}}, - {{'3', '1'}}, - {{'3', '2'}}, - {{'3', '3'}}, - {{'3', '4'}}, - {{'3', '5'}}, - {{'3', '6'}}, - {{'3', '7'}}, - {{'3', '8'}}, - {{'3', '9'}}, - {{'4', '0'}}, - {{'4', '1'}}, - {{'4', '2'}}, - {{'4', '3'}}, - {{'4', '4'}}, - {{'4', '5'}}, - {{'4', '6'}}, - {{'4', '7'}}, - {{'4', '8'}}, - {{'4', '9'}}, - {{'5', '0'}}, - {{'5', '1'}}, - {{'5', '2'}}, - {{'5', '3'}}, - {{'5', '4'}}, - {{'5', '5'}}, - {{'5', '6'}}, - {{'5', '7'}}, - {{'5', '8'}}, - {{'5', '9'}}, - {{'6', '0'}}, - {{'6', '1'}}, - {{'6', '2'}}, - {{'6', '3'}}, - {{'6', '4'}}, - {{'6', '5'}}, - {{'6', '6'}}, - {{'6', '7'}}, - {{'6', '8'}}, - {{'6', '9'}}, - {{'7', '0'}}, - {{'7', '1'}}, - {{'7', '2'}}, - {{'7', '3'}}, - {{'7', '4'}}, - {{'7', '5'}}, - {{'7', '6'}}, - {{'7', '7'}}, - {{'7', '8'}}, - {{'7', '9'}}, - {{'8', '0'}}, - {{'8', '1'}}, - {{'8', '2'}}, - {{'8', '3'}}, - {{'8', '4'}}, - {{'8', '5'}}, - {{'8', '6'}}, - {{'8', '7'}}, - {{'8', '8'}}, - {{'8', '9'}}, - {{'9', '0'}}, - {{'9', '1'}}, - {{'9', '2'}}, - {{'9', '3'}}, - {{'9', '4'}}, - {{'9', '5'}}, - {{'9', '6'}}, - {{'9', '7'}}, - {{'9', '8'}}, - {{'9', '9'}}, - }}; + static constexpr std::array, 100> digits_to_99{{ + {{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}}, + {{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}}, + {{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}}, + {{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}}, + {{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}}, + {{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}}, + {{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}}, + {{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}}, + {{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}}, + {{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}}, + }}; // special case for "0" if (x == 0) @@ -893,8 +800,10 @@ class serializer // guaranteed to round-trip, using strtof and strtod, resp. // // NB: The test below works if == . - static constexpr bool is_ieee_single_or_double = (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 24 && std::numeric_limits::max_exponent == 128) || - (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 53 && std::numeric_limits::max_exponent == 1024); + static constexpr bool is_ieee_single_or_double = (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 24 && + std::numeric_limits::max_exponent == 128) || + (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 53 && + std::numeric_limits::max_exponent == 1024); dump_float(x, std::integral_constant()); } @@ -945,10 +854,9 @@ class serializer o->write_characters(number_buffer.data(), static_cast(len)); // determine if we need to append ".0" - const bool value_is_int_like = - std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1, [](char c) { - return c == '.' || c == 'e'; - }); + const bool value_is_int_like = std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1, [](char c) { + return c == '.' || c == 'e'; + }); if (value_is_int_like) { @@ -979,417 +887,41 @@ class serializer */ static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept { - static const std::array utf8d = - { - { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, // 00..1F - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, // 20..3F - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, // 40..5F - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, // 60..7F - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, // 80..9F - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, // A0..BF - 8, - 8, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, // C0..DF - 0xA, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x4, - 0x3, - 0x3, // E0..EF - 0xB, - 0x6, - 0x6, - 0x6, - 0x5, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, // F0..FF - 0x0, - 0x1, - 0x2, - 0x3, - 0x5, - 0x8, - 0x7, - 0x1, - 0x1, - 0x1, - 0x4, - 0x6, - 0x1, - 0x1, - 0x1, - 0x1, // s0..s0 - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 1, // s1..s2 - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 2, - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, // s3..s4 - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 3, - 1, - 3, - 1, - 1, - 1, - 1, - 1, - 1, // s5..s6 - 1, - 3, - 1, - 1, - 1, - 1, - 1, - 3, - 1, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1 // s7..s8 - }}; + static const std::array utf8d = {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 00..1F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 20..3F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 40..5F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 60..7F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, // 80..9F + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, // A0..BF + 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, // C0..DF + 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, + 0x3, // E0..EF + 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, + 0x8, // F0..FF + 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, + 0x1, // s0..s0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, + 1, // s1..s2 + 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, // s3..s4 + 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, + 1, // s5..s6 + 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1 // s7..s8 + }}; JSON_ASSERT(byte < utf8d.size()); const std::uint8_t type = utf8d[byte]; - codep = (state != UTF8_ACCEPT) - ? (byte & 0x3fu) | (codep << 6u) - : (0xFFu >> type) & (byte); + codep = (state != UTF8_ACCEPT) ? (byte & 0x3fu) | (codep << 6u) : (0xFFu >> type) & (byte); const std::size_t index = 256u + static_cast(state) * 16u + static_cast(type); JSON_ASSERT(index < utf8d.size()); diff --git a/include/nlohmann/detail/string_concat.hpp b/include/nlohmann/detail/string_concat.hpp index 7bb7c9bc2c..a4c787b635 100644 --- a/include/nlohmann/detail/string_concat.hpp +++ b/include/nlohmann/detail/string_concat.hpp @@ -16,7 +16,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ inline std::size_t concat_length() { @@ -76,13 +77,26 @@ using string_can_append_data = decltype(std::declval().append(std:: template using detect_string_can_append_data = is_detected; -template::value && detect_string_can_append_op::value, int> = 0> +template::value && detect_string_can_append_op::value, int> = 0> inline void concat_into(OutStringType& out, Arg&& arg, Args&&... rest); -template::value && !detect_string_can_append_op::value && detect_string_can_append_iter::value, int> = 0> +template::value && !detect_string_can_append_op::value && + detect_string_can_append_iter::value, + int> = 0> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest); -template::value && !detect_string_can_append_op::value && !detect_string_can_append_iter::value && detect_string_can_append_data::value, int> = 0> +template::value && !detect_string_can_append_op::value && + !detect_string_can_append_iter::value && detect_string_can_append_data::value, + int> = 0> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest); template::value, int> = 0> @@ -92,21 +106,34 @@ inline void concat_into(OutStringType& out, Arg&& arg, Args&&... rest) concat_into(out, std::forward(rest)...); } -template::value && detect_string_can_append_op::value, int>> +template::value && detect_string_can_append_op::value, int>> inline void concat_into(OutStringType& out, Arg&& arg, Args&&... rest) { out += std::forward(arg); concat_into(out, std::forward(rest)...); } -template::value && !detect_string_can_append_op::value && detect_string_can_append_iter::value, int>> +template::value && !detect_string_can_append_op::value && + detect_string_can_append_iter::value, + int>> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest) { out.append(arg.begin(), arg.end()); concat_into(out, std::forward(rest)...); } -template::value && !detect_string_can_append_op::value && !detect_string_can_append_iter::value && detect_string_can_append_data::value, int>> +template::value && !detect_string_can_append_op::value && + !detect_string_can_append_iter::value && detect_string_can_append_data::value, + int>> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest) { out.append(arg.data(), arg.size()); diff --git a/include/nlohmann/detail/string_escape.hpp b/include/nlohmann/detail/string_escape.hpp index 14cb78c4f6..41addc9d3c 100644 --- a/include/nlohmann/detail/string_escape.hpp +++ b/include/nlohmann/detail/string_escape.hpp @@ -11,7 +11,8 @@ #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /*! @brief replace all occurrences of a substring by another string diff --git a/include/nlohmann/detail/value_t.hpp b/include/nlohmann/detail/value_t.hpp index 446ee5d189..eb7bcca3f8 100644 --- a/include/nlohmann/detail/value_t.hpp +++ b/include/nlohmann/detail/value_t.hpp @@ -19,7 +19,8 @@ #endif NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /////////////////////////// // JSON type enumeration // diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 6552553732..8746e7575c 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -130,16 +130,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe using lexer = ::nlohmann::detail::lexer_base; template - static ::nlohmann::detail::parser parser( - InputAdapterType adapter, - detail::parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) + static ::nlohmann::detail::parser + parser(InputAdapterType adapter, detail::parser_callback_t cb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false) { - return ::nlohmann::detail::parser(std::move(adapter), - std::move(cb), - allow_exceptions, - ignore_comments); + return ::nlohmann::detail::parser(std::move(adapter), std::move(cb), allow_exceptions, ignore_comments); } private: @@ -255,8 +249,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe result["copyright"] = "(C) 2013-2023 Niels Lohmann"; result["name"] = "JSON for Modern C++"; result["url"] = "https://github.com/nlohmann/json"; - result["version"]["string"] = - detail::concat(std::to_string(NLOHMANN_JSON_VERSION_MAJOR), '.', std::to_string(NLOHMANN_JSON_VERSION_MINOR), '.', std::to_string(NLOHMANN_JSON_VERSION_PATCH)); + result["version"]["string"] = detail::concat(std::to_string(NLOHMANN_JSON_VERSION_MAJOR), + '.', + std::to_string(NLOHMANN_JSON_VERSION_MINOR), + '.', + std::to_string(NLOHMANN_JSON_VERSION_PATCH)); result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR; result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR; result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH; @@ -274,34 +271,23 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe #endif #if defined(__ICC) || defined(__INTEL_COMPILER) - result["compiler"] = {{"family", "icc"}, { "version", - __INTEL_COMPILER }}; + result["compiler"] = {{"family", "icc"}, { "version", __INTEL_COMPILER }}; #elif defined(__clang__) - result["compiler"] = {{"family", "clang"}, { "version", - __clang_version__ }}; + result["compiler"] = {{"family", "clang"}, { "version", __clang_version__ }}; #elif defined(__GNUC__) || defined(__GNUG__) - result["compiler"] = {{"family", "gcc"}, { "version", - detail::concat( - std::to_string(__GNUC__), - '.', - std::to_string(__GNUC_MINOR__), - '.', - std::to_string(__GNUC_PATCHLEVEL__)) - }}; + result["compiler"] = {{"family", "gcc"}, + { "version", + detail::concat(std::to_string(__GNUC__), '.', std::to_string(__GNUC_MINOR__), '.', std::to_string(__GNUC_PATCHLEVEL__)) }}; #elif defined(__HP_cc) || defined(__HP_aCC) result["compiler"] = "hp" #elif defined(__IBMCPP__) - result["compiler"] = {{"family", "ilecpp"}, { "version", - __IBMCPP__ }}; + result["compiler"] = {{"family", "ilecpp"}, { "version", __IBMCPP__ }}; #elif defined(_MSC_VER) - result["compiler"] = {{"family", "msvc"}, { "version", - _MSC_VER }}; + result["compiler"] = {{"family", "msvc"}, { "version", _MSC_VER }}; #elif defined(__PGI) - result["compiler"] = {{"family", "pgcpp"}, { "version", - __PGI }}; + result["compiler"] = {{"family", "pgcpp"}, { "version", __PGI }}; #elif defined(__SUNPRO_CC) - result["compiler"] = {{"family", "sunpro"}, { "version", - __SUNPRO_CC }}; + result["compiler"] = {{"family", "sunpro"}, { "version", __SUNPRO_CC }}; #else result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; #endif @@ -339,11 +325,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief a type for an object /// @sa https://json.nlohmann.me/api/basic_json/object_t/ - using object_t = ObjectType>>; + using object_t = ObjectType>>; /// @brief a type for an array /// @sa https://json.nlohmann.me/api/basic_json/array_t/ @@ -587,10 +569,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe void destroy(value_t t) { - if ( - (t == value_t::object && object == nullptr) || - (t == value_t::array && array == nullptr) || - (t == value_t::string && string == nullptr) || + if ((t == value_t::object && object == nullptr) || (t == value_t::array && array == nullptr) || (t == value_t::string && string == nullptr) || (t == value_t::binary && binary == nullptr)) { //not initialized (e.g. due to exception in the ctor) @@ -862,12 +841,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ template, - detail::enable_if_t< - !detail::is_basic_json::value && detail::is_compatible_type::value, - int> = 0> + detail::enable_if_t::value && detail::is_compatible_type::value, + int> = 0> basic_json(CompatibleType&& val) noexcept(noexcept( // NOLINT(bugprone-forwarding-reference-overload,bugprone-exception-escape) - JSONSerializer::to_json(std::declval(), - std::forward(val)))) + JSONSerializer::to_json(std::declval(), std::forward(val)))) { JSONSerializer::to_json(*this, std::forward(val)); set_parents(); @@ -877,9 +854,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an existing one /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ template::value && !std::is_same::value, - int> = 0> + detail::enable_if_t::value && !std::is_same::value, int> = 0> basic_json(const BasicJsonType& val) { using other_boolean_t = typename BasicJsonType::boolean_t; @@ -933,9 +908,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a container (array or object) from an initializer list /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ - basic_json(initializer_list_t init, - bool type_deduction = true, - value_t manual_type = value_t::array) + basic_json(initializer_list_t init, bool type_deduction = true, value_t manual_type = value_t::array) { // check if each element is an array with two elements whose first // element is a string @@ -971,9 +944,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe for (auto& element_ref : init) { auto element = element_ref.moved_or_copied(); - m_data.m_value.object->emplace( - std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)), - std::move((*element.m_data.m_value.array)[1])); + m_data.m_value.object->emplace(std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)), + std::move((*element.m_data.m_value.array)[1])); } } else @@ -1058,7 +1030,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief construct a JSON container given an iterator range /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ - template::value || std::is_same::value, int>::type = 0> + template::value || + std::is_same::value, + int>::type = 0> basic_json(InputIT first, InputIT last) { JSON_ASSERT(first.m_object != nullptr); @@ -1132,15 +1107,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe case value_t::object: { - m_data.m_value.object = create(first.m_it.object_iterator, - last.m_it.object_iterator); + m_data.m_value.object = create(first.m_it.object_iterator, last.m_it.object_iterator); break; } case value_t::array: { - m_data.m_value.array = create(first.m_it.array_iterator, - last.m_it.array_iterator); + m_data.m_value.array = create(first.m_it.array_iterator, last.m_it.array_iterator); break; } @@ -1165,9 +1138,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /////////////////////////////////////// template, - std::is_same>::value, - int> = 0> + detail::enable_if_t, std::is_same>::value, int> = 0> basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {} @@ -1260,12 +1231,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief copy assignment /// @sa https://json.nlohmann.me/api/basic_json/operator=/ - basic_json& operator=(basic_json other) noexcept( - std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value && - std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value && - std::is_nothrow_move_assignable::value) + basic_json& operator=(basic_json other) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value && + std::is_nothrow_move_constructible::value && + std::is_nothrow_move_assignable::value && + std::is_nothrow_move_assignable::value) { // check that passed value is valid other.assert_invariant(); @@ -1580,7 +1549,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief get a pointer value (implicit) /// @sa https://json.nlohmann.me/api/basic_json/get_ptr/ - template::value && std::is_const::type>::value, int>::type = 0> + template< + typename PointerType, + typename std::enable_if::value && std::is_const::type>::value, int>::type = 0> constexpr auto get_ptr() const noexcept -> decltype(std::declval().get_impl_ptr(std::declval())) { // delegate the call to get_impl_ptr<>() const @@ -1627,12 +1598,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @since version 2.1.0 */ template::value && - detail::has_from_json::value, - int> = 0> - ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept( - JSONSerializer::from_json(std::declval(), std::declval()))) + detail::enable_if_t::value && detail::has_from_json::value, int> = 0> + ValueType get_impl(detail::priority_tag<0> /*unused*/) const + noexcept(noexcept(JSONSerializer::from_json(std::declval(), std::declval()))) { auto ret = ValueType(); JSONSerializer::from_json(*this, ret); @@ -1669,12 +1637,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @since version 2.1.0 */ - template::value, - int> = 0> - ValueType get_impl(detail::priority_tag<1> /*unused*/) const noexcept(noexcept( - JSONSerializer::from_json(std::declval()))) + template::value, int> = 0> + ValueType get_impl(detail::priority_tag<1> /*unused*/) const noexcept(noexcept(JSONSerializer::from_json(std::declval()))) { return JSONSerializer::from_json(*this); } @@ -1694,10 +1658,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @since version 3.2.0 */ - template::value, - int> = 0> + template::value, int> = 0> BasicJsonType get_impl(detail::priority_tag<2> /*unused*/) const { return *this; @@ -1717,10 +1678,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @since version 2.1.0 */ - template::value, - int> = 0> + template::value, int> = 0> basic_json get_impl(detail::priority_tag<3> /*unused*/) const { return *this; @@ -1730,12 +1688,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @brief get a pointer value (explicit) @copydoc get() */ - template::value, - int> = 0> - constexpr auto get_impl(detail::priority_tag<4> /*unused*/) const noexcept - -> decltype(std::declval().template get_ptr()) + template::value, int> = 0> + constexpr auto get_impl(detail::priority_tag<4> /*unused*/) const noexcept -> decltype(std::declval().template get_ptr()) { // delegate the call to get_ptr return get_ptr(); @@ -1770,15 +1724,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe constexpr #endif auto - get() const noexcept( - noexcept(std::declval().template get_impl(detail::priority_tag<4>{}))) + get() const noexcept(noexcept(std::declval().template get_impl(detail::priority_tag<4>{}))) -> decltype(std::declval().template get_impl(detail::priority_tag<4>{})) { // we cannot static_assert on ValueTypeCV being non-const, because // there is support for get(), which is why we // still need the uncvref - static_assert(!std::is_reference::value, - "get() cannot be used with reference types, you might want to use get_ref()"); + static_assert(!std::is_reference::value, "get() cannot be used with reference types, you might want to use get_ref()"); return get_impl(detail::priority_tag<4>{}); } @@ -1819,12 +1771,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief get a value (explicit) /// @sa https://json.nlohmann.me/api/basic_json/get_to/ template::value && - detail::has_from_json::value, - int> = 0> - ValueType& get_to(ValueType& v) const noexcept(noexcept( - JSONSerializer::from_json(std::declval(), v))) + detail::enable_if_t::value && detail::has_from_json::value, int> = 0> + ValueType& get_to(ValueType& v) const noexcept(noexcept(JSONSerializer::from_json(std::declval(), v))) { JSONSerializer::from_json(*this, v); return v; @@ -1832,27 +1780,20 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe // specialization to allow calling get_to with a basic_json value // see https://github.com/nlohmann/json/issues/2175 - template::value, - int> = 0> + template::value, int> = 0> ValueType& get_to(ValueType& v) const { v = *this; return v; } - template< - typename T, - std::size_t N, - typename Array = T (&)[N], // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - detail::enable_if_t< - detail::has_from_json::value, - int> = 0> + template::value, + int> = 0> Array get_to(T (&v)[N]) const // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - noexcept(noexcept(JSONSerializer::from_json( - std::declval(), - v))) + noexcept(noexcept(JSONSerializer::from_json(std::declval(), v))) { JSONSerializer::from_json(*this, v); return v; @@ -1869,7 +1810,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief get a reference value (implicit) /// @sa https://json.nlohmann.me/api/basic_json/get_ref/ - template::value && std::is_const::type>::value, int>::type = 0> + template::value && std::is_const::type>::value, + int>::type = 0> ReferenceType get_ref() const { // delegate call to get_ref_impl @@ -1905,15 +1848,21 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @since version 1.0.0 */ - template>, detail::negation>, detail::negation>>, detail::negation>, detail::negation>, detail::negation>>, + template>, + detail::negation>, + detail::negation>>, + detail::negation>, + detail::negation>, + detail::negation>>, #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) - detail::negation>, + detail::negation>, #endif #if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI - detail::negation>, + detail::negation>, #endif - detail::is_detected_lazy>::value, - int>::type = 0> + detail::is_detected_lazy>::value, + int>::type = 0> JSON_EXPLICIT operator ValueType() const { // delegate the call to get<>() const @@ -2108,7 +2057,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe else { // set parent for values added above - set_parents(begin() + static_cast(old_size), static_cast(idx + 1 - old_size)); + set_parents(begin() + static_cast(old_size), + static_cast(idx + 1 - old_size)); } #endif assert_invariant(); @@ -2225,21 +2175,18 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe private: template - using is_comparable_with_object_key = detail::is_comparable< - object_comparator_t, - const typename object_t::key_type&, - KeyType>; + using is_comparable_with_object_key = detail::is_comparable; template - using value_return_type = std::conditional< - detail::is_c_string_uncvref::value, - string_t, - typename std::decay::type>; + using value_return_type = std::conditional::value, string_t, typename std::decay::type>; public: /// @brief access specified object element with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const { // value only works for objects @@ -2260,7 +2207,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief access specified object element with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::type, detail::enable_if_t::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::type, + detail::enable_if_t::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> ReturnType value(const typename object_t::key_type& key, ValueType&& default_value) const { // value only works for objects @@ -2281,7 +2232,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief access specified object element with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::value && !detail::is_json_pointer::value && is_comparable_with_object_key::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::value && !detail::is_json_pointer::value && + is_comparable_with_object_key::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> ValueType value(KeyType&& key, const ValueType& default_value) const { // value only works for objects @@ -2302,7 +2258,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief access specified object element via JSON Pointer with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::type, detail::enable_if_t::value && !detail::is_json_pointer::value && is_comparable_with_object_key::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::type, + detail::enable_if_t::value && !detail::is_json_pointer::value && + is_comparable_with_object_key::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> ReturnType value(KeyType&& key, ValueType&& default_value) const { // value only works for objects @@ -2323,7 +2285,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief access specified object element via JSON Pointer with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::value && !std::is_same>::value, int> = 0> + template::value && !std::is_same>::value, int> = 0> ValueType value(const json_pointer& ptr, const ValueType& default_value) const { // value only works for objects @@ -2345,7 +2308,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief access specified object element via JSON Pointer with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::type, detail::enable_if_t::value && !std::is_same>::value, int> = 0> + template::type, + detail::enable_if_t::value && !std::is_same>::value, int> = 0> ReturnType value(const json_pointer& ptr, ValueType&& default_value) const { // value only works for objects @@ -2365,14 +2330,23 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this)); } - template::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer) // NOLINT(readability/alt_tokens) ValueType value(const ::nlohmann::json_pointer& ptr, const ValueType& default_value) const { return value(ptr.convert(), default_value); } - template::type, detail::enable_if_t::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::type, + detail::enable_if_t::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer) // NOLINT(readability/alt_tokens) ReturnType value(const ::nlohmann::json_pointer& ptr, ValueType&& default_value) const { @@ -2413,7 +2387,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief remove element given an iterator /// @sa https://json.nlohmann.me/api/basic_json/erase/ - template::value || std::is_same::value, int> = 0> + template::value || + std::is_same::value, + int> = 0> IteratorType erase(IteratorType pos) { // make sure iterator fits the current value @@ -2481,7 +2458,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief remove elements given an iterator range /// @sa https://json.nlohmann.me/api/basic_json/erase/ - template::value || std::is_same::value, int> = 0> + template::value || + std::is_same::value, + int> = 0> IteratorType erase(IteratorType first, IteratorType last) { // make sure iterator fits the current value @@ -2528,15 +2508,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe case value_t::object: { - result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator, - last.m_it.object_iterator); + result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator, last.m_it.object_iterator); break; } case value_t::array: { - result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator, - last.m_it.array_iterator); + result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator, last.m_it.array_iterator); break; } @@ -3163,9 +3141,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe if (is_object() && init.size() == 2 && (*init.begin())->is_string()) { basic_json&& key = init.begin()->moved_or_copied(); - push_back(typename object_t::value_type( - std::move(key.get_ref()), - (init.begin() + 1)->moved_or_copied())); + push_back(typename object_t::value_type(std::move(key.get_ref()), (init.begin() + 1)->moved_or_copied())); } else { @@ -3438,8 +3414,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ void swap(reference other) noexcept( - std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value && + std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value && std::is_nothrow_move_constructible::value && // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) std::is_nothrow_move_assignable::value) { @@ -3454,8 +3429,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ friend void swap(reference left, reference right) noexcept( - std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value && + std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value && std::is_nothrow_move_constructible::value && // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) std::is_nothrow_move_assignable::value) { @@ -3553,75 +3527,75 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe // note parentheses around operands are necessary; see // https://github.com/nlohmann/json/issues/1530 -#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \ - const auto lhs_type = lhs.type(); \ - const auto rhs_type = rhs.type(); \ - \ - if (lhs_type == rhs_type) /* NOLINT(readability/braces) */ \ - { \ - switch (lhs_type) \ - { \ - case value_t::array: \ - return (*lhs.m_data.m_value.array)op(*rhs.m_data.m_value.array); \ - \ - case value_t::object: \ - return (*lhs.m_data.m_value.object)op(*rhs.m_data.m_value.object); \ - \ - case value_t::null: \ - return (null_result); \ - \ - case value_t::string: \ - return (*lhs.m_data.m_value.string)op(*rhs.m_data.m_value.string); \ - \ - case value_t::boolean: \ - return (lhs.m_data.m_value.boolean)op(rhs.m_data.m_value.boolean); \ - \ - case value_t::number_integer: \ - return (lhs.m_data.m_value.number_integer)op(rhs.m_data.m_value.number_integer); \ - \ - case value_t::number_unsigned: \ - return (lhs.m_data.m_value.number_unsigned)op(rhs.m_data.m_value.number_unsigned); \ - \ - case value_t::number_float: \ - return (lhs.m_data.m_value.number_float)op(rhs.m_data.m_value.number_float); \ - \ - case value_t::binary: \ - return (*lhs.m_data.m_value.binary)op(*rhs.m_data.m_value.binary); \ - \ - case value_t::discarded: \ - default: \ - return (unordered_result); \ - } \ - } \ - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \ - { \ - return static_cast(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \ - } \ - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \ - { \ - return lhs.m_data.m_value.number_float op static_cast(rhs.m_data.m_value.number_integer); \ - } \ - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \ - { \ - return static_cast(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \ - } \ - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \ - { \ - return lhs.m_data.m_value.number_float op static_cast(rhs.m_data.m_value.number_unsigned); \ - } \ - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \ - { \ - return static_cast(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \ - } \ - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \ - { \ - return lhs.m_data.m_value.number_integer op static_cast(rhs.m_data.m_value.number_unsigned); \ - } \ - else if (compares_unordered(lhs, rhs)) \ - { \ - return (unordered_result); \ - } \ - \ +#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \ + const auto lhs_type = lhs.type(); \ + const auto rhs_type = rhs.type(); \ + \ + if (lhs_type == rhs_type) /* NOLINT(readability/braces) */ \ + { \ + switch (lhs_type) \ + { \ + case value_t::array: \ + return (*lhs.m_data.m_value.array)op(*rhs.m_data.m_value.array); \ + \ + case value_t::object: \ + return (*lhs.m_data.m_value.object)op(*rhs.m_data.m_value.object); \ + \ + case value_t::null: \ + return (null_result); \ + \ + case value_t::string: \ + return (*lhs.m_data.m_value.string)op(*rhs.m_data.m_value.string); \ + \ + case value_t::boolean: \ + return (lhs.m_data.m_value.boolean)op(rhs.m_data.m_value.boolean); \ + \ + case value_t::number_integer: \ + return (lhs.m_data.m_value.number_integer)op(rhs.m_data.m_value.number_integer); \ + \ + case value_t::number_unsigned: \ + return (lhs.m_data.m_value.number_unsigned)op(rhs.m_data.m_value.number_unsigned); \ + \ + case value_t::number_float: \ + return (lhs.m_data.m_value.number_float)op(rhs.m_data.m_value.number_float); \ + \ + case value_t::binary: \ + return (*lhs.m_data.m_value.binary)op(*rhs.m_data.m_value.binary); \ + \ + case value_t::discarded: \ + default: \ + return (unordered_result); \ + } \ + } \ + else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \ + { \ + return static_cast(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \ + } \ + else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \ + { \ + return lhs.m_data.m_value.number_float op static_cast(rhs.m_data.m_value.number_integer); \ + } \ + else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \ + { \ + return static_cast(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \ + } \ + else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \ + { \ + return lhs.m_data.m_value.number_float op static_cast(rhs.m_data.m_value.number_unsigned); \ + } \ + else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \ + { \ + return static_cast(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \ + } \ + else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \ + { \ + return lhs.m_data.m_value.number_integer op static_cast(rhs.m_data.m_value.number_unsigned); \ + } \ + else if (compares_unordered(lhs, rhs)) \ + { \ + return (unordered_result); \ + } \ + \ return (default_result); JSON_PRIVATE_UNLESS_TESTED : @@ -3633,7 +3607,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe static bool compares_unordered(const_reference lhs, const_reference rhs, bool inverse = false) noexcept { - if ((lhs.is_number_float() && std::isnan(lhs.m_data.m_value.number_float) && rhs.is_number()) || (rhs.is_number_float() && std::isnan(rhs.m_data.m_value.number_float) && lhs.is_number())) + if ((lhs.is_number_float() && std::isnan(lhs.m_data.m_value.number_float) && rhs.is_number()) || + (rhs.is_number_float() && std::isnan(rhs.m_data.m_value.number_float) && lhs.is_number())) { return true; } @@ -3975,10 +3950,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief deserialize from a compatible input /// @sa https://json.nlohmann.me/api/basic_json/parse/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json parse(InputType&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + parse(InputType&& i, const parser_callback_t cb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false) { basic_json result; parser(detail::input_adapter(std::forward(i)), cb, allow_exceptions, ignore_comments).parse(true, result); @@ -3988,11 +3961,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief deserialize from a pair of character iterators /// @sa https://json.nlohmann.me/api/basic_json/parse/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json parse(IteratorType first, - IteratorType last, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + parse(IteratorType first, IteratorType last, const parser_callback_t cb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false) { basic_json result; parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result); @@ -4001,10 +3971,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len)) - static basic_json parse(detail::span_input_adapter&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) + static basic_json + parse(detail::span_input_adapter&& i, const parser_callback_t cb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false) { basic_json result; parser(i.get(), cb, allow_exceptions, ignore_comments).parse(true, result); @@ -4014,8 +3982,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief check if the input is valid JSON /// @sa https://json.nlohmann.me/api/basic_json/accept/ template - static bool accept(InputType&& i, - const bool ignore_comments = false) + static bool accept(InputType&& i, const bool ignore_comments = false) { return parser(detail::input_adapter(std::forward(i)), nullptr, false, ignore_comments).accept(true); } @@ -4030,8 +3997,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len)) - static bool accept(detail::span_input_adapter&& i, - const bool ignore_comments = false) + static bool accept(detail::span_input_adapter&& i, const bool ignore_comments = false) { return parser(i.get(), nullptr, false, ignore_comments).accept(true); } @@ -4043,21 +4009,24 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe static bool sax_parse(InputType&& i, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true, const bool ignore_comments = false) { auto ia = detail::input_adapter(std::forward(i)); - return format == input_format_t::json - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - : detail::binary_reader(std::move(ia), format).sax_parse(format, sax, strict); + return format == input_format_t::json ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) + : detail::binary_reader(std::move(ia), format).sax_parse(format, sax, strict); } /// @brief generate SAX events /// @sa https://json.nlohmann.me/api/basic_json/sax_parse/ template JSON_HEDLEY_NON_NULL(3) - static bool sax_parse(IteratorType first, IteratorType last, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true, const bool ignore_comments = false) + static bool sax_parse(IteratorType first, + IteratorType last, + SAX* sax, + input_format_t format = input_format_t::json, + const bool strict = true, + const bool ignore_comments = false) { auto ia = detail::input_adapter(std::move(first), std::move(last)); - return format == input_format_t::json - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - : detail::binary_reader(std::move(ia), format).sax_parse(format, sax, strict); + return format == input_format_t::json ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) + : detail::binary_reader(std::move(ia), format).sax_parse(format, sax, strict); } /// @brief generate SAX events @@ -4067,7 +4036,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// sax_parse(ptr, ptr + len) instead. template JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...)) - JSON_HEDLEY_NON_NULL(2) static bool sax_parse(detail::span_input_adapter&& i, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true, const bool ignore_comments = false) + JSON_HEDLEY_NON_NULL(2) static bool sax_parse(detail::span_input_adapter&& i, + SAX* sax, + input_format_t format = input_format_t::json, + const bool strict = true, + const bool ignore_comments = false) { auto ia = i.get(); return format == input_format_t::json @@ -4148,8 +4121,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe data(const value_t v) : m_type(v) , m_value(v) - { - } + {} data(size_type cnt, const basic_json& val) : m_type(value_t::array) @@ -4232,9 +4204,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a UBJSON serialization of a given JSON value /// @sa https://json.nlohmann.me/api/basic_json/to_ubjson/ - static std::vector to_ubjson(const basic_json& j, - const bool use_size = false, - const bool use_type = false) + static std::vector to_ubjson(const basic_json& j, const bool use_size = false, const bool use_type = false) { std::vector result; to_ubjson(j, result, use_size, use_type); @@ -4257,9 +4227,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a BJData serialization of a given JSON value /// @sa https://json.nlohmann.me/api/basic_json/to_bjdata/ - static std::vector to_bjdata(const basic_json& j, - const bool use_size = false, - const bool use_type = false) + static std::vector to_bjdata(const basic_json& j, const bool use_size = false, const bool use_type = false) { std::vector result; to_bjdata(j, result, use_size, use_type); @@ -4306,10 +4274,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in CBOR format /// @sa https://json.nlohmann.me/api/basic_json/from_cbor/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + from_cbor(InputType&& i, const bool strict = true, const bool allow_exceptions = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4321,7 +4287,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in CBOR format /// @sa https://json.nlohmann.me/api/basic_json/from_cbor/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(IteratorType first, + IteratorType last, + const bool strict = true, + const bool allow_exceptions = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4331,8 +4301,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe } template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) static basic_json from_cbor(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) static basic_json + from_cbor(const T* ptr, + std::size_t len, + const bool strict = true, + const bool allow_exceptions = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) { return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler); } @@ -4355,9 +4329,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in MessagePack format /// @sa https://json.nlohmann.me/api/basic_json/from_msgpack/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(InputType&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4369,7 +4341,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in MessagePack format /// @sa https://json.nlohmann.me/api/basic_json/from_msgpack/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + from_msgpack(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4379,17 +4352,15 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe } template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) static basic_json from_msgpack(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) static basic_json + from_msgpack(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) { return from_msgpack(ptr, ptr + len, strict, allow_exceptions); } JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) - static basic_json from_msgpack(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) + static basic_json from_msgpack(detail::span_input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4402,9 +4373,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in UBJSON format /// @sa https://json.nlohmann.me/api/basic_json/from_ubjson/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(InputType&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4416,7 +4385,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in UBJSON format /// @sa https://json.nlohmann.me/api/basic_json/from_ubjson/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + from_ubjson(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4426,17 +4396,15 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe } template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) static basic_json from_ubjson(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) static basic_json + from_ubjson(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) { return from_ubjson(ptr, ptr + len, strict, allow_exceptions); } JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) - static basic_json from_ubjson(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) + static basic_json from_ubjson(detail::span_input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4449,9 +4417,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in BJData format /// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bjdata(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bjdata(InputType&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4463,7 +4429,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in BJData format /// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + from_bjdata(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4475,9 +4442,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in BSON format /// @sa https://json.nlohmann.me/api/basic_json/from_bson/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(InputType&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4489,7 +4454,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in BSON format /// @sa https://json.nlohmann.me/api/basic_json/from_bson/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + from_bson(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4499,17 +4465,15 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe } template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) static basic_json from_bson(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) static basic_json + from_bson(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) { return from_bson(ptr, ptr + len, strict, allow_exceptions); } JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) - static basic_json from_bson(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) + static basic_json from_bson(detail::span_input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -4759,9 +4723,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe for (const auto& val : json_patch) { // wrapper to get a value for an operation - const auto get_value = [&val](const std::string& op, - const std::string& member, - bool string_type) -> basic_json& { + const auto get_value = [&val](const std::string& op, const std::string& member, bool string_type) -> basic_json& { // find value auto it = val.m_data.m_value.object->find(member); @@ -4910,8 +4872,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe if (source.type() != target.type()) { // different types: replace value - result.push_back( - {{"op", "replace"}, {"path", path}, {"value", target}}); + result.push_back({{"op", "replace"}, {"path", path}, {"value", target}}); return result; } @@ -4945,10 +4906,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe // add other remaining elements while (i < target.size()) { - result.push_back( - {{"op", "add"}, - {"path", detail::concat(path, "/-")}, - {"value", target[i]}}); + result.push_back({{"op", "add"}, {"path", detail::concat(path, "/-")}, {"value", target[i]}}); ++i; } @@ -4972,8 +4930,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe else { // found a key that is not in o -> remove it - result.push_back(object( - {{"op", "remove"}, {"path", path_key}})); + result.push_back(object({{"op", "remove"}, {"path", path_key}})); } } @@ -4984,8 +4941,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe { // found a key that is not in this -> add it const auto path_key = detail::concat(path, '/', detail::escape(it.key())); - result.push_back( - {{"op", "add"}, {"path", path_key}, {"value", it.value()}}); + result.push_back({{"op", "add"}, {"path", path_key}, {"value", it.value()}}); } } @@ -5003,8 +4959,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe default: { // both primitive type: replace value - result.push_back( - {{"op", "replace"}, {"path", path}, {"value", target}}); + result.push_back({{"op", "replace"}, {"path", path}, {"value", target}}); break; } } @@ -5059,8 +5014,10 @@ std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j) return j.dump(); } -inline namespace literals { -inline namespace json_literals { +inline namespace literals +{ +inline namespace json_literals +{ /// @brief user-defined string literal for JSON values /// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json/ @@ -5116,8 +5073,7 @@ struct less<::nlohmann::detail::value_t> // do not remove the space after '<', @brief compare two value_t enum values @since version 3.0.0 */ - bool operator()(::nlohmann::detail::value_t lhs, - ::nlohmann::detail::value_t rhs) const noexcept + bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept { #if JSON_HAS_THREE_WAY_COMPARISON return std::is_lt(lhs <=> rhs); // *NOPAD* @@ -5133,8 +5089,10 @@ struct less<::nlohmann::detail::value_t> // do not remove the space after '<', /// @brief exchanges the values of two JSON objects /// @sa https://json.nlohmann.me/api/basic_json/std_swap/ NLOHMANN_BASIC_JSON_TPL_DECLARATION -inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) - is_nothrow_move_constructible::value && // NOLINT(misc-redundant-expression,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) +inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, + nlohmann::NLOHMANN_BASIC_JSON_TPL& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) + is_nothrow_move_constructible< + nlohmann::NLOHMANN_BASIC_JSON_TPL>::value && // NOLINT(misc-redundant-expression,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) is_nothrow_move_assignable::value) { j1.swap(j2); diff --git a/include/nlohmann/json_fwd.hpp b/include/nlohmann/json_fwd.hpp index 4e57a9127c..66d7e8c359 100644 --- a/include/nlohmann/json_fwd.hpp +++ b/include/nlohmann/json_fwd.hpp @@ -36,8 +36,7 @@ struct adl_serializer; /// a class to store JSON values /// @sa https://json.nlohmann.me/api/basic_json/ -template class ObjectType = - std::map, +template class ObjectType = std::map, template class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, @@ -45,8 +44,7 @@ template class ObjectType = class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer, + template class JSONSerializer = adl_serializer, class BinaryType = std::vector, // cppcheck-suppress syntaxError class CustomBaseClass = void> class basic_json; diff --git a/include/nlohmann/ordered_map.hpp b/include/nlohmann/ordered_map.hpp index 0f73460cd9..3cc4e97812 100644 --- a/include/nlohmann/ordered_map.hpp +++ b/include/nlohmann/ordered_map.hpp @@ -337,8 +337,8 @@ struct ordered_map : std::vector, Allocator> } template - using require_input_iter = typename std::enable_if::iterator_category, - std::input_iterator_tag>::value>::type; + using require_input_iter = + typename std::enable_if::iterator_category, std::input_iterator_tag>::value>::type; template> void insert(InputIt first, InputIt last) diff --git a/include/nlohmann/thirdparty/hedley/hedley.hpp b/include/nlohmann/thirdparty/hedley/hedley.hpp index 3fa94ade71..17c866943d 100644 --- a/include/nlohmann/thirdparty/hedley/hedley.hpp +++ b/include/nlohmann/thirdparty/hedley/hedley.hpp @@ -91,7 +91,8 @@ #undef JSON_HEDLEY_MSVC_VERSION #endif #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) + #define JSON_HEDLEY_MSVC_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) #elif defined(_MSC_FULL_VER) && !defined(__ICL) #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) #elif defined(_MSC_VER) && !defined(__ICL) @@ -165,11 +166,17 @@ #undef JSON_HEDLEY_SUNPRO_VERSION #endif #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) + #define JSON_HEDLEY_SUNPRO_VERSION \ + JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), \ + (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), \ + (__SUNPRO_C & 0xf) * 10) #elif defined(__SUNPRO_C) #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) + #define JSON_HEDLEY_SUNPRO_VERSION \ + JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), \ + (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), \ + (__SUNPRO_CC & 0xf) * 10) #elif defined(__SUNPRO_CC) #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) #endif @@ -203,9 +210,11 @@ #undef JSON_HEDLEY_ARM_VERSION #endif #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) + #define JSON_HEDLEY_ARM_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) #elif defined(__CC_ARM) && defined(__ARMCC_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) + #define JSON_HEDLEY_ARM_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) #endif #if defined(JSON_HEDLEY_ARM_VERSION_CHECK) @@ -240,12 +249,10 @@ #if defined(JSON_HEDLEY_TI_VERSION) #undef JSON_HEDLEY_TI_VERSION #endif - #if defined(__TI_COMPILER_VERSION__) && \ - (defined(__TMS470__) || defined(__TI_ARM__) || \ - defined(__MSP430__) || \ - defined(__TMS320C2000__)) + #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__) || defined(__MSP430__) || defined(__TMS320C2000__)) #if (__TI_COMPILER_VERSION__ >= 16000000) - #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #endif @@ -262,7 +269,8 @@ #undef JSON_HEDLEY_TI_CL2000_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) - #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_CL2000_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) @@ -278,7 +286,8 @@ #undef JSON_HEDLEY_TI_CL430_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) - #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_CL430_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) @@ -294,7 +303,8 @@ #undef JSON_HEDLEY_TI_ARMCL_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) - #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_ARMCL_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) @@ -310,7 +320,8 @@ #undef JSON_HEDLEY_TI_CL6X_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) - #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_CL6X_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) @@ -326,7 +337,8 @@ #undef JSON_HEDLEY_TI_CL7X_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) - #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_CL7X_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) @@ -342,7 +354,8 @@ #undef JSON_HEDLEY_TI_CLPRU_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) - #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_CLPRU_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) @@ -430,7 +443,8 @@ #undef JSON_HEDLEY_COMPCERT_VERSION #endif #if defined(__COMPCERT_VERSION__) - #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) + #define JSON_HEDLEY_COMPCERT_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) #endif #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) @@ -477,20 +491,10 @@ #if defined(JSON_HEDLEY_GCC_VERSION) #undef JSON_HEDLEY_GCC_VERSION #endif - #if defined(JSON_HEDLEY_GNUC_VERSION) && \ - !defined(__clang__) && \ - !defined(JSON_HEDLEY_INTEL_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_ARM_VERSION) && \ - !defined(JSON_HEDLEY_CRAY_VERSION) && \ - !defined(JSON_HEDLEY_TI_VERSION) && \ - !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ - !defined(__COMPCERT__) && \ + #if defined(JSON_HEDLEY_GNUC_VERSION) && !defined(__clang__) && !defined(JSON_HEDLEY_INTEL_VERSION) && !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_ARM_VERSION) && !defined(JSON_HEDLEY_CRAY_VERSION) && !defined(JSON_HEDLEY_TI_VERSION) && \ + !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && !defined(JSON_HEDLEY_TI_CL430_VERSION) && !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL6X_VERSION) && !defined(JSON_HEDLEY_TI_CL7X_VERSION) && !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && !defined(__COMPCERT__) && \ !defined(JSON_HEDLEY_MCST_LCC_VERSION) #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION #endif @@ -507,8 +511,7 @@ #if defined(JSON_HEDLEY_HAS_ATTRIBUTE) #undef JSON_HEDLEY_HAS_ATTRIBUTE #endif - #if defined(__has_attribute) && \ - ((!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 5, 9))) + #if defined(__has_attribute) && ((!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 5, 9))) #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) #else #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) @@ -535,9 +538,7 @@ #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE #endif - #if defined(__has_cpp_attribute) && \ - defined(__cplusplus) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0)) + #if defined(__has_cpp_attribute) && defined(__cplusplus) && (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0)) #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) #else #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) @@ -548,9 +549,8 @@ #endif #if !defined(__cplusplus) || !defined(__has_cpp_attribute) #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns, attribute) (0) - #elif !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0)) && \ + #elif !defined(JSON_HEDLEY_PGI_VERSION) && !defined(JSON_HEDLEY_IAR_VERSION) && \ + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0)) && \ (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19, 20, 0)) #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns, attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) #else @@ -710,23 +710,12 @@ #define JSON_HEDLEY_GCC_HAS_WARNING(warning, major, minor, patch) JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch) #endif - #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - defined(__clang__) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 0, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(5, 0, 0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 17) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(8, 0, 0) || \ + #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || defined(__clang__) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || JSON_HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 0, 0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_CRAY_VERSION_CHECK(5, 0, 0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 17) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(8, 0, 0) || \ (JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) && defined(__C99_PRAGMA_OPERATOR)) #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) @@ -750,19 +739,14 @@ #elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 6, 0) #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) #elif JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") - #elif JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 4, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) + #elif JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 4, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2, 90, 0) @@ -782,27 +766,20 @@ #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") #if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") #if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") xpr JSON_HEDLEY_DIAGNOSTIC_POP #else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + xpr JSON_HEDLEY_DIAGNOSTIC_POP #endif #else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") xpr JSON_HEDLEY_DIAGNOSTIC_POP #endif #endif #endif @@ -815,14 +792,13 @@ #endif #if defined(__cplusplus) #define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) - #elif JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 6, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) - #define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL((T)(expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) + #elif JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || JSON_HEDLEY_GCC_VERSION_CHECK(4, 6, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) + #define JSON_HEDLEY_CONST_CAST(T, expr) \ + (__extension__({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL((T)(expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) #else #define JSON_HEDLEY_CONST_CAST(T, expr) ((T)(expr)) #endif @@ -850,15 +826,13 @@ #endif #if defined(__cplusplus) #if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") - #define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wold-style-cast\"")((T)(expr)) \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wold-style-cast\"")((T)(expr)) JSON_HEDLEY_DIAGNOSTIC_POP #elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 3, 0) - #define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("diag_suppress=Pe137") \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("diag_suppress=Pe137") JSON_HEDLEY_DIAGNOSTIC_POP #else #define JSON_HEDLEY_CPP_CAST(T, expr) ((T)(expr)) #endif @@ -885,17 +859,11 @@ #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable : 4996)) #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") - #elif JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) + #elif JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) && !defined(__cplusplus) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") @@ -924,9 +892,7 @@ #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable : 4068)) - #elif JSON_HEDLEY_TI_VERSION_CHECK(16, 9, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ + #elif JSON_HEDLEY_TI_VERSION_CHECK(16, 9, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 3, 0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) @@ -958,9 +924,7 @@ #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") - #elif JSON_HEDLEY_TI_VERSION_CHECK(18, 1, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) + #elif JSON_HEDLEY_TI_VERSION_CHECK(18, 1, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") #elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") @@ -1004,48 +968,30 @@ #if defined(JSON_HEDLEY_DEPRECATED_FOR) #undef JSON_HEDLEY_DEPRECATED_FOR #endif - #if JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #if JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " #since)) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) - #elif (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(18, 1, 0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18, 1, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 3, 0) || \ + #elif (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || JSON_HEDLEY_TI_VERSION_CHECK(18, 1, 0) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18, 1, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 3, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) #elif defined(__cplusplus) && (__cplusplus >= 201402L) #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) - #elif JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) + #elif JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \ - JSON_HEDLEY_PELLES_VERSION_CHECK(6, 50, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_PELLES_VERSION_CHECK(6, 50, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) #elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) @@ -1059,9 +1005,7 @@ #if defined(JSON_HEDLEY_UNAVAILABLE) #undef JSON_HEDLEY_UNAVAILABLE #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 3, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(warning) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 3, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) #else @@ -1074,22 +1018,13 @@ #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) @@ -1110,11 +1045,8 @@ #if defined(JSON_HEDLEY_SENTINEL) #undef JSON_HEDLEY_SENTINEL #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5, 4, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5, 4, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) #else #define JSON_HEDLEY_SENTINEL(position) @@ -1125,35 +1057,23 @@ #endif #if JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) #define JSON_HEDLEY_NO_RETURN __noreturn - #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #define JSON_HEDLEY_NO_RETURN _Noreturn #elif defined(__cplusplus) && (__cplusplus >= 201103L) #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) - #elif JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 2, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) + #elif JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 2, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 0, 0) && defined(__cplusplus) #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") @@ -1183,27 +1103,20 @@ #if defined(JSON_HEDLEY_ASSUME) #undef JSON_HEDLEY_ASSUME #endif - #if JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #if JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_ASSUME(expr) __assume(expr) #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) - #elif JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) + #elif JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) #if defined(__cplusplus) #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) #else #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) #endif #endif - #if (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18, 10, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 5) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(10, 0, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18, 10, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 5) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(10, 0, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() #elif defined(JSON_HEDLEY_ASSUME) #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) @@ -1216,8 +1129,7 @@ #endif #endif #if defined(JSON_HEDLEY_UNREACHABLE) - #if JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) + #if JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) #else #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() @@ -1246,9 +1158,7 @@ JSON_HEDLEY_DIAGNOSTIC_PUSH #if defined(JSON_HEDLEY_NON_NULL) #undef JSON_HEDLEY_NON_NULL #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) #else @@ -1263,23 +1173,13 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format, 4, 4, 0) && defined(__USE_MINGW_ANSI_STDIO) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) - #elif JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #elif JSON_HEDLEY_HAS_ATTRIBUTE(format) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6, 0, 0) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) __declspec(vaformat(printf, string_idx, first_to_check)) @@ -1314,41 +1214,30 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) #endif - #if (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(9, 0, 0) || \ + #if (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || JSON_HEDLEY_GCC_VERSION_CHECK(9, 0, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability((expr), (value), (probability)) #define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, (probability)) #define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, (probability)) #define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) #define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) - #elif (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 27) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) - #define JSON_HEDLEY_PREDICT(expr, expected, probability) \ + #elif (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 27) || JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #define JSON_HEDLEY_PREDICT(expr, expected, probability) \ (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) - #define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ - (__extension__({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ + #define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ + (__extension__({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ })) - #define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ - (__extension__({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ + #define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ + (__extension__({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ })) #define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) #define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) @@ -1366,29 +1255,18 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_MALLOC) #undef JSON_HEDLEY_MALLOC #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_MALLOC __declspec(restrict) #else #define JSON_HEDLEY_MALLOC @@ -1397,32 +1275,19 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_PURE) #undef JSON_HEDLEY_PURE #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2, 96, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_ATTRIBUTE(pure) || JSON_HEDLEY_GCC_VERSION_CHECK(2, 96, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_PURE __attribute__((__pure__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) #define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") - #elif defined(__cplusplus) && \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0)) + #elif defined(__cplusplus) && \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0)) #define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") #else #define JSON_HEDLEY_PURE @@ -1431,25 +1296,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_CONST) #undef JSON_HEDLEY_CONST #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2, 5, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_ATTRIBUTE(const) || JSON_HEDLEY_GCC_VERSION_CHECK(2, 5, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_CONST __attribute__((__const__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) #define JSON_HEDLEY_CONST _Pragma("no_side_effect") @@ -1462,20 +1316,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) #define JSON_HEDLEY_RESTRICT restrict - #elif JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 4) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus)) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || \ - defined(__clang__) || \ + #elif JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 4) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus)) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || defined(__clang__) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_RESTRICT __restrict #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 3, 0) && !defined(__cplusplus) @@ -1487,21 +1332,13 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_INLINE) #undef JSON_HEDLEY_INLINE #endif - #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - (defined(__cplusplus) && (__cplusplus >= 199711L)) + #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || (defined(__cplusplus) && (__cplusplus >= 199711L)) #define JSON_HEDLEY_INLINE inline - #elif defined(JSON_HEDLEY_GCC_VERSION) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(6, 2, 0) + #elif defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_ARM_VERSION_CHECK(6, 2, 0) #define JSON_HEDLEY_INLINE __inline__ - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 1, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 1, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_INLINE __inline #else @@ -1511,36 +1348,20 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_ALWAYS_INLINE) #undef JSON_HEDLEY_ALWAYS_INLINE #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) + #if JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) #define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_ALWAYS_INLINE __forceinline - #elif defined(__cplusplus) && \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)) + #elif defined(__cplusplus) && \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)) #define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") #elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) #define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") @@ -1551,28 +1372,16 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_NEVER_INLINE) #undef JSON_HEDLEY_NEVER_INLINE #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) + #if JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) #elif JSON_HEDLEY_PGI_VERSION_CHECK(10, 2, 0) #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") @@ -1602,15 +1411,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_HEDLEY_PUBLIC __declspec(dllexport) #define JSON_HEDLEY_IMPORT __declspec(dllimport) #else - #if JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ - (defined(__TI_EABI__) && \ - ((JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0))) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ + (defined(__TI_EABI__) && \ + ((JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0))) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) #define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) @@ -1624,14 +1428,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_NO_THROW) #undef JSON_HEDLEY_NO_THROW #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 1, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 1, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) #define JSON_HEDLEY_NO_THROW __declspec(nothrow) #else #define JSON_HEDLEY_NO_THROW @@ -1640,9 +1440,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_FALL_THROUGH) #undef JSON_HEDLEY_FALL_THROUGH #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(7, 0, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || JSON_HEDLEY_GCC_VERSION_CHECK(7, 0, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang, fallthrough) #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) @@ -1657,9 +1455,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_RETURNS_NON_NULL) #undef JSON_HEDLEY_RETURNS_NON_NULL #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 9, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 9, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) #elif defined(_Ret_notnull_) /* SAL */ #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ @@ -1670,11 +1466,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_ARRAY_PARAM) #undef JSON_HEDLEY_ARRAY_PARAM #endif - #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__STDC_NO_VLA__) && \ - !defined(__cplusplus) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_TINYC_VERSION) + #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__STDC_NO_VLA__) && !defined(__cplusplus) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && !defined(JSON_HEDLEY_TINYC_VERSION) #define JSON_HEDLEY_ARRAY_PARAM(name) (name) #else #define JSON_HEDLEY_ARRAY_PARAM(name) @@ -1691,25 +1484,15 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_IS_CONSTEXPR_) #undef JSON_HEDLEY_IS_CONSTEXPR_ #endif - #if JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 19) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) && !defined(__cplusplus)) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 19) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) && !defined(__cplusplus)) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) #endif #if !defined(__cplusplus) - #if JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5, 4, 0) || \ + #if JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(5, 4, 0) || \ JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 24) #if defined(__INTPTR_TYPE__) #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*)((__INTPTR_TYPE__)((expr) * 0)) : (int*)0)), int*) @@ -1717,36 +1500,20 @@ JSON_HEDLEY_DIAGNOSTIC_POP #include #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*)((intptr_t)((expr) * 0)) : (int*)0)), int*) #endif - #elif ( \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ - !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION)) || \ - (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 9, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(17, 0, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5, 3, 0) + #elif (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(JSON_HEDLEY_SUNPRO_VERSION) && !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_IAR_VERSION)) || \ + (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 9, 0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(17, 0, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(5, 3, 0) #if defined(__INTPTR_TYPE__) #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*)((__INTPTR_TYPE__)((expr) * 0)) : (int*)0), int*: 1, void*: 0) #else #include #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*)((intptr_t) * 0) : (int*)0), int*: 1, void*: 0) #endif - #elif defined(JSON_HEDLEY_GCC_VERSION) || \ - defined(JSON_HEDLEY_INTEL_VERSION) || \ - defined(JSON_HEDLEY_TINYC_VERSION) || \ - defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(18, 12, 0) || \ - defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ - defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ - defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ - defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ - defined(__clang__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ - sizeof(void) != \ - sizeof(*( \ - 1 ? ((void*)((expr) * 0L)) : ((struct { char v[sizeof(void) * 2]; }*)1)))) + #elif defined(JSON_HEDLEY_GCC_VERSION) || defined(JSON_HEDLEY_INTEL_VERSION) || defined(JSON_HEDLEY_TINYC_VERSION) || \ + defined(JSON_HEDLEY_TI_ARMCL_VERSION) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(18, 12, 0) || defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ + defined(JSON_HEDLEY_TI_CL6X_VERSION) || defined(JSON_HEDLEY_TI_CL7X_VERSION) || defined(JSON_HEDLEY_TI_CLPRU_VERSION) || defined(__clang__) + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) (sizeof(void) != sizeof(*(1 ? ((void*)((expr) * 0L)) : ((struct { char v[sizeof(void) * 2]; }*)1)))) #endif #endif #if defined(JSON_HEDLEY_IS_CONSTEXPR_) @@ -1783,15 +1550,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_STATIC_ASSERT) #undef JSON_HEDLEY_STATIC_ASSERT #endif - #if !defined(__cplusplus) && ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(6, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - defined(_Static_assert)) + #if !defined(__cplusplus) && ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ + (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(6, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || defined(_Static_assert)) #define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) - #elif (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(16, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif (defined(__cplusplus) && (__cplusplus >= 201103L)) || JSON_HEDLEY_MSVC_VERSION_CHECK(16, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) #else #define JSON_HEDLEY_STATIC_ASSERT(expr, message) @@ -1818,13 +1581,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP #undef JSON_HEDLEY_MESSAGE #endif #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define JSON_HEDLEY_MESSAGE(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(message msg) \ + #define JSON_HEDLEY_MESSAGE(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(message msg) \ JSON_HEDLEY_DIAGNOSTIC_POP - #elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 4, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) + #elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 4, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) #define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5, 0, 0) #define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) @@ -1840,17 +1602,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP #undef JSON_HEDLEY_WARNING #endif #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define JSON_HEDLEY_WARNING(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(clang warning msg) \ + #define JSON_HEDLEY_WARNING(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(clang warning msg) \ JSON_HEDLEY_DIAGNOSTIC_POP - #elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 8, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) + #elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 8, 0) || JSON_HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) #define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) #else #define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) @@ -1864,16 +1623,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) #if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") - #define JSON_HEDLEY_REQUIRE(expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), #expr, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP - #define JSON_HEDLEY_REQUIRE_MSG(expr, msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), msg, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_REQUIRE(expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") __attribute__((diagnose_if(!(expr), #expr, "error"))) JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_REQUIRE_MSG(expr, msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") __attribute__((diagnose_if(!(expr), msg, "error"))) JSON_HEDLEY_DIAGNOSTIC_POP #else #define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) #define JSON_HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((diagnose_if(!(expr), msg, "error"))) @@ -1896,11 +1651,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP #undef JSON_HEDLEY_FLAGS_CAST #endif #if JSON_HEDLEY_INTEL_VERSION_CHECK(19, 0, 0) - #define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("warning(disable:188)")((T)(expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) + #define JSON_HEDLEY_FLAGS_CAST(T, expr) \ + (__extension__({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("warning(disable:188)")((T)(expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) #else #define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) #endif @@ -1908,8 +1664,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_EMPTY_BASES) #undef JSON_HEDLEY_EMPTY_BASES #endif - #if (JSON_HEDLEY_MSVC_VERSION_CHECK(19, 0, 23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20, 0, 0)) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #if (JSON_HEDLEY_MSVC_VERSION_CHECK(19, 0, 23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20, 0, 0)) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) #else #define JSON_HEDLEY_EMPTY_BASES diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ed8a2321bc..5ff5df8e25 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -91,52 +91,40 @@ // Construct the namespace ABI tags component #define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi##a##b -#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ - NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) +#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) -#define NLOHMANN_JSON_ABI_TAGS \ - NLOHMANN_JSON_ABI_TAGS_CONCAT( \ - NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ - NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) +#define NLOHMANN_JSON_ABI_TAGS NLOHMANN_JSON_ABI_TAGS_CONCAT(NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) // Construct the namespace version component -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ - _v##major##_##minor##_##patch -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) _v##major##_##minor##_##patch +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) #if NLOHMANN_JSON_NAMESPACE_NO_VERSION #define NLOHMANN_JSON_NAMESPACE_VERSION #else - #define NLOHMANN_JSON_NAMESPACE_VERSION \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ - NLOHMANN_JSON_VERSION_MINOR, \ - NLOHMANN_JSON_VERSION_PATCH) + #define NLOHMANN_JSON_NAMESPACE_VERSION \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH) #endif // Combine namespace components #define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a##b -#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ - NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) +#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) #ifndef NLOHMANN_JSON_NAMESPACE - #define NLOHMANN_JSON_NAMESPACE \ - nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) + #define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT(NLOHMANN_JSON_ABI_TAGS, NLOHMANN_JSON_NAMESPACE_VERSION) #endif #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN - #define NLOHMANN_JSON_NAMESPACE_BEGIN \ - namespace nlohmann { \ - inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) { + #define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { \ + inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT(NLOHMANN_JSON_ABI_TAGS, NLOHMANN_JSON_NAMESPACE_VERSION) \ + { #endif #ifndef NLOHMANN_JSON_NAMESPACE_END - #define NLOHMANN_JSON_NAMESPACE_END \ - } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ + #define NLOHMANN_JSON_NAMESPACE_END \ + } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ } // namespace nlohmann #endif @@ -193,7 +181,8 @@ // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /// struct to capture the start position of the current token struct position_t @@ -247,7 +236,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template struct make_void @@ -261,7 +251,8 @@ using void_t = typename make_void::type; NLOHMANN_JSON_NAMESPACE_END NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ // https://en.cppreference.com/w/cpp/experimental/is_detected struct nonesuch @@ -274,11 +265,7 @@ struct nonesuch void operator=(nonesuch&&) = delete; }; -template - class Op, - class... Args> +template class Op, class... Args> struct detector { using value_t = std::false_type; @@ -312,8 +299,7 @@ template class Op, class... Args> using is_detected_exact = std::is_same>; template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; +using is_detected_convertible = std::is_convertible, To>; } // namespace detail NLOHMANN_JSON_NAMESPACE_END @@ -411,7 +397,8 @@ NLOHMANN_JSON_NAMESPACE_END #undef JSON_HEDLEY_MSVC_VERSION #endif #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) + #define JSON_HEDLEY_MSVC_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) #elif defined(_MSC_FULL_VER) && !defined(__ICL) #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) #elif defined(_MSC_VER) && !defined(__ICL) @@ -485,11 +472,17 @@ NLOHMANN_JSON_NAMESPACE_END #undef JSON_HEDLEY_SUNPRO_VERSION #endif #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) + #define JSON_HEDLEY_SUNPRO_VERSION \ + JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), \ + (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), \ + (__SUNPRO_C & 0xf) * 10) #elif defined(__SUNPRO_C) #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) + #define JSON_HEDLEY_SUNPRO_VERSION \ + JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), \ + (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), \ + (__SUNPRO_CC & 0xf) * 10) #elif defined(__SUNPRO_CC) #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) #endif @@ -523,9 +516,11 @@ NLOHMANN_JSON_NAMESPACE_END #undef JSON_HEDLEY_ARM_VERSION #endif #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) + #define JSON_HEDLEY_ARM_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) #elif defined(__CC_ARM) && defined(__ARMCC_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) + #define JSON_HEDLEY_ARM_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) #endif #if defined(JSON_HEDLEY_ARM_VERSION_CHECK) @@ -560,12 +555,10 @@ NLOHMANN_JSON_NAMESPACE_END #if defined(JSON_HEDLEY_TI_VERSION) #undef JSON_HEDLEY_TI_VERSION #endif - #if defined(__TI_COMPILER_VERSION__) && \ - (defined(__TMS470__) || defined(__TI_ARM__) || \ - defined(__MSP430__) || \ - defined(__TMS320C2000__)) + #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__) || defined(__MSP430__) || defined(__TMS320C2000__)) #if (__TI_COMPILER_VERSION__ >= 16000000) - #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #endif @@ -582,7 +575,8 @@ NLOHMANN_JSON_NAMESPACE_END #undef JSON_HEDLEY_TI_CL2000_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) - #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_CL2000_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) @@ -598,7 +592,8 @@ NLOHMANN_JSON_NAMESPACE_END #undef JSON_HEDLEY_TI_CL430_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) - #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_CL430_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) @@ -614,7 +609,8 @@ NLOHMANN_JSON_NAMESPACE_END #undef JSON_HEDLEY_TI_ARMCL_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) - #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_ARMCL_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) @@ -630,7 +626,8 @@ NLOHMANN_JSON_NAMESPACE_END #undef JSON_HEDLEY_TI_CL6X_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) - #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_CL6X_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) @@ -646,7 +643,8 @@ NLOHMANN_JSON_NAMESPACE_END #undef JSON_HEDLEY_TI_CL7X_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) - #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_CL7X_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) @@ -662,7 +660,8 @@ NLOHMANN_JSON_NAMESPACE_END #undef JSON_HEDLEY_TI_CLPRU_VERSION #endif #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) - #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_CLPRU_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) @@ -750,7 +749,8 @@ NLOHMANN_JSON_NAMESPACE_END #undef JSON_HEDLEY_COMPCERT_VERSION #endif #if defined(__COMPCERT_VERSION__) - #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) + #define JSON_HEDLEY_COMPCERT_VERSION \ + JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) #endif #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) @@ -797,20 +797,10 @@ NLOHMANN_JSON_NAMESPACE_END #if defined(JSON_HEDLEY_GCC_VERSION) #undef JSON_HEDLEY_GCC_VERSION #endif - #if defined(JSON_HEDLEY_GNUC_VERSION) && \ - !defined(__clang__) && \ - !defined(JSON_HEDLEY_INTEL_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_ARM_VERSION) && \ - !defined(JSON_HEDLEY_CRAY_VERSION) && \ - !defined(JSON_HEDLEY_TI_VERSION) && \ - !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ - !defined(__COMPCERT__) && \ + #if defined(JSON_HEDLEY_GNUC_VERSION) && !defined(__clang__) && !defined(JSON_HEDLEY_INTEL_VERSION) && !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_ARM_VERSION) && !defined(JSON_HEDLEY_CRAY_VERSION) && !defined(JSON_HEDLEY_TI_VERSION) && \ + !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && !defined(JSON_HEDLEY_TI_CL430_VERSION) && !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL6X_VERSION) && !defined(JSON_HEDLEY_TI_CL7X_VERSION) && !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && !defined(__COMPCERT__) && \ !defined(JSON_HEDLEY_MCST_LCC_VERSION) #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION #endif @@ -827,8 +817,7 @@ NLOHMANN_JSON_NAMESPACE_END #if defined(JSON_HEDLEY_HAS_ATTRIBUTE) #undef JSON_HEDLEY_HAS_ATTRIBUTE #endif - #if defined(__has_attribute) && \ - ((!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 5, 9))) + #if defined(__has_attribute) && ((!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 5, 9))) #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) #else #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) @@ -855,9 +844,7 @@ NLOHMANN_JSON_NAMESPACE_END #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE #endif - #if defined(__has_cpp_attribute) && \ - defined(__cplusplus) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0)) + #if defined(__has_cpp_attribute) && defined(__cplusplus) && (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0)) #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) #else #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) @@ -868,9 +855,8 @@ NLOHMANN_JSON_NAMESPACE_END #endif #if !defined(__cplusplus) || !defined(__has_cpp_attribute) #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns, attribute) (0) - #elif !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0)) && \ + #elif !defined(JSON_HEDLEY_PGI_VERSION) && !defined(JSON_HEDLEY_IAR_VERSION) && \ + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0)) && \ (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19, 20, 0)) #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns, attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) #else @@ -1030,23 +1016,12 @@ NLOHMANN_JSON_NAMESPACE_END #define JSON_HEDLEY_GCC_HAS_WARNING(warning, major, minor, patch) JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch) #endif - #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - defined(__clang__) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 0, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(5, 0, 0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 17) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(8, 0, 0) || \ + #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || defined(__clang__) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || JSON_HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 0, 0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_CRAY_VERSION_CHECK(5, 0, 0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 17) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(8, 0, 0) || \ (JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) && defined(__C99_PRAGMA_OPERATOR)) #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) @@ -1070,19 +1045,14 @@ NLOHMANN_JSON_NAMESPACE_END #elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 6, 0) #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) #elif JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") - #elif JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 4, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) + #elif JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 4, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2, 90, 0) @@ -1102,27 +1072,20 @@ NLOHMANN_JSON_NAMESPACE_END #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") #if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") #if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") xpr JSON_HEDLEY_DIAGNOSTIC_POP #else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + xpr JSON_HEDLEY_DIAGNOSTIC_POP #endif #else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") xpr JSON_HEDLEY_DIAGNOSTIC_POP #endif #endif #endif @@ -1135,14 +1098,13 @@ NLOHMANN_JSON_NAMESPACE_END #endif #if defined(__cplusplus) #define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) - #elif JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 6, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) - #define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL((T)(expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) + #elif JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || JSON_HEDLEY_GCC_VERSION_CHECK(4, 6, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) + #define JSON_HEDLEY_CONST_CAST(T, expr) \ + (__extension__({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL((T)(expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) #else #define JSON_HEDLEY_CONST_CAST(T, expr) ((T)(expr)) #endif @@ -1170,15 +1132,13 @@ NLOHMANN_JSON_NAMESPACE_END #endif #if defined(__cplusplus) #if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") - #define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wold-style-cast\"")((T)(expr)) \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wold-style-cast\"")((T)(expr)) JSON_HEDLEY_DIAGNOSTIC_POP #elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 3, 0) - #define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("diag_suppress=Pe137") \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("diag_suppress=Pe137") JSON_HEDLEY_DIAGNOSTIC_POP #else #define JSON_HEDLEY_CPP_CAST(T, expr) ((T)(expr)) #endif @@ -1205,17 +1165,11 @@ NLOHMANN_JSON_NAMESPACE_END #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable : 4996)) #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") - #elif JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) + #elif JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) && !defined(__cplusplus) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") @@ -1244,9 +1198,7 @@ NLOHMANN_JSON_NAMESPACE_END #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable : 4068)) - #elif JSON_HEDLEY_TI_VERSION_CHECK(16, 9, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ + #elif JSON_HEDLEY_TI_VERSION_CHECK(16, 9, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 3, 0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) @@ -1278,9 +1230,7 @@ NLOHMANN_JSON_NAMESPACE_END #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") - #elif JSON_HEDLEY_TI_VERSION_CHECK(18, 1, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) + #elif JSON_HEDLEY_TI_VERSION_CHECK(18, 1, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") #elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") @@ -1324,48 +1274,30 @@ NLOHMANN_JSON_NAMESPACE_END #if defined(JSON_HEDLEY_DEPRECATED_FOR) #undef JSON_HEDLEY_DEPRECATED_FOR #endif - #if JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #if JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " #since)) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) - #elif (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(18, 1, 0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18, 1, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 3, 0) || \ + #elif (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || JSON_HEDLEY_TI_VERSION_CHECK(18, 1, 0) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18, 1, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 3, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) #elif defined(__cplusplus) && (__cplusplus >= 201402L) #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) - #elif JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) + #elif JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \ - JSON_HEDLEY_PELLES_VERSION_CHECK(6, 50, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_PELLES_VERSION_CHECK(6, 50, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) #elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) @@ -1379,9 +1311,7 @@ NLOHMANN_JSON_NAMESPACE_END #if defined(JSON_HEDLEY_UNAVAILABLE) #undef JSON_HEDLEY_UNAVAILABLE #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 3, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(warning) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 3, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) #else @@ -1394,22 +1324,13 @@ NLOHMANN_JSON_NAMESPACE_END #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) @@ -1430,11 +1351,8 @@ NLOHMANN_JSON_NAMESPACE_END #if defined(JSON_HEDLEY_SENTINEL) #undef JSON_HEDLEY_SENTINEL #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5, 4, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5, 4, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) #else #define JSON_HEDLEY_SENTINEL(position) @@ -1445,35 +1363,23 @@ NLOHMANN_JSON_NAMESPACE_END #endif #if JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) #define JSON_HEDLEY_NO_RETURN __noreturn - #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #define JSON_HEDLEY_NO_RETURN _Noreturn #elif defined(__cplusplus) && (__cplusplus >= 201103L) #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) - #elif JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 2, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) + #elif JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 2, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 0, 0) && defined(__cplusplus) #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") @@ -1503,27 +1409,20 @@ NLOHMANN_JSON_NAMESPACE_END #if defined(JSON_HEDLEY_ASSUME) #undef JSON_HEDLEY_ASSUME #endif - #if JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #if JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_ASSUME(expr) __assume(expr) #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) - #elif JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) + #elif JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) #if defined(__cplusplus) #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) #else #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) #endif #endif - #if (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18, 10, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 5) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(10, 0, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18, 10, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 5) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(10, 0, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() #elif defined(JSON_HEDLEY_ASSUME) #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) @@ -1536,8 +1435,7 @@ NLOHMANN_JSON_NAMESPACE_END #endif #endif #if defined(JSON_HEDLEY_UNREACHABLE) - #if JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) + #if JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) #else #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() @@ -1566,9 +1464,7 @@ JSON_HEDLEY_DIAGNOSTIC_PUSH #if defined(JSON_HEDLEY_NON_NULL) #undef JSON_HEDLEY_NON_NULL #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) #else @@ -1583,23 +1479,13 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format, 4, 4, 0) && defined(__USE_MINGW_ANSI_STDIO) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) - #elif JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #elif JSON_HEDLEY_HAS_ATTRIBUTE(format) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6, 0, 0) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) __declspec(vaformat(printf, string_idx, first_to_check)) @@ -1634,41 +1520,30 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) #endif - #if (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(9, 0, 0) || \ + #if (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || JSON_HEDLEY_GCC_VERSION_CHECK(9, 0, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability((expr), (value), (probability)) #define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, (probability)) #define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, (probability)) #define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) #define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) - #elif (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 27) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) - #define JSON_HEDLEY_PREDICT(expr, expected, probability) \ + #elif (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 27) || JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #define JSON_HEDLEY_PREDICT(expr, expected, probability) \ (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) - #define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ - (__extension__({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ + #define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ + (__extension__({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ })) - #define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ - (__extension__({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ + #define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ + (__extension__({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ })) #define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) #define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) @@ -1686,29 +1561,18 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_MALLOC) #undef JSON_HEDLEY_MALLOC #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_MALLOC __declspec(restrict) #else #define JSON_HEDLEY_MALLOC @@ -1717,32 +1581,19 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_PURE) #undef JSON_HEDLEY_PURE #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2, 96, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_ATTRIBUTE(pure) || JSON_HEDLEY_GCC_VERSION_CHECK(2, 96, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_PURE __attribute__((__pure__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) #define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") - #elif defined(__cplusplus) && \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0)) + #elif defined(__cplusplus) && \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0)) #define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") #else #define JSON_HEDLEY_PURE @@ -1751,25 +1602,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_CONST) #undef JSON_HEDLEY_CONST #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2, 5, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_ATTRIBUTE(const) || JSON_HEDLEY_GCC_VERSION_CHECK(2, 5, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_CONST __attribute__((__const__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) #define JSON_HEDLEY_CONST _Pragma("no_side_effect") @@ -1782,20 +1622,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) #define JSON_HEDLEY_RESTRICT restrict - #elif JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 4) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus)) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || \ - defined(__clang__) || \ + #elif JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 4) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus)) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || defined(__clang__) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_RESTRICT __restrict #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 3, 0) && !defined(__cplusplus) @@ -1807,21 +1638,13 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_INLINE) #undef JSON_HEDLEY_INLINE #endif - #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - (defined(__cplusplus) && (__cplusplus >= 199711L)) + #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || (defined(__cplusplus) && (__cplusplus >= 199711L)) #define JSON_HEDLEY_INLINE inline - #elif defined(JSON_HEDLEY_GCC_VERSION) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(6, 2, 0) + #elif defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_ARM_VERSION_CHECK(6, 2, 0) #define JSON_HEDLEY_INLINE __inline__ - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 1, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 1, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_INLINE __inline #else @@ -1831,36 +1654,20 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_ALWAYS_INLINE) #undef JSON_HEDLEY_ALWAYS_INLINE #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) + #if JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) #define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_ALWAYS_INLINE __forceinline - #elif defined(__cplusplus) && \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)) + #elif defined(__cplusplus) && \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)) #define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") #elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) #define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") @@ -1871,28 +1678,16 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_NEVER_INLINE) #undef JSON_HEDLEY_NEVER_INLINE #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) + #if JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0) #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) #elif JSON_HEDLEY_PGI_VERSION_CHECK(10, 2, 0) #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") @@ -1922,15 +1717,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_HEDLEY_PUBLIC __declspec(dllexport) #define JSON_HEDLEY_IMPORT __declspec(dllimport) #else - #if JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ - (defined(__TI_EABI__) && \ - ((JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0))) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ + (defined(__TI_EABI__) && \ + ((JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0))) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) #define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) @@ -1944,14 +1734,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_NO_THROW) #undef JSON_HEDLEY_NO_THROW #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + #if JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 1, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 1, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) #define JSON_HEDLEY_NO_THROW __declspec(nothrow) #else #define JSON_HEDLEY_NO_THROW @@ -1960,9 +1746,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_FALL_THROUGH) #undef JSON_HEDLEY_FALL_THROUGH #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(7, 0, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || JSON_HEDLEY_GCC_VERSION_CHECK(7, 0, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang, fallthrough) #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) @@ -1977,9 +1761,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_RETURNS_NON_NULL) #undef JSON_HEDLEY_RETURNS_NON_NULL #endif - #if JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 9, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 9, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) #elif defined(_Ret_notnull_) /* SAL */ #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ @@ -1990,11 +1772,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_ARRAY_PARAM) #undef JSON_HEDLEY_ARRAY_PARAM #endif - #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__STDC_NO_VLA__) && \ - !defined(__cplusplus) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_TINYC_VERSION) + #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__STDC_NO_VLA__) && !defined(__cplusplus) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && !defined(JSON_HEDLEY_TINYC_VERSION) #define JSON_HEDLEY_ARRAY_PARAM(name) (name) #else #define JSON_HEDLEY_ARRAY_PARAM(name) @@ -2011,25 +1790,15 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_IS_CONSTEXPR_) #undef JSON_HEDLEY_IS_CONSTEXPR_ #endif - #if JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 19) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) && !defined(__cplusplus)) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) + #if JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 19) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) && !defined(__cplusplus)) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) #endif #if !defined(__cplusplus) - #if JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5, 4, 0) || \ + #if JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(5, 4, 0) || \ JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 24) #if defined(__INTPTR_TYPE__) #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*)((__INTPTR_TYPE__)((expr) * 0)) : (int*)0)), int*) @@ -2037,36 +1806,20 @@ JSON_HEDLEY_DIAGNOSTIC_POP #include #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*)((intptr_t)((expr) * 0)) : (int*)0)), int*) #endif - #elif ( \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ - !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION)) || \ - (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4, 9, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(17, 0, 0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5, 3, 0) + #elif (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(JSON_HEDLEY_SUNPRO_VERSION) && !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_IAR_VERSION)) || \ + (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 9, 0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(17, 0, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(5, 3, 0) #if defined(__INTPTR_TYPE__) #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*)((__INTPTR_TYPE__)((expr) * 0)) : (int*)0), int*: 1, void*: 0) #else #include #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*)((intptr_t) * 0) : (int*)0), int*: 1, void*: 0) #endif - #elif defined(JSON_HEDLEY_GCC_VERSION) || \ - defined(JSON_HEDLEY_INTEL_VERSION) || \ - defined(JSON_HEDLEY_TINYC_VERSION) || \ - defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(18, 12, 0) || \ - defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ - defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ - defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ - defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ - defined(__clang__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ - sizeof(void) != \ - sizeof(*( \ - 1 ? ((void*)((expr) * 0L)) : ((struct { char v[sizeof(void) * 2]; }*)1)))) + #elif defined(JSON_HEDLEY_GCC_VERSION) || defined(JSON_HEDLEY_INTEL_VERSION) || defined(JSON_HEDLEY_TINYC_VERSION) || \ + defined(JSON_HEDLEY_TI_ARMCL_VERSION) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(18, 12, 0) || defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ + defined(JSON_HEDLEY_TI_CL6X_VERSION) || defined(JSON_HEDLEY_TI_CL7X_VERSION) || defined(JSON_HEDLEY_TI_CLPRU_VERSION) || defined(__clang__) + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) (sizeof(void) != sizeof(*(1 ? ((void*)((expr) * 0L)) : ((struct { char v[sizeof(void) * 2]; }*)1)))) #endif #endif #if defined(JSON_HEDLEY_IS_CONSTEXPR_) @@ -2103,15 +1856,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_STATIC_ASSERT) #undef JSON_HEDLEY_STATIC_ASSERT #endif - #if !defined(__cplusplus) && ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(6, 0, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - defined(_Static_assert)) + #if !defined(__cplusplus) && ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ + (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(6, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || defined(_Static_assert)) #define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) - #elif (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(16, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif (defined(__cplusplus) && (__cplusplus >= 201103L)) || JSON_HEDLEY_MSVC_VERSION_CHECK(16, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) #else #define JSON_HEDLEY_STATIC_ASSERT(expr, message) @@ -2138,13 +1887,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP #undef JSON_HEDLEY_MESSAGE #endif #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define JSON_HEDLEY_MESSAGE(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(message msg) \ + #define JSON_HEDLEY_MESSAGE(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(message msg) \ JSON_HEDLEY_DIAGNOSTIC_POP - #elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 4, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) + #elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 4, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) #define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5, 0, 0) #define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) @@ -2160,17 +1908,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP #undef JSON_HEDLEY_WARNING #endif #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define JSON_HEDLEY_WARNING(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(clang warning msg) \ + #define JSON_HEDLEY_WARNING(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(clang warning msg) \ JSON_HEDLEY_DIAGNOSTIC_POP - #elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 8, 0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) + #elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 8, 0) || JSON_HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) #define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) - #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) #else #define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) @@ -2184,16 +1929,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) #if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") - #define JSON_HEDLEY_REQUIRE(expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), #expr, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP - #define JSON_HEDLEY_REQUIRE_MSG(expr, msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), msg, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_REQUIRE(expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") __attribute__((diagnose_if(!(expr), #expr, "error"))) JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_REQUIRE_MSG(expr, msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") __attribute__((diagnose_if(!(expr), msg, "error"))) JSON_HEDLEY_DIAGNOSTIC_POP #else #define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) #define JSON_HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((diagnose_if(!(expr), msg, "error"))) @@ -2216,11 +1957,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP #undef JSON_HEDLEY_FLAGS_CAST #endif #if JSON_HEDLEY_INTEL_VERSION_CHECK(19, 0, 0) - #define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("warning(disable:188)")((T)(expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) + #define JSON_HEDLEY_FLAGS_CAST(T, expr) \ + (__extension__({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("warning(disable:188)")((T)(expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) #else #define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) #endif @@ -2228,8 +1970,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_EMPTY_BASES) #undef JSON_HEDLEY_EMPTY_BASES #endif - #if (JSON_HEDLEY_MSVC_VERSION_CHECK(19, 0, 23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20, 0, 0)) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) + #if (JSON_HEDLEY_MSVC_VERSION_CHECK(19, 0, 23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20, 0, 0)) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) #else #define JSON_HEDLEY_EMPTY_BASES @@ -2387,7 +2128,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif #ifndef JSON_HAS_THREE_WAY_COMPARISON - #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L + #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L && defined(__cpp_lib_three_way_comparison) && \ + __cpp_lib_three_way_comparison >= 201907L #define JSON_HAS_THREE_WAY_COMPARISON 1 #else #define JSON_HAS_THREE_WAY_COMPARISON 0 @@ -2484,119 +2226,196 @@ JSON_HEDLEY_DIAGNOSTIC_POP @def NLOHMANN_JSON_SERIALIZE_ENUM @since version 3.4.0 */ -#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ - template \ - inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), [e](const std::pair& ej_pair) -> bool { \ - return ej_pair.first == e; \ - }); \ - j = ((it != std::end(m)) ? it : std::begin(m))->second; \ - } \ - template \ - inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), [&j](const std::pair& ej_pair) -> bool { \ - return ej_pair.second == j; \ - }); \ - e = ((it != std::end(m)) ? it : std::begin(m))->first; \ +#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ + template \ + inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), [e](const std::pair& ej_pair) -> bool { \ + return ej_pair.first == e; \ + }); \ + j = ((it != std::end(m)) ? it : std::begin(m))->second; \ + } \ + template \ + inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), [&j](const std::pair& ej_pair) -> bool { \ + return ej_pair.second == j; \ + }); \ + e = ((it != std::end(m)) ? it : std::begin(m))->first; \ } // Ugly macros to avoid uglier copy-paste when specializing basic_json. They // may be removed in the future once the class is split. -#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ - template class ObjectType, \ - template \ - class ArrayType, \ - class StringType, \ - class BooleanType, \ - class NumberIntegerType, \ - class NumberUnsignedType, \ - class NumberFloatType, \ - template \ - class AllocatorType, \ - template \ - class JSONSerializer, \ - class BinaryType, \ +#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ + template class ObjectType, \ + template \ + class ArrayType, \ + class StringType, \ + class BooleanType, \ + class NumberIntegerType, \ + class NumberUnsignedType, \ + class NumberFloatType, \ + template \ + class AllocatorType, \ + template \ + class JSONSerializer, \ + class BinaryType, \ class CustomBaseClass> -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json +#define NLOHMANN_BASIC_JSON_TPL \ + basic_json // Macros to simplify conversion from/to types #define NLOHMANN_JSON_EXPAND(x) x -#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME, ...) NAME -#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ - NLOHMANN_JSON_PASTE64, \ - NLOHMANN_JSON_PASTE63, \ - NLOHMANN_JSON_PASTE62, \ - NLOHMANN_JSON_PASTE61, \ - NLOHMANN_JSON_PASTE60, \ - NLOHMANN_JSON_PASTE59, \ - NLOHMANN_JSON_PASTE58, \ - NLOHMANN_JSON_PASTE57, \ - NLOHMANN_JSON_PASTE56, \ - NLOHMANN_JSON_PASTE55, \ - NLOHMANN_JSON_PASTE54, \ - NLOHMANN_JSON_PASTE53, \ - NLOHMANN_JSON_PASTE52, \ - NLOHMANN_JSON_PASTE51, \ - NLOHMANN_JSON_PASTE50, \ - NLOHMANN_JSON_PASTE49, \ - NLOHMANN_JSON_PASTE48, \ - NLOHMANN_JSON_PASTE47, \ - NLOHMANN_JSON_PASTE46, \ - NLOHMANN_JSON_PASTE45, \ - NLOHMANN_JSON_PASTE44, \ - NLOHMANN_JSON_PASTE43, \ - NLOHMANN_JSON_PASTE42, \ - NLOHMANN_JSON_PASTE41, \ - NLOHMANN_JSON_PASTE40, \ - NLOHMANN_JSON_PASTE39, \ - NLOHMANN_JSON_PASTE38, \ - NLOHMANN_JSON_PASTE37, \ - NLOHMANN_JSON_PASTE36, \ - NLOHMANN_JSON_PASTE35, \ - NLOHMANN_JSON_PASTE34, \ - NLOHMANN_JSON_PASTE33, \ - NLOHMANN_JSON_PASTE32, \ - NLOHMANN_JSON_PASTE31, \ - NLOHMANN_JSON_PASTE30, \ - NLOHMANN_JSON_PASTE29, \ - NLOHMANN_JSON_PASTE28, \ - NLOHMANN_JSON_PASTE27, \ - NLOHMANN_JSON_PASTE26, \ - NLOHMANN_JSON_PASTE25, \ - NLOHMANN_JSON_PASTE24, \ - NLOHMANN_JSON_PASTE23, \ - NLOHMANN_JSON_PASTE22, \ - NLOHMANN_JSON_PASTE21, \ - NLOHMANN_JSON_PASTE20, \ - NLOHMANN_JSON_PASTE19, \ - NLOHMANN_JSON_PASTE18, \ - NLOHMANN_JSON_PASTE17, \ - NLOHMANN_JSON_PASTE16, \ - NLOHMANN_JSON_PASTE15, \ - NLOHMANN_JSON_PASTE14, \ - NLOHMANN_JSON_PASTE13, \ - NLOHMANN_JSON_PASTE12, \ - NLOHMANN_JSON_PASTE11, \ - NLOHMANN_JSON_PASTE10, \ - NLOHMANN_JSON_PASTE9, \ - NLOHMANN_JSON_PASTE8, \ - NLOHMANN_JSON_PASTE7, \ - NLOHMANN_JSON_PASTE6, \ - NLOHMANN_JSON_PASTE5, \ - NLOHMANN_JSON_PASTE4, \ - NLOHMANN_JSON_PASTE3, \ - NLOHMANN_JSON_PASTE2, \ - NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) +#define NLOHMANN_JSON_GET_MACRO(_1, \ + _2, \ + _3, \ + _4, \ + _5, \ + _6, \ + _7, \ + _8, \ + _9, \ + _10, \ + _11, \ + _12, \ + _13, \ + _14, \ + _15, \ + _16, \ + _17, \ + _18, \ + _19, \ + _20, \ + _21, \ + _22, \ + _23, \ + _24, \ + _25, \ + _26, \ + _27, \ + _28, \ + _29, \ + _30, \ + _31, \ + _32, \ + _33, \ + _34, \ + _35, \ + _36, \ + _37, \ + _38, \ + _39, \ + _40, \ + _41, \ + _42, \ + _43, \ + _44, \ + _45, \ + _46, \ + _47, \ + _48, \ + _49, \ + _50, \ + _51, \ + _52, \ + _53, \ + _54, \ + _55, \ + _56, \ + _57, \ + _58, \ + _59, \ + _60, \ + _61, \ + _62, \ + _63, \ + _64, \ + NAME, \ + ...) \ + NAME +#define NLOHMANN_JSON_PASTE(...) \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ + NLOHMANN_JSON_PASTE64, \ + NLOHMANN_JSON_PASTE63, \ + NLOHMANN_JSON_PASTE62, \ + NLOHMANN_JSON_PASTE61, \ + NLOHMANN_JSON_PASTE60, \ + NLOHMANN_JSON_PASTE59, \ + NLOHMANN_JSON_PASTE58, \ + NLOHMANN_JSON_PASTE57, \ + NLOHMANN_JSON_PASTE56, \ + NLOHMANN_JSON_PASTE55, \ + NLOHMANN_JSON_PASTE54, \ + NLOHMANN_JSON_PASTE53, \ + NLOHMANN_JSON_PASTE52, \ + NLOHMANN_JSON_PASTE51, \ + NLOHMANN_JSON_PASTE50, \ + NLOHMANN_JSON_PASTE49, \ + NLOHMANN_JSON_PASTE48, \ + NLOHMANN_JSON_PASTE47, \ + NLOHMANN_JSON_PASTE46, \ + NLOHMANN_JSON_PASTE45, \ + NLOHMANN_JSON_PASTE44, \ + NLOHMANN_JSON_PASTE43, \ + NLOHMANN_JSON_PASTE42, \ + NLOHMANN_JSON_PASTE41, \ + NLOHMANN_JSON_PASTE40, \ + NLOHMANN_JSON_PASTE39, \ + NLOHMANN_JSON_PASTE38, \ + NLOHMANN_JSON_PASTE37, \ + NLOHMANN_JSON_PASTE36, \ + NLOHMANN_JSON_PASTE35, \ + NLOHMANN_JSON_PASTE34, \ + NLOHMANN_JSON_PASTE33, \ + NLOHMANN_JSON_PASTE32, \ + NLOHMANN_JSON_PASTE31, \ + NLOHMANN_JSON_PASTE30, \ + NLOHMANN_JSON_PASTE29, \ + NLOHMANN_JSON_PASTE28, \ + NLOHMANN_JSON_PASTE27, \ + NLOHMANN_JSON_PASTE26, \ + NLOHMANN_JSON_PASTE25, \ + NLOHMANN_JSON_PASTE24, \ + NLOHMANN_JSON_PASTE23, \ + NLOHMANN_JSON_PASTE22, \ + NLOHMANN_JSON_PASTE21, \ + NLOHMANN_JSON_PASTE20, \ + NLOHMANN_JSON_PASTE19, \ + NLOHMANN_JSON_PASTE18, \ + NLOHMANN_JSON_PASTE17, \ + NLOHMANN_JSON_PASTE16, \ + NLOHMANN_JSON_PASTE15, \ + NLOHMANN_JSON_PASTE14, \ + NLOHMANN_JSON_PASTE13, \ + NLOHMANN_JSON_PASTE12, \ + NLOHMANN_JSON_PASTE11, \ + NLOHMANN_JSON_PASTE10, \ + NLOHMANN_JSON_PASTE9, \ + NLOHMANN_JSON_PASTE8, \ + NLOHMANN_JSON_PASTE7, \ + NLOHMANN_JSON_PASTE6, \ + NLOHMANN_JSON_PASTE5, \ + NLOHMANN_JSON_PASTE4, \ + NLOHMANN_JSON_PASTE3, \ + NLOHMANN_JSON_PASTE2, \ + NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) #define NLOHMANN_JSON_PASTE2(func, v1) func(v1) #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) @@ -2605,61 +2424,3397 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) #define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) #define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) -#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) -#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) -#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) -#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) -#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) -#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) -#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) -#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) -#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) -#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) -#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) -#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) -#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) -#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) -#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) -#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) -#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) -#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) -#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) -#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) -#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) -#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) -#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) -#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) -#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) -#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) -#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) -#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) -#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) -#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) -#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) -#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) -#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) -#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) -#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) -#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) -#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) -#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) -#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) -#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) -#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) -#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) -#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) -#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) -#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) -#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) -#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) -#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) -#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) +#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) +#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) +#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) +#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) +#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) +#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) +#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) +#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) +#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) +#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) +#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) +#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) +#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) +#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) \ + NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) +#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) +#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) +#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) +#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) +#define NLOHMANN_JSON_PASTE28(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) +#define NLOHMANN_JSON_PASTE29(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) +#define NLOHMANN_JSON_PASTE30(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE29(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29) +#define NLOHMANN_JSON_PASTE31(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE30(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30) +#define NLOHMANN_JSON_PASTE32(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE31(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31) +#define NLOHMANN_JSON_PASTE33(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE32(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32) +#define NLOHMANN_JSON_PASTE34(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE33(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33) +#define NLOHMANN_JSON_PASTE35(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE34(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34) +#define NLOHMANN_JSON_PASTE36(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE35(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35) +#define NLOHMANN_JSON_PASTE37(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE36(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36) +#define NLOHMANN_JSON_PASTE38(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE37(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37) +#define NLOHMANN_JSON_PASTE39(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE38(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38) +#define NLOHMANN_JSON_PASTE40(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE39(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39) +#define NLOHMANN_JSON_PASTE41(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE40(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40) +#define NLOHMANN_JSON_PASTE42(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE41(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41) +#define NLOHMANN_JSON_PASTE43(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE42(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42) +#define NLOHMANN_JSON_PASTE44(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE43(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43) +#define NLOHMANN_JSON_PASTE45(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE44(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44) +#define NLOHMANN_JSON_PASTE46(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE45(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45) +#define NLOHMANN_JSON_PASTE47(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE46(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46) +#define NLOHMANN_JSON_PASTE48(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE47(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47) +#define NLOHMANN_JSON_PASTE49(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE48(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48) +#define NLOHMANN_JSON_PASTE50(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE49(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49) +#define NLOHMANN_JSON_PASTE51(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE50(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50) +#define NLOHMANN_JSON_PASTE52(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE51(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51) +#define NLOHMANN_JSON_PASTE53(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE52(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52) +#define NLOHMANN_JSON_PASTE54(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE53(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53) +#define NLOHMANN_JSON_PASTE55(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE54(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54) +#define NLOHMANN_JSON_PASTE56(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE55(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55) +#define NLOHMANN_JSON_PASTE57(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE56(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56) +#define NLOHMANN_JSON_PASTE58(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE57(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57) +#define NLOHMANN_JSON_PASTE59(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE58(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58) +#define NLOHMANN_JSON_PASTE60(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE59(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59) +#define NLOHMANN_JSON_PASTE61(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE60(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60) +#define NLOHMANN_JSON_PASTE62(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE61(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61) +#define NLOHMANN_JSON_PASTE63(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE62(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62) +#define NLOHMANN_JSON_PASTE64(func, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62, \ + v63) \ + NLOHMANN_JSON_PASTE2(func, v1) \ + NLOHMANN_JSON_PASTE63(func, \ + v2, \ + v3, \ + v4, \ + v5, \ + v6, \ + v7, \ + v8, \ + v9, \ + v10, \ + v11, \ + v12, \ + v13, \ + v14, \ + v15, \ + v16, \ + v17, \ + v18, \ + v19, \ + v20, \ + v21, \ + v22, \ + v23, \ + v24, \ + v25, \ + v26, \ + v27, \ + v28, \ + v29, \ + v30, \ + v31, \ + v32, \ + v33, \ + v34, \ + v35, \ + v36, \ + v37, \ + v38, \ + v39, \ + v40, \ + v41, \ + v42, \ + v43, \ + v44, \ + v45, \ + v46, \ + v47, \ + v48, \ + v49, \ + v50, \ + v51, \ + v52, \ + v53, \ + v54, \ + v55, \ + v56, \ + v57, \ + v58, \ + v59, \ + v60, \ + v61, \ + v62, \ + v63) #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); @@ -2670,31 +5825,31 @@ JSON_HEDLEY_DIAGNOSTIC_POP @def NLOHMANN_DEFINE_TYPE_INTRUSIVE @since version 3.9.0 */ -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ - } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \ } -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ - } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ - { \ - const Type nlohmann_json_default_obj{}; \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + const Type nlohmann_json_default_obj{}; \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) \ } -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ } /*! @@ -2702,31 +5857,31 @@ JSON_HEDLEY_DIAGNOSTIC_POP @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE @since version 3.9.0 */ -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ - } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \ } -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ } -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ - { \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ - } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ - { \ - const Type nlohmann_json_default_obj{}; \ - NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) \ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \ + { \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \ + } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \ + { \ + const Type nlohmann_json_default_obj{}; \ + NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) \ } // inspired from https://stackoverflow.com/a/26745591 @@ -2735,37 +5890,36 @@ JSON_HEDLEY_DIAGNOSTIC_POP // // it allows using the detected idiom to retrieve the return type // of such an expression -#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ - namespace detail { \ - using std::std_name; \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - } \ - \ - namespace detail2 { \ - struct std_name##_tag \ - { \ - }; \ - \ - template \ - std_name##_tag std_name(T&&...); \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - \ - template \ - struct would_call_std_##std_name \ - { \ - static constexpr auto const value = ::nlohmann::detail:: \ - is_detected_exact::value; \ - }; \ - } /* namespace detail2 */ \ - \ - template \ - struct would_call_std_##std_name : detail2::would_call_std_##std_name \ - { \ - } +#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ + namespace detail \ + { \ + using std::std_name; \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + } \ + \ + namespace detail2 \ + { \ + struct std_name##_tag \ + {}; \ + \ + template \ + std_name##_tag std_name(T&&...); \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + \ + template \ + struct would_call_std_##std_name \ + { \ + static constexpr auto const value = ::nlohmann::detail::is_detected_exact::value; \ + }; \ + } /* namespace detail2 */ \ + \ + template \ + struct would_call_std_##std_name : detail2::would_call_std_##std_name \ + {} #ifndef JSON_USE_IMPLICIT_CONVERSIONS #define JSON_USE_IMPLICIT_CONVERSIONS 1 @@ -2803,7 +5957,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template using uncvref_t = typename std::remove_cv::type>::type; @@ -2864,7 +6019,8 @@ struct integer_sequence template using index_sequence = integer_sequence; -namespace utility_internal { +namespace utility_internal +{ template struct Extend; @@ -2887,8 +6043,7 @@ struct Extend, SeqSize, 1> template struct Gen { - using type = - typename Extend::type, N / 2, N % 2>::type; + using type = typename Extend::type, N / 2, N % 2>::type; }; template @@ -2991,7 +6146,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template struct iterator_types @@ -3013,14 +6169,11 @@ struct iterator_types< // doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. template struct iterator_traits -{ -}; +{}; template -struct iterator_traits::value>> - : iterator_types -{ -}; +struct iterator_traits::value>> : iterator_types +{}; template struct iterator_traits::value>> @@ -3114,8 +6267,7 @@ struct adl_serializer; /// a class to store JSON values /// @sa https://json.nlohmann.me/api/basic_json/ -template class ObjectType = - std::map, +template class ObjectType = std::map, template class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, @@ -3123,8 +6275,7 @@ template class ObjectType = class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer, + template class JSONSerializer = adl_serializer, class BinaryType = std::vector, // cppcheck-suppress syntaxError class CustomBaseClass = void> class basic_json; @@ -3162,7 +6313,8 @@ implementations of some @ref basic_json methods, and meta-programming helpers. @since version 2.1.0 */ -namespace detail { +namespace detail +{ ///////////// // helpers // @@ -3189,8 +6341,10 @@ struct is_basic_json : std::true_type // true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t // false_type otherwise template -struct is_basic_json_context : std::integral_constant::type>::type>::value || std::is_same::value> +struct is_basic_json_context + : std::integral_constant::type>::type>::value || + std::is_same::value> {}; ////////////////////// @@ -3262,8 +6416,7 @@ struct has_from_json::value>> { using serializer = typename BasicJsonType::template json_serializer; - static constexpr bool value = - is_detected_exact::value; + static constexpr bool value = is_detected_exact::value; }; // This trait checks if JSONSerializer::from_json(json const&) exists @@ -3277,8 +6430,7 @@ struct has_non_default_from_json { using serializer = typename BasicJsonType::template json_serializer; - static constexpr bool value = - is_detected_exact::value; + static constexpr bool value = is_detected_exact::value; }; // This trait checks if BasicJsonType::json_serializer::to_json exists @@ -3292,8 +6444,7 @@ struct has_to_json::value>> { using serializer = typename BasicJsonType::template json_serializer; - static constexpr bool value = - is_detected_exact::value; + static constexpr bool value = is_detected_exact::value; }; template @@ -3309,9 +6460,7 @@ struct actual_object_comparator { using object_t = typename BasicJsonType::object_t; using object_comparator_t = typename BasicJsonType::default_object_comparator_t; - using type = typename std::conditional::value, - typename object_t::key_compare, - object_comparator_t>::type; + using type = typename std::conditional::value, typename object_t::key_compare, object_comparator_t>::type; }; template @@ -3386,8 +6535,7 @@ template struct conjunction : B {}; template -struct conjunction - : std::conditional(B::value), conjunction, B>::type +struct conjunction : std::conditional(B::value), conjunction, B>::type {}; // https://en.cppreference.com/w/cpp/types/negation @@ -3403,23 +6551,19 @@ struct is_default_constructible : std::is_default_constructible {}; template -struct is_default_constructible> - : conjunction, is_default_constructible> +struct is_default_constructible> : conjunction, is_default_constructible> {}; template -struct is_default_constructible> - : conjunction, is_default_constructible> +struct is_default_constructible> : conjunction, is_default_constructible> {}; template -struct is_default_constructible> - : conjunction...> +struct is_default_constructible> : conjunction...> {}; template -struct is_default_constructible> - : conjunction...> +struct is_default_constructible> : conjunction...> {}; template @@ -3453,12 +6597,9 @@ struct is_iterator_traits> using traits = iterator_traits; public: - static constexpr auto value = - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value; + static constexpr auto value = is_detected::value && is_detected::value && + is_detected::value && is_detected::value && + is_detected::value; }; template @@ -3473,8 +6614,7 @@ struct is_range // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator // and https://en.cppreference.com/w/cpp/iterator/sentinel_for // but reimplementing these would be too much work, as a lot of other concepts are used underneath - static constexpr auto is_iterator_begin = - is_iterator_traits>::value; + static constexpr auto is_iterator_begin = is_iterator_traits>::value; public: static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; @@ -3506,22 +6646,17 @@ template struct is_compatible_object_type_impl< BasicJsonType, CompatibleObjectType, - enable_if_t::value && - is_detected::value>> + enable_if_t::value && is_detected::value>> { using object_t = typename BasicJsonType::object_t; // macOS's is_constructible does not play well with nonesuch... - static constexpr bool value = - is_constructible::value && - is_constructible::value; + static constexpr bool value = is_constructible::value && + is_constructible::value; }; template -struct is_compatible_object_type - : is_compatible_object_type_impl +struct is_compatible_object_type : is_compatible_object_type_impl {}; template @@ -3532,38 +6667,26 @@ template struct is_constructible_object_type_impl< BasicJsonType, ConstructibleObjectType, - enable_if_t::value && - is_detected::value>> + enable_if_t::value && is_detected::value>> { using object_t = typename BasicJsonType::object_t; - static constexpr bool value = - (is_default_constructible::value && - (std::is_move_assignable::value || - std::is_copy_assignable::value) && - (is_constructible::value && - std::is_same< - typename object_t::mapped_type, - typename ConstructibleObjectType::mapped_type>::value)) || - (has_from_json::value || - has_non_default_from_json< - BasicJsonType, - typename ConstructibleObjectType::mapped_type>::value); + static constexpr bool value = (is_default_constructible::value && + (std::is_move_assignable::value || std::is_copy_assignable::value) && + (is_constructible::value && + std::is_same::value)) || + (has_from_json::value || + has_non_default_from_json::value); }; template -struct is_constructible_object_type - : is_constructible_object_type_impl +struct is_constructible_object_type : is_constructible_object_type_impl {}; template struct is_compatible_string_type { - static constexpr auto value = - is_constructible::value; + static constexpr auto value = is_constructible::value; }; template @@ -3576,12 +6699,8 @@ struct is_constructible_string_type using laundered_type = ConstructibleStringType; #endif - static constexpr auto value = - conjunction< - is_constructible, - is_detected_exact>::value; + static constexpr auto value = conjunction, + is_detected_exact>::value; }; template @@ -3589,24 +6708,19 @@ struct is_compatible_array_type_impl : std::false_type {}; template -struct is_compatible_array_type_impl< - BasicJsonType, - CompatibleArrayType, - enable_if_t< - is_detected::value && - is_iterator_traits>>::value && - // special case for types like std::filesystem::path whose iterator's value_type are themselves - // c.f. https://github.com/nlohmann/json/pull/3073 - !std::is_same>::value>> +struct is_compatible_array_type_impl::value && + is_iterator_traits>>::value && + // special case for types like std::filesystem::path whose iterator's value_type are themselves + // c.f. https://github.com/nlohmann/json/pull/3073 + !std::is_same>::value>> { - static constexpr bool value = - is_constructible>::value; + static constexpr bool value = is_constructible>::value; }; template -struct is_compatible_array_type - : is_compatible_array_type_impl +struct is_compatible_array_type : is_compatible_array_type_impl {}; template @@ -3614,48 +6728,34 @@ struct is_constructible_array_type_impl : std::false_type {}; template -struct is_constructible_array_type_impl< - BasicJsonType, - ConstructibleArrayType, - enable_if_t::value>> - : std::true_type +struct is_constructible_array_type_impl::value>> : std::true_type {}; template struct is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, - enable_if_t::value && - !is_compatible_string_type::value && - is_default_constructible::value && - (std::is_move_assignable::value || - std::is_copy_assignable::value) && + enable_if_t::value && + !is_compatible_string_type::value && is_default_constructible::value && + (std::is_move_assignable::value || std::is_copy_assignable::value) && is_detected::value && is_iterator_traits>>::value && is_detected::value && // special case for types like std::filesystem::path whose iterator's value_type are themselves // c.f. https://github.com/nlohmann/json/pull/3073 !std::is_same>::value && - is_complete_type< - detected_t>::value>> + is_complete_type>::value>> { using value_type = range_value_t; - static constexpr bool value = - std::is_same::value || - has_from_json::value || - has_non_default_from_json< - BasicJsonType, - value_type>::value; + static constexpr bool value = std::is_same::value || + has_from_json::value || has_non_default_from_json::value; }; template -struct is_constructible_array_type - : is_constructible_array_type_impl +struct is_constructible_array_type : is_constructible_array_type_impl {}; template @@ -3663,28 +6763,21 @@ struct is_compatible_integer_type_impl : std::false_type {}; template -struct is_compatible_integer_type_impl< - RealIntegerType, - CompatibleNumberIntegerType, - enable_if_t::value && - std::is_integral::value && - !std::is_same::value>> +struct is_compatible_integer_type_impl::value && std::is_integral::value && + !std::is_same::value>> { // is there an assert somewhere on overflows? using RealLimits = std::numeric_limits; using CompatibleLimits = std::numeric_limits; - static constexpr auto value = - is_constructible::value && - CompatibleLimits::is_integer && - RealLimits::is_signed == CompatibleLimits::is_signed; + static constexpr auto value = is_constructible::value && CompatibleLimits::is_integer && + RealLimits::is_signed == CompatibleLimits::is_signed; }; template -struct is_compatible_integer_type - : is_compatible_integer_type_impl +struct is_compatible_integer_type : is_compatible_integer_type_impl {}; template @@ -3692,18 +6785,13 @@ struct is_compatible_type_impl : std::false_type {}; template -struct is_compatible_type_impl< - BasicJsonType, - CompatibleType, - enable_if_t::value>> +struct is_compatible_type_impl::value>> { - static constexpr bool value = - has_to_json::value; + static constexpr bool value = has_to_json::value; }; template -struct is_compatible_type - : is_compatible_type_impl +struct is_compatible_type : is_compatible_type_impl {}; template @@ -3744,7 +6832,12 @@ struct is_comparable : std::false_type {}; template -struct is_comparable()(std::declval(), std::declval())), decltype(std::declval()(std::declval(), std::declval()))>> : std::true_type +struct is_comparable< + Compare, + A, + B, + void_t()(std::declval(), std::declval())), decltype(std::declval()(std::declval(), std::declval()))>> + : std::true_type {}; template @@ -3752,11 +6845,18 @@ using detect_is_transparent = typename T::is_transparent; // type trait to check if KeyType can be used as object key (without a BasicJsonType) // see is_usable_as_basic_json_key_type below -template> -using is_usable_as_key_type = typename std::conditional< - is_comparable::value && !(ExcludeObjectKeyType && std::is_same::value) && (!RequireTransparentComparator || is_detected::value) && !is_json_pointer::value, - std::true_type, - std::false_type>::type; +template> +using is_usable_as_key_type = + typename std::conditional::value && + !(ExcludeObjectKeyType && std::is_same::value) && + (!RequireTransparentComparator || is_detected::value) && !is_json_pointer::value, + std::true_type, + std::false_type>::type; // type trait to check if KeyType can be used as object key // true if: @@ -3764,29 +6864,27 @@ using is_usable_as_key_type = typename std::conditional< // - if ExcludeObjectKeyType is true, KeyType is not BasicJsonType::object_t::key_type // - the comparator is transparent or RequireTransparentComparator is false // - KeyType is not a JSON iterator or json_pointer -template> -using is_usable_as_basic_json_key_type = typename std::conditional< - is_usable_as_key_type::value && - !is_json_iterator_of::value, - std::true_type, - std::false_type>::type; +template> +using is_usable_as_basic_json_key_type = typename std::conditional::value && + !is_json_iterator_of::value, + std::true_type, + std::false_type>::type; template using detect_erase_with_key_type = decltype(std::declval().erase(std::declval())); // type trait to check if object_t has an erase() member functions accepting KeyType template -using has_erase_with_key_type = typename std::conditional< - is_detected< - detect_erase_with_key_type, - typename BasicJsonType::object_t, - KeyType>::value, - std::true_type, - std::false_type>::type; +using has_erase_with_key_type = + typename std::conditional::value, std::true_type, std::false_type>::type; // a naive helper to check if a type is an ordered_map (exploits the fact that // ordered_map inherits capacity() from std::vector) @@ -3835,12 +6933,12 @@ using all_unsigned = conjunction...>; // there's a disjunction trait in another PR; replace when merged template -using same_sign = std::integral_constant::value || all_unsigned::value>; +using same_sign = std::integral_constant::value || all_unsigned::value>; template -using never_out_of_range = std::integral_constant::value && (sizeof(T) < sizeof(OfType))) || (same_sign::value && sizeof(OfType) == sizeof(T))>; +using never_out_of_range = + std::integral_constant::value && (sizeof(T) < sizeof(OfType))) || (same_sign::value && sizeof(OfType) == sizeof(T))>; template::value, bool TSigned = std::is_signed::value> struct value_in_range_of_impl2; @@ -3881,11 +6979,15 @@ struct value_in_range_of_impl2 static constexpr bool test(T val) { using CommonType = typename std::common_type::type; - return static_cast(val) >= static_cast((std::numeric_limits::min)()) && static_cast(val) <= static_cast((std::numeric_limits::max)()); + return static_cast(val) >= static_cast((std::numeric_limits::min)()) && + static_cast(val) <= static_cast((std::numeric_limits::max)()); } }; -template::value, typename = detail::enable_if_t::value>> +template::value, + typename = detail::enable_if_t::value>> struct value_in_range_of_impl1; template @@ -3919,7 +7021,8 @@ using bool_constant = std::integral_constant; // is_c_string /////////////////////////////////////////////////////////////////////////////// -namespace impl { +namespace impl +{ template inline constexpr bool is_c_string() @@ -3945,7 +7048,8 @@ using is_c_string_uncvref = is_c_string>; // is_transparent /////////////////////////////////////////////////////////////////////////////// -namespace impl { +namespace impl +{ template inline constexpr bool is_transparent() @@ -3983,7 +7087,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ inline std::size_t concat_length() { @@ -4043,13 +7148,26 @@ using string_can_append_data = decltype(std::declval().append(std:: template using detect_string_can_append_data = is_detected; -template::value && detect_string_can_append_op::value, int> = 0> +template::value && detect_string_can_append_op::value, int> = 0> inline void concat_into(OutStringType& out, Arg&& arg, Args&&... rest); -template::value && !detect_string_can_append_op::value && detect_string_can_append_iter::value, int> = 0> +template::value && !detect_string_can_append_op::value && + detect_string_can_append_iter::value, + int> = 0> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest); -template::value && !detect_string_can_append_op::value && !detect_string_can_append_iter::value && detect_string_can_append_data::value, int> = 0> +template::value && !detect_string_can_append_op::value && + !detect_string_can_append_iter::value && detect_string_can_append_data::value, + int> = 0> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest); template::value, int> = 0> @@ -4059,21 +7177,34 @@ inline void concat_into(OutStringType& out, Arg&& arg, Args&&... rest) concat_into(out, std::forward(rest)...); } -template::value && detect_string_can_append_op::value, int>> +template::value && detect_string_can_append_op::value, int>> inline void concat_into(OutStringType& out, Arg&& arg, Args&&... rest) { out += std::forward(arg); concat_into(out, std::forward(rest)...); } -template::value && !detect_string_can_append_op::value && detect_string_can_append_iter::value, int>> +template::value && !detect_string_can_append_op::value && + detect_string_can_append_iter::value, + int>> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest) { out.append(arg.begin(), arg.end()); concat_into(out, std::forward(rest)...); } -template::value && !detect_string_can_append_op::value && !detect_string_can_append_iter::value && detect_string_can_append_data::value, int>> +template::value && !detect_string_can_append_op::value && + !detect_string_can_append_iter::value && detect_string_can_append_data::value, + int>> inline void concat_into(OutStringType& out, const Arg& arg, Args&&... rest) { out.append(arg.data(), arg.size()); @@ -4104,7 +7235,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /*! @brief replace all occurrences of a substring by another string @@ -4183,7 +7315,8 @@ NLOHMANN_JSON_NAMESPACE_END #endif NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /////////////////////////// // JSON type enumeration // @@ -4241,7 +7374,7 @@ Returns an ordering that is similar to Python: @since version 1.0.0 */ #if JSON_HAS_THREE_WAY_COMPARISON -inline std::partial_ordering operator<=> (const value_t lhs, const value_t rhs) noexcept // *NOPAD* +inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD* #else inline bool operator<(const value_t lhs, const value_t rhs) noexcept #endif @@ -4286,7 +7419,8 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept NLOHMANN_JSON_NAMESPACE_END NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ //////////////// // exceptions // @@ -4415,7 +7549,12 @@ class parse_error : public exception template::value, int> = 0> static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, BasicJsonContext context) { - const std::string w = concat(exception::name("parse_error", id_), "parse error", (byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""), ": ", exception::diagnostics(context), what_arg); + const std::string w = concat(exception::name("parse_error", id_), + "parse error", + (byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""), + ": ", + exception::diagnostics(context), + what_arg); return {id_, byte_, w.c_str()}; } @@ -4537,7 +7676,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ // dispatching helper struct template @@ -4561,14 +7701,16 @@ NLOHMANN_JSON_NAMESPACE_END #if JSON_HAS_EXPERIMENTAL_FILESYSTEM #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ namespace std_fs = std::experimental::filesystem; } // namespace detail NLOHMANN_JSON_NAMESPACE_END #elif JSON_HAS_FILESYSTEM #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ namespace std_fs = std::filesystem; } // namespace detail NLOHMANN_JSON_NAMESPACE_END @@ -4581,7 +7723,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n) @@ -4594,7 +7737,9 @@ inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n) } // overloads for basic_json template parameters -template::value && !std::is_same::value, int> = 0> +template::value && !std::is_same::value, int> = 0> void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) { switch (static_cast(j)) @@ -4647,12 +7792,12 @@ inline void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s = *j.template get_ptr(); } -template< - typename BasicJsonType, - typename StringType, - enable_if_t< - std::is_assignable::value && is_detected_exact::value && !std::is_same::value && !is_json_ref::value, - int> = 0> +template::value && + is_detected_exact::value && + !std::is_same::value && !is_json_ref::value, + int> = 0> inline void from_json(const BasicJsonType& j, StringType& s) { if (JSON_HEDLEY_UNLIKELY(!j.is_string())) @@ -4736,8 +7881,7 @@ inline void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType: } template -auto from_json_array_impl(const BasicJsonType& j, std::array& arr, priority_tag<2> /*unused*/) - -> decltype(j.template get(), void()) +auto from_json_array_impl(const BasicJsonType& j, std::array& arr, priority_tag<2> /*unused*/) -> decltype(j.template get(), void()) { for (std::size_t i = 0; i < N; ++i) { @@ -4745,11 +7889,11 @@ auto from_json_array_impl(const BasicJsonType& j, std::array& arr, priorit } } -template::value, int> = 0> +template::value, int> = 0> auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/) - -> decltype(arr.reserve(std::declval()), - j.template get(), - void()) + -> decltype(arr.reserve(std::declval()), j.template get(), void()) { using std::end; @@ -4763,29 +7907,31 @@ auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, p arr = std::move(ret); } -template::value, int> = 0> +template::value, int> = 0> inline void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<0> /*unused*/) { using std::end; ConstructibleArrayType ret; - std::transform( - j.begin(), - j.end(), - std::inserter(ret, end(ret)), - [](const BasicJsonType& i) { - // get() returns *this, this won't call a from_json - // method when value_type is BasicJsonType - return i.template get(); - }); + std::transform(j.begin(), j.end(), std::inserter(ret, end(ret)), [](const BasicJsonType& i) { + // get() returns *this, this won't call a from_json + // method when value_type is BasicJsonType + return i.template get(); + }); arr = std::move(ret); } -template::value && !is_constructible_object_type::value && !is_constructible_string_type::value && !std::is_same::value && !is_basic_json::value, int> = 0> +template::value && + !is_constructible_object_type::value && + !is_constructible_string_type::value && + !std::is_same::value && !is_basic_json::value, + int> = 0> auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) - -> decltype(from_json_array_impl(j, arr, priority_tag<3>{}), - j.template get(), - void()) + -> decltype(from_json_array_impl(j, arr, priority_tag<3>{}), j.template get(), void()) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { @@ -4796,9 +7942,8 @@ auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) } template -std::array from_json_inplace_array_impl(BasicJsonType&& j, - identity_tag> /*unused*/, - index_sequence /*unused*/) +std::array +from_json_inplace_array_impl(BasicJsonType&& j, identity_tag> /*unused*/, index_sequence /*unused*/) { return {{std::forward(j).at(Idx).template get()...}}; } @@ -4826,7 +7971,9 @@ inline void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin = *j.template get_ptr(); } -template::value, int> = 0> +template::value, int> = 0> inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { if (JSON_HEDLEY_UNLIKELY(!j.is_object())) @@ -4837,13 +7984,9 @@ inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) ConstructibleObjectType ret; const auto* inner_object = j.template get_ptr(); using value_type = typename ConstructibleObjectType::value_type; - std::transform( - inner_object->begin(), - inner_object->end(), - std::inserter(ret, ret.begin()), - [](typename BasicJsonType::object_t::value_type const& p) { - return value_type(p.first, p.second.template get()); - }); + std::transform(inner_object->begin(), inner_object->end(), std::inserter(ret, ret.begin()), [](typename BasicJsonType::object_t::value_type const& p) { + return value_type(p.first, p.second.template get()); + }); obj = std::move(ret); } @@ -4851,7 +7994,13 @@ inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) // (BooleanType, etc..); note: Is it really necessary to provide explicit // overloads for boolean_t etc. in case of a custom BooleanType which is not // an arithmetic type? -template::value && !std::is_same::value && !std::is_same::value && !std::is_same::value && !std::is_same::value, int> = 0> +template::value && !std::is_same::value && + !std::is_same::value && + !std::is_same::value && + !std::is_same::value, + int> = 0> inline void from_json(const BasicJsonType& j, ArithmeticType& val) { switch (static_cast(j)) @@ -4897,8 +8046,7 @@ std::tuple from_json_tuple_impl_base(BasicJsonType&& j, index_sequence< template std::pair from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<0> /*unused*/) { - return {std::forward(j).at(0).template get(), - std::forward(j).at(1).template get()}; + return {std::forward(j).at(0).template get(), std::forward(j).at(1).template get()}; } template @@ -4931,7 +8079,12 @@ auto from_json(BasicJsonType&& j, TupleRelated&& t) return from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3>{}); } -template::value>> +template::value>> inline void from_json(const BasicJsonType& j, std::map& m) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) @@ -4949,7 +8102,13 @@ inline void from_json(const BasicJsonType& j, std::map::value>> +template::value>> inline void from_json(const BasicJsonType& j, std::unordered_map& m) { if (JSON_HEDLEY_UNLIKELY(!j.is_array())) @@ -4982,9 +8141,8 @@ inline void from_json(const BasicJsonType& j, std_fs::path& p) struct from_json_fn { template - auto operator()(const BasicJsonType& j, T&& val) const - noexcept(noexcept(from_json(j, std::forward(val)))) - -> decltype(from_json(j, std::forward(val))) + auto operator()(const BasicJsonType& j, T&& val) const noexcept(noexcept(from_json(j, std::forward(val)))) + -> decltype(from_json(j, std::forward(val))) { return from_json(j, std::forward(val)); } @@ -5051,7 +8209,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template void int_to_string(string_type& target, std::size_t value) @@ -5085,7 +8244,8 @@ class iteration_proxy_value public: explicit iteration_proxy_value() = default; - explicit iteration_proxy_value(IteratorType it, std::size_t array_index_ = 0) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_default_constructible::value) + explicit iteration_proxy_value(IteratorType it, std::size_t array_index_ = 0) noexcept(std::is_nothrow_move_constructible::value && + std::is_nothrow_default_constructible::value) : anchor(std::move(it)) , array_index(array_index_) {} @@ -5093,8 +8253,12 @@ class iteration_proxy_value iteration_proxy_value(iteration_proxy_value const&) = default; iteration_proxy_value& operator=(iteration_proxy_value const&) = default; // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions - iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) - iteration_proxy_value& operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable::value && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) + iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible::value && + std::is_nothrow_move_constructible::value) = + default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) + iteration_proxy_value& operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable::value && + std::is_nothrow_move_assignable::value) = + default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) ~iteration_proxy_value() = default; /// dereference operator (needed for range-based for) @@ -5234,7 +8398,8 @@ NLOHMANN_JSON_NAMESPACE_END // Structured Bindings Support to the iteration_proxy_value class // For further reference see https://blog.tartanllama.xyz/structured-bindings/ // And see https://github.com/nlohmann/json/pull/1391 -namespace std { +namespace std +{ #if defined(__clang__) // Fix: https://github.com/nlohmann/json/issues/1401 @@ -5250,8 +8415,7 @@ template class tuple_element> // NOLINT(cert-dcl58-cpp) { public: - using type = decltype(get(std::declval< - ::nlohmann::detail::iteration_proxy_value>())); + using type = decltype(get(std::declval<::nlohmann::detail::iteration_proxy_value>())); }; #if defined(__clang__) #pragma clang diagnostic pop @@ -5275,7 +8439,8 @@ inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::i // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ ////////////////// // constructors // @@ -5325,7 +8490,9 @@ struct external_constructor j.assert_invariant(); } - template::value, int> = 0> + template::value, int> = 0> static void construct(BasicJsonType& j, const CompatibleStringType& str) { j.m_data.m_value.destroy(j.m_data.m_type); @@ -5419,7 +8586,9 @@ struct external_constructor j.assert_invariant(); } - template::value, int> = 0> + template::value, int> = 0> static void construct(BasicJsonType& j, const CompatibleArrayType& arr) { using std::begin; @@ -5486,7 +8655,9 @@ struct external_constructor j.assert_invariant(); } - template::value, int> = 0> + template::value, int> = 0> static void construct(BasicJsonType& j, const CompatibleObjectType& obj) { using std::begin; @@ -5510,13 +8681,22 @@ inline void to_json(BasicJsonType& j, T b) noexcept external_constructor::construct(j, b); } -template::reference, BoolRef>::value && !std::is_same::reference, typename BasicJsonType::boolean_t&>::value) || (std::is_same::const_reference, BoolRef>::value && !std::is_same::const_reference>, typename BasicJsonType::boolean_t>::value)) && std::is_convertible::value, int> = 0> +template::reference, BoolRef>::value && + !std::is_same::reference, typename BasicJsonType::boolean_t&>::value) || + (std::is_same::const_reference, BoolRef>::value && + !std::is_same::const_reference>, typename BasicJsonType::boolean_t>::value)) && + std::is_convertible::value, + int> = 0> inline void to_json(BasicJsonType& j, const BoolRef& b) noexcept { external_constructor::construct(j, static_cast(b)); } -template::value, int> = 0> +template::value, int> = 0> inline void to_json(BasicJsonType& j, const CompatibleString& s) { external_constructor::construct(j, s); @@ -5534,13 +8714,17 @@ inline void to_json(BasicJsonType& j, FloatType val) noexcept external_constructor::construct(j, static_cast(val)); } -template::value, int> = 0> +template::value, int> = 0> inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept { external_constructor::construct(j, static_cast(val)); } -template::value, int> = 0> +template::value, int> = 0> inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept { external_constructor::construct(j, static_cast(val)); @@ -5561,7 +8745,13 @@ inline void to_json(BasicJsonType& j, const std::vector& e) external_constructor::construct(j, e); } -template::value && !is_compatible_object_type::value && !is_compatible_string_type::value && !std::is_same::value && !is_basic_json::value, int> = 0> +template< + typename BasicJsonType, + typename CompatibleArrayType, + enable_if_t::value && !is_compatible_object_type::value && + !is_compatible_string_type::value && + !std::is_same::value && !is_basic_json::value, + int> = 0> inline void to_json(BasicJsonType& j, const CompatibleArrayType& arr) { external_constructor::construct(j, arr); @@ -5585,7 +8775,9 @@ inline void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) external_constructor::construct(j, std::move(arr)); } -template::value && !is_basic_json::value, int> = 0> +template::value && !is_basic_json::value, int> = 0> inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj) { external_constructor::construct(j, obj); @@ -5597,19 +8789,21 @@ inline void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) external_constructor::construct(j, std::move(obj)); } -template< - typename BasicJsonType, - typename T, - std::size_t N, - enable_if_t::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - int> = 0> +template::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) + int> = 0> inline void to_json(BasicJsonType& j, const T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) { external_constructor::construct(j, arr); } -template::value && std::is_constructible::value, int> = 0> +template::value && std::is_constructible::value, int> = 0> inline void to_json(BasicJsonType& j, const std::pair& p) { j = {p.first, p.second}; @@ -5645,8 +8839,7 @@ inline void to_json(BasicJsonType& j, const std_fs::path& p) struct to_json_fn { template - auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) - -> decltype(to_json(j, std::forward(val)), void()) + auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) -> decltype(to_json(j, std::forward(val)), void()) { return to_json(j, std::forward(val)); } @@ -5679,8 +8872,7 @@ struct adl_serializer /// @brief convert a JSON value to any value type /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ template - static auto from_json(BasicJsonType&& j, TargetType& val) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), val))) + static auto from_json(BasicJsonType&& j, TargetType& val) noexcept(noexcept(::nlohmann::from_json(std::forward(j), val))) -> decltype(::nlohmann::from_json(std::forward(j), val), void()) { ::nlohmann::from_json(std::forward(j), val); @@ -5689,8 +8881,7 @@ struct adl_serializer /// @brief convert a JSON value to any value type /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ template - static auto from_json(BasicJsonType&& j) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag{}))) + static auto from_json(BasicJsonType&& j) noexcept(noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag{}))) -> decltype(::nlohmann::from_json(std::forward(j), detail::identity_tag{})) { return ::nlohmann::from_json(std::forward(j), detail::identity_tag{}); @@ -5699,8 +8890,7 @@ struct adl_serializer /// @brief convert any value type to a JSON value /// @sa https://json.nlohmann.me/api/adl_serializer/to_json/ template - static auto to_json(BasicJsonType& j, TargetType&& val) noexcept( - noexcept(::nlohmann::to_json(j, std::forward(val)))) + static auto to_json(BasicJsonType& j, TargetType&& val) noexcept(noexcept(::nlohmann::to_json(j, std::forward(val)))) -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) { ::nlohmann::to_json(j, std::forward(val)); @@ -5836,7 +9026,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ // boost::hash_combine inline std::size_t combine(std::size_t seed, std::size_t h) noexcept @@ -6002,7 +9193,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /// the supported input formats enum class input_format_t @@ -6161,10 +9353,8 @@ template struct wide_string_input_helper { // UTF-32 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) + static void + fill_buffer(BaseInputAdapter& input, std::array::int_type, 4>& utf8_bytes, size_t& utf8_bytes_index, size_t& utf8_bytes_filled) { utf8_bytes_index = 0; @@ -6219,10 +9409,8 @@ template struct wide_string_input_helper { // UTF-16 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) + static void + fill_buffer(BaseInputAdapter& input, std::array::int_type, 4>& utf8_bytes, size_t& utf8_bytes_index, size_t& utf8_bytes_filled) { utf8_bytes_index = 0; @@ -6372,7 +9560,8 @@ typename iterator_input_adapter_factory::adapter_type input_adapte // Enables ADL on begin(container) and end(container) // Encloses the using declarations in namespace for not to leak them to outside scope -namespace container_input_adapter_factory_impl { +namespace container_input_adapter_factory_impl +{ using std::begin; using std::end; @@ -6382,8 +9571,7 @@ struct container_input_adapter_factory {}; template -struct container_input_adapter_factory()), end(std::declval()))>> +struct container_input_adapter_factory()), end(std::declval()))>> { using adapter_type = decltype(input_adapter(begin(std::declval()), end(std::declval()))); @@ -6422,13 +9610,11 @@ inline input_stream_adapter input_adapter(std::istream&& stream) using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval(), std::declval())); // Null-delimited strings, and the like. -template::value && - !std::is_array::value && - std::is_integral::type>::value && - sizeof(typename std::remove_pointer::type) == 1, - int>::type = 0> +template< + typename CharT, + typename std::enable_if::value && !std::is_array::value && + std::is_integral::type>::value && sizeof(typename std::remove_pointer::type) == 1, + int>::type = 0> contiguous_bytes_input_adapter input_adapter(CharT b) { auto length = std::strlen(reinterpret_cast(b)); @@ -6437,7 +9623,8 @@ contiguous_bytes_input_adapter input_adapter(CharT b) } template -auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) +auto input_adapter(T (&array)[N]) + -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) { return input_adapter(array, array + N); } @@ -6449,19 +9636,16 @@ class span_input_adapter { public: template::value && - std::is_integral::type>::value && - sizeof(typename std::remove_pointer::type) == 1, - int>::type = 0> + typename std::enable_if::value && std::is_integral::type>::value && + sizeof(typename std::remove_pointer::type) == 1, + int>::type = 0> span_input_adapter(CharT b, std::size_t l) : ia(reinterpret_cast(b), reinterpret_cast(b) + l) {} - template::iterator_category, std::random_access_iterator_tag>::value, - int>::type = 0> + template< + class IteratorType, + typename std::enable_if::iterator_category, std::random_access_iterator_tag>::value, int>::type = 0> span_input_adapter(IteratorType first, IteratorType last) : ia(input_adapter(first, last)) {} @@ -6611,9 +9795,7 @@ struct json_sax @param[in] ex an exception object describing the error @return whether parsing should proceed (must return false) */ - virtual bool parse_error(std::size_t position, - const std::string& last_token, - const detail::exception& ex) = 0; + virtual bool parse_error(std::size_t position, const std::string& last_token, const detail::exception& ex) = 0; json_sax() = default; json_sax(const json_sax&) = default; @@ -6623,7 +9805,8 @@ struct json_sax virtual ~json_sax() = default; }; -namespace detail { +namespace detail +{ /*! @brief SAX implementation to create a JSON value from SAX events @@ -6785,9 +9968,7 @@ class json_sax_dom_parser object to which we can add elements */ template - JSON_HEDLEY_RETURNS_NON_NULL - BasicJsonType* - handle_value(Value&& v) + JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType* handle_value(Value&& v) { if (ref_stack.empty()) { @@ -6833,9 +10014,7 @@ class json_sax_dom_callback_parser using parser_callback_t = typename BasicJsonType::parser_callback_t; using parse_event_t = typename BasicJsonType::parse_event_t; - json_sax_dom_callback_parser(BasicJsonType& r, - const parser_callback_t cb, - const bool allow_exceptions_ = true) + json_sax_dom_callback_parser(BasicJsonType& r, const parser_callback_t cb, const bool allow_exceptions_ = true) : root(r) , callback(cb) , allow_exceptions(allow_exceptions_) @@ -7236,7 +10415,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /////////// // lexer // @@ -8396,8 +11576,7 @@ class lexer : public lexer_base default: { - error_message = - "invalid number; expected '+', '-', or digit after exponent"; + error_message = "invalid number; expected '+', '-', or digit after exponent"; return token_type::parse_error; } } @@ -8666,7 +11845,8 @@ class lexer : public lexer_base { // escape control characters std::array cs{{}}; - static_cast((std::snprintf)(cs.data(), cs.size(), "", static_cast(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast(( + std::snprintf)(cs.data(), cs.size(), "", static_cast(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) result += cs.data(); } else @@ -8759,17 +11939,23 @@ class lexer : public lexer_base // literals case 't': { - std::array true_literal = {{static_cast('t'), static_cast('r'), static_cast('u'), static_cast('e')}}; + std::array true_literal = { + {static_cast('t'), static_cast('r'), static_cast('u'), static_cast('e')}}; return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); } case 'f': { - std::array false_literal = {{static_cast('f'), static_cast('a'), static_cast('l'), static_cast('s'), static_cast('e')}}; + std::array false_literal = {{static_cast('f'), + static_cast('a'), + static_cast('l'), + static_cast('s'), + static_cast('e')}}; return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); } case 'n': { - std::array null_literal = {{static_cast('n'), static_cast('u'), static_cast('l'), static_cast('l')}}; + std::array null_literal = { + {static_cast('n'), static_cast('u'), static_cast('l'), static_cast('l')}}; return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); } @@ -8863,66 +12049,54 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template using null_function_t = decltype(std::declval().null()); template -using boolean_function_t = - decltype(std::declval().boolean(std::declval())); +using boolean_function_t = decltype(std::declval().boolean(std::declval())); template -using number_integer_function_t = - decltype(std::declval().number_integer(std::declval())); +using number_integer_function_t = decltype(std::declval().number_integer(std::declval())); template -using number_unsigned_function_t = - decltype(std::declval().number_unsigned(std::declval())); +using number_unsigned_function_t = decltype(std::declval().number_unsigned(std::declval())); template -using number_float_function_t = decltype(std::declval().number_float( - std::declval(), - std::declval())); +using number_float_function_t = decltype(std::declval().number_float(std::declval(), std::declval())); template -using string_function_t = - decltype(std::declval().string(std::declval())); +using string_function_t = decltype(std::declval().string(std::declval())); template -using binary_function_t = - decltype(std::declval().binary(std::declval())); +using binary_function_t = decltype(std::declval().binary(std::declval())); template -using start_object_function_t = - decltype(std::declval().start_object(std::declval())); +using start_object_function_t = decltype(std::declval().start_object(std::declval())); template -using key_function_t = - decltype(std::declval().key(std::declval())); +using key_function_t = decltype(std::declval().key(std::declval())); template using end_object_function_t = decltype(std::declval().end_object()); template -using start_array_function_t = - decltype(std::declval().start_array(std::declval())); +using start_array_function_t = decltype(std::declval().start_array(std::declval())); template using end_array_function_t = decltype(std::declval().end_array()); template -using parse_error_function_t = decltype(std::declval().parse_error( - std::declval(), - std::declval(), - std::declval())); +using parse_error_function_t = + decltype(std::declval().parse_error(std::declval(), std::declval(), std::declval())); template struct is_sax { private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); + static_assert(is_basic_json::value, "BasicJsonType must be of type basic_json<...>"); using number_integer_t = typename BasicJsonType::number_integer_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t; @@ -8933,27 +12107,21 @@ struct is_sax public: static constexpr bool value = - is_detected_exact::value && - is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value; + is_detected_exact::value && is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value; }; template struct is_sax_static_asserts { private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); + static_assert(is_basic_json::value, "BasicJsonType must be of type basic_json<...>"); using number_integer_t = typename BasicJsonType::number_integer_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t; @@ -8963,40 +12131,25 @@ struct is_sax_static_asserts using exception_t = typename BasicJsonType::exception; public: - static_assert(is_detected_exact::value, - "Missing/invalid function: bool null()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_integer(number_integer_t)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool null()"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool boolean(bool)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool boolean(bool)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool number_integer(number_integer_t)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); static_assert(is_detected_exact::value, "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool string(string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool binary(binary_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_object(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool key(string_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_object()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_array(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_array()"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool parse_error(std::size_t, const " - "std::string&, const exception&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool string(string_t&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool binary(binary_t&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool start_object(std::size_t)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool key(string_t&)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool end_object()"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool start_array(std::size_t)"); + static_assert(is_detected_exact::value, "Missing/invalid function: bool end_array()"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool parse_error(std::size_t, const " + "std::string&, const exception&)"); }; } // namespace detail @@ -9009,7 +12162,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /// how to treat CBOR tags enum class cbor_tag_handler_t @@ -9079,10 +12233,7 @@ class binary_reader @return whether parsing was successful */ JSON_HEDLEY_NON_NULL(3) - bool sax_parse(const input_format_t format, - json_sax_t* sax_, - const bool strict = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + bool sax_parse(const input_format_t format, json_sax_t* sax_, const bool strict = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) { sax = sax_; bool result = false; @@ -9125,7 +12276,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(current != char_traits::eof())) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(110, + chars_read, + exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), + nullptr)); } } @@ -9201,7 +12358,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(len < 1)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), + nullptr)); } return get_string(input_format_t::bson, len - static_cast(1), result) && get() != char_traits::eof(); @@ -9222,7 +12385,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(len < 0)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, concat("byte array length cannot be negative, is ", std::to_string(len)), "binary"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format_t::bson, concat("byte array length cannot be negative, is ", std::to_string(len)), "binary"), + nullptr)); } // All BSON binary values have a subtype @@ -9243,8 +12412,7 @@ class binary_reader Unsupported BSON record type 0x... @return whether a valid BSON-object/array was passed to the SAX parser */ - bool parse_bson_element_internal(const char_int_type element_type, - const std::size_t element_type_parse_position) + bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position) { switch (element_type) { @@ -9303,9 +12471,14 @@ class binary_reader default: // anything else not supported (yet) { std::array cr{{}}; - static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast((std::snprintf)(cr.data(), + cr.size(), + "%.2hhX", + static_cast(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) const std::string cr_str{cr.data()}; - return sax->parse_error(element_type_parse_position, cr_str, parse_error::create(114, element_type_parse_position, concat("Unsupported BSON record type 0x", cr_str), nullptr)); + return sax->parse_error(element_type_parse_position, + cr_str, + parse_error::create(114, element_type_parse_position, concat("Unsupported BSON record type 0x", cr_str), nullptr)); } } } @@ -9390,8 +12563,7 @@ class binary_reader @return whether a valid CBOR value was passed to the SAX parser */ - bool parse_cbor_internal(const bool get_char, - const cbor_tag_handler_t tag_handler) + bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler) { switch (get_char ? get() : current) { @@ -9498,7 +12670,8 @@ class binary_reader case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) { std::uint64_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - static_cast(number)); + return get_number(input_format_t::cbor, number) && + sax->number_integer(static_cast(-1) - static_cast(number)); } // Binary data (0x00..0x17 bytes follow) @@ -9596,9 +12769,7 @@ class binary_reader case 0x95: case 0x96: case 0x97: - return get_cbor_array( - conditional_static_cast(static_cast(current) & 0x1Fu), - tag_handler); + return get_cbor_array(conditional_static_cast(static_cast(current) & 0x1Fu), tag_handler); case 0x98: // array (one-byte uint8_t for n follows) { @@ -9706,7 +12877,12 @@ class binary_reader case cbor_tag_handler_t::error: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); + return sax->parse_error(chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), + nullptr)); } case cbor_tag_handler_t::ignore: @@ -9835,17 +13011,12 @@ class binary_reader case 0: return std::ldexp(mant, -24); case 31: - return (mant == 0) - ? std::numeric_limits::infinity() - : std::numeric_limits::quiet_NaN(); + return (mant == 0) ? std::numeric_limits::infinity() : std::numeric_limits::quiet_NaN(); default: return std::ldexp(mant + 1024, exp - 25); } }(); - return sax->number_float((half & 0x8000u) != 0 - ? static_cast(-val) - : static_cast(val), - ""); + return sax->number_float((half & 0x8000u) != 0 ? static_cast(-val) : static_cast(val), ""); } case 0xFA: // Single-Precision Float (four-byte IEEE 754) @@ -9863,7 +13034,10 @@ class binary_reader default: // anything else (0xFF is handled inside the other types) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); } } } @@ -9958,7 +13132,16 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, concat("expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token), "string"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create( + 113, + chars_read, + exception_message(input_format_t::cbor, + concat("expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token), + "string"), + nullptr)); } } } @@ -10015,29 +13198,25 @@ class binary_reader case 0x58: // Binary data (one-byte uint8_t for n follows) { std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } case 0x59: // Binary data (two-byte uint16_t for n follow) { std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } case 0x5A: // Binary data (four-byte uint32_t for n follow) { std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } case 0x5B: // Binary data (eight-byte uint64_t for n follow) { std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); + return get_number(input_format_t::cbor, len) && get_binary(input_format_t::cbor, len, result); } case 0x5F: // Binary data (indefinite length) @@ -10057,7 +13236,16 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, concat("expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token), "binary"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create( + 113, + chars_read, + exception_message(input_format_t::cbor, + concat("expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token), + "binary"), + nullptr)); } } } @@ -10068,8 +13256,7 @@ class binary_reader @param[in] tag_handler how CBOR tags should be treated @return whether array creation completed */ - bool get_cbor_array(const std::size_t len, - const cbor_tag_handler_t tag_handler) + bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler) { if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) { @@ -10106,8 +13293,7 @@ class binary_reader @param[in] tag_handler how CBOR tags should be treated @return whether object creation completed */ - bool get_cbor_object(const std::size_t len, - const cbor_tag_handler_t tag_handler) + bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler) { if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) { @@ -10527,7 +13713,10 @@ class binary_reader default: // anything else { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, concat("invalid byte: 0x", last_token), "value"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, concat("invalid byte: 0x", last_token), "value"), nullptr)); } } } @@ -10609,7 +13798,15 @@ class binary_reader default: { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, concat("expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token), "string"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(113, + chars_read, + exception_message(input_format_t::msgpack, + concat("expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token), + "string"), + nullptr)); } } } @@ -10637,92 +13834,73 @@ class binary_reader case 0xC4: // bin 8 { std::uint8_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); + return get_number(input_format_t::msgpack, len) && get_binary(input_format_t::msgpack, len, result); } case 0xC5: // bin 16 { std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); + return get_number(input_format_t::msgpack, len) && get_binary(input_format_t::msgpack, len, result); } case 0xC6: // bin 32 { std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); + return get_number(input_format_t::msgpack, len) && get_binary(input_format_t::msgpack, len, result); } case 0xC7: // ext 8 { std::uint8_t len{}; std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, len) && get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && assign_and_return_true(subtype); } case 0xC8: // ext 16 { std::uint16_t len{}; std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, len) && get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && assign_and_return_true(subtype); } case 0xC9: // ext 32 { std::uint32_t len{}; std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, len) && get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && assign_and_return_true(subtype); } case 0xD4: // fixext 1 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 1, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 1, result) && assign_and_return_true(subtype); } case 0xD5: // fixext 2 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 2, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 2, result) && assign_and_return_true(subtype); } case 0xD6: // fixext 4 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 4, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 4, result) && assign_and_return_true(subtype); } case 0xD7: // fixext 8 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 8, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 8, result) && assign_and_return_true(subtype); } case 0xD8: // fixext 16 { std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 16, result) && - assign_and_return_true(subtype); + return get_number(input_format_t::msgpack, subtype) && get_binary(input_format_t::msgpack, 16, result) && assign_and_return_true(subtype); } default: // LCOV_EXCL_LINE @@ -11001,7 +14179,12 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } result = static_cast(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char return true; @@ -11016,7 +14199,12 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } result = static_cast(number); return true; @@ -11031,7 +14219,12 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } result = static_cast(number); return true; @@ -11046,11 +14239,18 @@ class binary_reader } if (number < 0) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + parse_error::create(113, + chars_read, + exception_message(input_format, "count in an optimized container must be positive", "size"), + nullptr)); } if (!value_in_range_of(number)) { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "integer value overflow", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + out_of_range::create(408, exception_message(input_format, "integer value overflow", "size"), nullptr)); } result = static_cast(number); return true; @@ -11099,7 +14299,9 @@ class binary_reader } if (!value_in_range_of(number)) { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "integer value overflow", "size"), nullptr)); + return sax->parse_error(chars_read, + get_token_string(), + out_of_range::create(408, exception_message(input_format, "integer value overflow", "size"), nullptr)); } result = detail::conditional_static_cast(number); return true; @@ -11113,7 +14315,10 @@ class binary_reader } if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr)); } std::vector dim; if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim))) @@ -11145,9 +14350,14 @@ class binary_reader for (auto i : dim) { result *= i; - if (result == 0 || result == npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be npos as it is used to initialize size in get_ubjson_size_type() + if (result == 0 || + result == + npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be npos as it is used to initialize size in get_ubjson_size_type() { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(static_cast(i)))) { @@ -11200,10 +14410,17 @@ class binary_reader if (current == '$') { result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (input_format == input_format_t::bjdata && JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second))) + if (input_format == input_format_t::bjdata && + JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second))) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, concat("marker 0x", last_token, " is not a permitted optimized array type"), "type"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format, concat("marker 0x", last_token, " is not a permitted optimized array type"), "type"), + nullptr)); } if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "type"))) @@ -11219,7 +14436,13 @@ class binary_reader return false; } auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), + nullptr)); } const bool is_error = get_ubjson_size_value(result.first, is_ndarray); @@ -11227,7 +14450,10 @@ class binary_reader { if (inside_ndarray) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, exception_message(input_format, "ndarray can not be recursive", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(112, chars_read, exception_message(input_format, "ndarray can not be recursive", "size"), nullptr)); } result.second |= (1 << 8); // use bit 8 to indicate ndarray, all UBJSON and BJData markers should be ASCII letters } @@ -11239,7 +14465,10 @@ class binary_reader const bool is_error = get_ubjson_size_value(result.first, is_ndarray); if (input_format == input_format_t::bjdata && is_ndarray) { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, exception_message(input_format, "ndarray requires both type and size", "size"), nullptr)); + return sax->parse_error( + chars_read, + get_token_string(), + parse_error::create(112, chars_read, exception_message(input_format, "ndarray requires both type and size", "size"), nullptr)); } return is_error; } @@ -11365,17 +14594,12 @@ class binary_reader case 0: return std::ldexp(mant, -24); case 31: - return (mant == 0) - ? std::numeric_limits::infinity() - : std::numeric_limits::quiet_NaN(); + return (mant == 0) ? std::numeric_limits::infinity() : std::numeric_limits::quiet_NaN(); default: return std::ldexp(mant + 1024, exp - 25); } }(); - return sax->number_float((half & 0x8000u) != 0 - ? static_cast(-val) - : static_cast(val), - ""); + return sax->number_float((half & 0x8000u) != 0 ? static_cast(-val) : static_cast(val), ""); } case 'd': @@ -11405,7 +14629,14 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(current > 127)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, concat("byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token), "char"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create( + 113, + chars_read, + exception_message(input_format, concat("byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token), "char"), + nullptr)); } string_t s(1, static_cast(current)); return sax->string(s); @@ -11427,7 +14658,9 @@ class binary_reader break; } auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "value"), nullptr)); + return sax->parse_error(chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "value"), nullptr)); } /*! @@ -11454,7 +14687,10 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(it == bjd_types_map.end() || it->first != size_and_type.second)) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr)); } string_t type = it->second; // sax->string() takes a reference @@ -11551,7 +14787,13 @@ class binary_reader if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0) { auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, "BJData object does not support ND-array size in optimized format", "object"), nullptr)); + return sax->parse_error( + chars_read, + last_token, + parse_error::create(112, + chars_read, + exception_message(input_format, "BJData object does not support ND-array size in optimized format", "object"), + nullptr)); } string_t key; @@ -11655,7 +14897,13 @@ class binary_reader if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input)) { - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); + return sax->parse_error( + chars_read, + number_string, + parse_error::create(115, + chars_read, + exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), + nullptr)); } switch (result_number) @@ -11681,7 +14929,14 @@ class binary_reader case token_type::end_of_input: case token_type::literal_or_value: default: - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); + return sax->parse_error( + chars_read, + number_string, + parse_error::create( + 115, + chars_read, + exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), + nullptr)); } } @@ -11776,9 +15031,7 @@ class binary_reader the input before we run out of string memory. */ template - bool get_string(const input_format_t format, - const NumberType len, - string_t& result) + bool get_string(const input_format_t format, const NumberType len, string_t& result) { bool success = true; for (NumberType i = 0; i < len; i++) @@ -11809,9 +15062,7 @@ class binary_reader the input before we run out of memory. */ template - bool get_binary(const input_format_t format, - const NumberType len, - binary_t& result) + bool get_binary(const input_format_t format, const NumberType len, binary_t& result) { bool success = true; for (NumberType i = 0; i < len; i++) @@ -11837,7 +15088,9 @@ class binary_reader { if (JSON_HEDLEY_UNLIKELY(current == char_traits::eof())) { - return sax->parse_error(chars_read, "", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr)); + return sax->parse_error(chars_read, + "", + parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr)); } return true; } @@ -11848,7 +15101,8 @@ class binary_reader std::string get_token_string() const { std::array cr{{}}; - static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast( + (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) return std::string{cr.data()}; } @@ -11858,9 +15112,7 @@ class binary_reader @param[in] context further context information @return a message string to use in the parse_error exceptions */ - std::string exception_message(const input_format_t format, - const std::string& detail, - const std::string& context) const + std::string exception_message(const input_format_t format, const std::string& detail, const std::string& context) const { std::string error_msg = "syntax error while parsing "; @@ -11916,33 +15168,29 @@ class binary_reader json_sax_t* sax = nullptr; // excluded markers in bjdata optimized type -#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \ - make_array('F', 'H', 'N', 'S', 'T', 'Z', '[', '{') - -#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \ - make_array( \ - bjd_type{'C', "char"}, \ - bjd_type{'D', "double"}, \ - bjd_type{'I', "int16"}, \ - bjd_type{'L', "int64"}, \ - bjd_type{'M', "uint64"}, \ - bjd_type{'U', "uint8"}, \ - bjd_type{'d', "single"}, \ - bjd_type{'i', "int8"}, \ - bjd_type{'l', "int32"}, \ - bjd_type{'m', "uint32"}, \ - bjd_type{'u', "uint16"}) +#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ make_array('F', 'H', 'N', 'S', 'T', 'Z', '[', '{') + +#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \ + make_array(bjd_type{'C', "char"}, \ + bjd_type{'D', "double"}, \ + bjd_type{'I', "int16"}, \ + bjd_type{'L', "int64"}, \ + bjd_type{'M', "uint64"}, \ + bjd_type{'U', "uint8"}, \ + bjd_type{'d', "single"}, \ + bjd_type{'i', "int8"}, \ + bjd_type{'l', "int32"}, \ + bjd_type{'m', "uint32"}, \ + bjd_type{'u', "uint16"}) JSON_PRIVATE_UNLESS_TESTED : // lookup tables // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) - const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers = - JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_; + const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers = JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_; using bjd_type = std::pair; // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) - const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) bjd_types_map = - JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_; + const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) bjd_types_map = JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_; #undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ #undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ @@ -11993,7 +15241,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ //////////// // parser // //////////// @@ -12015,8 +15264,7 @@ enum class parse_event_t : std::uint8_t }; template -using parser_callback_t = - std::function; +using parser_callback_t = std::function; /*! @brief syntax analysis @@ -12178,9 +15426,10 @@ class parser // parse key if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) { @@ -12190,9 +15439,10 @@ class parser // parse separator (:) if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); } // remember we are now inside an object @@ -12303,22 +15553,28 @@ class parser case token_type::parse_error: { // using "uninitialized" to avoid "expected" message - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr)); } case token_type::end_of_input: { if (JSON_HEDLEY_UNLIKELY(m_lexer.get_position().chars_read_total == 1)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), "attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, + m_lexer.get_position(), + "attempting to parse an empty input; check that your input string or stream contains the expected JSON", + nullptr)); } - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); } case token_type::uninitialized: case token_type::end_array: @@ -12328,9 +15584,10 @@ class parser case token_type::literal_or_value: default: // the last token was unexpected { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); } } } @@ -12387,9 +15644,10 @@ class parser // parse key if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); } if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) @@ -12400,9 +15658,10 @@ class parser // parse separator (:) if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); + return sax->parse_error( + m_lexer.get_position(), + m_lexer.get_token_string(), + parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); } // parse values @@ -12508,7 +15767,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /* @brief an iterator for primitive JSON types @@ -12625,7 +15885,8 @@ class primitive_iterator_t NLOHMANN_JSON_NAMESPACE_END NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /*! @brief an iterator value @@ -12674,7 +15935,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ // forward declare, to be able to friend it later on template @@ -12702,7 +15964,8 @@ template class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) { /// the iterator with BasicJsonType of different const-ness - using other_iter_impl = iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; + using other_iter_impl = + iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; /// allow basic_json to access private members friend other_iter_impl; friend BasicJsonType; @@ -12712,10 +15975,10 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec using object_t = typename BasicJsonType::object_t; using array_t = typename BasicJsonType::array_t; // make sure BasicJsonType is basic_json or const basic_json - static_assert(is_basic_json::type>::value, - "iter_impl only accepts (const) basic_json"); + static_assert(is_basic_json::type>::value, "iter_impl only accepts (const) basic_json"); // superficial check for the LegacyBidirectionalIterator named requirement - static_assert(std::is_base_of::value && std::is_base_of::iterator_category>::value, + static_assert(std::is_base_of::value && + std::is_base_of::iterator_category>::value, "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement."); public: @@ -12731,14 +15994,11 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// a type to represent differences between iterators using difference_type = typename BasicJsonType::difference_type; /// defines a pointer to the type iterated over (value_type) - using pointer = typename std::conditional::value, - typename BasicJsonType::const_pointer, - typename BasicJsonType::pointer>::type; + using pointer = + typename std::conditional::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer>::type; /// defines a reference to the type iterated over (value_type) using reference = - typename std::conditional::value, - typename BasicJsonType::const_reference, - typename BasicJsonType::reference>::type; + typename std::conditional::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference>::type; iter_impl() = default; ~iter_impl() = default; @@ -13123,7 +16383,8 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec @brief comparison: equal @pre The iterator is initialized; i.e. `m_object != nullptr`. */ - template::value || std::is_same::value), std::nullptr_t> = nullptr> + template::value || std::is_same::value), std::nullptr_t> = nullptr> bool operator==(const IterImpl& other) const { // if objects are not the same, the comparison is undefined @@ -13159,7 +16420,8 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec @brief comparison: not equal @pre The iterator is initialized; i.e. `m_object != nullptr`. */ - template::value || std::is_same::value), std::nullptr_t> = nullptr> + template::value || std::is_same::value), std::nullptr_t> = nullptr> bool operator!=(const IterImpl& other) const { return !operator==(other); @@ -13426,7 +16688,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ ////////////////////// // reverse_iterator // @@ -13558,7 +16821,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /*! @brief Default base class of the @ref basic_json class. @@ -13574,10 +16838,7 @@ struct json_default_base {}; template -using json_base_class = typename std::conditional< - std::is_same::value, - json_default_base, - T>::type; +using json_base_class = typename std::conditional::value, json_default_base, T>::type; } // namespace detail NLOHMANN_JSON_NAMESPACE_END @@ -13681,9 +16942,7 @@ class json_pointer /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ json_pointer& operator/=(const json_pointer& ptr) { - reference_tokens.insert(reference_tokens.end(), - ptr.reference_tokens.begin(), - ptr.reference_tokens.end()); + reference_tokens.insert(reference_tokens.end(), ptr.reference_tokens.begin(), ptr.reference_tokens.end()); return *this; } @@ -13704,8 +16963,7 @@ class json_pointer /// @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ - friend json_pointer operator/(const json_pointer& lhs, - const json_pointer& rhs) + friend json_pointer operator/(const json_pointer& lhs, const json_pointer& rhs) { return json_pointer(lhs) /= rhs; } @@ -13942,15 +17200,12 @@ class json_pointer if (ptr->is_null()) { // check if reference token is a number - const bool nums = - std::all_of(reference_token.begin(), reference_token.end(), [](const unsigned char x) { - return std::isdigit(x); - }); + const bool nums = std::all_of(reference_token.begin(), reference_token.end(), [](const unsigned char x) { + return std::isdigit(x); + }); // change value to array for numbers or "-" or to object otherwise - *ptr = (nums || reference_token == "-") - ? detail::value_t::array - : detail::value_t::object; + *ptr = (nums || reference_token == "-") ? detail::value_t::array : detail::value_t::object; } switch (ptr->type()) @@ -14018,7 +17273,10 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), ptr)); + JSON_THROW(detail::out_of_range::create( + 402, + detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), + ptr)); } // note: at performs range check @@ -14074,7 +17332,10 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" cannot be used for const access - JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), ptr)); + JSON_THROW(detail::out_of_range::create( + 402, + detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), + ptr)); } // use unchecked array access @@ -14123,7 +17384,10 @@ class json_pointer if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), ptr)); + JSON_THROW(detail::out_of_range::create( + 402, + detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), + ptr)); } // note: at performs range check @@ -14253,7 +17517,8 @@ class json_pointer // check if nonempty reference string begins with slash if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) { - JSON_THROW(detail::parse_error::create(107, 1, detail::concat("JSON pointer must be empty or begin with '/' - was: '", reference_string, "'"), nullptr)); + JSON_THROW( + detail::parse_error::create(107, 1, detail::concat("JSON pointer must be empty or begin with '/' - was: '", reference_string, "'"), nullptr)); } // extract the reference tokens: @@ -14277,16 +17542,12 @@ class json_pointer auto reference_token = reference_string.substr(start, slash - start); // check reference tokens are properly escaped - for (std::size_t pos = reference_token.find_first_of('~'); - pos != string_t::npos; - pos = reference_token.find_first_of('~', pos + 1)) + for (std::size_t pos = reference_token.find_first_of('~'); pos != string_t::npos; pos = reference_token.find_first_of('~', pos + 1)) { JSON_ASSERT(reference_token[pos] == '~'); // ~ must be followed by 0 or 1 - if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || - (reference_token[pos + 1] != '0' && - reference_token[pos + 1] != '1'))) + if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || (reference_token[pos + 1] != '0' && reference_token[pos + 1] != '1'))) { JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", nullptr)); } @@ -14309,9 +17570,7 @@ class json_pointer @note Empty objects or arrays are flattened to `null`. */ template - static void flatten(const string_t& reference_string, - const BasicJsonType& value, - BasicJsonType& result) + static void flatten(const string_t& reference_string, const BasicJsonType& value, BasicJsonType& result) { switch (value.type()) { @@ -14327,9 +17586,7 @@ class json_pointer // iterate array and use index as reference string for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i) { - flatten(detail::concat(reference_string, '/', std::to_string(i)), - value.m_data.m_value.array->operator[](i), - result); + flatten(detail::concat(reference_string, '/', std::to_string(i)), value.m_data.m_value.array->operator[](i), result); } } break; @@ -14381,8 +17638,7 @@ class json_pointer @throw type_error.313 if value cannot be unflattened */ template - static BasicJsonType - unflatten(const BasicJsonType& value) + static BasicJsonType unflatten(const BasicJsonType& value) { if (JSON_HEDLEY_UNLIKELY(!value.is_object())) { @@ -14444,7 +17700,7 @@ class json_pointer /// @brief 3-way compares two JSON pointers template - std::strong_ordering operator<=> (const json_pointer& rhs) const noexcept // *NOPAD* + std::strong_ordering operator<=>(const json_pointer& rhs) const noexcept // *NOPAD* { return reference_tokens <=> rhs.reference_tokens; // *NOPAD* } @@ -14453,49 +17709,42 @@ class json_pointer /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const json_pointer& lhs, - const json_pointer& rhs) noexcept; + friend bool operator==(const json_pointer& lhs, const json_pointer& rhs) noexcept; /// @brief compares JSON pointer and string for equality /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const json_pointer& lhs, - const StringType& rhs); + friend bool operator==(const json_pointer& lhs, const StringType& rhs); /// @brief compares string and JSON pointer for equality /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const StringType& lhs, - const json_pointer& rhs); + friend bool operator==(const StringType& lhs, const json_pointer& rhs); /// @brief compares two JSON pointers for inequality /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const json_pointer& lhs, - const json_pointer& rhs) noexcept; + friend bool operator!=(const json_pointer& lhs, const json_pointer& rhs) noexcept; /// @brief compares JSON pointer and string for inequality /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const json_pointer& lhs, - const StringType& rhs); + friend bool operator!=(const json_pointer& lhs, const StringType& rhs); /// @brief compares string and JSON pointer for inequality /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const StringType& lhs, - const json_pointer& rhs); + friend bool operator!=(const StringType& lhs, const json_pointer& rhs); /// @brief compares two JSON pointer for less-than template // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator<(const json_pointer& lhs, - const json_pointer& rhs) noexcept; + friend bool operator<(const json_pointer& lhs, const json_pointer& rhs) noexcept; #endif private: @@ -14506,58 +17755,47 @@ class json_pointer #if !JSON_HAS_THREE_WAY_COMPARISON // functions cannot be defined inside class due to ODR violations template -inline bool operator==(const json_pointer& lhs, - const json_pointer& rhs) noexcept +inline bool operator==(const json_pointer& lhs, const json_pointer& rhs) noexcept { return lhs.reference_tokens == rhs.reference_tokens; } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) -inline bool operator==(const json_pointer& lhs, - const StringType& rhs) +inline bool operator==(const json_pointer& lhs, const StringType& rhs) { return lhs == json_pointer(rhs); } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) -inline bool operator==(const StringType& lhs, - const json_pointer& rhs) +inline bool operator==(const StringType& lhs, const json_pointer& rhs) { return json_pointer(lhs) == rhs; } template -inline bool operator!=(const json_pointer& lhs, - const json_pointer& rhs) noexcept +inline bool operator!=(const json_pointer& lhs, const json_pointer& rhs) noexcept { return !(lhs == rhs); } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) -inline bool operator!=(const json_pointer& lhs, - const StringType& rhs) +inline bool operator!=(const json_pointer& lhs, const StringType& rhs) { return !(lhs == rhs); } -template::string_t> +template::string_t> JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) -inline bool operator!=(const StringType& lhs, - const json_pointer& rhs) +inline bool operator!=(const StringType& lhs, const json_pointer& rhs) { return !(lhs == rhs); } template -inline bool operator<(const json_pointer& lhs, - const json_pointer& rhs) noexcept +inline bool operator<(const json_pointer& lhs, const json_pointer& rhs) noexcept { return lhs.reference_tokens < rhs.reference_tokens; } @@ -14582,7 +17820,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ template class json_ref @@ -14602,9 +17841,7 @@ class json_ref : owned_value(init) {} - template< - class... Args, - enable_if_t::value, int> = 0> + template::value, int> = 0> json_ref(Args&&... args) : owned_value(std::forward(args)...) {} @@ -14697,7 +17934,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /// abstract output adapter interface template @@ -14826,7 +18064,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /////////////////// // binary writer // @@ -14899,9 +18138,7 @@ class binary_writer case value_t::boolean: { - oa->write_character(j.m_data.m_value.boolean - ? to_char_type(0xF5) - : to_char_type(0xF4)); + oa->write_character(j.m_data.m_value.boolean ? to_char_type(0xF5) : to_char_type(0xF4)); break; } @@ -15054,9 +18291,7 @@ class binary_writer // LCOV_EXCL_STOP // step 2: write the string - oa->write_characters( - reinterpret_cast(j.m_data.m_value.string->c_str()), - j.m_data.m_value.string->size()); + oa->write_characters(reinterpret_cast(j.m_data.m_value.string->c_str()), j.m_data.m_value.string->size()); break; } @@ -15155,9 +18390,7 @@ class binary_writer // LCOV_EXCL_STOP // step 2: write each element - oa->write_characters( - reinterpret_cast(j.m_data.m_value.binary->data()), - N); + oa->write_characters(reinterpret_cast(j.m_data.m_value.binary->data()), N); break; } @@ -15223,9 +18456,7 @@ class binary_writer case value_t::boolean: // true and false { - oa->write_character(j.m_data.m_value.boolean - ? to_char_type(0xC3) - : to_char_type(0xC2)); + oa->write_character(j.m_data.m_value.boolean ? to_char_type(0xC3) : to_char_type(0xC2)); break; } @@ -15374,9 +18605,7 @@ class binary_writer } // step 2: write the string - oa->write_characters( - reinterpret_cast(j.m_data.m_value.string->c_str()), - j.m_data.m_value.string->size()); + oa->write_characters(reinterpret_cast(j.m_data.m_value.string->c_str()), j.m_data.m_value.string->size()); break; } @@ -15461,18 +18690,16 @@ class binary_writer } else if (N <= (std::numeric_limits::max)()) { - const std::uint8_t output_type = use_ext - ? 0xC8 // ext 16 - : 0xC5; // bin 16 + const std::uint8_t output_type = use_ext ? 0xC8 // ext 16 + : 0xC5; // bin 16 oa->write_character(to_char_type(output_type)); write_number(static_cast(N)); } else if (N <= (std::numeric_limits::max)()) { - const std::uint8_t output_type = use_ext - ? 0xC9 // ext 32 - : 0xC6; // bin 32 + const std::uint8_t output_type = use_ext ? 0xC9 // ext 32 + : 0xC6; // bin 32 oa->write_character(to_char_type(output_type)); write_number(static_cast(N)); @@ -15485,9 +18712,7 @@ class binary_writer } // step 2: write the byte string - oa->write_characters( - reinterpret_cast(j.m_data.m_value.binary->data()), - N); + oa->write_characters(reinterpret_cast(j.m_data.m_value.binary->data()), N); break; } @@ -15553,9 +18778,7 @@ class binary_writer { if (add_prefix) { - oa->write_character(j.m_data.m_value.boolean - ? to_char_type('T') - : to_char_type('F')); + oa->write_character(j.m_data.m_value.boolean ? to_char_type('T') : to_char_type('F')); } break; } @@ -15585,9 +18808,7 @@ class binary_writer oa->write_character(to_char_type('S')); } write_number_with_ubjson_prefix(j.m_data.m_value.string->size(), true, use_bjdata); - oa->write_characters( - reinterpret_cast(j.m_data.m_value.string->c_str()), - j.m_data.m_value.string->size()); + oa->write_characters(reinterpret_cast(j.m_data.m_value.string->c_str()), j.m_data.m_value.string->size()); break; } @@ -15658,9 +18879,7 @@ class binary_writer if (use_type) { - oa->write_characters( - reinterpret_cast(j.m_data.m_value.binary->data()), - j.m_data.m_value.binary->size()); + oa->write_characters(reinterpret_cast(j.m_data.m_value.binary->data()), j.m_data.m_value.binary->size()); } else { @@ -15681,9 +18900,13 @@ class binary_writer case value_t::object: { - if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find("_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find("_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find("_ArrayData_") != j.m_data.m_value.object->end()) + if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find("_ArrayType_") != j.m_data.m_value.object->end() && + j.m_data.m_value.object->find("_ArraySize_") != j.m_data.m_value.object->end() && + j.m_data.m_value.object->find("_ArrayData_") != j.m_data.m_value.object->end()) { - if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type)) // decode bjdata ndarray in the JData format (https://github.com/NeuroJSON/jdata) + if (!write_bjdata_ndarray(*j.m_data.m_value.object, + use_count, + use_type)) // decode bjdata ndarray in the JData format (https://github.com/NeuroJSON/jdata) { break; } @@ -15722,9 +18945,7 @@ class binary_writer for (const auto& el : *j.m_data.m_value.object) { write_number_with_ubjson_prefix(el.first.size(), true, use_bjdata); - oa->write_characters( - reinterpret_cast(el.first.c_str()), - el.first.size()); + oa->write_characters(reinterpret_cast(el.first.c_str()), el.first.size()); write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata); } @@ -15766,20 +18987,16 @@ class binary_writer /*! @brief Writes the given @a element_type and @a name to the output adapter */ - void write_bson_entry_header(const string_t& name, - const std::uint8_t element_type) + void write_bson_entry_header(const string_t& name, const std::uint8_t element_type) { oa->write_character(to_char_type(element_type)); // boolean - oa->write_characters( - reinterpret_cast(name.c_str()), - name.size() + 1u); + oa->write_characters(reinterpret_cast(name.c_str()), name.size() + 1u); } /*! @brief Writes a BSON element with key @a name and boolean value @a value */ - void write_bson_boolean(const string_t& name, - const bool value) + void write_bson_boolean(const string_t& name, const bool value) { write_bson_entry_header(name, 0x08); oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00)); @@ -15788,8 +19005,7 @@ class binary_writer /*! @brief Writes a BSON element with key @a name and double value @a value */ - void write_bson_double(const string_t& name, - const double value) + void write_bson_double(const string_t& name, const double value) { write_bson_entry_header(name, 0x01); write_number(value, true); @@ -15806,15 +19022,12 @@ class binary_writer /*! @brief Writes a BSON element with key @a name and string value @a value */ - void write_bson_string(const string_t& name, - const string_t& value) + void write_bson_string(const string_t& name, const string_t& value) { write_bson_entry_header(name, 0x02); write_number(static_cast(value.size() + 1ul), true); - oa->write_characters( - reinterpret_cast(value.c_str()), - value.size() + 1); + oa->write_characters(reinterpret_cast(value.c_str()), value.size() + 1); } /*! @@ -15830,16 +19043,14 @@ class binary_writer */ static std::size_t calc_bson_integer_size(const std::int64_t value) { - return (std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)() - ? sizeof(std::int32_t) - : sizeof(std::int64_t); + return (std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)() ? sizeof(std::int32_t) + : sizeof(std::int64_t); } /*! @brief Writes a BSON element with key @a name and integer @a value */ - void write_bson_integer(const string_t& name, - const std::int64_t value) + void write_bson_integer(const string_t& name, const std::int64_t value) { if ((std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)()) { @@ -15858,16 +19069,13 @@ class binary_writer */ static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept { - return (value <= static_cast((std::numeric_limits::max)())) - ? sizeof(std::int32_t) - : sizeof(std::int64_t); + return (value <= static_cast((std::numeric_limits::max)())) ? sizeof(std::int32_t) : sizeof(std::int64_t); } /*! @brief Writes a BSON element with key @a name and unsigned @a value */ - void write_bson_unsigned(const string_t& name, - const BasicJsonType& j) + void write_bson_unsigned(const string_t& name, const BasicJsonType& j) { if (j.m_data.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { @@ -15881,15 +19089,17 @@ class binary_writer } else { - JSON_THROW(out_of_range::create(407, concat("integer number ", std::to_string(j.m_data.m_value.number_unsigned), " cannot be represented by BSON as it does not fit int64"), &j)); + JSON_THROW(out_of_range::create( + 407, + concat("integer number ", std::to_string(j.m_data.m_value.number_unsigned), " cannot be represented by BSON as it does not fit int64"), + &j)); } } /*! @brief Writes a BSON element with key @a name and object @a value */ - void write_bson_object_entry(const string_t& name, - const typename BasicJsonType::object_t& value) + void write_bson_object_entry(const string_t& name, const typename BasicJsonType::object_t& value) { write_bson_entry_header(name, 0x03); // object write_bson_object(value); @@ -15902,9 +19112,12 @@ class binary_writer { std::size_t array_index = 0ul; - const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), static_cast(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type& el) { - return result + calc_bson_element_size(std::to_string(array_index++), el); - }); + const std::size_t embedded_document_size = std::accumulate(std::begin(value), + std::end(value), + static_cast(0), + [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type& el) { + return result + calc_bson_element_size(std::to_string(array_index++), el); + }); return sizeof(std::int32_t) + embedded_document_size + 1ul; } @@ -15920,8 +19133,7 @@ class binary_writer /*! @brief Writes a BSON element with key @a name and array @a value */ - void write_bson_array(const string_t& name, - const typename BasicJsonType::array_t& value) + void write_bson_array(const string_t& name, const typename BasicJsonType::array_t& value) { write_bson_entry_header(name, 0x04); // array write_number(static_cast(calc_bson_array_size(value)), true); @@ -15939,8 +19151,7 @@ class binary_writer /*! @brief Writes a BSON element with key @a name and binary value @a value */ - void write_bson_binary(const string_t& name, - const binary_t& value) + void write_bson_binary(const string_t& name, const binary_t& value) { write_bson_entry_header(name, 0x05); @@ -15954,8 +19165,7 @@ class binary_writer @brief Calculates the size necessary to serialize the JSON value @a j with its @a name @return The calculated size for the BSON document entry for @a j with the given @a name. */ - static std::size_t calc_bson_element_size(const string_t& name, - const BasicJsonType& j) + static std::size_t calc_bson_element_size(const string_t& name, const BasicJsonType& j) { const auto header_size = calc_bson_entry_header_size(name, j); switch (j.type()) @@ -16002,8 +19212,7 @@ class binary_writer @param name The name to associate with the JSON entity @a j within the current BSON document */ - void write_bson_element(const string_t& name, - const BasicJsonType& j) + void write_bson_element(const string_t& name, const BasicJsonType& j) { switch (j.type()) { @@ -16051,9 +19260,10 @@ class binary_writer */ static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value) { - const std::size_t document_size = std::accumulate(value.begin(), value.end(), static_cast(0), [](size_t result, const typename BasicJsonType::object_t::value_type& el) { - return result += calc_bson_element_size(el.first, el.second); - }); + const std::size_t document_size = + std::accumulate(value.begin(), value.end(), static_cast(0), [](size_t result, const typename BasicJsonType::object_t::value_type& el) { + return result += calc_bson_element_size(el.first, el.second); + }); return sizeof(std::int32_t) + document_size + 1ul; } @@ -16108,9 +19318,7 @@ class binary_writer // UBJSON: write number (floating point) template::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix, - const bool use_bjdata) + void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata) { if (add_prefix) { @@ -16121,9 +19329,7 @@ class binary_writer // UBJSON: write number (unsigned integer) template::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix, - const bool use_bjdata) + void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata) { if (n <= static_cast((std::numeric_limits::max)())) { @@ -16207,9 +19413,7 @@ class binary_writer // UBJSON: write number (signed integer) template::value && !std::is_floating_point::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix, - const bool use_bjdata) + void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata) { if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) { @@ -16219,7 +19423,8 @@ class binary_writer } write_number(static_cast(n), use_bjdata); } - else if (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)())) + else if (static_cast((std::numeric_limits::min)()) <= n && + n <= static_cast((std::numeric_limits::max)())) { if (add_prefix) { @@ -16235,7 +19440,8 @@ class binary_writer } write_number(static_cast(n), use_bjdata); } - else if (use_bjdata && (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) + else if (use_bjdata && (static_cast((std::numeric_limits::min)()) <= n && + n <= static_cast((std::numeric_limits::max)()))) { if (add_prefix) { @@ -16251,7 +19457,8 @@ class binary_writer } write_number(static_cast(n), use_bjdata); } - else if (use_bjdata && (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) + else if (use_bjdata && (static_cast((std::numeric_limits::min)()) <= n && + n <= static_cast((std::numeric_limits::max)()))) { if (add_prefix) { @@ -16300,31 +19507,38 @@ class binary_writer case value_t::number_integer: { - if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) + if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) { return 'i'; } - if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) + if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) { return 'U'; } - if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) + if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) { return 'I'; } - if (use_bjdata && ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)())) + if (use_bjdata && ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)())) { return 'u'; } - if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) + if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) { return 'l'; } - if (use_bjdata && ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)())) + if (use_bjdata && ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)())) { return 'm'; } - if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) + if ((std::numeric_limits::min)() <= j.m_data.m_value.number_integer && + j.m_data.m_value.number_integer <= (std::numeric_limits::max)()) { return 'L'; } @@ -16404,7 +19618,17 @@ class binary_writer */ bool write_bjdata_ndarray(const typename BasicJsonType::object_t& value, const bool use_count, const bool use_type) { - std::map bjdtype = {{"uint8", 'U'}, {"int8", 'i'}, {"uint16", 'u'}, {"int16", 'I'}, {"uint32", 'm'}, {"int32", 'l'}, {"uint64", 'M'}, {"int64", 'L'}, {"single", 'd'}, {"double", 'D'}, {"char", 'C'}}; + std::map bjdtype = {{"uint8", 'U'}, + {"int8", 'i'}, + {"uint16", 'u'}, + {"int16", 'I'}, + {"uint32", 'm'}, + {"int32", 'l'}, + {"uint64", 'M'}, + {"int64", 'L'}, + {"single", 'd'}, + {"double", 'D'}, + {"char", 'C'}}; string_t key = "_ArrayType_"; auto it = bjdtype.find(static_cast(value.at(key))); @@ -16553,16 +19777,13 @@ class binary_writer static_cast(n) <= static_cast((std::numeric_limits::max)()) && static_cast(static_cast(n)) == static_cast(n)) { - oa->write_character(format == detail::input_format_t::cbor - ? get_cbor_float_prefix(static_cast(n)) - : get_msgpack_float_prefix(static_cast(n))); + oa->write_character(format == detail::input_format_t::cbor ? get_cbor_float_prefix(static_cast(n)) + : get_msgpack_float_prefix(static_cast(n))); write_number(static_cast(n)); } else { - oa->write_character(format == detail::input_format_t::cbor - ? get_cbor_float_prefix(n) - : get_msgpack_float_prefix(n)); + oa->write_character(format == detail::input_format_t::cbor ? get_cbor_float_prefix(n) : get_msgpack_float_prefix(n)); write_number(n); } #ifdef __GNUC__ @@ -16575,15 +19796,13 @@ class binary_writer // between uint8_t and CharType. In case CharType is not unsigned, // such a conversion is required to allow values greater than 128. // See for a discussion. - template::value && std::is_signed::value>* = nullptr> + template::value && std::is_signed::value>* = nullptr> static constexpr CharType to_char_type(std::uint8_t x) noexcept { return *reinterpret_cast(&x); } - template::value && std::is_unsigned::value>* = nullptr> + template::value && std::is_unsigned::value>* = nullptr> static CharType to_char_type(std::uint8_t x) noexcept { static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t"); @@ -16593,14 +19812,16 @@ class binary_writer return result; } - template::value>* = nullptr> + template::value>* = nullptr> static constexpr CharType to_char_type(std::uint8_t x) noexcept { return x; } - template::value && std::is_signed::value && std::is_same::type>::value>* = nullptr> + template::value && std::is_signed::value && std::is_same::type>::value>* = + nullptr> static constexpr CharType to_char_type(InputCharType x) noexcept { return x; @@ -16662,7 +19883,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /*! @brief implements the Grisu2 algorithm for binary to decimal floating-point @@ -16683,7 +19905,8 @@ For a detailed description of the algorithm see: Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language Design and Implementation, PLDI 1996 */ -namespace dtoa_impl { +namespace dtoa_impl +{ template Target reinterpret_bits(const Source source) @@ -16842,8 +20065,7 @@ boundaries compute_boundaries(FloatType value) // If v is normalized: // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1)) - static_assert(std::numeric_limits::is_iec559, - "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); + static_assert(std::numeric_limits::is_iec559, "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); constexpr int kPrecision = std::numeric_limits::digits; // = p (includes the hidden bit) constexpr int kBias = std::numeric_limits::max_exponent - 1 + (kPrecision - 1); @@ -16857,9 +20079,7 @@ boundaries compute_boundaries(FloatType value) const std::uint64_t F = bits & (kHiddenBit - 1); const bool is_denormal = E == 0; - const diyfp v = is_denormal - ? diyfp(F, kMinExp) - : diyfp(F + kHiddenBit, static_cast(E) - kBias); + const diyfp v = is_denormal ? diyfp(F, kMinExp) : diyfp(F + kHiddenBit, static_cast(E) - kBias); // Compute the boundaries m- and m+ of the floating-point value // v = f * 2^e. @@ -16884,9 +20104,8 @@ boundaries compute_boundaries(FloatType value) const bool lower_boundary_is_closer = F == 0 && E > 1; const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1); - const diyfp m_minus = lower_boundary_is_closer - ? diyfp(4 * v.f - 1, v.e - 2) // (B) - : diyfp(2 * v.f - 1, v.e - 1); // (A) + const diyfp m_minus = lower_boundary_is_closer ? diyfp(4 * v.f - 1, v.e - 2) // (B) + : diyfp(2 * v.f - 1, v.e - 1); // (A) // Determine the normalized w+ = m+. const diyfp w_plus = diyfp::normalize(m_plus); @@ -17024,89 +20243,28 @@ inline cached_power get_cached_power_for_binary_exponent(int e) constexpr int kCachedPowersMinDecExp = -300; constexpr int kCachedPowersDecStep = 8; - static constexpr std::array kCachedPowers = - { - { - {0xAB70FE17C79AC6CA, -1060, -300}, - {0xFF77B1FCBEBCDC4F, -1034, -292}, - {0xBE5691EF416BD60C, -1007, -284}, - {0x8DD01FAD907FFC3C, -980, -276}, - {0xD3515C2831559A83, -954, -268}, - {0x9D71AC8FADA6C9B5, -927, -260}, - {0xEA9C227723EE8BCB, -901, -252}, - {0xAECC49914078536D, -874, -244}, - {0x823C12795DB6CE57, -847, -236}, - {0xC21094364DFB5637, -821, -228}, - {0x9096EA6F3848984F, -794, -220}, - {0xD77485CB25823AC7, -768, -212}, - {0xA086CFCD97BF97F4, -741, -204}, - {0xEF340A98172AACE5, -715, -196}, - {0xB23867FB2A35B28E, -688, -188}, - {0x84C8D4DFD2C63F3B, -661, -180}, - {0xC5DD44271AD3CDBA, -635, -172}, - {0x936B9FCEBB25C996, -608, -164}, - {0xDBAC6C247D62A584, -582, -156}, - {0xA3AB66580D5FDAF6, -555, -148}, - {0xF3E2F893DEC3F126, -529, -140}, - {0xB5B5ADA8AAFF80B8, -502, -132}, - {0x87625F056C7C4A8B, -475, -124}, - {0xC9BCFF6034C13053, -449, -116}, - {0x964E858C91BA2655, -422, -108}, - {0xDFF9772470297EBD, -396, -100}, - {0xA6DFBD9FB8E5B88F, -369, -92}, - {0xF8A95FCF88747D94, -343, -84}, - {0xB94470938FA89BCF, -316, -76}, - {0x8A08F0F8BF0F156B, -289, -68}, - {0xCDB02555653131B6, -263, -60}, - {0x993FE2C6D07B7FAC, -236, -52}, - {0xE45C10C42A2B3B06, -210, -44}, - {0xAA242499697392D3, -183, -36}, - {0xFD87B5F28300CA0E, -157, -28}, - {0xBCE5086492111AEB, -130, -20}, - {0x8CBCCC096F5088CC, -103, -12}, - {0xD1B71758E219652C, -77, -4}, - {0x9C40000000000000, -50, 4}, - {0xE8D4A51000000000, -24, 12}, - {0xAD78EBC5AC620000, 3, 20}, - {0x813F3978F8940984, 30, 28}, - {0xC097CE7BC90715B3, 56, 36}, - {0x8F7E32CE7BEA5C70, 83, 44}, - {0xD5D238A4ABE98068, 109, 52}, - {0x9F4F2726179A2245, 136, 60}, - {0xED63A231D4C4FB27, 162, 68}, - {0xB0DE65388CC8ADA8, 189, 76}, - {0x83C7088E1AAB65DB, 216, 84}, - {0xC45D1DF942711D9A, 242, 92}, - {0x924D692CA61BE758, 269, 100}, - {0xDA01EE641A708DEA, 295, 108}, - {0xA26DA3999AEF774A, 322, 116}, - {0xF209787BB47D6B85, 348, 124}, - {0xB454E4A179DD1877, 375, 132}, - {0x865B86925B9BC5C2, 402, 140}, - {0xC83553C5C8965D3D, 428, 148}, - {0x952AB45CFA97A0B3, 455, 156}, - {0xDE469FBD99A05FE3, 481, 164}, - {0xA59BC234DB398C25, 508, 172}, - {0xF6C69A72A3989F5C, 534, 180}, - {0xB7DCBF5354E9BECE, 561, 188}, - {0x88FCF317F22241E2, 588, 196}, - {0xCC20CE9BD35C78A5, 614, 204}, - {0x98165AF37B2153DF, 641, 212}, - {0xE2A0B5DC971F303A, 667, 220}, - {0xA8D9D1535CE3B396, 694, 228}, - {0xFB9B7CD9A4A7443C, 720, 236}, - {0xBB764C4CA7A44410, 747, 244}, - {0x8BAB8EEFB6409C1A, 774, 252}, - {0xD01FEF10A657842C, 800, 260}, - {0x9B10A4E5E9913129, 827, 268}, - {0xE7109BFBA19C0C9D, 853, 276}, - {0xAC2820D9623BF429, 880, 284}, - {0x80444B5E7AA7CF85, 907, 292}, - {0xBF21E44003ACDD2D, 933, 300}, - {0x8E679C2F5E44FF8F, 960, 308}, - {0xD433179D9C8CB841, 986, 316}, - {0x9E19DB92B4E31BA9, 1013, 324}, - }}; + static constexpr std::array kCachedPowers = {{ + {0xAB70FE17C79AC6CA, -1060, -300}, {0xFF77B1FCBEBCDC4F, -1034, -292}, {0xBE5691EF416BD60C, -1007, -284}, {0x8DD01FAD907FFC3C, -980, -276}, + {0xD3515C2831559A83, -954, -268}, {0x9D71AC8FADA6C9B5, -927, -260}, {0xEA9C227723EE8BCB, -901, -252}, {0xAECC49914078536D, -874, -244}, + {0x823C12795DB6CE57, -847, -236}, {0xC21094364DFB5637, -821, -228}, {0x9096EA6F3848984F, -794, -220}, {0xD77485CB25823AC7, -768, -212}, + {0xA086CFCD97BF97F4, -741, -204}, {0xEF340A98172AACE5, -715, -196}, {0xB23867FB2A35B28E, -688, -188}, {0x84C8D4DFD2C63F3B, -661, -180}, + {0xC5DD44271AD3CDBA, -635, -172}, {0x936B9FCEBB25C996, -608, -164}, {0xDBAC6C247D62A584, -582, -156}, {0xA3AB66580D5FDAF6, -555, -148}, + {0xF3E2F893DEC3F126, -529, -140}, {0xB5B5ADA8AAFF80B8, -502, -132}, {0x87625F056C7C4A8B, -475, -124}, {0xC9BCFF6034C13053, -449, -116}, + {0x964E858C91BA2655, -422, -108}, {0xDFF9772470297EBD, -396, -100}, {0xA6DFBD9FB8E5B88F, -369, -92}, {0xF8A95FCF88747D94, -343, -84}, + {0xB94470938FA89BCF, -316, -76}, {0x8A08F0F8BF0F156B, -289, -68}, {0xCDB02555653131B6, -263, -60}, {0x993FE2C6D07B7FAC, -236, -52}, + {0xE45C10C42A2B3B06, -210, -44}, {0xAA242499697392D3, -183, -36}, {0xFD87B5F28300CA0E, -157, -28}, {0xBCE5086492111AEB, -130, -20}, + {0x8CBCCC096F5088CC, -103, -12}, {0xD1B71758E219652C, -77, -4}, {0x9C40000000000000, -50, 4}, {0xE8D4A51000000000, -24, 12}, + {0xAD78EBC5AC620000, 3, 20}, {0x813F3978F8940984, 30, 28}, {0xC097CE7BC90715B3, 56, 36}, {0x8F7E32CE7BEA5C70, 83, 44}, + {0xD5D238A4ABE98068, 109, 52}, {0x9F4F2726179A2245, 136, 60}, {0xED63A231D4C4FB27, 162, 68}, {0xB0DE65388CC8ADA8, 189, 76}, + {0x83C7088E1AAB65DB, 216, 84}, {0xC45D1DF942711D9A, 242, 92}, {0x924D692CA61BE758, 269, 100}, {0xDA01EE641A708DEA, 295, 108}, + {0xA26DA3999AEF774A, 322, 116}, {0xF209787BB47D6B85, 348, 124}, {0xB454E4A179DD1877, 375, 132}, {0x865B86925B9BC5C2, 402, 140}, + {0xC83553C5C8965D3D, 428, 148}, {0x952AB45CFA97A0B3, 455, 156}, {0xDE469FBD99A05FE3, 481, 164}, {0xA59BC234DB398C25, 508, 172}, + {0xF6C69A72A3989F5C, 534, 180}, {0xB7DCBF5354E9BECE, 561, 188}, {0x88FCF317F22241E2, 588, 196}, {0xCC20CE9BD35C78A5, 614, 204}, + {0x98165AF37B2153DF, 641, 212}, {0xE2A0B5DC971F303A, 667, 220}, {0xA8D9D1535CE3B396, 694, 228}, {0xFB9B7CD9A4A7443C, 720, 236}, + {0xBB764C4CA7A44410, 747, 244}, {0x8BAB8EEFB6409C1A, 774, 252}, {0xD01FEF10A657842C, 800, 260}, {0x9B10A4E5E9913129, 827, 268}, + {0xE7109BFBA19C0C9D, 853, 276}, {0xAC2820D9623BF429, 880, 284}, {0x80444B5E7AA7CF85, 907, 292}, {0xBF21E44003ACDD2D, 933, 300}, + {0x8E679C2F5E44FF8F, 960, 308}, {0xD433179D9C8CB841, 986, 316}, {0x9E19DB92B4E31BA9, 1013, 324}, + }}; // This computation gives exactly the same results for k as // k = ceil((kAlpha - e - 1) * 0.30102999566398114) @@ -17525,8 +20683,7 @@ template JSON_HEDLEY_NON_NULL(1) void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) { - static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, - "internal error: not enough precision"); + static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, "internal error: not enough precision"); JSON_ASSERT(std::isfinite(value)); JSON_ASSERT(value > 0); @@ -17698,8 +20855,7 @@ format. Returns an iterator pointing past-the-end of the decimal representation. */ template JSON_HEDLEY_NON_NULL(1, 2) -JSON_HEDLEY_RETURNS_NON_NULL - char* to_chars(char* first, const char* last, FloatType value) +JSON_HEDLEY_RETURNS_NON_NULL char* to_chars(char* first, const char* last, FloatType value) { static_cast(last); // maybe unused - fix warning JSON_ASSERT(std::isfinite(value)); @@ -17769,7 +20925,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail { +namespace detail +{ /////////////////// // serialization // @@ -17839,11 +20996,7 @@ class serializer @param[in] indent_step the indent level @param[in] current_indent the current indent level (only used internally) */ - void dump(const BasicJsonType& val, - const bool pretty_print, - const bool ensure_ascii, - const unsigned int indent_step, - const unsigned int current_indent = 0) + void dump(const BasicJsonType& val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent = 0) { switch (val.m_data.m_type) { @@ -17940,9 +21093,7 @@ class serializer } // first n-1 elements - for (auto i = val.m_data.m_value.array->cbegin(); - i != val.m_data.m_value.array->cend() - 1; - ++i) + for (auto i = val.m_data.m_value.array->cbegin(); i != val.m_data.m_value.array->cend() - 1; ++i) { o->write_characters(indent_string.c_str(), new_indent); dump(*i, true, ensure_ascii, indent_step, new_indent); @@ -17963,9 +21114,7 @@ class serializer o->write_character('['); // first n-1 elements - for (auto i = val.m_data.m_value.array->cbegin(); - i != val.m_data.m_value.array->cend() - 1; - ++i) + for (auto i = val.m_data.m_value.array->cbegin(); i != val.m_data.m_value.array->cend() - 1; ++i) { dump(*i, false, ensure_ascii, indent_step, current_indent); o->write_character(','); @@ -18008,9 +21157,7 @@ class serializer if (!val.m_data.m_value.binary->empty()) { - for (auto i = val.m_data.m_value.binary->cbegin(); - i != val.m_data.m_value.binary->cend() - 1; - ++i) + for (auto i = val.m_data.m_value.binary->cbegin(); i != val.m_data.m_value.binary->cend() - 1; ++i) { dump_integer(*i); o->write_characters(", ", 2); @@ -18040,9 +21187,7 @@ class serializer if (!val.m_data.m_value.binary->empty()) { - for (auto i = val.m_data.m_value.binary->cbegin(); - i != val.m_data.m_value.binary->cend() - 1; - ++i) + for (auto i = val.m_data.m_value.binary->cbegin(); i != val.m_data.m_value.binary->cend() - 1; ++i) { dump_integer(*i); o->write_character(','); @@ -18212,7 +21357,11 @@ class serializer else { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - static_cast((std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x", static_cast(0xD7C0u + (codepoint >> 10u)), static_cast(0xDC00u + (codepoint & 0x3FFu)))); + static_cast((std::snprintf)(string_buffer.data() + bytes, + 13, + "\\u%04x\\u%04x", + static_cast(0xD7C0u + (codepoint >> 10u)), + static_cast(0xDC00u + (codepoint & 0x3FFu)))); bytes += 12; } } @@ -18247,7 +21396,8 @@ class serializer { case error_handler_t::strict: { - JSON_THROW(type_error::create(316, concat("invalid UTF-8 byte at index ", std::to_string(i), ": 0x", hex_bytes(byte | 0)), nullptr)); + JSON_THROW( + type_error::create(316, concat("invalid UTF-8 byte at index ", std::to_string(i), ": 0x", hex_bytes(byte | 0)), nullptr)); } case error_handler_t::ignore: @@ -18339,7 +21489,8 @@ class serializer { case error_handler_t::strict: { - JSON_THROW(type_error::create(316, concat("incomplete UTF-8 string; last byte: 0x", hex_bytes(static_cast(s.back() | 0))), nullptr)); + JSON_THROW( + type_error::create(316, concat("incomplete UTF-8 string; last byte: 0x", hex_bytes(static_cast(s.back() | 0))), nullptr)); } case error_handler_t::ignore: @@ -18442,112 +21593,24 @@ class serializer @param[in] x integer number (signed or unsigned) to dump @tparam NumberType either @a number_integer_t or @a number_unsigned_t */ - template::value || std::is_same::value || std::is_same::value || std::is_same::value, int> = 0> + template::value || std::is_same::value || + std::is_same::value || std::is_same::value, + int> = 0> void dump_integer(NumberType x) { - static constexpr std::array, 100> digits_to_99{ - { - {{'0', '0'}}, - {{'0', '1'}}, - {{'0', '2'}}, - {{'0', '3'}}, - {{'0', '4'}}, - {{'0', '5'}}, - {{'0', '6'}}, - {{'0', '7'}}, - {{'0', '8'}}, - {{'0', '9'}}, - {{'1', '0'}}, - {{'1', '1'}}, - {{'1', '2'}}, - {{'1', '3'}}, - {{'1', '4'}}, - {{'1', '5'}}, - {{'1', '6'}}, - {{'1', '7'}}, - {{'1', '8'}}, - {{'1', '9'}}, - {{'2', '0'}}, - {{'2', '1'}}, - {{'2', '2'}}, - {{'2', '3'}}, - {{'2', '4'}}, - {{'2', '5'}}, - {{'2', '6'}}, - {{'2', '7'}}, - {{'2', '8'}}, - {{'2', '9'}}, - {{'3', '0'}}, - {{'3', '1'}}, - {{'3', '2'}}, - {{'3', '3'}}, - {{'3', '4'}}, - {{'3', '5'}}, - {{'3', '6'}}, - {{'3', '7'}}, - {{'3', '8'}}, - {{'3', '9'}}, - {{'4', '0'}}, - {{'4', '1'}}, - {{'4', '2'}}, - {{'4', '3'}}, - {{'4', '4'}}, - {{'4', '5'}}, - {{'4', '6'}}, - {{'4', '7'}}, - {{'4', '8'}}, - {{'4', '9'}}, - {{'5', '0'}}, - {{'5', '1'}}, - {{'5', '2'}}, - {{'5', '3'}}, - {{'5', '4'}}, - {{'5', '5'}}, - {{'5', '6'}}, - {{'5', '7'}}, - {{'5', '8'}}, - {{'5', '9'}}, - {{'6', '0'}}, - {{'6', '1'}}, - {{'6', '2'}}, - {{'6', '3'}}, - {{'6', '4'}}, - {{'6', '5'}}, - {{'6', '6'}}, - {{'6', '7'}}, - {{'6', '8'}}, - {{'6', '9'}}, - {{'7', '0'}}, - {{'7', '1'}}, - {{'7', '2'}}, - {{'7', '3'}}, - {{'7', '4'}}, - {{'7', '5'}}, - {{'7', '6'}}, - {{'7', '7'}}, - {{'7', '8'}}, - {{'7', '9'}}, - {{'8', '0'}}, - {{'8', '1'}}, - {{'8', '2'}}, - {{'8', '3'}}, - {{'8', '4'}}, - {{'8', '5'}}, - {{'8', '6'}}, - {{'8', '7'}}, - {{'8', '8'}}, - {{'8', '9'}}, - {{'9', '0'}}, - {{'9', '1'}}, - {{'9', '2'}}, - {{'9', '3'}}, - {{'9', '4'}}, - {{'9', '5'}}, - {{'9', '6'}}, - {{'9', '7'}}, - {{'9', '8'}}, - {{'9', '9'}}, - }}; + static constexpr std::array, 100> digits_to_99{{ + {{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}}, + {{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}}, + {{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}}, + {{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}}, + {{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}}, + {{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}}, + {{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}}, + {{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}}, + {{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}}, + {{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}}, + }}; // special case for "0" if (x == 0) @@ -18630,8 +21693,10 @@ class serializer // guaranteed to round-trip, using strtof and strtod, resp. // // NB: The test below works if == . - static constexpr bool is_ieee_single_or_double = (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 24 && std::numeric_limits::max_exponent == 128) || - (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 53 && std::numeric_limits::max_exponent == 1024); + static constexpr bool is_ieee_single_or_double = (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 24 && + std::numeric_limits::max_exponent == 128) || + (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 53 && + std::numeric_limits::max_exponent == 1024); dump_float(x, std::integral_constant()); } @@ -18682,10 +21747,9 @@ class serializer o->write_characters(number_buffer.data(), static_cast(len)); // determine if we need to append ".0" - const bool value_is_int_like = - std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1, [](char c) { - return c == '.' || c == 'e'; - }); + const bool value_is_int_like = std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1, [](char c) { + return c == '.' || c == 'e'; + }); if (value_is_int_like) { @@ -18716,417 +21780,41 @@ class serializer */ static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept { - static const std::array utf8d = - { - { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, // 00..1F - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, // 20..3F - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, // 40..5F - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, // 60..7F - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, - 9, // 80..9F - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, // A0..BF - 8, - 8, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, // C0..DF - 0xA, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x3, - 0x4, - 0x3, - 0x3, // E0..EF - 0xB, - 0x6, - 0x6, - 0x6, - 0x5, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, - 0x8, // F0..FF - 0x0, - 0x1, - 0x2, - 0x3, - 0x5, - 0x8, - 0x7, - 0x1, - 0x1, - 0x1, - 0x4, - 0x6, - 0x1, - 0x1, - 0x1, - 0x1, // s0..s0 - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 1, // s1..s2 - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 2, - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, // s3..s4 - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 3, - 1, - 3, - 1, - 1, - 1, - 1, - 1, - 1, // s5..s6 - 1, - 3, - 1, - 1, - 1, - 1, - 1, - 3, - 1, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1 // s7..s8 - }}; + static const std::array utf8d = {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 00..1F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 20..3F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 40..5F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 60..7F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, // 80..9F + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, // A0..BF + 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, // C0..DF + 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, + 0x3, // E0..EF + 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, + 0x8, // F0..FF + 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, + 0x1, // s0..s0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, + 1, // s1..s2 + 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, // s3..s4 + 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, + 1, // s5..s6 + 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1 // s7..s8 + }}; JSON_ASSERT(byte < utf8d.size()); const std::uint8_t type = utf8d[byte]; - codep = (state != UTF8_ACCEPT) - ? (byte & 0x3fu) | (codep << 6u) - : (0xFFu >> type) & (byte); + codep = (state != UTF8_ACCEPT) ? (byte & 0x3fu) | (codep << 6u) : (0xFFu >> type) & (byte); const std::size_t index = 256u + static_cast(state) * 16u + static_cast(type); JSON_ASSERT(index < utf8d.size()); @@ -19536,8 +22224,8 @@ struct ordered_map : std::vector, Allocator> } template - using require_input_iter = typename std::enable_if::iterator_category, - std::input_iterator_tag>::value>::type; + using require_input_iter = + typename std::enable_if::iterator_category, std::input_iterator_tag>::value>::type; template> void insert(InputIt first, InputIt last) @@ -19623,16 +22311,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe using lexer = ::nlohmann::detail::lexer_base; template - static ::nlohmann::detail::parser parser( - InputAdapterType adapter, - detail::parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) + static ::nlohmann::detail::parser + parser(InputAdapterType adapter, detail::parser_callback_t cb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false) { - return ::nlohmann::detail::parser(std::move(adapter), - std::move(cb), - allow_exceptions, - ignore_comments); + return ::nlohmann::detail::parser(std::move(adapter), std::move(cb), allow_exceptions, ignore_comments); } private: @@ -19748,8 +22430,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe result["copyright"] = "(C) 2013-2023 Niels Lohmann"; result["name"] = "JSON for Modern C++"; result["url"] = "https://github.com/nlohmann/json"; - result["version"]["string"] = - detail::concat(std::to_string(NLOHMANN_JSON_VERSION_MAJOR), '.', std::to_string(NLOHMANN_JSON_VERSION_MINOR), '.', std::to_string(NLOHMANN_JSON_VERSION_PATCH)); + result["version"]["string"] = detail::concat(std::to_string(NLOHMANN_JSON_VERSION_MAJOR), + '.', + std::to_string(NLOHMANN_JSON_VERSION_MINOR), + '.', + std::to_string(NLOHMANN_JSON_VERSION_PATCH)); result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR; result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR; result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH; @@ -19767,34 +22452,23 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe #endif #if defined(__ICC) || defined(__INTEL_COMPILER) - result["compiler"] = {{"family", "icc"}, { "version", - __INTEL_COMPILER }}; + result["compiler"] = {{"family", "icc"}, { "version", __INTEL_COMPILER }}; #elif defined(__clang__) - result["compiler"] = {{"family", "clang"}, { "version", - __clang_version__ }}; + result["compiler"] = {{"family", "clang"}, { "version", __clang_version__ }}; #elif defined(__GNUC__) || defined(__GNUG__) - result["compiler"] = {{"family", "gcc"}, { "version", - detail::concat( - std::to_string(__GNUC__), - '.', - std::to_string(__GNUC_MINOR__), - '.', - std::to_string(__GNUC_PATCHLEVEL__)) - }}; + result["compiler"] = {{"family", "gcc"}, + { "version", + detail::concat(std::to_string(__GNUC__), '.', std::to_string(__GNUC_MINOR__), '.', std::to_string(__GNUC_PATCHLEVEL__)) }}; #elif defined(__HP_cc) || defined(__HP_aCC) result["compiler"] = "hp" #elif defined(__IBMCPP__) - result["compiler"] = {{"family", "ilecpp"}, { "version", - __IBMCPP__ }}; + result["compiler"] = {{"family", "ilecpp"}, { "version", __IBMCPP__ }}; #elif defined(_MSC_VER) - result["compiler"] = {{"family", "msvc"}, { "version", - _MSC_VER }}; + result["compiler"] = {{"family", "msvc"}, { "version", _MSC_VER }}; #elif defined(__PGI) - result["compiler"] = {{"family", "pgcpp"}, { "version", - __PGI }}; + result["compiler"] = {{"family", "pgcpp"}, { "version", __PGI }}; #elif defined(__SUNPRO_CC) - result["compiler"] = {{"family", "sunpro"}, { "version", - __SUNPRO_CC }}; + result["compiler"] = {{"family", "sunpro"}, { "version", __SUNPRO_CC }}; #else result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; #endif @@ -19832,11 +22506,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief a type for an object /// @sa https://json.nlohmann.me/api/basic_json/object_t/ - using object_t = ObjectType>>; + using object_t = ObjectType>>; /// @brief a type for an array /// @sa https://json.nlohmann.me/api/basic_json/array_t/ @@ -20080,10 +22750,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe void destroy(value_t t) { - if ( - (t == value_t::object && object == nullptr) || - (t == value_t::array && array == nullptr) || - (t == value_t::string && string == nullptr) || + if ((t == value_t::object && object == nullptr) || (t == value_t::array && array == nullptr) || (t == value_t::string && string == nullptr) || (t == value_t::binary && binary == nullptr)) { //not initialized (e.g. due to exception in the ctor) @@ -20355,12 +23022,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ template, - detail::enable_if_t< - !detail::is_basic_json::value && detail::is_compatible_type::value, - int> = 0> + detail::enable_if_t::value && detail::is_compatible_type::value, + int> = 0> basic_json(CompatibleType&& val) noexcept(noexcept( // NOLINT(bugprone-forwarding-reference-overload,bugprone-exception-escape) - JSONSerializer::to_json(std::declval(), - std::forward(val)))) + JSONSerializer::to_json(std::declval(), std::forward(val)))) { JSONSerializer::to_json(*this, std::forward(val)); set_parents(); @@ -20370,9 +23035,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an existing one /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ template::value && !std::is_same::value, - int> = 0> + detail::enable_if_t::value && !std::is_same::value, int> = 0> basic_json(const BasicJsonType& val) { using other_boolean_t = typename BasicJsonType::boolean_t; @@ -20426,9 +23089,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a container (array or object) from an initializer list /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ - basic_json(initializer_list_t init, - bool type_deduction = true, - value_t manual_type = value_t::array) + basic_json(initializer_list_t init, bool type_deduction = true, value_t manual_type = value_t::array) { // check if each element is an array with two elements whose first // element is a string @@ -20464,9 +23125,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe for (auto& element_ref : init) { auto element = element_ref.moved_or_copied(); - m_data.m_value.object->emplace( - std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)), - std::move((*element.m_data.m_value.array)[1])); + m_data.m_value.object->emplace(std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)), + std::move((*element.m_data.m_value.array)[1])); } } else @@ -20551,7 +23211,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief construct a JSON container given an iterator range /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ - template::value || std::is_same::value, int>::type = 0> + template::value || + std::is_same::value, + int>::type = 0> basic_json(InputIT first, InputIT last) { JSON_ASSERT(first.m_object != nullptr); @@ -20625,15 +23288,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe case value_t::object: { - m_data.m_value.object = create(first.m_it.object_iterator, - last.m_it.object_iterator); + m_data.m_value.object = create(first.m_it.object_iterator, last.m_it.object_iterator); break; } case value_t::array: { - m_data.m_value.array = create(first.m_it.array_iterator, - last.m_it.array_iterator); + m_data.m_value.array = create(first.m_it.array_iterator, last.m_it.array_iterator); break; } @@ -20658,9 +23319,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /////////////////////////////////////// template, - std::is_same>::value, - int> = 0> + detail::enable_if_t, std::is_same>::value, int> = 0> basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {} @@ -20753,12 +23412,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief copy assignment /// @sa https://json.nlohmann.me/api/basic_json/operator=/ - basic_json& operator=(basic_json other) noexcept( - std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value && - std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value && - std::is_nothrow_move_assignable::value) + basic_json& operator=(basic_json other) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value && + std::is_nothrow_move_constructible::value && + std::is_nothrow_move_assignable::value && + std::is_nothrow_move_assignable::value) { // check that passed value is valid other.assert_invariant(); @@ -21073,7 +23730,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief get a pointer value (implicit) /// @sa https://json.nlohmann.me/api/basic_json/get_ptr/ - template::value && std::is_const::type>::value, int>::type = 0> + template< + typename PointerType, + typename std::enable_if::value && std::is_const::type>::value, int>::type = 0> constexpr auto get_ptr() const noexcept -> decltype(std::declval().get_impl_ptr(std::declval())) { // delegate the call to get_impl_ptr<>() const @@ -21120,12 +23779,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @since version 2.1.0 */ template::value && - detail::has_from_json::value, - int> = 0> - ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept( - JSONSerializer::from_json(std::declval(), std::declval()))) + detail::enable_if_t::value && detail::has_from_json::value, int> = 0> + ValueType get_impl(detail::priority_tag<0> /*unused*/) const + noexcept(noexcept(JSONSerializer::from_json(std::declval(), std::declval()))) { auto ret = ValueType(); JSONSerializer::from_json(*this, ret); @@ -21162,12 +23818,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @since version 2.1.0 */ - template::value, - int> = 0> - ValueType get_impl(detail::priority_tag<1> /*unused*/) const noexcept(noexcept( - JSONSerializer::from_json(std::declval()))) + template::value, int> = 0> + ValueType get_impl(detail::priority_tag<1> /*unused*/) const noexcept(noexcept(JSONSerializer::from_json(std::declval()))) { return JSONSerializer::from_json(*this); } @@ -21187,10 +23839,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @since version 3.2.0 */ - template::value, - int> = 0> + template::value, int> = 0> BasicJsonType get_impl(detail::priority_tag<2> /*unused*/) const { return *this; @@ -21210,10 +23859,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @since version 2.1.0 */ - template::value, - int> = 0> + template::value, int> = 0> basic_json get_impl(detail::priority_tag<3> /*unused*/) const { return *this; @@ -21223,12 +23869,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @brief get a pointer value (explicit) @copydoc get() */ - template::value, - int> = 0> - constexpr auto get_impl(detail::priority_tag<4> /*unused*/) const noexcept - -> decltype(std::declval().template get_ptr()) + template::value, int> = 0> + constexpr auto get_impl(detail::priority_tag<4> /*unused*/) const noexcept -> decltype(std::declval().template get_ptr()) { // delegate the call to get_ptr return get_ptr(); @@ -21263,15 +23905,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe constexpr #endif auto - get() const noexcept( - noexcept(std::declval().template get_impl(detail::priority_tag<4>{}))) + get() const noexcept(noexcept(std::declval().template get_impl(detail::priority_tag<4>{}))) -> decltype(std::declval().template get_impl(detail::priority_tag<4>{})) { // we cannot static_assert on ValueTypeCV being non-const, because // there is support for get(), which is why we // still need the uncvref - static_assert(!std::is_reference::value, - "get() cannot be used with reference types, you might want to use get_ref()"); + static_assert(!std::is_reference::value, "get() cannot be used with reference types, you might want to use get_ref()"); return get_impl(detail::priority_tag<4>{}); } @@ -21312,12 +23952,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief get a value (explicit) /// @sa https://json.nlohmann.me/api/basic_json/get_to/ template::value && - detail::has_from_json::value, - int> = 0> - ValueType& get_to(ValueType& v) const noexcept(noexcept( - JSONSerializer::from_json(std::declval(), v))) + detail::enable_if_t::value && detail::has_from_json::value, int> = 0> + ValueType& get_to(ValueType& v) const noexcept(noexcept(JSONSerializer::from_json(std::declval(), v))) { JSONSerializer::from_json(*this, v); return v; @@ -21325,27 +23961,20 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe // specialization to allow calling get_to with a basic_json value // see https://github.com/nlohmann/json/issues/2175 - template::value, - int> = 0> + template::value, int> = 0> ValueType& get_to(ValueType& v) const { v = *this; return v; } - template< - typename T, - std::size_t N, - typename Array = T (&)[N], // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - detail::enable_if_t< - detail::has_from_json::value, - int> = 0> + template::value, + int> = 0> Array get_to(T (&v)[N]) const // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - noexcept(noexcept(JSONSerializer::from_json( - std::declval(), - v))) + noexcept(noexcept(JSONSerializer::from_json(std::declval(), v))) { JSONSerializer::from_json(*this, v); return v; @@ -21362,7 +23991,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief get a reference value (implicit) /// @sa https://json.nlohmann.me/api/basic_json/get_ref/ - template::value && std::is_const::type>::value, int>::type = 0> + template::value && std::is_const::type>::value, + int>::type = 0> ReferenceType get_ref() const { // delegate call to get_ref_impl @@ -21398,15 +24029,21 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe @since version 1.0.0 */ - template>, detail::negation>, detail::negation>>, detail::negation>, detail::negation>, detail::negation>>, + template>, + detail::negation>, + detail::negation>>, + detail::negation>, + detail::negation>, + detail::negation>>, #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) - detail::negation>, + detail::negation>, #endif #if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI - detail::negation>, + detail::negation>, #endif - detail::is_detected_lazy>::value, - int>::type = 0> + detail::is_detected_lazy>::value, + int>::type = 0> JSON_EXPLICIT operator ValueType() const { // delegate the call to get<>() const @@ -21601,7 +24238,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe else { // set parent for values added above - set_parents(begin() + static_cast(old_size), static_cast(idx + 1 - old_size)); + set_parents(begin() + static_cast(old_size), + static_cast(idx + 1 - old_size)); } #endif assert_invariant(); @@ -21718,21 +24356,18 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe private: template - using is_comparable_with_object_key = detail::is_comparable< - object_comparator_t, - const typename object_t::key_type&, - KeyType>; + using is_comparable_with_object_key = detail::is_comparable; template - using value_return_type = std::conditional< - detail::is_c_string_uncvref::value, - string_t, - typename std::decay::type>; + using value_return_type = std::conditional::value, string_t, typename std::decay::type>; public: /// @brief access specified object element with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const { // value only works for objects @@ -21753,7 +24388,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief access specified object element with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::type, detail::enable_if_t::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::type, + detail::enable_if_t::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> ReturnType value(const typename object_t::key_type& key, ValueType&& default_value) const { // value only works for objects @@ -21774,7 +24413,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief access specified object element with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::value && !detail::is_json_pointer::value && is_comparable_with_object_key::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::value && !detail::is_json_pointer::value && + is_comparable_with_object_key::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> ValueType value(KeyType&& key, const ValueType& default_value) const { // value only works for objects @@ -21795,7 +24439,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief access specified object element via JSON Pointer with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::type, detail::enable_if_t::value && !detail::is_json_pointer::value && is_comparable_with_object_key::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::type, + detail::enable_if_t::value && !detail::is_json_pointer::value && + is_comparable_with_object_key::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> ReturnType value(KeyType&& key, ValueType&& default_value) const { // value only works for objects @@ -21816,7 +24466,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief access specified object element via JSON Pointer with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::value && !std::is_same>::value, int> = 0> + template::value && !std::is_same>::value, int> = 0> ValueType value(const json_pointer& ptr, const ValueType& default_value) const { // value only works for objects @@ -21838,7 +24489,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief access specified object element via JSON Pointer with default value /// @sa https://json.nlohmann.me/api/basic_json/value/ - template::type, detail::enable_if_t::value && !std::is_same>::value, int> = 0> + template::type, + detail::enable_if_t::value && !std::is_same>::value, int> = 0> ReturnType value(const json_pointer& ptr, ValueType&& default_value) const { // value only works for objects @@ -21858,14 +24511,23 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this)); } - template::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer) // NOLINT(readability/alt_tokens) ValueType value(const ::nlohmann::json_pointer& ptr, const ValueType& default_value) const { return value(ptr.convert(), default_value); } - template::type, detail::enable_if_t::value && detail::is_getable::value && !std::is_same>::value, int> = 0> + template::type, + detail::enable_if_t::value && detail::is_getable::value && + !std::is_same>::value, + int> = 0> JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer) // NOLINT(readability/alt_tokens) ReturnType value(const ::nlohmann::json_pointer& ptr, ValueType&& default_value) const { @@ -21906,7 +24568,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief remove element given an iterator /// @sa https://json.nlohmann.me/api/basic_json/erase/ - template::value || std::is_same::value, int> = 0> + template::value || + std::is_same::value, + int> = 0> IteratorType erase(IteratorType pos) { // make sure iterator fits the current value @@ -21974,7 +24639,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief remove elements given an iterator range /// @sa https://json.nlohmann.me/api/basic_json/erase/ - template::value || std::is_same::value, int> = 0> + template::value || + std::is_same::value, + int> = 0> IteratorType erase(IteratorType first, IteratorType last) { // make sure iterator fits the current value @@ -22021,15 +24689,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe case value_t::object: { - result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator, - last.m_it.object_iterator); + result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator, last.m_it.object_iterator); break; } case value_t::array: { - result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator, - last.m_it.array_iterator); + result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator, last.m_it.array_iterator); break; } @@ -22656,9 +25322,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe if (is_object() && init.size() == 2 && (*init.begin())->is_string()) { basic_json&& key = init.begin()->moved_or_copied(); - push_back(typename object_t::value_type( - std::move(key.get_ref()), - (init.begin() + 1)->moved_or_copied())); + push_back(typename object_t::value_type(std::move(key.get_ref()), (init.begin() + 1)->moved_or_copied())); } else { @@ -22931,8 +25595,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ void swap(reference other) noexcept( - std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value && + std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value && std::is_nothrow_move_constructible::value && // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) std::is_nothrow_move_assignable::value) { @@ -22947,8 +25610,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief exchanges the values /// @sa https://json.nlohmann.me/api/basic_json/swap/ friend void swap(reference left, reference right) noexcept( - std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value && + std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value && std::is_nothrow_move_constructible::value && // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) std::is_nothrow_move_assignable::value) { @@ -23046,75 +25708,75 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe // note parentheses around operands are necessary; see // https://github.com/nlohmann/json/issues/1530 -#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \ - const auto lhs_type = lhs.type(); \ - const auto rhs_type = rhs.type(); \ - \ - if (lhs_type == rhs_type) /* NOLINT(readability/braces) */ \ - { \ - switch (lhs_type) \ - { \ - case value_t::array: \ - return (*lhs.m_data.m_value.array)op(*rhs.m_data.m_value.array); \ - \ - case value_t::object: \ - return (*lhs.m_data.m_value.object)op(*rhs.m_data.m_value.object); \ - \ - case value_t::null: \ - return (null_result); \ - \ - case value_t::string: \ - return (*lhs.m_data.m_value.string)op(*rhs.m_data.m_value.string); \ - \ - case value_t::boolean: \ - return (lhs.m_data.m_value.boolean)op(rhs.m_data.m_value.boolean); \ - \ - case value_t::number_integer: \ - return (lhs.m_data.m_value.number_integer)op(rhs.m_data.m_value.number_integer); \ - \ - case value_t::number_unsigned: \ - return (lhs.m_data.m_value.number_unsigned)op(rhs.m_data.m_value.number_unsigned); \ - \ - case value_t::number_float: \ - return (lhs.m_data.m_value.number_float)op(rhs.m_data.m_value.number_float); \ - \ - case value_t::binary: \ - return (*lhs.m_data.m_value.binary)op(*rhs.m_data.m_value.binary); \ - \ - case value_t::discarded: \ - default: \ - return (unordered_result); \ - } \ - } \ - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \ - { \ - return static_cast(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \ - } \ - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \ - { \ - return lhs.m_data.m_value.number_float op static_cast(rhs.m_data.m_value.number_integer); \ - } \ - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \ - { \ - return static_cast(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \ - } \ - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \ - { \ - return lhs.m_data.m_value.number_float op static_cast(rhs.m_data.m_value.number_unsigned); \ - } \ - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \ - { \ - return static_cast(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \ - } \ - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \ - { \ - return lhs.m_data.m_value.number_integer op static_cast(rhs.m_data.m_value.number_unsigned); \ - } \ - else if (compares_unordered(lhs, rhs)) \ - { \ - return (unordered_result); \ - } \ - \ +#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \ + const auto lhs_type = lhs.type(); \ + const auto rhs_type = rhs.type(); \ + \ + if (lhs_type == rhs_type) /* NOLINT(readability/braces) */ \ + { \ + switch (lhs_type) \ + { \ + case value_t::array: \ + return (*lhs.m_data.m_value.array)op(*rhs.m_data.m_value.array); \ + \ + case value_t::object: \ + return (*lhs.m_data.m_value.object)op(*rhs.m_data.m_value.object); \ + \ + case value_t::null: \ + return (null_result); \ + \ + case value_t::string: \ + return (*lhs.m_data.m_value.string)op(*rhs.m_data.m_value.string); \ + \ + case value_t::boolean: \ + return (lhs.m_data.m_value.boolean)op(rhs.m_data.m_value.boolean); \ + \ + case value_t::number_integer: \ + return (lhs.m_data.m_value.number_integer)op(rhs.m_data.m_value.number_integer); \ + \ + case value_t::number_unsigned: \ + return (lhs.m_data.m_value.number_unsigned)op(rhs.m_data.m_value.number_unsigned); \ + \ + case value_t::number_float: \ + return (lhs.m_data.m_value.number_float)op(rhs.m_data.m_value.number_float); \ + \ + case value_t::binary: \ + return (*lhs.m_data.m_value.binary)op(*rhs.m_data.m_value.binary); \ + \ + case value_t::discarded: \ + default: \ + return (unordered_result); \ + } \ + } \ + else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \ + { \ + return static_cast(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \ + } \ + else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \ + { \ + return lhs.m_data.m_value.number_float op static_cast(rhs.m_data.m_value.number_integer); \ + } \ + else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \ + { \ + return static_cast(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \ + } \ + else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \ + { \ + return lhs.m_data.m_value.number_float op static_cast(rhs.m_data.m_value.number_unsigned); \ + } \ + else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \ + { \ + return static_cast(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \ + } \ + else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \ + { \ + return lhs.m_data.m_value.number_integer op static_cast(rhs.m_data.m_value.number_unsigned); \ + } \ + else if (compares_unordered(lhs, rhs)) \ + { \ + return (unordered_result); \ + } \ + \ return (default_result); JSON_PRIVATE_UNLESS_TESTED : @@ -23126,7 +25788,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe static bool compares_unordered(const_reference lhs, const_reference rhs, bool inverse = false) noexcept { - if ((lhs.is_number_float() && std::isnan(lhs.m_data.m_value.number_float) && rhs.is_number()) || (rhs.is_number_float() && std::isnan(rhs.m_data.m_value.number_float) && lhs.is_number())) + if ((lhs.is_number_float() && std::isnan(lhs.m_data.m_value.number_float) && rhs.is_number()) || + (rhs.is_number_float() && std::isnan(rhs.m_data.m_value.number_float) && lhs.is_number())) { return true; } @@ -23164,7 +25827,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief comparison: equal /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ template - requires std::is_scalar_v bool operator==(ScalarType rhs) const noexcept + requires std::is_scalar_v + bool operator==(ScalarType rhs) const noexcept { return *this == basic_json(rhs); } @@ -23182,7 +25846,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief comparison: 3-way /// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/ - std::partial_ordering operator<=> (const_reference rhs) const noexcept // *NOPAD* + std::partial_ordering operator<=>(const_reference rhs) const noexcept // *NOPAD* { const_reference lhs = *this; // default_result is used if we cannot compare values. In that case, @@ -23197,7 +25861,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/ template requires std::is_scalar_v - std::partial_ordering operator<=> (ScalarType rhs) const noexcept // *NOPAD* + std::partial_ordering operator<=>(ScalarType rhs) const noexcept // *NOPAD* { return *this <=> basic_json(rhs); // *NOPAD* } @@ -23221,7 +25885,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief comparison: less than or equal /// @sa https://json.nlohmann.me/api/basic_json/operator_le/ template - requires std::is_scalar_v bool operator<=(ScalarType rhs) const noexcept + requires std::is_scalar_v + bool operator<=(ScalarType rhs) const noexcept { return *this <= basic_json(rhs); } @@ -23241,7 +25906,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief comparison: greater than or equal /// @sa https://json.nlohmann.me/api/basic_json/operator_ge/ template - requires std::is_scalar_v bool operator>=(ScalarType rhs) const noexcept + requires std::is_scalar_v + bool operator>=(ScalarType rhs) const noexcept { return *this >= basic_json(rhs); } @@ -23465,10 +26131,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief deserialize from a compatible input /// @sa https://json.nlohmann.me/api/basic_json/parse/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json parse(InputType&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + parse(InputType&& i, const parser_callback_t cb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false) { basic_json result; parser(detail::input_adapter(std::forward(i)), cb, allow_exceptions, ignore_comments).parse(true, result); @@ -23478,11 +26142,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief deserialize from a pair of character iterators /// @sa https://json.nlohmann.me/api/basic_json/parse/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json parse(IteratorType first, - IteratorType last, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + parse(IteratorType first, IteratorType last, const parser_callback_t cb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false) { basic_json result; parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result); @@ -23491,10 +26152,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len)) - static basic_json parse(detail::span_input_adapter&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) + static basic_json + parse(detail::span_input_adapter&& i, const parser_callback_t cb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false) { basic_json result; parser(i.get(), cb, allow_exceptions, ignore_comments).parse(true, result); @@ -23504,8 +26163,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief check if the input is valid JSON /// @sa https://json.nlohmann.me/api/basic_json/accept/ template - static bool accept(InputType&& i, - const bool ignore_comments = false) + static bool accept(InputType&& i, const bool ignore_comments = false) { return parser(detail::input_adapter(std::forward(i)), nullptr, false, ignore_comments).accept(true); } @@ -23520,8 +26178,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len)) - static bool accept(detail::span_input_adapter&& i, - const bool ignore_comments = false) + static bool accept(detail::span_input_adapter&& i, const bool ignore_comments = false) { return parser(i.get(), nullptr, false, ignore_comments).accept(true); } @@ -23533,21 +26190,24 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe static bool sax_parse(InputType&& i, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true, const bool ignore_comments = false) { auto ia = detail::input_adapter(std::forward(i)); - return format == input_format_t::json - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - : detail::binary_reader(std::move(ia), format).sax_parse(format, sax, strict); + return format == input_format_t::json ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) + : detail::binary_reader(std::move(ia), format).sax_parse(format, sax, strict); } /// @brief generate SAX events /// @sa https://json.nlohmann.me/api/basic_json/sax_parse/ template JSON_HEDLEY_NON_NULL(3) - static bool sax_parse(IteratorType first, IteratorType last, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true, const bool ignore_comments = false) + static bool sax_parse(IteratorType first, + IteratorType last, + SAX* sax, + input_format_t format = input_format_t::json, + const bool strict = true, + const bool ignore_comments = false) { auto ia = detail::input_adapter(std::move(first), std::move(last)); - return format == input_format_t::json - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - : detail::binary_reader(std::move(ia), format).sax_parse(format, sax, strict); + return format == input_format_t::json ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) + : detail::binary_reader(std::move(ia), format).sax_parse(format, sax, strict); } /// @brief generate SAX events @@ -23557,7 +26217,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// sax_parse(ptr, ptr + len) instead. template JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...)) - JSON_HEDLEY_NON_NULL(2) static bool sax_parse(detail::span_input_adapter&& i, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true, const bool ignore_comments = false) + JSON_HEDLEY_NON_NULL(2) static bool sax_parse(detail::span_input_adapter&& i, + SAX* sax, + input_format_t format = input_format_t::json, + const bool strict = true, + const bool ignore_comments = false) { auto ia = i.get(); return format == input_format_t::json @@ -23638,8 +26302,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe data(const value_t v) : m_type(v) , m_value(v) - { - } + {} data(size_type cnt, const basic_json& val) : m_type(value_t::array) @@ -23722,9 +26385,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a UBJSON serialization of a given JSON value /// @sa https://json.nlohmann.me/api/basic_json/to_ubjson/ - static std::vector to_ubjson(const basic_json& j, - const bool use_size = false, - const bool use_type = false) + static std::vector to_ubjson(const basic_json& j, const bool use_size = false, const bool use_type = false) { std::vector result; to_ubjson(j, result, use_size, use_type); @@ -23747,9 +26408,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a BJData serialization of a given JSON value /// @sa https://json.nlohmann.me/api/basic_json/to_bjdata/ - static std::vector to_bjdata(const basic_json& j, - const bool use_size = false, - const bool use_type = false) + static std::vector to_bjdata(const basic_json& j, const bool use_size = false, const bool use_type = false) { std::vector result; to_bjdata(j, result, use_size, use_type); @@ -23796,10 +26455,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in CBOR format /// @sa https://json.nlohmann.me/api/basic_json/from_cbor/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + from_cbor(InputType&& i, const bool strict = true, const bool allow_exceptions = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23811,7 +26468,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in CBOR format /// @sa https://json.nlohmann.me/api/basic_json/from_cbor/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(IteratorType first, + IteratorType last, + const bool strict = true, + const bool allow_exceptions = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23821,8 +26482,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe } template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) static basic_json from_cbor(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) + JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) static basic_json + from_cbor(const T* ptr, + std::size_t len, + const bool strict = true, + const bool allow_exceptions = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) { return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler); } @@ -23845,9 +26510,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in MessagePack format /// @sa https://json.nlohmann.me/api/basic_json/from_msgpack/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(InputType&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23859,7 +26522,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in MessagePack format /// @sa https://json.nlohmann.me/api/basic_json/from_msgpack/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + from_msgpack(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23869,17 +26533,15 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe } template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) static basic_json from_msgpack(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) static basic_json + from_msgpack(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) { return from_msgpack(ptr, ptr + len, strict, allow_exceptions); } JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) - static basic_json from_msgpack(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) + static basic_json from_msgpack(detail::span_input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23892,9 +26554,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in UBJSON format /// @sa https://json.nlohmann.me/api/basic_json/from_ubjson/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(InputType&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23906,7 +26566,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in UBJSON format /// @sa https://json.nlohmann.me/api/basic_json/from_ubjson/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + from_ubjson(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23916,17 +26577,15 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe } template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) static basic_json from_ubjson(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) static basic_json + from_ubjson(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) { return from_ubjson(ptr, ptr + len, strict, allow_exceptions); } JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) - static basic_json from_ubjson(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) + static basic_json from_ubjson(detail::span_input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23939,9 +26598,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in BJData format /// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bjdata(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bjdata(InputType&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23953,7 +26610,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in BJData format /// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + from_bjdata(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23965,9 +26623,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in BSON format /// @sa https://json.nlohmann.me/api/basic_json/from_bson/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(InputType&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23979,7 +26635,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe /// @brief create a JSON value from an input in BSON format /// @sa https://json.nlohmann.me/api/basic_json/from_bson/ template - JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json + from_bson(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -23989,17 +26646,15 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe } template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) static basic_json from_bson(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) + JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) static basic_json + from_bson(const T* ptr, std::size_t len, const bool strict = true, const bool allow_exceptions = true) { return from_bson(ptr, ptr + len, strict, allow_exceptions); } JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) - static basic_json from_bson(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) + static basic_json from_bson(detail::span_input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) { basic_json result; detail::json_sax_dom_parser sdp(result, allow_exceptions); @@ -24249,9 +26904,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe for (const auto& val : json_patch) { // wrapper to get a value for an operation - const auto get_value = [&val](const std::string& op, - const std::string& member, - bool string_type) -> basic_json& { + const auto get_value = [&val](const std::string& op, const std::string& member, bool string_type) -> basic_json& { // find value auto it = val.m_data.m_value.object->find(member); @@ -24400,8 +27053,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe if (source.type() != target.type()) { // different types: replace value - result.push_back( - {{"op", "replace"}, {"path", path}, {"value", target}}); + result.push_back({{"op", "replace"}, {"path", path}, {"value", target}}); return result; } @@ -24435,10 +27087,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe // add other remaining elements while (i < target.size()) { - result.push_back( - {{"op", "add"}, - {"path", detail::concat(path, "/-")}, - {"value", target[i]}}); + result.push_back({{"op", "add"}, {"path", detail::concat(path, "/-")}, {"value", target[i]}}); ++i; } @@ -24462,8 +27111,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe else { // found a key that is not in o -> remove it - result.push_back(object( - {{"op", "remove"}, {"path", path_key}})); + result.push_back(object({{"op", "remove"}, {"path", path_key}})); } } @@ -24474,8 +27122,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe { // found a key that is not in this -> add it const auto path_key = detail::concat(path, '/', detail::escape(it.key())); - result.push_back( - {{"op", "add"}, {"path", path_key}, {"value", it.value()}}); + result.push_back({{"op", "add"}, {"path", path_key}, {"value", it.value()}}); } } @@ -24493,8 +27140,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spe default: { // both primitive type: replace value - result.push_back( - {{"op", "replace"}, {"path", path}, {"value", target}}); + result.push_back({{"op", "replace"}, {"path", path}, {"value", target}}); break; } } @@ -24549,8 +27195,10 @@ std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j) return j.dump(); } -inline namespace literals { -inline namespace json_literals { +inline namespace literals +{ +inline namespace json_literals +{ /// @brief user-defined string literal for JSON values /// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json/ @@ -24606,8 +27254,7 @@ struct less<::nlohmann::detail::value_t> // do not remove the space after '<', @brief compare two value_t enum values @since version 3.0.0 */ - bool operator()(::nlohmann::detail::value_t lhs, - ::nlohmann::detail::value_t rhs) const noexcept + bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept { #if JSON_HAS_THREE_WAY_COMPARISON return std::is_lt(lhs <=> rhs); // *NOPAD* @@ -24623,8 +27270,10 @@ struct less<::nlohmann::detail::value_t> // do not remove the space after '<', /// @brief exchanges the values of two JSON objects /// @sa https://json.nlohmann.me/api/basic_json/std_swap/ NLOHMANN_BASIC_JSON_TPL_DECLARATION -inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) - is_nothrow_move_constructible::value && // NOLINT(misc-redundant-expression,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) +inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, + nlohmann::NLOHMANN_BASIC_JSON_TPL& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) + is_nothrow_move_constructible< + nlohmann::NLOHMANN_BASIC_JSON_TPL>::value && // NOLINT(misc-redundant-expression,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) is_nothrow_move_assignable::value) { j1.swap(j2); diff --git a/single_include/nlohmann/json_fwd.hpp b/single_include/nlohmann/json_fwd.hpp index a053939358..ccf06a3e1b 100644 --- a/single_include/nlohmann/json_fwd.hpp +++ b/single_include/nlohmann/json_fwd.hpp @@ -66,52 +66,40 @@ // Construct the namespace ABI tags component #define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi##a##b -#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ - NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) +#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) -#define NLOHMANN_JSON_ABI_TAGS \ - NLOHMANN_JSON_ABI_TAGS_CONCAT( \ - NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ - NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) +#define NLOHMANN_JSON_ABI_TAGS NLOHMANN_JSON_ABI_TAGS_CONCAT(NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) // Construct the namespace version component -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ - _v##major##_##minor##_##patch -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) _v##major##_##minor##_##patch +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) #if NLOHMANN_JSON_NAMESPACE_NO_VERSION #define NLOHMANN_JSON_NAMESPACE_VERSION #else - #define NLOHMANN_JSON_NAMESPACE_VERSION \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ - NLOHMANN_JSON_VERSION_MINOR, \ - NLOHMANN_JSON_VERSION_PATCH) + #define NLOHMANN_JSON_NAMESPACE_VERSION \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH) #endif // Combine namespace components #define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a##b -#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ - NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) +#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) #ifndef NLOHMANN_JSON_NAMESPACE - #define NLOHMANN_JSON_NAMESPACE \ - nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) + #define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT(NLOHMANN_JSON_ABI_TAGS, NLOHMANN_JSON_NAMESPACE_VERSION) #endif #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN - #define NLOHMANN_JSON_NAMESPACE_BEGIN \ - namespace nlohmann { \ - inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) { + #define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { \ + inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT(NLOHMANN_JSON_ABI_TAGS, NLOHMANN_JSON_NAMESPACE_VERSION) \ + { #endif #ifndef NLOHMANN_JSON_NAMESPACE_END - #define NLOHMANN_JSON_NAMESPACE_END \ - } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ + #define NLOHMANN_JSON_NAMESPACE_END \ + } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ } // namespace nlohmann #endif @@ -135,8 +123,7 @@ struct adl_serializer; /// a class to store JSON values /// @sa https://json.nlohmann.me/api/basic_json/ -template class ObjectType = - std::map, +template class ObjectType = std::map, template class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, @@ -144,8 +131,7 @@ template class ObjectType = class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer, + template class JSONSerializer = adl_serializer, class BinaryType = std::vector, // cppcheck-suppress syntaxError class CustomBaseClass = void> class basic_json; diff --git a/tests/abi/config/custom.cpp b/tests/abi/config/custom.cpp index dbbb9ca534..c64371376d 100644 --- a/tests/abi/config/custom.cpp +++ b/tests/abi/config/custom.cpp @@ -12,7 +12,9 @@ // define custom namespace #define NLOHMANN_JSON_NAMESPACE nlohmann // this line may be omitted -#define NLOHMANN_JSON_NAMESPACE_BEGIN namespace nlohmann { +#define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { #define NLOHMANN_JSON_NAMESPACE_END } #include diff --git a/tests/benchmarks/src/benchmarks.cpp b/tests/benchmarks/src/benchmarks.cpp index f8d8b90e43..bc50a9a1b2 100644 --- a/tests/benchmarks/src/benchmarks.cpp +++ b/tests/benchmarks/src/benchmarks.cpp @@ -6,12 +6,12 @@ // SPDX-FileCopyrightText: 2013-2023 Niels Lohmann // SPDX-License-Identifier: MIT -#include #include -#include #include #include #include +#include +#include using json = nlohmann::json; diff --git a/tests/src/fuzzer-parse_bjdata.cpp b/tests/src/fuzzer-parse_bjdata.cpp index c52a27d741..30f1ddd004 100644 --- a/tests/src/fuzzer-parse_bjdata.cpp +++ b/tests/src/fuzzer-parse_bjdata.cpp @@ -26,8 +26,8 @@ drivers. */ #include -#include #include +#include using json = nlohmann::json; diff --git a/tests/src/fuzzer-parse_bson.cpp b/tests/src/fuzzer-parse_bson.cpp index 9e514e8eda..fa2a221db9 100644 --- a/tests/src/fuzzer-parse_bson.cpp +++ b/tests/src/fuzzer-parse_bson.cpp @@ -20,8 +20,8 @@ drivers. */ #include -#include #include +#include using json = nlohmann::json; diff --git a/tests/src/fuzzer-parse_cbor.cpp b/tests/src/fuzzer-parse_cbor.cpp index aea25852f1..db92aca8fd 100644 --- a/tests/src/fuzzer-parse_cbor.cpp +++ b/tests/src/fuzzer-parse_cbor.cpp @@ -20,8 +20,8 @@ drivers. */ #include -#include #include +#include using json = nlohmann::json; diff --git a/tests/src/fuzzer-parse_json.cpp b/tests/src/fuzzer-parse_json.cpp index 152ac5bffe..be04e80309 100644 --- a/tests/src/fuzzer-parse_json.cpp +++ b/tests/src/fuzzer-parse_json.cpp @@ -21,8 +21,8 @@ drivers. */ #include -#include #include +#include using json = nlohmann::json; diff --git a/tests/src/fuzzer-parse_msgpack.cpp b/tests/src/fuzzer-parse_msgpack.cpp index 861d7b23ca..0106b4053a 100644 --- a/tests/src/fuzzer-parse_msgpack.cpp +++ b/tests/src/fuzzer-parse_msgpack.cpp @@ -20,8 +20,8 @@ drivers. */ #include -#include #include +#include using json = nlohmann::json; diff --git a/tests/src/fuzzer-parse_ubjson.cpp b/tests/src/fuzzer-parse_ubjson.cpp index 0c04a3d1e5..2830bef758 100644 --- a/tests/src/fuzzer-parse_ubjson.cpp +++ b/tests/src/fuzzer-parse_ubjson.cpp @@ -26,8 +26,8 @@ drivers. */ #include -#include #include +#include using json = nlohmann::json; diff --git a/tests/src/make_test_data_available.hpp b/tests/src/make_test_data_available.hpp index 35d4ee2fe0..23c54cdffc 100644 --- a/tests/src/make_test_data_available.hpp +++ b/tests/src/make_test_data_available.hpp @@ -13,7 +13,8 @@ #include // unique_ptr #include -namespace utils { +namespace utils +{ inline bool check_testsuite_downloaded() { @@ -23,7 +24,10 @@ inline bool check_testsuite_downloaded() TEST_CASE("check test suite is downloaded") { - REQUIRE_MESSAGE(utils::check_testsuite_downloaded(), "Test data not found in '" TEST_DATA_DIRECTORY "'. Please execute target 'download_test_data' before running this test suite. See for more information."); + REQUIRE_MESSAGE( + utils::check_testsuite_downloaded(), + "Test data not found in '" TEST_DATA_DIRECTORY + "'. Please execute target 'download_test_data' before running this test suite. See for more information."); } } // namespace utils diff --git a/tests/src/test_utils.hpp b/tests/src/test_utils.hpp index c52c7eb9fb..74d1e958e3 100644 --- a/tests/src/test_utils.hpp +++ b/tests/src/test_utils.hpp @@ -12,7 +12,8 @@ #include // ifstream, istreambuf_iterator, ios #include // vector -namespace utils { +namespace utils +{ inline std::vector read_binary_file(const std::string& filename) { diff --git a/tests/src/unit-32bit.cpp b/tests/src/unit-32bit.cpp index 32f5b8335a..eceb9781b4 100644 --- a/tests/src/unit-32bit.cpp +++ b/tests/src/unit-32bit.cpp @@ -110,10 +110,14 @@ TEST_CASE("BJData") std::vector const vMX = {'[', '$', 'U', '#', '[', 'M', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 'U', 0x01, ']'}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", json::out_of_range&); + CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), + "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", + json::out_of_range&); CHECK(json::from_bjdata(vM, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vMX), "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", json::out_of_range&); + CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vMX), + "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", + json::out_of_range&); CHECK(json::from_bjdata(vMX, true, false).is_discarded()); } @@ -123,10 +127,14 @@ TEST_CASE("BJData") std::vector const vM = {'[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']'}; json _; - 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_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()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", json::out_of_range&); + CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), + "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", + json::out_of_range&); CHECK(json::from_bjdata(vM, true, false).is_discarded()); } } diff --git a/tests/src/unit-algorithms.cpp b/tests/src/unit-algorithms.cpp index e4b6106317..1a9049f009 100644 --- a/tests/src/unit-algorithms.cpp +++ b/tests/src/unit-algorithms.cpp @@ -201,7 +201,9 @@ TEST_CASE("algorithms") SECTION("sorting an object") { json j({{"one", 1}, {"two", 2}}); - CHECK_THROWS_WITH_AS(std::sort(j.begin(), j.end()), "[json.exception.invalid_iterator.209] cannot use offsets with object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(std::sort(j.begin(), j.end()), + "[json.exception.invalid_iterator.209] cannot use offsets with object iterators", + json::invalid_iterator&); } } diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index f5c028c626..98a8ac6b22 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -12,7 +12,8 @@ #include using nlohmann::json; -namespace { +namespace +{ // special test case to check if memory is leaked if constructor throws template struct bad_allocator : std::allocator @@ -43,21 +44,15 @@ TEST_CASE("bad_alloc") SECTION("bad_alloc") { // create JSON type using the throwing allocator - using bad_json = nlohmann::basic_json; + using bad_json = nlohmann::basic_json; // creating an object should throw CHECK_THROWS_AS(bad_json(bad_json::value_t::object), std::bad_alloc&); } } -namespace { +namespace +{ bool next_construct_fails = false; bool next_destroy_fails = false; bool next_deallocate_fails = false; @@ -123,14 +118,7 @@ void my_allocator_clean_up(T* p) TEST_CASE("controlled bad_alloc") { // create JSON type using the throwing allocator - using my_json = nlohmann::basic_json; + using my_json = nlohmann::basic_json; SECTION("class json_value") { @@ -219,7 +207,8 @@ TEST_CASE("controlled bad_alloc") } } -namespace { +namespace +{ template struct allocator_no_forward : std::allocator { @@ -247,14 +236,7 @@ TEST_CASE("bad my_allocator::construct") { SECTION("my_allocator::construct doesn't forward") { - using bad_alloc_json = nlohmann::basic_json; + using bad_alloc_json = nlohmann::basic_json; bad_alloc_json j; j["test"] = bad_alloc_json::array_t(); diff --git a/tests/src/unit-alt-string.cpp b/tests/src/unit-alt-string.cpp index d86f9d71d1..4c31f833d5 100644 --- a/tests/src/unit-alt-string.cpp +++ b/tests/src/unit-alt-string.cpp @@ -174,16 +174,7 @@ void int_to_string(alt_string& target, std::size_t value) target = std::to_string(value).c_str(); } -using alt_json = nlohmann::basic_json< - std::map, - std::vector, - alt_string, - bool, - std::int64_t, - std::uint64_t, - double, - std::allocator, - nlohmann::adl_serializer>; +using alt_json = nlohmann::basic_json; bool operator<(const char* op1, const alt_string& op2) noexcept { diff --git a/tests/src/unit-assert_macro.cpp b/tests/src/unit-assert_macro.cpp index d059130f6f..a9a04f1d68 100644 --- a/tests/src/unit-assert_macro.cpp +++ b/tests/src/unit-assert_macro.cpp @@ -18,10 +18,10 @@ DOCTEST_CLANG_SUPPRESS_WARNING("-Wstrict-overflow") static int assert_counter; /// set failure variable to true instead of calling assert(x) -#define JSON_ASSERT(x) \ - { \ - if (!(x)) \ - ++assert_counter; \ +#define JSON_ASSERT(x) \ + { \ + if (!(x)) \ + ++assert_counter; \ } #include diff --git a/tests/src/unit-bjdata.cpp b/tests/src/unit-bjdata.cpp index 6cd927df50..dec0a14c57 100644 --- a/tests/src/unit-bjdata.cpp +++ b/tests/src/unit-bjdata.cpp @@ -21,7 +21,8 @@ using nlohmann::json; #include #include -namespace { +namespace +{ class SaxCountdown { public: @@ -89,7 +90,9 @@ class SaxCountdown return events_left-- > 0; } - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static) + bool parse_error(std::size_t /*unused*/, + const std::string& /*unused*/, + const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static) { return false; } @@ -316,14 +319,10 @@ TEST_CASE("BJData") // check individual bytes CHECK(result[0] == 'L'); - int64_t const restored = (static_cast(result[8]) << 070) + - (static_cast(result[7]) << 060) + - (static_cast(result[6]) << 050) + - (static_cast(result[5]) << 040) + - (static_cast(result[4]) << 030) + - (static_cast(result[3]) << 020) + - (static_cast(result[2]) << 010) + - static_cast(result[1]); + int64_t const restored = (static_cast(result[8]) << 070) + (static_cast(result[7]) << 060) + + (static_cast(result[6]) << 050) + (static_cast(result[5]) << 040) + + (static_cast(result[4]) << 030) + (static_cast(result[3]) << 020) + + (static_cast(result[2]) << 010) + static_cast(result[1]); CHECK(restored == i); // roundtrip @@ -369,10 +368,8 @@ TEST_CASE("BJData") // check individual bytes CHECK(result[0] == 'l'); - int32_t const restored = (static_cast(result[4]) << 030) + - (static_cast(result[3]) << 020) + - (static_cast(result[2]) << 010) + - static_cast(result[1]); + int32_t const restored = (static_cast(result[4]) << 030) + (static_cast(result[3]) << 020) + + (static_cast(result[2]) << 010) + static_cast(result[1]); CHECK(restored == i); // roundtrip @@ -575,11 +572,7 @@ TEST_CASE("BJData") SECTION("32768..65535 (uint16)") { - for (const uint32_t i : - { - 32768u, - 55555u, - 65535u}) + for (const uint32_t i : {32768u, 55555u, 65535u}) { CAPTURE(i) @@ -615,11 +608,7 @@ TEST_CASE("BJData") SECTION("65536..2147483647 (int32)") { - for (const uint32_t i : - { - 65536u, - 77777u, - 2147483647u}) + for (const uint32_t i : {65536u, 77777u, 2147483647u}) { CAPTURE(i) @@ -646,10 +635,8 @@ TEST_CASE("BJData") // check individual bytes CHECK(result[0] == 'l'); - uint32_t const restored = (static_cast(result[4]) << 030) + - (static_cast(result[3]) << 020) + - (static_cast(result[2]) << 010) + - static_cast(result[1]); + uint32_t const restored = (static_cast(result[4]) << 030) + (static_cast(result[3]) << 020) + + (static_cast(result[2]) << 010) + static_cast(result[1]); CHECK(restored == i); // roundtrip @@ -660,11 +647,7 @@ TEST_CASE("BJData") SECTION("2147483648..4294967295 (uint32)") { - for (const uint32_t i : - { - 2147483648u, - 3333333333u, - 4294967295u}) + for (const uint32_t i : {2147483648u, 3333333333u, 4294967295u}) { CAPTURE(i) @@ -691,10 +674,8 @@ TEST_CASE("BJData") // check individual bytes CHECK(result[0] == 'm'); - uint32_t const restored = (static_cast(result[4]) << 030) + - (static_cast(result[3]) << 020) + - (static_cast(result[2]) << 010) + - static_cast(result[1]); + uint32_t const restored = (static_cast(result[4]) << 030) + (static_cast(result[3]) << 020) + + (static_cast(result[2]) << 010) + static_cast(result[1]); CHECK(restored == i); // roundtrip @@ -737,14 +718,10 @@ TEST_CASE("BJData") // check individual bytes CHECK(result[0] == 'L'); - uint64_t const restored = (static_cast(result[8]) << 070) + - (static_cast(result[7]) << 060) + - (static_cast(result[6]) << 050) + - (static_cast(result[5]) << 040) + - (static_cast(result[4]) << 030) + - (static_cast(result[3]) << 020) + - (static_cast(result[2]) << 010) + - static_cast(result[1]); + uint64_t const restored = (static_cast(result[8]) << 070) + (static_cast(result[7]) << 060) + + (static_cast(result[6]) << 050) + (static_cast(result[5]) << 040) + + (static_cast(result[4]) << 030) + (static_cast(result[3]) << 020) + + (static_cast(result[2]) << 010) + static_cast(result[1]); CHECK(restored == i); // roundtrip @@ -786,14 +763,10 @@ TEST_CASE("BJData") // check individual bytes CHECK(result[0] == 'M'); - uint64_t const restored = (static_cast(result[8]) << 070) + - (static_cast(result[7]) << 060) + - (static_cast(result[6]) << 050) + - (static_cast(result[5]) << 040) + - (static_cast(result[4]) << 030) + - (static_cast(result[3]) << 020) + - (static_cast(result[2]) << 010) + - static_cast(result[1]); + uint64_t const restored = (static_cast(result[8]) << 070) + (static_cast(result[7]) << 060) + + (static_cast(result[6]) << 050) + (static_cast(result[5]) << 040) + + (static_cast(result[4]) << 030) + (static_cast(result[3]) << 020) + + (static_cast(result[2]) << 010) + static_cast(result[1]); CHECK(restored == i); // roundtrip @@ -904,11 +877,7 @@ TEST_CASE("BJData") SECTION("32768..65535 (uint16)") { - for (const uint32_t i : - { - 32768u, - 55555u, - 65535u}) + for (const uint32_t i : {32768u, 55555u, 65535u}) { CAPTURE(i) @@ -942,11 +911,7 @@ TEST_CASE("BJData") } SECTION("65536..2147483647 (int32)") { - for (const uint32_t i : - { - 65536u, - 77777u, - 2147483647u}) + for (const uint32_t i : {65536u, 77777u, 2147483647u}) { CAPTURE(i) @@ -972,10 +937,8 @@ TEST_CASE("BJData") // check individual bytes CHECK(result[0] == 'l'); - uint32_t const restored = (static_cast(result[4]) << 030) + - (static_cast(result[3]) << 020) + - (static_cast(result[2]) << 010) + - static_cast(result[1]); + uint32_t const restored = (static_cast(result[4]) << 030) + (static_cast(result[3]) << 020) + + (static_cast(result[2]) << 010) + static_cast(result[1]); CHECK(restored == i); // roundtrip @@ -986,11 +949,7 @@ TEST_CASE("BJData") SECTION("2147483648..4294967295 (uint32)") { - for (const uint32_t i : - { - 2147483648u, - 3333333333u, - 4294967295u}) + for (const uint32_t i : {2147483648u, 3333333333u, 4294967295u}) { CAPTURE(i) @@ -1016,10 +975,8 @@ TEST_CASE("BJData") // check individual bytes CHECK(result[0] == 'm'); - uint32_t const restored = (static_cast(result[4]) << 030) + - (static_cast(result[3]) << 020) + - (static_cast(result[2]) << 010) + - static_cast(result[1]); + uint32_t const restored = (static_cast(result[4]) << 030) + (static_cast(result[3]) << 020) + + (static_cast(result[2]) << 010) + static_cast(result[1]); CHECK(restored == i); // roundtrip @@ -1061,14 +1018,10 @@ TEST_CASE("BJData") // check individual bytes CHECK(result[0] == 'L'); - uint64_t const restored = (static_cast(result[8]) << 070) + - (static_cast(result[7]) << 060) + - (static_cast(result[6]) << 050) + - (static_cast(result[5]) << 040) + - (static_cast(result[4]) << 030) + - (static_cast(result[3]) << 020) + - (static_cast(result[2]) << 010) + - static_cast(result[1]); + uint64_t const restored = (static_cast(result[8]) << 070) + (static_cast(result[7]) << 060) + + (static_cast(result[6]) << 050) + (static_cast(result[5]) << 040) + + (static_cast(result[4]) << 030) + (static_cast(result[3]) << 020) + + (static_cast(result[2]) << 010) + static_cast(result[1]); CHECK(restored == i); // roundtrip @@ -1110,14 +1063,10 @@ TEST_CASE("BJData") // check individual bytes CHECK(result[0] == 'M'); - uint64_t const restored = (static_cast(result[8]) << 070) + - (static_cast(result[7]) << 060) + - (static_cast(result[6]) << 050) + - (static_cast(result[5]) << 040) + - (static_cast(result[4]) << 030) + - (static_cast(result[3]) << 020) + - (static_cast(result[2]) << 010) + - static_cast(result[1]); + uint64_t const restored = (static_cast(result[8]) << 070) + (static_cast(result[7]) << 060) + + (static_cast(result[6]) << 050) + (static_cast(result[5]) << 040) + + (static_cast(result[4]) << 030) + (static_cast(result[3]) << 020) + + (static_cast(result[2]) << 010) + static_cast(result[1]); CHECK(restored == i); // roundtrip @@ -1132,17 +1081,7 @@ TEST_CASE("BJData") { double v = 3.1415925; json const j = v; - std::vector const expected = - { - 'D', - 0xfc, - 0xde, - 0xa6, - 0x3f, - 0xfb, - 0x21, - 0x09, - 0x40}; + std::vector const expected = {'D', 0xfc, 0xde, 0xa6, 0x3f, 0xfb, 0x21, 0x09, 0x40}; const auto result = json::to_bjdata(j); CHECK(result == expected); @@ -1170,7 +1109,10 @@ TEST_CASE("BJData") { json _; 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_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()); } @@ -1178,7 +1120,10 @@ TEST_CASE("BJData") { json _; 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_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()); } } @@ -1274,7 +1219,8 @@ TEST_CASE("BJData") { SECTION("unsigned integer number") { - 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'}; + 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"); @@ -1282,7 +1228,8 @@ TEST_CASE("BJData") SECTION("signed integer number") { - 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'}; + 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"); @@ -1290,7 +1237,8 @@ TEST_CASE("BJData") SECTION("floating-point number") { - 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'}; + 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"); @@ -1307,11 +1255,20 @@ TEST_CASE("BJData") json _; 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); + 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 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); + 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 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); + 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); } } } @@ -1389,14 +1346,7 @@ TEST_CASE("BJData") SECTION("N = 256..32767") { - for (const size_t N : - { - 256u, - 999u, - 1025u, - 3333u, - 2048u, - 32767u}) + for (const size_t N : {256u, 999u, 1025u, 3333u, 2048u, 32767u}) { CAPTURE(N) @@ -1427,11 +1377,7 @@ TEST_CASE("BJData") SECTION("N = 32768..65535") { - for (const size_t N : - { - 32768u, - 55555u, - 65535u}) + for (const size_t N : {32768u, 55555u, 65535u}) { CAPTURE(N) @@ -1462,11 +1408,7 @@ TEST_CASE("BJData") SECTION("N = 65536..2147483647") { - for (const size_t N : - { - 65536u, - 77777u, - 1048576u}) + for (const size_t N : {65536u, 77777u, 1048576u}) { CAPTURE(N) @@ -1590,14 +1532,7 @@ TEST_CASE("BJData") SECTION("N = 256..32767") { - for (const std::size_t N : - { - 256u, - 999u, - 1025u, - 3333u, - 2048u, - 32767u}) + for (const std::size_t N : {256u, 999u, 1025u, 3333u, 2048u, 32767u}) { CAPTURE(N) @@ -1631,11 +1566,7 @@ TEST_CASE("BJData") SECTION("N = 32768..65535") { - for (const std::size_t N : - { - 32768u, - 55555u, - 65535u}) + for (const std::size_t N : {32768u, 55555u, 65535u}) { CAPTURE(N) @@ -1669,11 +1600,7 @@ TEST_CASE("BJData") SECTION("N = 65536..2147483647") { - for (const std::size_t N : - { - 65536u, - 77777u, - 1048576u}) + for (const std::size_t N : {65536u, 77777u, 1048576u}) { CAPTURE(N) @@ -2101,25 +2028,7 @@ TEST_CASE("BJData") SECTION("size=false type=false") { json const j = json::parse(R"({"a": {"b": {"c": {}}}})"); - std::vector const expected = - { - '{', - 'i', - 1, - 'a', - '{', - 'i', - 1, - 'b', - '{', - 'i', - 1, - 'c', - '{', - '}', - '}', - '}', - '}'}; + std::vector const expected = {'{', 'i', 1, 'a', '{', 'i', 1, 'b', '{', 'i', 1, 'c', '{', '}', '}', '}', '}'}; const auto result = json::to_bjdata(j); CHECK(result == expected); @@ -2131,33 +2040,8 @@ TEST_CASE("BJData") SECTION("size=true type=false") { json const j = json::parse(R"({"a": {"b": {"c": {}}}})"); - std::vector const expected = - { - '{', - '#', - 'i', - 1, - 'i', - 1, - 'a', - '{', - '#', - 'i', - 1, - 'i', - 1, - 'b', - '{', - '#', - 'i', - 1, - 'i', - 1, - 'c', - '{', - '#', - 'i', - 0}; + std::vector const expected = {'{', '#', 'i', 1, 'i', 1, 'a', '{', '#', 'i', 1, 'i', 1, + 'b', '{', '#', 'i', 1, 'i', 1, 'c', '{', '#', 'i', 0}; const auto result = json::to_bjdata(j, true); CHECK(result == expected); @@ -2169,33 +2053,8 @@ TEST_CASE("BJData") SECTION("size=true type=true ignore object type marker") { json const j = json::parse(R"({"a": {"b": {"c": {}}}})"); - std::vector const expected = - { - '{', - '#', - 'i', - 1, - 'i', - 1, - 'a', - '{', - '#', - 'i', - 1, - 'i', - 1, - 'b', - '{', - '#', - 'i', - 1, - 'i', - 1, - 'c', - '{', - '#', - 'i', - 0}; + std::vector const expected = {'{', '#', 'i', 1, 'i', 1, 'a', '{', '#', 'i', 1, 'i', 1, + 'b', '{', '#', 'i', 1, 'i', 1, 'c', '{', '#', 'i', 0}; const auto result = json::to_bjdata(j, true, true); CHECK(result == expected); @@ -2221,9 +2080,10 @@ TEST_CASE("BJData") SECTION("strict mode") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vec), - "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing BJData value: expected end of input; last byte: 0x5A", - json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(vec), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing BJData value: expected end of input; last byte: 0x5A", + json::parse_error&); } } } @@ -2396,9 +2256,12 @@ TEST_CASE("BJData") std::vector const v_u = {'[', '#', 'i', 2, 'u', 0x0F, 0xA7, 'u', 0x0F, 0xA7}; std::vector const v_l = {'[', '#', 'i', 2, 'l', 0xFF, 0xFF, 0xFF, 0x7F, 'l', 0xFF, 0xFF, 0xFF, 0x7F}; std::vector const v_m = {'[', '#', 'i', 2, 'm', 0xFF, 0xC9, 0x9A, 0xBB, 'm', 0xFF, 0xC9, 0x9A, 0xBB}; - std::vector const v_L = {'[', '#', 'i', 2, 'L', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 'L', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}; - std::vector const v_M = {'[', '#', 'i', 2, 'M', 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 'M', 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; - std::vector const v_D = {'[', '#', 'i', 2, 'D', 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40, 'D', 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40}; + std::vector const v_L = {'[', '#', 'i', 2, 'L', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x7F, 'L', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}; + std::vector const v_M = {'[', '#', 'i', 2, 'M', 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, + 0xE0, 0x8D, 'M', 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; + std::vector const v_D = {'[', '#', 'i', 2, 'D', 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, + 0x09, 0x40, 'D', 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40}; std::vector const v_S = {'[', '#', 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'}; std::vector const v_C = {'[', '#', 'i', 2, 'C', 'a', 'C', 'a'}; @@ -2445,9 +2308,12 @@ TEST_CASE("BJData") std::vector const v_u = {'[', '$', 'u', '#', 'i', 2, 0x0F, 0xA7, 0x0F, 0xA7}; std::vector const v_l = {'[', '$', 'l', '#', 'i', 2, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F}; std::vector const v_m = {'[', '$', 'm', '#', 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB}; - std::vector const v_L = {'[', '$', 'L', '#', '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, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; - std::vector const v_D = {'[', '$', 'D', '#', 'i', 2, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40}; + std::vector const v_L = {'[', '$', 'L', '#', '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, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, + 0xB6, 0xE0, 0x8D, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; + std::vector const v_D = {'[', '$', 'D', '#', '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, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'}; std::vector const v_C = {'[', '$', 'C', '#', 'i', 2, 'a', 'a'}; @@ -2490,9 +2356,12 @@ TEST_CASE("BJData") 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_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'}; @@ -2518,14 +2387,28 @@ TEST_CASE("BJData") std::vector const v_e = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 1, 0xFE, 0xFF}; std::vector const v_U = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; std::vector const v_i = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; - std::vector const v_u = {'[', '$', 'u', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00}; - std::vector const v_I = {'[', '$', 'I', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00}; - std::vector const v_m = {'[', '$', 'm', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00}; - std::vector const v_l = {'[', '$', 'l', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00}; - std::vector const v_M = {'[', '$', 'M', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - std::vector const v_L = {'[', '$', 'L', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - std::vector const v_d = {'[', '$', 'd', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0xA0, 0x40, 0x00, 0x00, 0xC0, 0x40}; - std::vector const v_D = {'[', '$', 'D', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x40}; + std::vector const v_u = {'[', '$', 'u', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, + 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00}; + std::vector const v_I = {'[', '$', 'I', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, + 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00}; + std::vector const v_m = {'[', '$', 'm', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00}; + std::vector const v_l = {'[', '$', 'l', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00}; + std::vector const v_M = {'[', '$', 'M', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + std::vector const v_L = {'[', '$', 'L', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + std::vector const v_d = {'[', '$', 'd', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, + 0x00, 0x40, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0xA0, 0x40, 0x00, 0x00, 0xC0, 0x40}; + std::vector const v_D = {'[', '$', 'D', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x40}; std::vector const v_C = {'[', '$', 'C', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 'a', 'b', 'c', 'd', 'e', 'f'}; // check if vector is parsed correctly @@ -2569,9 +2452,12 @@ TEST_CASE("BJData") 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_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}; @@ -2602,9 +2488,12 @@ TEST_CASE("BJData") 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_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'}; @@ -2651,14 +2540,18 @@ TEST_CASE("BJData") { 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&); + 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 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"); + 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"); } } @@ -2668,14 +2561,19 @@ TEST_CASE("BJData") { 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&); + 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 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&); + 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&); } SECTION("parse bjdata markers in ubjson") @@ -2687,9 +2585,18 @@ TEST_CASE("BJData") json _; // check if string is parsed correctly to "a" - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(s_u), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON string: expected length type specification (U, i, I, l, L); last byte: 0x75", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(s_m), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON string: expected length type specification (U, i, I, l, L); last byte: 0x6D", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(s_M), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON string: expected length type specification (U, i, I, l, L); last byte: 0x4D", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_ubjson(s_u), + "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON string: expected length type specification (U, i, I, l, L); last byte: 0x75", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_ubjson(s_m), + "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON string: expected length type specification (U, i, I, l, L); last byte: 0x6D", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_ubjson(s_M), + "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON string: expected length type specification (U, i, I, l, L); last byte: 0x4D", + json::parse_error&); } } @@ -2699,7 +2606,10 @@ TEST_CASE("BJData") { 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&); + 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") @@ -2718,44 +2628,79 @@ TEST_CASE("BJData") 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&); + 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&); CHECK(json::from_bjdata(v1, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v2), "[json.exception.parse_error.113] parse error at byte 6: syntax error while parsing BJData size: count in an optimized container must be positive", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(v2), + "[json.exception.parse_error.113] parse error at byte 6: syntax error while parsing BJData size: count in an optimized container must be positive", + json::parse_error&); CHECK(json::from_bjdata(v2, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v3), "[json.exception.parse_error.113] parse error at byte 7: syntax error while parsing BJData size: count in an optimized container must be positive", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(v3), + "[json.exception.parse_error.113] parse error at byte 7: syntax error while parsing BJData size: count in an optimized container must be positive", + json::parse_error&); CHECK(json::from_bjdata(v3, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v4), "[json.exception.parse_error.113] parse error at byte 6: syntax error while parsing BJData size: count in an optimized container must be positive", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(v4), + "[json.exception.parse_error.113] parse error at byte 6: syntax error while parsing BJData size: count in an optimized container must be positive", + json::parse_error&); CHECK(json::from_bjdata(v4, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v5), "[json.exception.parse_error.113] parse error at byte 7: syntax error while parsing BJData size: count in an optimized container must be positive", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(v5), + "[json.exception.parse_error.113] parse error at byte 7: syntax error while parsing BJData size: count in an optimized container must be positive", + json::parse_error&); CHECK(json::from_bjdata(v5, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v6), "[json.exception.parse_error.113] parse error at byte 5: syntax error while parsing BJData size: count in an optimized container must be positive", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(v6), + "[json.exception.parse_error.113] parse error at byte 5: syntax error while parsing BJData size: count in an optimized container must be positive", + json::parse_error&); CHECK(json::from_bjdata(v6, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vI), "[json.exception.parse_error.113] parse error at byte 5: syntax error while parsing BJData size: count in an optimized container must be positive", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(vI), + "[json.exception.parse_error.113] parse error at byte 5: syntax error while parsing BJData size: count in an optimized container must be positive", + json::parse_error&); CHECK(json::from_bjdata(vI, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vl), "[json.exception.parse_error.113] parse error at byte 7: syntax error while parsing BJData size: count in an optimized container must be positive", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(vl), + "[json.exception.parse_error.113] parse error at byte 7: syntax error while parsing BJData size: count in an optimized container must be positive", + json::parse_error&); CHECK(json::from_bjdata(vl, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vL), "[json.exception.parse_error.113] parse error at byte 11: syntax error while parsing BJData size: count in an optimized container must be positive", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(vL), + "[json.exception.parse_error.113] parse error at byte 11: syntax error while parsing BJData size: count in an optimized container must be positive", + json::parse_error&); CHECK(json::from_bjdata(vL, true, false).is_discarded()); #if SIZE_MAX != 0xffffffff - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), "[json.exception.out_of_range.408] syntax error while parsing BJData size: excessive ndarray size caused overflow", json::out_of_range&); + CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), + "[json.exception.out_of_range.408] syntax error while parsing BJData size: excessive ndarray size caused overflow", + json::out_of_range&); #else - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", json::out_of_range&); + CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), + "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", + json::out_of_range&); #endif CHECK(json::from_bjdata(vM, true, false).is_discarded()); #if SIZE_MAX != 0xffffffff - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vMX), "[json.exception.out_of_range.408] syntax error while parsing BJData size: excessive ndarray size caused overflow", json::out_of_range&); + CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vMX), + "[json.exception.out_of_range.408] syntax error while parsing BJData size: excessive ndarray size caused overflow", + json::out_of_range&); #else - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vMX), "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", json::out_of_range&); + CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vMX), + "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", + json::out_of_range&); #endif CHECK(json::from_bjdata(vMX, true, false).is_discarded()); } @@ -2767,9 +2712,13 @@ TEST_CASE("BJData") std::vector const vM = {'[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']'}; json _; - 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_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()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", json::out_of_range&); + CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM), + "[json.exception.out_of_range.408] syntax error while parsing BJData size: integer value overflow", + json::out_of_range&); CHECK(json::from_bjdata(vM, true, false).is_discarded()); #endif } @@ -2782,16 +2731,28 @@ TEST_CASE("BJData") 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_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()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v_T), "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x54 is not a permitted optimized array type", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(v_T), + "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x54 is not a permitted optimized array type", + json::parse_error&); CHECK(json::from_bjdata(v_T, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v_F), "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x46 is not a permitted optimized array type", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(v_F), + "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x46 is not a permitted optimized array type", + json::parse_error&); CHECK(json::from_bjdata(v_F, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v_Z), "[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_THROWS_WITH_AS( + _ = json::from_bjdata(v_Z), + "[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_Z, true, false).is_discarded()); } @@ -2803,16 +2764,28 @@ TEST_CASE("BJData") 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_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()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v_T), "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x54 is not a permitted optimized array type", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(v_T), + "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x54 is not a permitted optimized array type", + json::parse_error&); CHECK(json::from_bjdata(v_T, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v_F), "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x46 is not a permitted optimized array type", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bjdata(v_F), + "[json.exception.parse_error.112] parse error at byte 3: syntax error while parsing BJData type: marker 0x46 is not a permitted optimized array type", + json::parse_error&); CHECK(json::from_bjdata(v_F, true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v_Z), "[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_THROWS_WITH_AS( + _ = json::from_bjdata(v_Z), + "[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_Z, true, false).is_discarded()); } } @@ -2821,15 +2794,21 @@ TEST_CASE("BJData") { 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_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 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_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 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_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()); } @@ -2837,39 +2816,57 @@ TEST_CASE("BJData") { 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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()); } @@ -2877,19 +2874,31 @@ TEST_CASE("BJData") { json _; 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_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 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_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 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_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 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_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()); } @@ -2897,19 +2906,28 @@ TEST_CASE("BJData") { 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_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 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_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 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_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 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_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()); } @@ -2917,15 +2935,21 @@ TEST_CASE("BJData") { 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_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 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_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 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_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()); } @@ -2933,43 +2957,65 @@ TEST_CASE("BJData") { 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 const vT1 = {'[', '$', 'T', '#', '[', '$', 'i', '#', 'i', 2, 2, 3}; @@ -2979,39 +3025,65 @@ TEST_CASE("BJData") CHECK(json::from_bjdata(vh, true, false).is_discarded()); 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 dimensional vector is not allowed", json::parse_error&); + 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 dimensional vector is not allowed", + json::parse_error&); CHECK(json::from_bjdata(vR, true, false).is_discarded()); 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_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 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 dimensional vector is not allowed", json::parse_error&); + 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 dimensional vector is not allowed", + json::parse_error&); CHECK(json::from_bjdata(vR1, true, false).is_discarded()); 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_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 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_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 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_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 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 dimensional vector is not allowed", json::parse_error&); + 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 dimensional vector is not allowed", + json::parse_error&); CHECK(json::from_bjdata(vR5, true, false).is_discarded()); 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_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 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 dimensional vector is not allowed", json::parse_error&); + 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 dimensional vector is not allowed", + json::parse_error&); CHECK(json::from_bjdata(vH, true, false).is_discarded()); } @@ -3019,43 +3091,65 @@ TEST_CASE("BJData") { 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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()); } } @@ -3109,7 +3203,8 @@ TEST_CASE("BJData") SECTION("array of L") { json const j = {5000000000, -5000000000}; - std::vector const expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFA, 0xD5, 0xFE, 0xFF, 0xFF, 0xFF}; + std::vector const 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); } } @@ -3173,8 +3268,10 @@ TEST_CASE("BJData") SECTION("array of L") { json const j = {5000000000u, 5000000001u}; - std::vector const expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00, 0x01, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00}; - std::vector const expected_size = {'[', '#', 'i', 2, 'L', 0x00, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00, 'L', 0x01, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00}; + std::vector const expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0xF2, 0x05, 0x2A, 0x01, + 0x00, 0x00, 0x00, 0x01, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00}; + std::vector const 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); CHECK(json::to_bjdata(j, true) == expected_size); } @@ -3182,8 +3279,10 @@ TEST_CASE("BJData") SECTION("array of M") { json const j = {10223372036854775807ull, 10223372036854775808ull}; - std::vector const expected = {'[', '$', 'M', '#', 'i', 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 0x00, 0x00, 0x64, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; - std::vector const expected_size = {'[', '#', 'i', 2, 'M', 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 'M', 0x00, 0x00, 0x64, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; + std::vector const expected = {'[', '$', 'M', '#', 'i', 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, + 0xB6, 0xE0, 0x8D, 0x00, 0x00, 0x64, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D}; + std::vector const 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); CHECK(json::to_bjdata(j, true) == expected_size); } @@ -3205,7 +3304,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { json const j = {"foo", "bar", "baz"}; std::vector v = {'[', 'S', 'i', 3, 'f', 'o', 'o', 'S', 'i', 3, 'b', 'a', 'r', 'S', 'i', 3, 'b', 'a', 'z', ']'}; - 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', ']'}; + 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', ']'}; CHECK(json::to_bjdata(j) == v); CHECK(json::from_bjdata(v) == j); CHECK(json::from_bjdata(v2) == j); @@ -3214,140 +3314,29 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") SECTION("Boolean Types") { json const j = {{"authorized", true}, {"verified", false}}; - std::vector v = {'{', 'i', 10, 'a', 'u', 't', 'h', 'o', 'r', 'i', 'z', 'e', 'd', 'T', 'i', 8, 'v', 'e', 'r', 'i', 'f', 'i', 'e', 'd', 'F', '}'}; + std::vector v = {'{', 'i', 10, 'a', 'u', 't', 'h', 'o', 'r', 'i', 'z', 'e', 'd', + 'T', 'i', 8, 'v', 'e', 'r', 'i', 'f', 'i', 'e', 'd', 'F', '}'}; CHECK(json::to_bjdata(j) == v); CHECK(json::from_bjdata(v) == j); } SECTION("Numeric Types") { - json j = - { - {"int8", 16}, - {"uint8", 255}, - {"int16", 32767}, - {"uint16", 42767}, - {"int32", 2147483647}, - {"uint32", 3147483647}, - {"int64", 9223372036854775807}, - {"uint64", 10223372036854775807ull}, - {"float64", 113243.7863123}}; - std::vector v = {'{', - 'i', - 7, - 'f', - 'l', - 'o', - 'a', - 't', - '6', - '4', - 'D', - 0xcf, - 0x34, - 0xbc, - 0x94, - 0xbc, - 0xa5, - 0xfb, - 0x40, - 'i', - 5, - 'i', - 'n', - 't', - '1', - '6', - 'I', - 0xff, - 0x7f, - 'i', - 5, - 'i', - 'n', - 't', - '3', - '2', - 'l', - 0xff, - 0xff, - 0xff, - 0x7f, - 'i', - 5, - 'i', - 'n', - 't', - '6', - '4', - 'L', - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0x7f, - 'i', - 4, - 'i', - 'n', - 't', - '8', - 'i', - 16, - 'i', - 6, - 'u', - 'i', - 'n', - 't', - '1', - '6', - 'u', - 0x0F, - 0xA7, - 'i', - 6, - 'u', - 'i', - 'n', - 't', - '3', - '2', - 'm', - 0xFF, - 0xC9, - 0x9A, - 0xBB, - 'i', - 6, - 'u', - 'i', - 'n', - 't', - '6', - '4', - 'M', - 0xFF, - 0xFF, - 0x63, - 0xA7, - 0xB3, - 0xB6, - 0xE0, - 0x8D, - 'i', - 5, - 'u', - 'i', - 'n', - 't', - '8', - 'U', - 0xff, - '}'}; + json j = {{"int8", 16}, + {"uint8", 255}, + {"int16", 32767}, + {"uint16", 42767}, + {"int32", 2147483647}, + {"uint32", 3147483647}, + {"int64", 9223372036854775807}, + {"uint64", 10223372036854775807ull}, + {"float64", 113243.7863123}}; + std::vector v = {'{', 'i', 7, 'f', 'l', 'o', 'a', 't', '6', '4', 'D', 0xcf, 0x34, 0xbc, 0x94, 0xbc, 0xa5, 0xfb, 0x40, 'i', + 5, 'i', 'n', 't', '1', '6', 'I', 0xff, 0x7f, 'i', 5, 'i', 'n', 't', '3', '2', 'l', 0xff, 0xff, 0xff, + 0x7f, 'i', 5, 'i', 'n', 't', '6', '4', 'L', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 'i', 4, 'i', + 'n', 't', '8', 'i', 16, 'i', 6, 'u', 'i', 'n', 't', '1', '6', 'u', 0x0F, 0xA7, 'i', 6, 'u', 'i', + 'n', 't', '3', '2', 'm', 0xFF, 0xC9, 0x9A, 0xBB, 'i', 6, 'u', 'i', 'n', 't', '6', '4', 'M', 0xFF, 0xFF, + 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D, 'i', 5, 'u', 'i', 'n', 't', '8', 'U', 0xff, '}'}; CHECK(json::to_bjdata(j) == v); CHECK(json::from_bjdata(v) == j); } @@ -3393,7 +3382,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the float has been replaced by a double json const j = {nullptr, true, false, 4782345193, 153.132, "ham"}; - std::vector v = {'[', 'Z', 'T', 'F', 'L', 0xE9, 0xCB, 0x0C, 0x1D, 0x01, 0x00, 0x00, 0x00, 'D', 0x4e, 0x62, 0x10, 0x58, 0x39, 0x24, 0x63, 0x40, 'S', 'i', 3, 'h', 'a', 'm', ']'}; + std::vector v = {'[', 'Z', 'T', 'F', 'L', 0xE9, 0xCB, 0x0C, 0x1D, 0x01, 0x00, 0x00, 0x00, 'D', 0x4e, + 0x62, 0x10, 0x58, 0x39, 0x24, 0x63, 0x40, 'S', 'i', 3, 'h', 'a', 'm', ']'}; CHECK(json::to_bjdata(j) == v); CHECK(json::from_bjdata(v) == j); } @@ -3402,7 +3392,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the float has been replaced by a double json const j = {nullptr, true, false, 4782345193, 153.132, "ham"}; - std::vector v = {'[', '#', 'i', 6, 'Z', 'T', 'F', 'L', 0xE9, 0xCB, 0x0C, 0x1D, 0x01, 0x00, 0x00, 0x00, 'D', 0x4e, 0x62, 0x10, 0x58, 0x39, 0x24, 0x63, 0x40, 'S', 'i', 3, 'h', 'a', 'm'}; + std::vector v = {'[', '#', 'i', 6, 'Z', 'T', 'F', 'L', 0xE9, 0xCB, 0x0C, 0x1D, 0x01, 0x00, 0x00, 0x00, + 'D', 0x4e, 0x62, 0x10, 0x58, 0x39, 0x24, 0x63, 0x40, 'S', 'i', 3, 'h', 'a', 'm'}; CHECK(json::to_bjdata(j, true) == v); CHECK(json::from_bjdata(v) == j); } @@ -3411,7 +3402,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the float has been replaced by a double json const j = {nullptr, true, false, 4782345193, 153.132, "ham"}; - std::vector v = {'[', '#', 'i', 6, 'Z', 'T', 'F', 'L', 0xE9, 0xCB, 0x0C, 0x1D, 0x01, 0x00, 0x00, 0x00, 'D', 0x4e, 0x62, 0x10, 0x58, 0x39, 0x24, 0x63, 0x40, 'S', 'i', 3, 'h', 'a', 'm'}; + std::vector v = {'[', '#', 'i', 6, 'Z', 'T', 'F', 'L', 0xE9, 0xCB, 0x0C, 0x1D, 0x01, 0x00, 0x00, 0x00, + 'D', 0x4e, 0x62, 0x10, 0x58, 0x39, 0x24, 0x63, 0x40, 'S', 'i', 3, 'h', 'a', 'm'}; CHECK(json::to_bjdata(j, true, true) == v); CHECK(json::from_bjdata(v) == j); } @@ -3421,103 +3413,23 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { SECTION("size=false type=false") { - json j = - { - {"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; - std::vector v = {'{', 'i', 4, 'p', 'o', 's', 't', '{', 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, 'r', 'k', 'a', 'l', 'l', 'a', 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ', 't', 'o', 't', 'a', 'l', 'l', 'y', ' ', 'a', 'g', 'r', 'e', 'e', '!', 'i', 2, 'i', 'd', 'I', 0x71, 0x04, 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'L', 0x60, 0x66, 0x78, 0xB1, 0x3D, 0x01, 0x00, 0x00, '}', '}'}; + json j = {{"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; + std::vector v = {'{', 'i', 4, 'p', 'o', 's', 't', '{', 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, 'r', + 'k', 'a', 'l', 'l', 'a', 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ', 't', 'o', 't', 'a', + 'l', 'l', 'y', ' ', 'a', 'g', 'r', 'e', 'e', '!', 'i', 2, 'i', 'd', 'I', 0x71, 0x04, 'i', 9, 't', + 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'L', 0x60, 0x66, 0x78, 0xB1, 0x3D, 0x01, 0x00, 0x00, '}', '}'}; CHECK(json::to_bjdata(j) == v); CHECK(json::from_bjdata(v) == j); } SECTION("size=true type=false") { - json j = - { - {"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; + json j = {{"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; std::vector v = { - '{', - '#', - 'i', - 1, - 'i', - 4, - 'p', - 'o', - 's', - 't', - '{', - '#', - 'i', - 4, - 'i', - 6, - 'a', - 'u', - 't', - 'h', - 'o', - 'r', - 'S', - 'i', - 6, - 'r', - 'k', - 'a', - 'l', - 'l', - 'a', - 'i', - 4, - 'b', - 'o', - 'd', - 'y', - 'S', - 'i', - 16, - 'I', - ' ', - 't', - 'o', - 't', - 'a', - 'l', - 'l', - 'y', - ' ', - 'a', - 'g', - 'r', - 'e', - 'e', - '!', - 'i', - 2, - 'i', - 'd', - 'I', - 0x71, - 0x04, - 'i', - 9, - 't', - 'i', - 'm', - 'e', - 's', - 't', - 'a', - 'm', - 'p', - 'L', - 0x60, - 0x66, - 0x78, - 0xB1, - 0x3D, - 0x01, - 0x00, - 0x00, + '{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '{', '#', 'i', 4, 'i', 6, 'a', 'u', 't', 'h', 'o', + 'r', 'S', 'i', 6, 'r', 'k', 'a', 'l', 'l', 'a', 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ', + 't', 'o', 't', 'a', 'l', 'l', 'y', ' ', 'a', 'g', 'r', 'e', 'e', '!', 'i', 2, 'i', 'd', 'I', 0x71, 0x04, + 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'L', 0x60, 0x66, 0x78, 0xB1, 0x3D, 0x01, 0x00, 0x00, }; CHECK(json::to_bjdata(j, true) == v); CHECK(json::from_bjdata(v) == j); @@ -3525,93 +3437,12 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") SECTION("size=true type=true") { - json j = - { - {"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; + json j = {{"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; std::vector v = { - '{', - '#', - 'i', - 1, - 'i', - 4, - 'p', - 'o', - 's', - 't', - '{', - '#', - 'i', - 4, - 'i', - 6, - 'a', - 'u', - 't', - 'h', - 'o', - 'r', - 'S', - 'i', - 6, - 'r', - 'k', - 'a', - 'l', - 'l', - 'a', - 'i', - 4, - 'b', - 'o', - 'd', - 'y', - 'S', - 'i', - 16, - 'I', - ' ', - 't', - 'o', - 't', - 'a', - 'l', - 'l', - 'y', - ' ', - 'a', - 'g', - 'r', - 'e', - 'e', - '!', - 'i', - 2, - 'i', - 'd', - 'I', - 0x71, - 0x04, - 'i', - 9, - 't', - 'i', - 'm', - 'e', - 's', - 't', - 'a', - 'm', - 'p', - 'L', - 0x60, - 0x66, - 0x78, - 0xB1, - 0x3D, - 0x01, - 0x00, - 0x00, + '{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '{', '#', 'i', 4, 'i', 6, 'a', 'u', 't', 'h', 'o', + 'r', 'S', 'i', 6, 'r', 'k', 'a', 'l', 'l', 'a', 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ', + 't', 'o', 't', 'a', 'l', 'l', 'y', ' ', 'a', 'g', 'r', 'e', 'e', '!', 'i', 2, 'i', 'd', 'I', 0x71, 0x04, + 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'L', 0x60, 0x66, 0x78, 0xB1, 0x3D, 0x01, 0x00, 0x00, }; CHECK(json::to_bjdata(j, true, true) == v); CHECK(json::from_bjdata(v) == j); @@ -3626,53 +3457,9 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the floats have been replaced by doubles json const j = {29.97, 31.13, 67.0, 2.113, 23.888}; - std::vector v = {'[', - 'D', - 0xb8, - 0x1e, - 0x85, - 0xeb, - 0x51, - 0xf8, - 0x3d, - 0x40, - 'D', - 0xe1, - 0x7a, - 0x14, - 0xae, - 0x47, - 0x21, - 0x3f, - 0x40, - 'D', - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xc0, - 0x50, - 0x40, - 'D', - 0x81, - 0x95, - 0x43, - 0x8b, - 0x6c, - 0xe7, - 0x00, - 0x40, - 'D', - 0x17, - 0xd9, - 0xce, - 0xf7, - 0x53, - 0xe3, - 0x37, - 0x40, - ']'}; + std::vector v = {'[', 'D', 0xb8, 0x1e, 0x85, 0xeb, 0x51, 0xf8, 0x3d, 0x40, 'D', 0xe1, 0x7a, 0x14, 0xae, 0x47, + 0x21, 0x3f, 0x40, 'D', 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x50, 0x40, 'D', 0x81, 0x95, 0x43, + 0x8b, 0x6c, 0xe7, 0x00, 0x40, 'D', 0x17, 0xd9, 0xce, 0xf7, 0x53, 0xe3, 0x37, 0x40, ']'}; CHECK(json::to_bjdata(j) == v); CHECK(json::from_bjdata(v) == j); } @@ -3682,55 +3469,9 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") // note the floats have been replaced by doubles json const j = {29.97, 31.13, 67.0, 2.113, 23.888}; std::vector v = { - '[', - '#', - 'i', - 5, - 'D', - 0xb8, - 0x1e, - 0x85, - 0xeb, - 0x51, - 0xf8, - 0x3d, - 0x40, - 'D', - 0xe1, - 0x7a, - 0x14, - 0xae, - 0x47, - 0x21, - 0x3f, - 0x40, - 'D', - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xc0, - 0x50, - 0x40, - 'D', - 0x81, - 0x95, - 0x43, - 0x8b, - 0x6c, - 0xe7, - 0x00, - 0x40, - 'D', - 0x17, - 0xd9, - 0xce, - 0xf7, - 0x53, - 0xe3, - 0x37, - 0x40, + '[', '#', 'i', 5, 'D', 0xb8, 0x1e, 0x85, 0xeb, 0x51, 0xf8, 0x3d, 0x40, 'D', 0xe1, 0x7a, 0x14, + 0xae, 0x47, 0x21, 0x3f, 0x40, 'D', 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x50, 0x40, 'D', 0x81, 0x95, + 0x43, 0x8b, 0x6c, 0xe7, 0x00, 0x40, 'D', 0x17, 0xd9, 0xce, 0xf7, 0x53, 0xe3, 0x37, 0x40, }; CHECK(json::to_bjdata(j, true) == v); CHECK(json::from_bjdata(v) == j); @@ -3741,52 +3482,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") // note the floats have been replaced by doubles json const j = {29.97, 31.13, 67.0, 2.113, 23.888}; std::vector v = { - '[', - '$', - 'D', - '#', - 'i', - 5, - 0xb8, - 0x1e, - 0x85, - 0xeb, - 0x51, - 0xf8, - 0x3d, - 0x40, - 0xe1, - 0x7a, - 0x14, - 0xae, - 0x47, - 0x21, - 0x3f, - 0x40, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xc0, - 0x50, - 0x40, - 0x81, - 0x95, - 0x43, - 0x8b, - 0x6c, - 0xe7, - 0x00, - 0x40, - 0x17, - 0xd9, - 0xce, - 0xf7, - 0x53, - 0xe3, - 0x37, - 0x40, + '[', '$', 'D', '#', 'i', 5, 0xb8, 0x1e, 0x85, 0xeb, 0x51, 0xf8, 0x3d, 0x40, 0xe1, 0x7a, 0x14, 0xae, 0x47, 0x21, 0x3f, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0x50, 0x40, 0x81, 0x95, 0x43, 0x8b, 0x6c, 0xe7, 0x00, 0x40, 0x17, 0xd9, 0xce, 0xf7, 0x53, 0xe3, 0x37, 0x40, }; CHECK(json::to_bjdata(j, true, true) == v); CHECK(json::from_bjdata(v) == j); @@ -3799,51 +3496,9 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the floats have been replaced by doubles json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}}; - std::vector v = {'{', - 'i', - 3, - 'a', - 'l', - 't', - 'D', - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xc0, - 0x50, - 0x40, - 'i', - 3, - 'l', - 'a', - 't', - 'D', - 0x60, - 0xe5, - 0xd0, - 0x22, - 0xdb, - 0xf9, - 0x3d, - 0x40, - 'i', - 4, - 'l', - 'o', - 'n', - 'g', - 'D', - 0xa8, - 0xc6, - 0x4b, - 0x37, - 0x89, - 0x21, - 0x3f, - 0x40, - '}'}; + std::vector v = {'{', 'i', 3, 'a', 'l', 't', 'D', 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x50, 0x40, + 'i', 3, 'l', 'a', 't', 'D', 0x60, 0xe5, 0xd0, 0x22, 0xdb, 0xf9, 0x3d, 0x40, 'i', + 4, 'l', 'o', 'n', 'g', 'D', 0xa8, 0xc6, 0x4b, 0x37, 0x89, 0x21, 0x3f, 0x40, '}'}; CHECK(json::to_bjdata(j) == v); CHECK(json::from_bjdata(v) == j); } @@ -3853,53 +3508,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") // note the floats have been replaced by doubles json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}}; std::vector v = { - '{', - '#', - 'i', - 3, - 'i', - 3, - 'a', - 'l', - 't', - 'D', - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xc0, - 0x50, - 0x40, - 'i', - 3, - 'l', - 'a', - 't', - 'D', - 0x60, - 0xe5, - 0xd0, - 0x22, - 0xdb, - 0xf9, - 0x3d, - 0x40, - 'i', - 4, - 'l', - 'o', - 'n', - 'g', - 'D', - 0xa8, - 0xc6, - 0x4b, - 0x37, - 0x89, - 0x21, - 0x3f, - 0x40, + '{', '#', 'i', 3, 'i', 3, 'a', 'l', 't', 'D', 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x50, 0x40, 'i', 3, 'l', 'a', 't', 'D', + 0x60, 0xe5, 0xd0, 0x22, 0xdb, 0xf9, 0x3d, 0x40, 'i', 4, 'l', 'o', 'n', 'g', 'D', 0xa8, 0xc6, 0x4b, 0x37, 0x89, 0x21, 0x3f, 0x40, }; CHECK(json::to_bjdata(j, true) == v); CHECK(json::from_bjdata(v) == j); @@ -3910,52 +3520,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") // note the floats have been replaced by doubles json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}}; std::vector v = { - '{', - '$', - 'D', - '#', - 'i', - 3, - 'i', - 3, - 'a', - 'l', - 't', - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xc0, - 0x50, - 0x40, - 'i', - 3, - 'l', - 'a', - 't', - 0x60, - 0xe5, - 0xd0, - 0x22, - 0xdb, - 0xf9, - 0x3d, - 0x40, - 'i', - 4, - 'l', - 'o', - 'n', - 'g', - 0xa8, - 0xc6, - 0x4b, - 0x37, - 0x89, - 0x21, - 0x3f, - 0x40, + '{', '$', 'D', '#', 'i', 3, 'i', 3, 'a', 'l', 't', 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x50, 0x40, 'i', 3, 'l', 'a', + 't', 0x60, 0xe5, 0xd0, 0x22, 0xdb, 0xf9, 0x3d, 0x40, 'i', 4, 'l', 'o', 'n', 'g', 0xa8, 0xc6, 0x4b, 0x37, 0x89, 0x21, 0x3f, 0x40, }; CHECK(json::to_bjdata(j, true, true) == v); CHECK(json::from_bjdata(v) == j); @@ -3968,15 +3534,22 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { json _; 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_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()); } SECTION("Object") { json _; - 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&); + 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()); } } @@ -3987,28 +3560,7 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") TEST_CASE("all BJData first bytes") { // these bytes will fail immediately with exception parse_error.112 - std::set supported = - { - 'T', - 'F', - 'Z', - 'U', - 'i', - 'I', - 'l', - 'L', - 'd', - 'D', - 'C', - 'S', - '[', - '{', - 'N', - 'H', - 'u', - 'm', - 'M', - 'h'}; + std::set supported = {'T', 'F', 'Z', 'U', 'i', 'I', 'l', 'L', 'd', 'D', 'C', 'S', '[', '{', 'N', 'H', 'u', 'm', 'M', 'h'}; for (auto i = 0; i < 256; ++i) { @@ -4041,50 +3593,48 @@ TEST_CASE("BJData roundtrips" * doctest::skip()) { SECTION("input from self-generated BJData files") { - for (const std::string filename : - { - TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json", - TEST_DATA_DIRECTORY "/json.org/1.json", - TEST_DATA_DIRECTORY "/json.org/2.json", - TEST_DATA_DIRECTORY "/json.org/3.json", - TEST_DATA_DIRECTORY "/json.org/4.json", - TEST_DATA_DIRECTORY "/json.org/5.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip01.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip02.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip03.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip04.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip05.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip06.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip07.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip08.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip09.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip10.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip11.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip12.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip13.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip14.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip15.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip16.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip17.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip18.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip19.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip20.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip21.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip22.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip23.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip24.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip25.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip26.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip27.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip28.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip29.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip30.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip31.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip32.json", - TEST_DATA_DIRECTORY "/json_testsuite/sample.json", - TEST_DATA_DIRECTORY "/json_tests/pass1.json", - TEST_DATA_DIRECTORY "/json_tests/pass2.json", - TEST_DATA_DIRECTORY "/json_tests/pass3.json"}) + for (const std::string filename : {TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json", + TEST_DATA_DIRECTORY "/json.org/1.json", + TEST_DATA_DIRECTORY "/json.org/2.json", + TEST_DATA_DIRECTORY "/json.org/3.json", + TEST_DATA_DIRECTORY "/json.org/4.json", + TEST_DATA_DIRECTORY "/json.org/5.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip01.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip02.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip03.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip04.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip05.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip06.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip07.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip08.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip09.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip10.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip11.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip12.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip13.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip14.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip15.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip16.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip17.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip18.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip19.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip20.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip21.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip22.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip23.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip24.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip25.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip26.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip27.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip28.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip29.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip30.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip31.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip32.json", + TEST_DATA_DIRECTORY "/json_testsuite/sample.json", + TEST_DATA_DIRECTORY "/json_tests/pass1.json", + TEST_DATA_DIRECTORY "/json_tests/pass2.json", + TEST_DATA_DIRECTORY "/json_tests/pass3.json"}) { CAPTURE(filename) diff --git a/tests/src/unit-bson.cpp b/tests/src/unit-bson.cpp index fd6c1667a5..5759b6e1d2 100644 --- a/tests/src/unit-bson.cpp +++ b/tests/src/unit-bson.cpp @@ -24,7 +24,9 @@ TEST_CASE("BSON") SECTION("null") { json const j = nullptr; - CHECK_THROWS_WITH_AS(json::to_bson(j), "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is null", json::type_error&); + CHECK_THROWS_WITH_AS(json::to_bson(j), + "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is null", + json::type_error&); } SECTION("boolean") @@ -32,48 +34,60 @@ TEST_CASE("BSON") SECTION("true") { json const j = true; - CHECK_THROWS_WITH_AS(json::to_bson(j), "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is boolean", json::type_error&); + CHECK_THROWS_WITH_AS(json::to_bson(j), + "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is boolean", + json::type_error&); } SECTION("false") { json const j = false; - CHECK_THROWS_WITH_AS(json::to_bson(j), "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is boolean", json::type_error&); + CHECK_THROWS_WITH_AS(json::to_bson(j), + "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is boolean", + json::type_error&); } } SECTION("number") { json const j = 42; - CHECK_THROWS_WITH_AS(json::to_bson(j), "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is number", json::type_error&); + CHECK_THROWS_WITH_AS(json::to_bson(j), + "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is number", + json::type_error&); } SECTION("float") { json const j = 4.2; - CHECK_THROWS_WITH_AS(json::to_bson(j), "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is number", json::type_error&); + CHECK_THROWS_WITH_AS(json::to_bson(j), + "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is number", + json::type_error&); } SECTION("string") { json const j = "not supported"; - CHECK_THROWS_WITH_AS(json::to_bson(j), "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is string", json::type_error&); + CHECK_THROWS_WITH_AS(json::to_bson(j), + "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is string", + json::type_error&); } SECTION("array") { json const j = std::vector{1, 2, 3, 4, 5, 6, 7}; - CHECK_THROWS_WITH_AS(json::to_bson(j), "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is array", json::type_error&); + CHECK_THROWS_WITH_AS(json::to_bson(j), + "[json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is array", + json::type_error&); } } SECTION("keys containing code-point U+0000 cannot be serialized to BSON") { - json const j = - { - {std::string("en\0try", 6), true}}; + json const j = {{std::string("en\0try", 6), true}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(json::to_bson(j), "[json.exception.out_of_range.409] (/en) BSON key cannot contain code point U+0000 (at byte 2)", json::out_of_range&); + CHECK_THROWS_WITH_AS(json::to_bson(j), + "[json.exception.out_of_range.409] (/en) BSON key cannot contain code point U+0000 (at byte 2)", + json::out_of_range&); #else CHECK_THROWS_WITH_AS(json::to_bson(j), "[json.exception.out_of_range.409] BSON key cannot contain code point U+0000 (at byte 2)", json::out_of_range&); #endif @@ -82,20 +96,12 @@ TEST_CASE("BSON") SECTION("string length must be at least 1") { // from https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11175 - std::vector const v = - { - 0x20, - 0x20, - 0x20, - 0x20, - 0x02, - 0x00, - 0x00, - 0x00, - 0x00, - 0x80}; + std::vector const v = {0x20, 0x20, 0x20, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x80}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_bson(v), "[json.exception.parse_error.112] parse error at byte 10: syntax error while parsing BSON string: string length must be at least 1, is -2147483648", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_bson(v), + "[json.exception.parse_error.112] parse error at byte 10: syntax error while parsing BSON string: string length must be at least 1, is -2147483648", + json::parse_error&); } SECTION("objects") @@ -103,15 +109,14 @@ TEST_CASE("BSON") SECTION("empty object") { json const j = json::object(); - std::vector const expected = - { - 0x05, - 0x00, - 0x00, - 0x00, // size (little endian) - // no entries - 0x00 // end marker - }; + std::vector const expected = { + 0x05, + 0x00, + 0x00, + 0x00, // size (little endian) + // no entries + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -123,26 +128,23 @@ TEST_CASE("BSON") SECTION("non-empty object with bool") { - json const j = - { - {"entry", true}}; + json const j = {{"entry", true}}; - std::vector const expected = - { - 0x0D, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x08, // entry: boolean - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0x01, // value = true - 0x00 // end marker - }; + std::vector const expected = { + 0x0D, + 0x00, + 0x00, + 0x00, // size (little endian) + 0x08, // entry: boolean + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + 0x01, // value = true + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -154,26 +156,23 @@ TEST_CASE("BSON") SECTION("non-empty object with bool") { - json const j = - { - {"entry", false}}; + json const j = {{"entry", false}}; - std::vector const expected = - { - 0x0D, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x08, // entry: boolean - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0x00, // value = false - 0x00 // end marker - }; + std::vector const expected = { + 0x0D, + 0x00, + 0x00, + 0x00, // size (little endian) + 0x08, // entry: boolean + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + 0x00, // value = false + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -185,33 +184,15 @@ TEST_CASE("BSON") SECTION("non-empty object with double") { - json const j = - { - {"entry", 4.2}}; + json const j = {{"entry", 4.2}}; - std::vector const expected = - { - 0x14, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x01, /// entry: double - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0xcd, - 0xcc, - 0xcc, - 0xcc, - 0xcc, - 0xcc, - 0x10, - 0x40, - 0x00 // end marker - }; + std::vector const expected = { + 0x14, 0x00, 0x00, + 0x00, // size (little endian) + 0x01, /// entry: double + 'e', 'n', 't', 'r', 'y', '\x00', 0xcd, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x10, 0x40, + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -223,37 +204,15 @@ TEST_CASE("BSON") SECTION("non-empty object with string") { - json const j = - { - {"entry", "bsonstr"}}; + json const j = {{"entry", "bsonstr"}}; - std::vector const expected = - { - 0x18, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x02, /// entry: string (UTF-8) - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0x08, - 0x00, - 0x00, - 0x00, - 'b', - 's', - 'o', - 'n', - 's', - 't', - 'r', - '\x00', - 0x00 // end marker - }; + std::vector const expected = { + 0x18, 0x00, 0x00, + 0x00, // size (little endian) + 0x02, /// entry: string (UTF-8) + 'e', 'n', 't', 'r', 'y', '\x00', 0x08, 0x00, 0x00, 0x00, 'b', 's', 'o', 'n', 's', 't', 'r', '\x00', + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -265,25 +224,22 @@ TEST_CASE("BSON") SECTION("non-empty object with null member") { - json const j = - { - {"entry", nullptr}}; + json const j = {{"entry", nullptr}}; - std::vector const expected = - { - 0x0C, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x0A, /// entry: null - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0x00 // end marker - }; + std::vector const expected = { + 0x0C, + 0x00, + 0x00, + 0x00, // size (little endian) + 0x0A, /// entry: null + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -295,29 +251,26 @@ TEST_CASE("BSON") SECTION("non-empty object with integer (32-bit) member") { - json const j = - { - {"entry", std::int32_t{0x12345678}}}; + json const j = {{"entry", std::int32_t{0x12345678}}}; - std::vector const expected = - { - 0x10, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x10, /// entry: int32 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0x78, - 0x56, - 0x34, - 0x12, - 0x00 // end marker - }; + std::vector const expected = { + 0x10, + 0x00, + 0x00, + 0x00, // size (little endian) + 0x10, /// entry: int32 + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + 0x78, + 0x56, + 0x34, + 0x12, + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -329,33 +282,15 @@ TEST_CASE("BSON") SECTION("non-empty object with integer (64-bit) member") { - json const j = - { - {"entry", std::int64_t{0x1234567804030201}}}; + json const j = {{"entry", std::int64_t{0x1234567804030201}}}; - std::vector const expected = - { - 0x14, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x12, /// entry: int64 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0x01, - 0x02, - 0x03, - 0x04, - 0x78, - 0x56, - 0x34, - 0x12, - 0x00 // end marker - }; + std::vector const expected = { + 0x14, 0x00, 0x00, + 0x00, // size (little endian) + 0x12, /// entry: int64 + 'e', 'n', 't', 'r', 'y', '\x00', 0x01, 0x02, 0x03, 0x04, 0x78, 0x56, 0x34, 0x12, + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -367,29 +302,26 @@ TEST_CASE("BSON") SECTION("non-empty object with negative integer (32-bit) member") { - json const j = - { - {"entry", std::int32_t{-1}}}; + json const j = {{"entry", std::int32_t{-1}}}; - std::vector const expected = - { - 0x10, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x10, /// entry: int32 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0x00 // end marker - }; + std::vector const expected = { + 0x10, + 0x00, + 0x00, + 0x00, // size (little endian) + 0x10, /// entry: int32 + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -401,29 +333,26 @@ TEST_CASE("BSON") SECTION("non-empty object with negative integer (64-bit) member") { - json const j = - { - {"entry", std::int64_t{-1}}}; + json const j = {{"entry", std::int64_t{-1}}}; - std::vector const expected = - { - 0x10, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x10, /// entry: int32 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0x00 // end marker - }; + std::vector const expected = { + 0x10, + 0x00, + 0x00, + 0x00, // size (little endian) + 0x10, /// entry: int32 + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -436,33 +365,15 @@ TEST_CASE("BSON") SECTION("non-empty object with unsigned integer (64-bit) member") { // directly encoding uint64 is not supported in bson (only for timestamp values) - json const j = - { - {"entry", std::uint64_t{0x1234567804030201}}}; + json const j = {{"entry", std::uint64_t{0x1234567804030201}}}; - std::vector const expected = - { - 0x14, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x12, /// entry: int64 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0x01, - 0x02, - 0x03, - 0x04, - 0x78, - 0x56, - 0x34, - 0x12, - 0x00 // end marker - }; + std::vector const expected = { + 0x14, 0x00, 0x00, + 0x00, // size (little endian) + 0x12, /// entry: int64 + 'e', 'n', 't', 'r', 'y', '\x00', 0x01, 0x02, 0x03, 0x04, 0x78, 0x56, 0x34, 0x12, + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -474,29 +385,26 @@ TEST_CASE("BSON") SECTION("non-empty object with small unsigned integer member") { - json const j = - { - {"entry", std::uint64_t{0x42}}}; + json const j = {{"entry", std::uint64_t{0x42}}}; - std::vector const expected = - { - 0x10, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x10, /// entry: int32 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0x42, - 0x00, - 0x00, - 0x00, - 0x00 // end marker - }; + std::vector const expected = { + 0x10, + 0x00, + 0x00, + 0x00, // size (little endian) + 0x10, /// entry: int32 + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + 0x42, + 0x00, + 0x00, + 0x00, + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -508,33 +416,30 @@ TEST_CASE("BSON") SECTION("non-empty object with object member") { - json const j = - { - {"entry", json::object()}}; + json const j = {{"entry", json::object()}}; - std::vector const expected = - { - 0x11, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x03, /// entry: embedded document - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - - 0x05, - 0x00, - 0x00, - 0x00, // size (little endian) - // no entries - 0x00, // end marker (embedded document) - - 0x00 // end marker - }; + std::vector const expected = { + 0x11, + 0x00, + 0x00, + 0x00, // size (little endian) + 0x03, /// entry: embedded document + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + + 0x05, + 0x00, + 0x00, + 0x00, // size (little endian) + // no entries + 0x00, // end marker (embedded document) + + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -546,33 +451,30 @@ TEST_CASE("BSON") SECTION("non-empty object with array member") { - json const j = - { - {"entry", json::array()}}; + json const j = {{"entry", json::array()}}; - std::vector const expected = - { - 0x11, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x04, /// entry: embedded document - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - - 0x05, - 0x00, - 0x00, - 0x00, // size (little endian) - // no entries - 0x00, // end marker (embedded document) - - 0x00 // end marker - }; + std::vector const expected = { + 0x11, + 0x00, + 0x00, + 0x00, // size (little endian) + 0x04, /// entry: embedded document + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + + 0x05, + 0x00, + 0x00, + 0x00, // size (little endian) + // no entries + 0x00, // end marker (embedded document) + + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -584,88 +486,23 @@ TEST_CASE("BSON") SECTION("non-empty object with non-empty array member") { - json const j = - { - {"entry", json::array({1, 2, 3, 4, 5, 6, 7, 8})}}; + json const j = {{"entry", json::array({1, 2, 3, 4, 5, 6, 7, 8})}}; - std::vector const expected = - { - 0x49, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x04, /// entry: embedded document - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - - 0x3D, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x10, - '0', - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x10, - '1', - 0x00, - 0x02, - 0x00, - 0x00, - 0x00, - 0x10, - '2', - 0x00, - 0x03, - 0x00, - 0x00, - 0x00, - 0x10, - '3', - 0x00, - 0x04, - 0x00, - 0x00, - 0x00, - 0x10, - '4', - 0x00, - 0x05, - 0x00, - 0x00, - 0x00, - 0x10, - '5', - 0x00, - 0x06, - 0x00, - 0x00, - 0x00, - 0x10, - '6', - 0x00, - 0x07, - 0x00, - 0x00, - 0x00, - 0x10, - '7', - 0x00, - 0x08, - 0x00, - 0x00, - 0x00, - 0x00, // end marker (embedded document) - - 0x00 // end marker - }; + std::vector const expected = { + 0x49, 0x00, 0x00, + 0x00, // size (little endian) + 0x04, /// entry: embedded document + 'e', 'n', 't', 'r', 'y', '\x00', + + 0x3D, 0x00, 0x00, + 0x00, // size (little endian) + 0x10, '0', 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, '1', 0x00, 0x02, 0x00, 0x00, 0x00, 0x10, '2', 0x00, 0x03, 0x00, + 0x00, 0x00, 0x10, '3', 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, '4', 0x00, 0x05, 0x00, 0x00, 0x00, 0x10, '5', 0x00, + 0x06, 0x00, 0x00, 0x00, 0x10, '6', 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, '7', 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, // end marker (embedded document) + + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -679,42 +516,21 @@ TEST_CASE("BSON") { const size_t N = 10; const auto s = std::vector(N, 'x'); - json const j = - { - {"entry", json::binary(s, 0)}}; + json const j = {{"entry", json::binary(s, 0)}}; - std::vector const expected = - { - 0x1B, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x05, // entry: binary - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - - 0x0A, - 0x00, - 0x00, - 0x00, // size of binary (little endian) - 0x00, // Generic binary subtype - 0x78, - 0x78, - 0x78, - 0x78, - 0x78, - 0x78, - 0x78, - 0x78, - 0x78, - 0x78, - - 0x00 // end marker - }; + std::vector const expected = { + 0x1B, 0x00, 0x00, + 0x00, // size (little endian) + 0x05, // entry: binary + 'e', 'n', 't', 'r', 'y', '\x00', + + 0x0A, 0x00, 0x00, + 0x00, // size of binary (little endian) + 0x00, // Generic binary subtype + 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, + + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -728,48 +544,21 @@ TEST_CASE("BSON") { // an MD5 hash const std::vector md5hash = {0xd7, 0x7e, 0x27, 0x54, 0xbe, 0x12, 0x37, 0xfe, 0xd6, 0x0c, 0x33, 0x98, 0x30, 0x3b, 0x8d, 0xc4}; - json const j = - { - {"entry", json::binary(md5hash, 5)}}; + json const j = {{"entry", json::binary(md5hash, 5)}}; - std::vector const expected = - { - 0x21, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x05, // entry: binary - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - - 0x10, - 0x00, - 0x00, - 0x00, // size of binary (little endian) - 0x05, // MD5 binary subtype - 0xd7, - 0x7e, - 0x27, - 0x54, - 0xbe, - 0x12, - 0x37, - 0xfe, - 0xd6, - 0x0c, - 0x33, - 0x98, - 0x30, - 0x3b, - 0x8d, - 0xc4, - - 0x00 // end marker - }; + std::vector const expected = { + 0x21, 0x00, 0x00, + 0x00, // size (little endian) + 0x05, // entry: binary + 'e', 'n', 't', 'r', 'y', '\x00', + + 0x10, 0x00, 0x00, + 0x00, // size of binary (little endian) + 0x05, // MD5 binary subtype + 0xd7, 0x7e, 0x27, 0x54, 0xbe, 0x12, 0x37, 0xfe, 0xd6, 0x0c, 0x33, 0x98, 0x30, 0x3b, 0x8d, 0xc4, + + 0x00 // end marker + }; const auto result = json::to_bson(j); CHECK(result == expected); @@ -782,94 +571,87 @@ TEST_CASE("BSON") SECTION("Some more complex document") { // directly encoding uint64 is not supported in bson (only for timestamp values) - json const j = - { - {"double", 42.5}, - {"entry", 4.2}, - {"number", 12345}, - {"object", {{"string", "value"}}}}; - - std::vector const expected = - { - /*size */ 0x4f, - 0x00, - 0x00, - 0x00, - /*entry*/ 0x01, - 'd', - 'o', - 'u', - 'b', - 'l', - 'e', - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x40, - 0x45, - 0x40, - /*entry*/ 0x01, - 'e', - 'n', - 't', - 'r', - 'y', - 0x00, - 0xcd, - 0xcc, - 0xcc, - 0xcc, - 0xcc, - 0xcc, - 0x10, - 0x40, - /*entry*/ 0x10, - 'n', - 'u', - 'm', - 'b', - 'e', - 'r', - 0x00, - 0x39, - 0x30, - 0x00, - 0x00, - /*entry*/ 0x03, - 'o', - 'b', - 'j', - 'e', - 'c', - 't', - 0x00, - /*entry: obj-size */ 0x17, - 0x00, - 0x00, - 0x00, - /*entry: obj-entry*/ 0x02, - 's', - 't', - 'r', - 'i', - 'n', - 'g', - 0x00, - 0x06, - 0x00, - 0x00, - 0x00, - 'v', - 'a', - 'l', - 'u', - 'e', - 0, - /*entry: obj-term.*/ 0x00, - /*obj-term*/ 0x00}; + json const j = {{"double", 42.5}, {"entry", 4.2}, {"number", 12345}, {"object", {{"string", "value"}}}}; + + std::vector const expected = {/*size */ 0x4f, + 0x00, + 0x00, + 0x00, + /*entry*/ 0x01, + 'd', + 'o', + 'u', + 'b', + 'l', + 'e', + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x45, + 0x40, + /*entry*/ 0x01, + 'e', + 'n', + 't', + 'r', + 'y', + 0x00, + 0xcd, + 0xcc, + 0xcc, + 0xcc, + 0xcc, + 0xcc, + 0x10, + 0x40, + /*entry*/ 0x10, + 'n', + 'u', + 'm', + 'b', + 'e', + 'r', + 0x00, + 0x39, + 0x30, + 0x00, + 0x00, + /*entry*/ 0x03, + 'o', + 'b', + 'j', + 'e', + 'c', + 't', + 0x00, + /*entry: obj-size */ 0x17, + 0x00, + 0x00, + 0x00, + /*entry: obj-entry*/ 0x02, + 's', + 't', + 'r', + 'i', + 'n', + 'g', + 0x00, + 0x06, + 0x00, + 0x00, + 0x00, + 'v', + 'a', + 'l', + 'u', + 'e', + 0, + /*entry: obj-term.*/ 0x00, + /*obj-term*/ 0x00}; const auto result = json::to_bson(j); CHECK(result == expected); @@ -884,7 +666,8 @@ TEST_CASE("BSON") { SECTION("Example 1") { - std::vector input = {0x16, 0x00, 0x00, 0x00, 0x02, 'h', 'e', 'l', 'l', 'o', 0x00, 0x06, 0x00, 0x00, 0x00, 'w', 'o', 'r', 'l', 'd', 0x00, 0x00}; + std::vector input = {0x16, 0x00, 0x00, 0x00, 0x02, 'h', 'e', 'l', 'l', 'o', 0x00, + 0x06, 0x00, 0x00, 0x00, 'w', 'o', 'r', 'l', 'd', 0x00, 0x00}; json parsed = json::from_bson(input); json expected = {{"hello", "world"}}; CHECK(parsed == expected); @@ -895,7 +678,9 @@ TEST_CASE("BSON") SECTION("Example 2") { - std::vector input = {0x31, 0x00, 0x00, 0x00, 0x04, 'B', 'S', 'O', 'N', 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x30, 0x00, 0x08, 0x00, 0x00, 0x00, 'a', 'w', 'e', 's', 'o', 'm', 'e', 0x00, 0x01, 0x31, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x14, 0x40, 0x10, 0x32, 0x00, 0xc2, 0x07, 0x00, 0x00, 0x00, 0x00}; + std::vector input = {0x31, 0x00, 0x00, 0x00, 0x04, 'B', 'S', 'O', 'N', 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x30, 0x00, + 0x08, 0x00, 0x00, 0x00, 'a', 'w', 'e', 's', 'o', 'm', 'e', 0x00, 0x01, 0x31, 0x00, 0x33, 0x33, + 0x33, 0x33, 0x33, 0x33, 0x14, 0x40, 0x10, 0x32, 0x00, 0xc2, 0x07, 0x00, 0x00, 0x00, 0x00}; json parsed = json::from_bson(input); json expected = {{"BSON", {"awesome", 5.05, 1986}}}; CHECK(parsed == expected); @@ -908,94 +693,87 @@ TEST_CASE("BSON") TEST_CASE("BSON input/output_adapters") { - json json_representation = - { - {"double", 42.5}, - {"entry", 4.2}, - {"number", 12345}, - {"object", {{"string", "value"}}}}; - - std::vector const bson_representation = - { - /*size */ 0x4f, - 0x00, - 0x00, - 0x00, - /*entry*/ 0x01, - 'd', - 'o', - 'u', - 'b', - 'l', - 'e', - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x40, - 0x45, - 0x40, - /*entry*/ 0x01, - 'e', - 'n', - 't', - 'r', - 'y', - 0x00, - 0xcd, - 0xcc, - 0xcc, - 0xcc, - 0xcc, - 0xcc, - 0x10, - 0x40, - /*entry*/ 0x10, - 'n', - 'u', - 'm', - 'b', - 'e', - 'r', - 0x00, - 0x39, - 0x30, - 0x00, - 0x00, - /*entry*/ 0x03, - 'o', - 'b', - 'j', - 'e', - 'c', - 't', - 0x00, - /*entry: obj-size */ 0x17, - 0x00, - 0x00, - 0x00, - /*entry: obj-entry*/ 0x02, - 's', - 't', - 'r', - 'i', - 'n', - 'g', - 0x00, - 0x06, - 0x00, - 0x00, - 0x00, - 'v', - 'a', - 'l', - 'u', - 'e', - 0, - /*entry: obj-term.*/ 0x00, - /*obj-term*/ 0x00}; + json json_representation = {{"double", 42.5}, {"entry", 4.2}, {"number", 12345}, {"object", {{"string", "value"}}}}; + + std::vector const bson_representation = {/*size */ 0x4f, + 0x00, + 0x00, + 0x00, + /*entry*/ 0x01, + 'd', + 'o', + 'u', + 'b', + 'l', + 'e', + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x45, + 0x40, + /*entry*/ 0x01, + 'e', + 'n', + 't', + 'r', + 'y', + 0x00, + 0xcd, + 0xcc, + 0xcc, + 0xcc, + 0xcc, + 0xcc, + 0x10, + 0x40, + /*entry*/ 0x10, + 'n', + 'u', + 'm', + 'b', + 'e', + 'r', + 0x00, + 0x39, + 0x30, + 0x00, + 0x00, + /*entry*/ 0x03, + 'o', + 'b', + 'j', + 'e', + 'c', + 't', + 0x00, + /*entry: obj-size */ 0x17, + 0x00, + 0x00, + 0x00, + /*entry: obj-entry*/ 0x02, + 's', + 't', + 'r', + 'i', + 'n', + 'g', + 0x00, + 0x06, + 0x00, + 0x00, + 0x00, + 'v', + 'a', + 'l', + 'u', + 'e', + 0, + /*entry: obj-term.*/ 0x00, + /*obj-term*/ 0x00}; json j2; CHECK_NOTHROW(j2 = json::from_bson(bson_representation)); @@ -1031,7 +809,8 @@ TEST_CASE("BSON input/output_adapters") } } -namespace { +namespace +{ class SaxCountdown { public: @@ -1099,7 +878,9 @@ class SaxCountdown return events_left-- > 0; } - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static) + bool parse_error(std::size_t /*unused*/, + const std::string& /*unused*/, + const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static) { return false; } @@ -1113,20 +894,21 @@ TEST_CASE("Incomplete BSON Input") { SECTION("Incomplete BSON Input 1") { - std::vector const incomplete_bson = - { - 0x0D, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x08, // entry: boolean - 'e', - 'n', - 't' // unexpected EOF - }; + std::vector const incomplete_bson = { + 0x0D, + 0x00, + 0x00, + 0x00, // size (little endian) + 0x08, // entry: boolean + 'e', + 'n', + 't' // unexpected EOF + }; json _; - CHECK_THROWS_WITH_AS(_ = json::from_bson(incomplete_bson), "[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing BSON cstring: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_bson(incomplete_bson), + "[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing BSON cstring: unexpected end of input", + json::parse_error&); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); @@ -1136,17 +918,18 @@ TEST_CASE("Incomplete BSON Input") SECTION("Incomplete BSON Input 2") { - std::vector const incomplete_bson = - { - 0x0D, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x08, // entry: boolean, unexpected EOF - }; + std::vector const incomplete_bson = { + 0x0D, + 0x00, + 0x00, + 0x00, // size (little endian) + 0x08, // entry: boolean, unexpected EOF + }; json _; - CHECK_THROWS_WITH_AS(_ = json::from_bson(incomplete_bson), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing BSON cstring: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_bson(incomplete_bson), + "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing BSON cstring: unexpected end of input", + json::parse_error&); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); SaxCountdown scp(0); @@ -1155,41 +938,23 @@ TEST_CASE("Incomplete BSON Input") SECTION("Incomplete BSON Input 3") { - std::vector const incomplete_bson = - { - 0x41, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x04, /// entry: embedded document - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', + std::vector const incomplete_bson = { + 0x41, 0x00, 0x00, + 0x00, // size (little endian) + 0x04, /// entry: embedded document + 'e', 'n', 't', 'r', 'y', '\x00', - 0x35, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x10, - 0x00, - 0x01, - 0x00, - 0x00, - 0x00, - 0x10, - 0x00, - 0x02, - 0x00, - 0x00, - 0x00 - // missing input data... - }; + 0x35, 0x00, 0x00, + 0x00, // size (little endian) + 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x02, 0x00, 0x00, 0x00 + // missing input data... + }; json _; - CHECK_THROWS_WITH_AS(_ = json::from_bson(incomplete_bson), "[json.exception.parse_error.110] parse error at byte 28: syntax error while parsing BSON element list: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_bson(incomplete_bson), + "[json.exception.parse_error.110] parse error at byte 28: syntax error while parsing BSON element list: unexpected end of input", + json::parse_error&); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); SaxCountdown scp(1); @@ -1198,14 +963,15 @@ TEST_CASE("Incomplete BSON Input") SECTION("Incomplete BSON Input 4") { - std::vector const incomplete_bson = - { - 0x0D, - 0x00, // size (incomplete), unexpected EOF - }; + std::vector const incomplete_bson = { + 0x0D, + 0x00, // size (incomplete), unexpected EOF + }; json _; - CHECK_THROWS_WITH_AS(_ = json::from_bson(incomplete_bson), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing BSON number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_bson(incomplete_bson), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing BSON number: unexpected end of input", + json::parse_error&); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); SaxCountdown scp(0); @@ -1224,9 +990,7 @@ TEST_CASE("Incomplete BSON Input") SECTION("array") { - json const j = - { - {"entry", json::array()}}; + json const j = {{"entry", json::array()}}; auto bson_vec = json::to_bson(j); SaxCountdown scp(2); CHECK(!json::sax_parse(bson_vec, &scp, json::input_format_t::bson)); @@ -1237,68 +1001,47 @@ TEST_CASE("Incomplete BSON Input") TEST_CASE("Negative size of binary value") { // invalid BSON: the size of the binary value is -1 - std::vector const input = - { - 0x21, - 0x00, - 0x00, - 0x00, // size (little endian) - 0x05, // entry: binary - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - - 0xFF, - 0xFF, - 0xFF, - 0xFF, // size of binary (little endian) - 0x05, // MD5 binary subtype - 0xd7, - 0x7e, - 0x27, - 0x54, - 0xbe, - 0x12, - 0x37, - 0xfe, - 0xd6, - 0x0c, - 0x33, - 0x98, - 0x30, - 0x3b, - 0x8d, - 0xc4, - - 0x00 // end marker - }; + std::vector const input = { + 0x21, 0x00, 0x00, + 0x00, // size (little endian) + 0x05, // entry: binary + 'e', 'n', 't', 'r', 'y', '\x00', + + 0xFF, 0xFF, 0xFF, + 0xFF, // size of binary (little endian) + 0x05, // MD5 binary subtype + 0xd7, 0x7e, 0x27, 0x54, 0xbe, 0x12, 0x37, 0xfe, 0xd6, 0x0c, 0x33, 0x98, 0x30, 0x3b, 0x8d, 0xc4, + + 0x00 // end marker + }; json _; - CHECK_THROWS_WITH_AS(_ = json::from_bson(input), "[json.exception.parse_error.112] parse error at byte 15: syntax error while parsing BSON binary: byte array length cannot be negative, is -1", json::parse_error); + CHECK_THROWS_WITH_AS( + _ = json::from_bson(input), + "[json.exception.parse_error.112] parse error at byte 15: syntax error while parsing BSON binary: byte array length cannot be negative, is -1", + json::parse_error); } TEST_CASE("Unsupported BSON input") { - std::vector const bson = - { - 0x0C, - 0x00, - 0x00, - 0x00, // size (little endian) - 0xFF, // entry type: Min key (not supported yet) - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - 0x00 // end marker - }; + std::vector const bson = { + 0x0C, + 0x00, + 0x00, + 0x00, // size (little endian) + 0xFF, // entry type: Min key (not supported yet) + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + 0x00 // end marker + }; json _; - CHECK_THROWS_WITH_AS(_ = json::from_bson(bson), "[json.exception.parse_error.114] parse error at byte 5: Unsupported BSON record type 0xFF", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_bson(bson), + "[json.exception.parse_error.114] parse error at byte 5: Unsupported BSON record type 0xFF", + json::parse_error&); CHECK(json::from_bson(bson, true, false).is_discarded()); SaxCountdown scp(0); @@ -1331,35 +1074,32 @@ TEST_CASE("BSON numerical data") { CAPTURE(i) - json const j = - { - {"entry", i}}; + json const j = {{"entry", i}}; CHECK(j.at("entry").is_number_integer()); std::uint64_t const iu = *reinterpret_cast(&i); - std::vector const expected_bson = - { - 0x14u, - 0x00u, - 0x00u, - 0x00u, // size (little endian) - 0x12u, /// entry: int64 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - static_cast((iu >> (8u * 0u)) & 0xffu), - static_cast((iu >> (8u * 1u)) & 0xffu), - static_cast((iu >> (8u * 2u)) & 0xffu), - static_cast((iu >> (8u * 3u)) & 0xffu), - static_cast((iu >> (8u * 4u)) & 0xffu), - static_cast((iu >> (8u * 5u)) & 0xffu), - static_cast((iu >> (8u * 6u)) & 0xffu), - static_cast((iu >> (8u * 7u)) & 0xffu), - 0x00u // end marker - }; + std::vector const expected_bson = { + 0x14u, + 0x00u, + 0x00u, + 0x00u, // size (little endian) + 0x12u, /// entry: int64 + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + static_cast((iu >> (8u * 0u)) & 0xffu), + static_cast((iu >> (8u * 1u)) & 0xffu), + static_cast((iu >> (8u * 2u)) & 0xffu), + static_cast((iu >> (8u * 3u)) & 0xffu), + static_cast((iu >> (8u * 4u)) & 0xffu), + static_cast((iu >> (8u * 5u)) & 0xffu), + static_cast((iu >> (8u * 6u)) & 0xffu), + static_cast((iu >> (8u * 7u)) & 0xffu), + 0x00u // end marker + }; const auto bson = json::to_bson(j); CHECK(bson == expected_bson); @@ -1374,62 +1114,58 @@ TEST_CASE("BSON numerical data") SECTION("signed std::int32_t: INT32_MIN .. INT32_MAX") { - std::vector const numbers{ - (std::numeric_limits::min)(), - -2147483647L, - -1000000000L, - -100000000L, - -10000000L, - -1000000L, - -100000L, - -10000L, - -1000L, - -100L, - -10L, - -1L, - 0L, - 1L, - 10L, - 100L, - 1000L, - 10000L, - 100000L, - 1000000L, - 10000000L, - 100000000L, - 1000000000L, - 2147483646L, - (std::numeric_limits::max)()}; + std::vector const numbers{(std::numeric_limits::min)(), + -2147483647L, + -1000000000L, + -100000000L, + -10000000L, + -1000000L, + -100000L, + -10000L, + -1000L, + -100L, + -10L, + -1L, + 0L, + 1L, + 10L, + 100L, + 1000L, + 10000L, + 100000L, + 1000000L, + 10000000L, + 100000000L, + 1000000000L, + 2147483646L, + (std::numeric_limits::max)()}; for (const auto i : numbers) { CAPTURE(i) - json const j = - { - {"entry", i}}; + json const j = {{"entry", i}}; CHECK(j.at("entry").is_number_integer()); std::uint32_t const iu = *reinterpret_cast(&i); - std::vector const expected_bson = - { - 0x10u, - 0x00u, - 0x00u, - 0x00u, // size (little endian) - 0x10u, /// entry: int32 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - static_cast((iu >> (8u * 0u)) & 0xffu), - static_cast((iu >> (8u * 1u)) & 0xffu), - static_cast((iu >> (8u * 2u)) & 0xffu), - static_cast((iu >> (8u * 3u)) & 0xffu), - 0x00u // end marker - }; + std::vector const expected_bson = { + 0x10u, + 0x00u, + 0x00u, + 0x00u, // size (little endian) + 0x10u, /// entry: int32 + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + static_cast((iu >> (8u * 0u)) & 0xffu), + static_cast((iu >> (8u * 1u)) & 0xffu), + static_cast((iu >> (8u * 2u)) & 0xffu), + static_cast((iu >> (8u * 3u)) & 0xffu), + 0x00u // end marker + }; const auto bson = json::to_bson(j); CHECK(bson == expected_bson); @@ -1462,35 +1198,32 @@ TEST_CASE("BSON numerical data") { CAPTURE(i) - json const j = - { - {"entry", i}}; + json const j = {{"entry", i}}; CHECK(j.at("entry").is_number_integer()); std::uint64_t const iu = *reinterpret_cast(&i); - std::vector const expected_bson = - { - 0x14u, - 0x00u, - 0x00u, - 0x00u, // size (little endian) - 0x12u, /// entry: int64 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - static_cast((iu >> (8u * 0u)) & 0xffu), - static_cast((iu >> (8u * 1u)) & 0xffu), - static_cast((iu >> (8u * 2u)) & 0xffu), - static_cast((iu >> (8u * 3u)) & 0xffu), - static_cast((iu >> (8u * 4u)) & 0xffu), - static_cast((iu >> (8u * 5u)) & 0xffu), - static_cast((iu >> (8u * 6u)) & 0xffu), - static_cast((iu >> (8u * 7u)) & 0xffu), - 0x00u // end marker - }; + std::vector const expected_bson = { + 0x14u, + 0x00u, + 0x00u, + 0x00u, // size (little endian) + 0x12u, /// entry: int64 + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + static_cast((iu >> (8u * 0u)) & 0xffu), + static_cast((iu >> (8u * 1u)) & 0xffu), + static_cast((iu >> (8u * 2u)) & 0xffu), + static_cast((iu >> (8u * 3u)) & 0xffu), + static_cast((iu >> (8u * 4u)) & 0xffu), + static_cast((iu >> (8u * 5u)) & 0xffu), + static_cast((iu >> (8u * 6u)) & 0xffu), + static_cast((iu >> (8u * 7u)) & 0xffu), + 0x00u // end marker + }; const auto bson = json::to_bson(j); CHECK(bson == expected_bson); @@ -1508,49 +1241,45 @@ TEST_CASE("BSON numerical data") { SECTION("unsigned std::uint64_t: 0 .. INT32_MAX") { - std::vector const numbers{ - 0ULL, - 1ULL, - 10ULL, - 100ULL, - 1000ULL, - 10000ULL, - 100000ULL, - 1000000ULL, - 10000000ULL, - 100000000ULL, - 1000000000ULL, - 2147483646ULL, - static_cast((std::numeric_limits::max)())}; + std::vector const numbers{0ULL, + 1ULL, + 10ULL, + 100ULL, + 1000ULL, + 10000ULL, + 100000ULL, + 1000000ULL, + 10000000ULL, + 100000000ULL, + 1000000000ULL, + 2147483646ULL, + static_cast((std::numeric_limits::max)())}; for (const auto i : numbers) { CAPTURE(i) - json const j = - { - {"entry", i}}; + json const j = {{"entry", i}}; auto iu = i; - std::vector const expected_bson = - { - 0x10u, - 0x00u, - 0x00u, - 0x00u, // size (little endian) - 0x10u, /// entry: int32 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - static_cast((iu >> (8u * 0u)) & 0xffu), - static_cast((iu >> (8u * 1u)) & 0xffu), - static_cast((iu >> (8u * 2u)) & 0xffu), - static_cast((iu >> (8u * 3u)) & 0xffu), - 0x00u // end marker - }; + std::vector const expected_bson = { + 0x10u, + 0x00u, + 0x00u, + 0x00u, // size (little endian) + 0x10u, /// entry: int32 + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + static_cast((iu >> (8u * 0u)) & 0xffu), + static_cast((iu >> (8u * 1u)) & 0xffu), + static_cast((iu >> (8u * 2u)) & 0xffu), + static_cast((iu >> (8u * 3u)) & 0xffu), + 0x00u // end marker + }; const auto bson = json::to_bson(j); CHECK(bson == expected_bson); @@ -1586,34 +1315,31 @@ TEST_CASE("BSON numerical data") { CAPTURE(i) - json const j = - { - {"entry", i}}; + json const j = {{"entry", i}}; auto iu = i; - std::vector const expected_bson = - { - 0x14u, - 0x00u, - 0x00u, - 0x00u, // size (little endian) - 0x12u, /// entry: int64 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - static_cast((iu >> (8u * 0u)) & 0xffu), - static_cast((iu >> (8u * 1u)) & 0xffu), - static_cast((iu >> (8u * 2u)) & 0xffu), - static_cast((iu >> (8u * 3u)) & 0xffu), - static_cast((iu >> (8u * 4u)) & 0xffu), - static_cast((iu >> (8u * 5u)) & 0xffu), - static_cast((iu >> (8u * 6u)) & 0xffu), - static_cast((iu >> (8u * 7u)) & 0xffu), - 0x00u // end marker - }; + std::vector const expected_bson = { + 0x14u, + 0x00u, + 0x00u, + 0x00u, // size (little endian) + 0x12u, /// entry: int64 + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + static_cast((iu >> (8u * 0u)) & 0xffu), + static_cast((iu >> (8u * 1u)) & 0xffu), + static_cast((iu >> (8u * 2u)) & 0xffu), + static_cast((iu >> (8u * 3u)) & 0xffu), + static_cast((iu >> (8u * 4u)) & 0xffu), + static_cast((iu >> (8u * 5u)) & 0xffu), + static_cast((iu >> (8u * 6u)) & 0xffu), + static_cast((iu >> (8u * 7u)) & 0xffu), + 0x00u // end marker + }; const auto bson = json::to_bson(j); CHECK(bson == expected_bson); @@ -1641,40 +1367,41 @@ TEST_CASE("BSON numerical data") { CAPTURE(i) - json const j = - { - {"entry", i}}; + json const j = {{"entry", i}}; auto iu = i; - std::vector const expected_bson = - { - 0x14u, - 0x00u, - 0x00u, - 0x00u, // size (little endian) - 0x12u, /// entry: int64 - 'e', - 'n', - 't', - 'r', - 'y', - '\x00', - static_cast((iu >> (8u * 0u)) & 0xffu), - static_cast((iu >> (8u * 1u)) & 0xffu), - static_cast((iu >> (8u * 2u)) & 0xffu), - static_cast((iu >> (8u * 3u)) & 0xffu), - static_cast((iu >> (8u * 4u)) & 0xffu), - static_cast((iu >> (8u * 5u)) & 0xffu), - static_cast((iu >> (8u * 6u)) & 0xffu), - static_cast((iu >> (8u * 7u)) & 0xffu), - 0x00u // end marker - }; + std::vector const expected_bson = { + 0x14u, + 0x00u, + 0x00u, + 0x00u, // size (little endian) + 0x12u, /// entry: int64 + 'e', + 'n', + 't', + 'r', + 'y', + '\x00', + static_cast((iu >> (8u * 0u)) & 0xffu), + static_cast((iu >> (8u * 1u)) & 0xffu), + static_cast((iu >> (8u * 2u)) & 0xffu), + static_cast((iu >> (8u * 3u)) & 0xffu), + static_cast((iu >> (8u * 4u)) & 0xffu), + static_cast((iu >> (8u * 5u)) & 0xffu), + static_cast((iu >> (8u * 6u)) & 0xffu), + static_cast((iu >> (8u * 7u)) & 0xffu), + 0x00u // end marker + }; CHECK_THROWS_AS(json::to_bson(j), json::out_of_range&); #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_STD_STR(json::to_bson(j), "[json.exception.out_of_range.407] (/entry) integer number " + std::to_string(i) + " cannot be represented by BSON as it does not fit int64"); + CHECK_THROWS_WITH_STD_STR(json::to_bson(j), + "[json.exception.out_of_range.407] (/entry) integer number " + std::to_string(i) + + " cannot be represented by BSON as it does not fit int64"); #else - CHECK_THROWS_WITH_STD_STR(json::to_bson(j), "[json.exception.out_of_range.407] integer number " + std::to_string(i) + " cannot be represented by BSON as it does not fit int64"); + CHECK_THROWS_WITH_STD_STR(json::to_bson(j), + "[json.exception.out_of_range.407] integer number " + std::to_string(i) + + " cannot be represented by BSON as it does not fit int64"); #endif } } @@ -1686,13 +1413,11 @@ TEST_CASE("BSON roundtrips" * doctest::skip()) { SECTION("reference files") { - for (const std::string filename : - { - TEST_DATA_DIRECTORY "/json.org/1.json", - TEST_DATA_DIRECTORY "/json.org/2.json", - TEST_DATA_DIRECTORY "/json.org/3.json", - TEST_DATA_DIRECTORY "/json.org/4.json", - TEST_DATA_DIRECTORY "/json.org/5.json"}) + for (const std::string filename : {TEST_DATA_DIRECTORY "/json.org/1.json", + TEST_DATA_DIRECTORY "/json.org/2.json", + TEST_DATA_DIRECTORY "/json.org/3.json", + TEST_DATA_DIRECTORY "/json.org/4.json", + TEST_DATA_DIRECTORY "/json.org/5.json"}) { CAPTURE(filename) diff --git a/tests/src/unit-cbor.cpp b/tests/src/unit-cbor.cpp index d094dd308d..b6b01d3c3e 100644 --- a/tests/src/unit-cbor.cpp +++ b/tests/src/unit-cbor.cpp @@ -20,7 +20,8 @@ using nlohmann::json; #include #include -namespace { +namespace +{ class SaxCountdown { public: @@ -88,7 +89,9 @@ class SaxCountdown return events_left-- > 0; } - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static) + bool parse_error(std::size_t /*unused*/, + const std::string& /*unused*/, + const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static) { return false; } @@ -217,14 +220,10 @@ TEST_CASE("CBOR") // check individual bytes CHECK(result[0] == 0x3b); - const uint64_t restored = (static_cast(result[1]) << 070) + - (static_cast(result[2]) << 060) + - (static_cast(result[3]) << 050) + - (static_cast(result[4]) << 040) + - (static_cast(result[5]) << 030) + - (static_cast(result[6]) << 020) + - (static_cast(result[7]) << 010) + - static_cast(result[8]); + const uint64_t restored = (static_cast(result[1]) << 070) + (static_cast(result[2]) << 060) + + (static_cast(result[3]) << 050) + (static_cast(result[4]) << 040) + + (static_cast(result[5]) << 030) + (static_cast(result[6]) << 020) + + (static_cast(result[7]) << 010) + static_cast(result[8]); CHECK(restored == positive); CHECK(-1 - static_cast(restored) == i); @@ -272,10 +271,8 @@ TEST_CASE("CBOR") // check individual bytes CHECK(result[0] == 0x3a); - const uint32_t restored = (static_cast(result[1]) << 030) + - (static_cast(result[2]) << 020) + - (static_cast(result[3]) << 010) + - static_cast(result[4]); + const uint32_t restored = (static_cast(result[1]) << 030) + (static_cast(result[2]) << 020) + + (static_cast(result[3]) << 010) + static_cast(result[4]); CHECK(restored == positive); CHECK(-1LL - restored == i); @@ -506,11 +503,7 @@ TEST_CASE("CBOR") SECTION("65536..4294967295") { - for (const uint32_t i : - { - 65536u, - 77777u, - 1048576u}) + for (const uint32_t i : {65536u, 77777u, 1048576u}) { CAPTURE(i) @@ -537,10 +530,8 @@ TEST_CASE("CBOR") // check individual bytes CHECK(result[0] == 0x1a); - const uint32_t restored = (static_cast(result[1]) << 030) + - (static_cast(result[2]) << 020) + - (static_cast(result[3]) << 010) + - static_cast(result[4]); + const uint32_t restored = (static_cast(result[1]) << 030) + (static_cast(result[2]) << 020) + + (static_cast(result[3]) << 010) + static_cast(result[4]); CHECK(restored == i); // roundtrip @@ -551,10 +542,7 @@ TEST_CASE("CBOR") SECTION("4294967296..4611686018427387903") { - for (const uint64_t i : - { - 4294967296ul, - 4611686018427387903ul}) + for (const uint64_t i : {4294967296ul, 4611686018427387903ul}) { CAPTURE(i) @@ -585,14 +573,10 @@ TEST_CASE("CBOR") // check individual bytes CHECK(result[0] == 0x1b); - const uint64_t restored = (static_cast(result[1]) << 070) + - (static_cast(result[2]) << 060) + - (static_cast(result[3]) << 050) + - (static_cast(result[4]) << 040) + - (static_cast(result[5]) << 030) + - (static_cast(result[6]) << 020) + - (static_cast(result[7]) << 010) + - static_cast(result[8]); + const uint64_t restored = (static_cast(result[1]) << 070) + (static_cast(result[2]) << 060) + + (static_cast(result[3]) << 050) + (static_cast(result[4]) << 040) + + (static_cast(result[5]) << 030) + (static_cast(result[6]) << 020) + + (static_cast(result[7]) << 010) + static_cast(result[8]); CHECK(restored == i); // roundtrip @@ -740,11 +724,7 @@ TEST_CASE("CBOR") SECTION("65536..4294967295 (four-byte uint32_t)") { - for (const uint32_t i : - { - 65536u, - 77777u, - 1048576u}) + for (const uint32_t i : {65536u, 77777u, 1048576u}) { CAPTURE(i) @@ -770,10 +750,8 @@ TEST_CASE("CBOR") // check individual bytes CHECK(result[0] == 0x1a); - const uint32_t restored = (static_cast(result[1]) << 030) + - (static_cast(result[2]) << 020) + - (static_cast(result[3]) << 010) + - static_cast(result[4]); + const uint32_t restored = (static_cast(result[1]) << 030) + (static_cast(result[2]) << 020) + + (static_cast(result[3]) << 010) + static_cast(result[4]); CHECK(restored == i); // roundtrip @@ -784,10 +762,7 @@ TEST_CASE("CBOR") SECTION("4294967296..4611686018427387903 (eight-byte uint64_t)") { - for (const uint64_t i : - { - 4294967296ul, - 4611686018427387903ul}) + for (const uint64_t i : {4294967296ul, 4611686018427387903ul}) { CAPTURE(i) @@ -817,14 +792,10 @@ TEST_CASE("CBOR") // check individual bytes CHECK(result[0] == 0x1b); - const uint64_t restored = (static_cast(result[1]) << 070) + - (static_cast(result[2]) << 060) + - (static_cast(result[3]) << 050) + - (static_cast(result[4]) << 040) + - (static_cast(result[5]) << 030) + - (static_cast(result[6]) << 020) + - (static_cast(result[7]) << 010) + - static_cast(result[8]); + const uint64_t restored = (static_cast(result[1]) << 070) + (static_cast(result[2]) << 060) + + (static_cast(result[3]) << 050) + (static_cast(result[4]) << 040) + + (static_cast(result[5]) << 030) + (static_cast(result[6]) << 020) + + (static_cast(result[7]) << 010) + static_cast(result[8]); CHECK(restored == i); // roundtrip @@ -840,17 +811,7 @@ TEST_CASE("CBOR") { double v = 3.1415925; const json j = v; - std::vector expected = - { - 0xfb, - 0x40, - 0x09, - 0x21, - 0xfb, - 0x3f, - 0xa6, - 0xde, - 0xfc}; + std::vector expected = {0xfb, 0x40, 0x09, 0x21, 0xfb, 0x3f, 0xa6, 0xde, 0xfc}; const auto result = json::to_cbor(j); CHECK(result == expected); @@ -934,13 +895,7 @@ TEST_CASE("CBOR") { float v = (std::numeric_limits::max)(); const json j = v; - const std::vector expected = - { - 0xfa, - 0x7f, - 0x7f, - 0xff, - 0xff}; + const std::vector expected = {0xfa, 0x7f, 0x7f, 0xff, 0xff}; const auto result = json::to_cbor(j); CHECK(result == expected); // roundtrip @@ -951,13 +906,7 @@ TEST_CASE("CBOR") { auto v = static_cast(std::numeric_limits::lowest()); const json j = v; - const std::vector expected = - { - 0xfa, - 0xff, - 0x7f, - 0xff, - 0xff}; + const std::vector expected = {0xfa, 0xff, 0x7f, 0xff, 0xff}; const auto result = json::to_cbor(j); CHECK(result == expected); // roundtrip @@ -968,17 +917,7 @@ TEST_CASE("CBOR") { double v = static_cast((std::numeric_limits::max)()) + 0.1e+34; const json j = v; - const std::vector expected = - { - 0xfb, - 0x47, - 0xf0, - 0x00, - 0x03, - 0x04, - 0xdc, - 0x64, - 0x49}; + const std::vector expected = {0xfb, 0x47, 0xf0, 0x00, 0x03, 0x04, 0xdc, 0x64, 0x49}; // double const auto result = json::to_cbor(j); CHECK(result == expected); @@ -990,13 +929,7 @@ TEST_CASE("CBOR") { double v = static_cast(std::numeric_limits::lowest()) - 1.0; const json j = v; - const std::vector expected = - { - 0xfa, - 0xff, - 0x7f, - 0xff, - 0xff}; + const std::vector expected = {0xfa, 0xff, 0x7f, 0xff, 0xff}; // the same with lowest float const auto result = json::to_cbor(j); CHECK(result == expected); @@ -1013,13 +946,19 @@ TEST_CASE("CBOR") SECTION("no byte follows") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0xf9})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_cbor(std::vector({0xf9})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); CHECK(json::from_cbor(std::vector({0xf9}), true, false).is_discarded()); } SECTION("only one byte follows") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0xf9, 0x7c})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_cbor(std::vector({0xf9, 0x7c})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); CHECK(json::from_cbor(std::vector({0xf9, 0x7c}), true, false).is_discarded()); } } @@ -1180,14 +1119,7 @@ TEST_CASE("CBOR") SECTION("N = 256..65535") { - for (const size_t N : - { - 256u, - 999u, - 1025u, - 3333u, - 2048u, - 65535u}) + for (const size_t N : {256u, 999u, 1025u, 3333u, 2048u, 65535u}) { CAPTURE(N) @@ -1217,11 +1149,7 @@ TEST_CASE("CBOR") SECTION("N = 65536..4294967295") { - for (const size_t N : - { - 65536u, - 77777u, - 1048576u}) + for (const size_t N : {65536u, 77777u, 1048576u}) { CAPTURE(N) @@ -1364,18 +1292,7 @@ TEST_CASE("CBOR") SECTION("{\"a\": {\"b\": {\"c\": {}}}}") { const json j = json::parse(R"({"a": {"b": {"c": {}}}})"); - const std::vector expected = - { - 0xa1, - 0x61, - 0x61, - 0xa1, - 0x61, - 0x62, - 0xa1, - 0x61, - 0x63, - 0xa0}; + const std::vector expected = {0xa1, 0x61, 0x61, 0xa1, 0x61, 0x62, 0xa1, 0x61, 0x63, 0xa0}; const auto result = json::to_cbor(j); CHECK(result == expected); @@ -1542,14 +1459,7 @@ TEST_CASE("CBOR") SECTION("N = 256..65535") { - for (const size_t N : - { - 256u, - 999u, - 1025u, - 3333u, - 2048u, - 65535u}) + for (const size_t N : {256u, 999u, 1025u, 3333u, 2048u, 65535u}) { CAPTURE(N) @@ -1579,11 +1489,7 @@ TEST_CASE("CBOR") SECTION("N = 65536..4294967295") { - for (const size_t N : - { - 65536u, - 77777u, - 1048576u}) + for (const size_t N : {65536u, 77777u, 1048576u}) { CAPTURE(N) @@ -1699,40 +1605,97 @@ TEST_CASE("CBOR") SECTION("empty byte vector") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector()), "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing CBOR value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector()), + "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing CBOR value: unexpected end of input", + json::parse_error&); CHECK(json::from_cbor(std::vector(), true, false).is_discarded()); } SECTION("too short byte vector") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x18})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x19})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x19, 0x00})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1a})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1a, 0x00})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1a, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1a, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x62})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x62, 0x60})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR string: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x7F})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x7F, 0x60})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR string: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x82, 0x01})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x9F, 0x01})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0xBF, 0x61, 0x61, 0xF5})), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR string: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0xA1, 0x61, 0X61})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR value: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0xBF, 0x61, 0X61})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR value: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x5F})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR binary: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x5F, 0x00})), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR binary: expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x00", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x41})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR binary: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x18})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x19})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x19, 0x00})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1a})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1a, 0x00})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1a, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1a, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x62})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x62, 0x60})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR string: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x7F})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x7F, 0x60})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR string: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x82, 0x01})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x9F, 0x01})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0xBF, 0x61, 0x61, 0xF5})), + "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR string: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0xA1, 0x61, 0X61})), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR value: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0xBF, 0x61, 0X61})), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR value: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x5F})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR binary: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_cbor(std::vector({0x5F, 0x00})), + "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR binary: expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x00", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x41})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR binary: unexpected end of input", + json::parse_error&); CHECK(json::from_cbor(std::vector({0x18}), true, false).is_discarded()); CHECK(json::from_cbor(std::vector({0x19}), true, false).is_discarded()); @@ -1768,108 +1731,110 @@ TEST_CASE("CBOR") SECTION("concrete examples") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1c})), "[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0x1C", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0x1c})), + "[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0x1C", + json::parse_error&); CHECK(json::from_cbor(std::vector({0x1c}), true, false).is_discarded()); - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0xf8})), "[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0xF8", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0xf8})), + "[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0xF8", + json::parse_error&); CHECK(json::from_cbor(std::vector({0xf8}), true, false).is_discarded()); } SECTION("all unsupported bytes") { - for (const auto byte : - { - // ? - 0x1c, - 0x1d, - 0x1e, - 0x1f, - // ? - 0x3c, - 0x3d, - 0x3e, - 0x3f, - // ? - 0x5c, - 0x5d, - 0x5e, - // ? - 0x7c, - 0x7d, - 0x7e, - // ? - 0x9c, - 0x9d, - 0x9e, - // ? - 0xbc, - 0xbd, - 0xbe, - // date/time - 0xc0, - 0xc1, - // bignum - 0xc2, - 0xc3, - // fraction - 0xc4, - // bigfloat - 0xc5, - // tagged item - 0xc6, - 0xc7, - 0xc8, - 0xc9, - 0xca, - 0xcb, - 0xcc, - 0xcd, - 0xce, - 0xcf, - 0xd0, - 0xd1, - 0xd2, - 0xd3, - 0xd4, - // expected conversion - 0xd5, - 0xd6, - 0xd7, - // more tagged items - 0xd8, - 0xd9, - 0xda, - 0xdb, - // ? - 0xdc, - 0xdd, - 0xde, - 0xdf, - // (simple value) - 0xe0, - 0xe1, - 0xe2, - 0xe3, - 0xe4, - 0xe5, - 0xe6, - 0xe7, - 0xe8, - 0xe9, - 0xea, - 0xeb, - 0xec, - 0xed, - 0xee, - 0xef, - 0xf0, - 0xf1, - 0xf2, - 0xf3, - // undefined - 0xf7, - // simple value - 0xf8}) + for (const auto byte : {// ? + 0x1c, + 0x1d, + 0x1e, + 0x1f, + // ? + 0x3c, + 0x3d, + 0x3e, + 0x3f, + // ? + 0x5c, + 0x5d, + 0x5e, + // ? + 0x7c, + 0x7d, + 0x7e, + // ? + 0x9c, + 0x9d, + 0x9e, + // ? + 0xbc, + 0xbd, + 0xbe, + // date/time + 0xc0, + 0xc1, + // bignum + 0xc2, + 0xc3, + // fraction + 0xc4, + // bigfloat + 0xc5, + // tagged item + 0xc6, + 0xc7, + 0xc8, + 0xc9, + 0xca, + 0xcb, + 0xcc, + 0xcd, + 0xce, + 0xcf, + 0xd0, + 0xd1, + 0xd2, + 0xd3, + 0xd4, + // expected conversion + 0xd5, + 0xd6, + 0xd7, + // more tagged items + 0xd8, + 0xd9, + 0xda, + 0xdb, + // ? + 0xdc, + 0xdd, + 0xde, + 0xdf, + // (simple value) + 0xe0, + 0xe1, + 0xe2, + 0xe3, + 0xe4, + 0xe5, + 0xe6, + 0xe7, + 0xe8, + 0xe9, + 0xea, + 0xeb, + 0xec, + 0xed, + 0xee, + 0xef, + 0xf0, + 0xf1, + 0xf2, + 0xf3, + // undefined + 0xf7, + // simple value + 0xf8}) { json _; CHECK_THROWS_AS(_ = json::from_cbor(std::vector({static_cast(byte)})), json::parse_error&); @@ -1881,7 +1846,10 @@ TEST_CASE("CBOR") SECTION("invalid string in map") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector({0xa1, 0xff, 0x01})), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xFF", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_cbor(std::vector({0xa1, 0xff, 0x01})), + "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xFF", + json::parse_error&); CHECK(json::from_cbor(std::vector({0xa1, 0xff, 0x01}), true, false).is_discarded()); } @@ -1898,7 +1866,10 @@ TEST_CASE("CBOR") SECTION("strict mode") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR value: expected end of input; last byte: 0xF6", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_cbor(vec), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR value: expected end of input; last byte: 0xF6", + json::parse_error&); CHECK(json::from_cbor(vec, true, false).is_discarded()); } } @@ -1984,28 +1955,13 @@ TEST_CASE("CBOR regressions") detected. */ for (const std::string filename : - { - TEST_DATA_DIRECTORY "/cbor_regression/test01", - TEST_DATA_DIRECTORY "/cbor_regression/test02", - TEST_DATA_DIRECTORY "/cbor_regression/test03", - TEST_DATA_DIRECTORY "/cbor_regression/test04", - TEST_DATA_DIRECTORY "/cbor_regression/test05", - TEST_DATA_DIRECTORY "/cbor_regression/test06", - TEST_DATA_DIRECTORY "/cbor_regression/test07", - TEST_DATA_DIRECTORY "/cbor_regression/test08", - TEST_DATA_DIRECTORY "/cbor_regression/test09", - TEST_DATA_DIRECTORY "/cbor_regression/test10", - TEST_DATA_DIRECTORY "/cbor_regression/test11", - TEST_DATA_DIRECTORY "/cbor_regression/test12", - TEST_DATA_DIRECTORY "/cbor_regression/test13", - TEST_DATA_DIRECTORY "/cbor_regression/test14", - TEST_DATA_DIRECTORY "/cbor_regression/test15", - TEST_DATA_DIRECTORY "/cbor_regression/test16", - TEST_DATA_DIRECTORY "/cbor_regression/test17", - TEST_DATA_DIRECTORY "/cbor_regression/test18", - TEST_DATA_DIRECTORY "/cbor_regression/test19", - TEST_DATA_DIRECTORY "/cbor_regression/test20", - TEST_DATA_DIRECTORY "/cbor_regression/test21"}) + {TEST_DATA_DIRECTORY "/cbor_regression/test01", TEST_DATA_DIRECTORY "/cbor_regression/test02", TEST_DATA_DIRECTORY "/cbor_regression/test03", + TEST_DATA_DIRECTORY "/cbor_regression/test04", TEST_DATA_DIRECTORY "/cbor_regression/test05", TEST_DATA_DIRECTORY "/cbor_regression/test06", + TEST_DATA_DIRECTORY "/cbor_regression/test07", TEST_DATA_DIRECTORY "/cbor_regression/test08", TEST_DATA_DIRECTORY "/cbor_regression/test09", + TEST_DATA_DIRECTORY "/cbor_regression/test10", TEST_DATA_DIRECTORY "/cbor_regression/test11", TEST_DATA_DIRECTORY "/cbor_regression/test12", + TEST_DATA_DIRECTORY "/cbor_regression/test13", TEST_DATA_DIRECTORY "/cbor_regression/test14", TEST_DATA_DIRECTORY "/cbor_regression/test15", + TEST_DATA_DIRECTORY "/cbor_regression/test16", TEST_DATA_DIRECTORY "/cbor_regression/test17", TEST_DATA_DIRECTORY "/cbor_regression/test18", + TEST_DATA_DIRECTORY "/cbor_regression/test19", TEST_DATA_DIRECTORY "/cbor_regression/test20", TEST_DATA_DIRECTORY "/cbor_regression/test21"}) { CAPTURE(filename) @@ -2059,153 +2015,151 @@ TEST_CASE("CBOR roundtrips" * doctest::skip()) exclude_packed.insert(TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key.json"); exclude_packed.insert(TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_long_strings.json"); - for (const std::string filename : - { - TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json", - TEST_DATA_DIRECTORY "/json.org/1.json", - TEST_DATA_DIRECTORY "/json.org/2.json", - TEST_DATA_DIRECTORY "/json.org/3.json", - TEST_DATA_DIRECTORY "/json.org/4.json", - TEST_DATA_DIRECTORY "/json.org/5.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip01.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip02.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip03.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip04.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip05.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip06.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip07.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip08.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip09.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip10.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip11.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip12.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip13.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip14.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip15.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip16.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip17.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip18.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip19.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip20.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip21.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip22.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip23.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip24.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip25.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip26.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip27.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip28.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip29.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip30.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip31.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip32.json", - TEST_DATA_DIRECTORY "/json_testsuite/sample.json", // kills AppVeyor - TEST_DATA_DIRECTORY "/json_tests/pass1.json", - TEST_DATA_DIRECTORY "/json_tests/pass2.json", - TEST_DATA_DIRECTORY "/json_tests/pass3.json", - TEST_DATA_DIRECTORY "/regression/floats.json", - TEST_DATA_DIRECTORY "/regression/signed_ints.json", - TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", - TEST_DATA_DIRECTORY "/regression/working_file.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_arraysWithSpaces.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty-string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_ending_with_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_heterogeneous.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_1_and_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_leading_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_several_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_trailing_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e+1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_after_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_close_to_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_huge_neg_exp.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_huge_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_int_with_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_minus_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_one.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_neg_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_pos_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_fraction_exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_exp.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_overflow.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_exponent.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_overflow.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_underflow.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_real.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_neg_int.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_pos_int.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_very_big_negative_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_basic.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key_and_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_escaped_null_in_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_extreme_numbers.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_long_strings.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_simple.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_string_unicode.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_with_newlines.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_UTF-16_Surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pair.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pairs.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_allowed_escapes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_and_u_escaped_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_doublequotes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_comments.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_a.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_n.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_control_character.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_noncharacter.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array_with_leading_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_last_surrogates_1_and_2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_newline_uescaped.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+1FFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_null_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_one-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_pi.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_simple_ascii.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_three-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_two-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2028_line_sep.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2029_par_sep.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_uEscape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unescaped_char_delete.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicodeEscapedBackslash.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+2064_invisible_plus.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_escaped_double_quote.json", - // TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf16.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_with_del_character.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_negative_real.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_true.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_string_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_trailing_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_true_in_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_whitespace_array.json"}) + for (const std::string filename : {TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json", + TEST_DATA_DIRECTORY "/json.org/1.json", + TEST_DATA_DIRECTORY "/json.org/2.json", + TEST_DATA_DIRECTORY "/json.org/3.json", + TEST_DATA_DIRECTORY "/json.org/4.json", + TEST_DATA_DIRECTORY "/json.org/5.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip01.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip02.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip03.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip04.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip05.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip06.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip07.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip08.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip09.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip10.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip11.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip12.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip13.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip14.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip15.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip16.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip17.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip18.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip19.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip20.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip21.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip22.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip23.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip24.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip25.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip26.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip27.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip28.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip29.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip30.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip31.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip32.json", + TEST_DATA_DIRECTORY "/json_testsuite/sample.json", // kills AppVeyor + TEST_DATA_DIRECTORY "/json_tests/pass1.json", + TEST_DATA_DIRECTORY "/json_tests/pass2.json", + TEST_DATA_DIRECTORY "/json_tests/pass3.json", + TEST_DATA_DIRECTORY "/regression/floats.json", + TEST_DATA_DIRECTORY "/regression/signed_ints.json", + TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", + TEST_DATA_DIRECTORY "/regression/working_file.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_arraysWithSpaces.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty-string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_ending_with_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_heterogeneous.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_1_and_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_leading_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_several_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_trailing_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e+1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_after_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_close_to_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_huge_neg_exp.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_huge_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_int_with_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_minus_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_one.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_neg_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_pos_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_fraction_exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_exp.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_overflow.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_exponent.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_overflow.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_underflow.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_real.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_neg_int.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_pos_int.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_very_big_negative_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_basic.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key_and_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_escaped_null_in_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_extreme_numbers.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_long_strings.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_simple.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_string_unicode.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_with_newlines.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_UTF-16_Surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pair.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pairs.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_allowed_escapes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_and_u_escaped_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_doublequotes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_comments.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_a.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_n.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_control_character.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_noncharacter.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array_with_leading_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_last_surrogates_1_and_2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_newline_uescaped.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+1FFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_null_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_one-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_pi.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_simple_ascii.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_three-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_two-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2028_line_sep.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2029_par_sep.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_uEscape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unescaped_char_delete.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicodeEscapedBackslash.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+2064_invisible_plus.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_escaped_double_quote.json", + // TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf16.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_with_del_character.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_negative_real.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_true.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_string_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_trailing_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_true_in_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_whitespace_array.json"}) { CAPTURE(filename) @@ -2281,102 +2235,100 @@ TEST_CASE("CBOR roundtrips" * doctest::skip()) TEST_CASE("all CBOR first bytes") { // these bytes will fail immediately with exception parse_error.112 - std::set unsupported = - { - //// types not supported by this library - - // date/time - 0xc0, - 0xc1, - // bignum - 0xc2, - 0xc3, - // decimal fracion - 0xc4, - // bigfloat - 0xc5, - // tagged item - 0xc6, - 0xc7, - 0xc8, - 0xc9, - 0xca, - 0xcb, - 0xcc, - 0xcd, - 0xce, - 0xcf, - 0xd0, - 0xd1, - 0xd2, - 0xd3, - 0xd4, - 0xd8, - 0xd9, - 0xda, - 0xdb, - // expected conversion - 0xd5, - 0xd6, - 0xd7, - // simple value - 0xe0, - 0xe1, - 0xe2, - 0xe3, - 0xe4, - 0xe5, - 0xe6, - 0xe7, - 0xe8, - 0xe9, - 0xea, - 0xeb, - 0xec, - 0xed, - 0xef, - 0xf0, - 0xf1, - 0xf2, - 0xf3, - 0xf8, - // undefined - 0xf7, - - //// bytes not specified by CBOR - - 0x1c, - 0x1d, - 0x1e, - 0x1f, - 0x3c, - 0x3d, - 0x3e, - 0x3f, - 0x5c, - 0x5d, - 0x5e, - 0x7c, - 0x7d, - 0x7e, - 0x9c, - 0x9d, - 0x9e, - 0xbc, - 0xbd, - 0xbe, - 0xdc, - 0xdd, - 0xde, - 0xdf, - 0xee, - 0xfc, - 0xfe, - 0xfd, - - /// break cannot be the first byte - - 0xff}; + std::set unsupported = {//// types not supported by this library + + // date/time + 0xc0, + 0xc1, + // bignum + 0xc2, + 0xc3, + // decimal fracion + 0xc4, + // bigfloat + 0xc5, + // tagged item + 0xc6, + 0xc7, + 0xc8, + 0xc9, + 0xca, + 0xcb, + 0xcc, + 0xcd, + 0xce, + 0xcf, + 0xd0, + 0xd1, + 0xd2, + 0xd3, + 0xd4, + 0xd8, + 0xd9, + 0xda, + 0xdb, + // expected conversion + 0xd5, + 0xd6, + 0xd7, + // simple value + 0xe0, + 0xe1, + 0xe2, + 0xe3, + 0xe4, + 0xe5, + 0xe6, + 0xe7, + 0xe8, + 0xe9, + 0xea, + 0xeb, + 0xec, + 0xed, + 0xef, + 0xf0, + 0xf1, + 0xf2, + 0xf3, + 0xf8, + // undefined + 0xf7, + + //// bytes not specified by CBOR + + 0x1c, + 0x1d, + 0x1e, + 0x1f, + 0x3c, + 0x3d, + 0x3e, + 0x3f, + 0x5c, + 0x5d, + 0x5e, + 0x7c, + 0x7d, + 0x7e, + 0x9c, + 0x9d, + 0x9e, + 0xbc, + 0xbd, + 0xbe, + 0xdc, + 0xdd, + 0xde, + 0xdf, + 0xee, + 0xfc, + 0xfe, + 0xfd, + + /// break cannot be the first byte + + 0xff}; for (auto i = 0; i < 256; ++i) { @@ -2545,7 +2497,8 @@ TEST_CASE("examples from RFC 7049 Appendix A") CHECK(json::parse("\"\\ud800\\udd51\"") == json::from_cbor(std::vector({0x64, 0xf0, 0x90, 0x85, 0x91}))); // indefinite length strings - CHECK(json::parse("\"streaming\"") == json::from_cbor(std::vector({0x7f, 0x65, 0x73, 0x74, 0x72, 0x65, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x67, 0xff}))); + CHECK(json::parse("\"streaming\"") == + json::from_cbor(std::vector({0x7f, 0x65, 0x73, 0x74, 0x72, 0x65, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x67, 0xff}))); } SECTION("byte arrays") @@ -2559,20 +2512,35 @@ TEST_CASE("examples from RFC 7049 Appendix A") // 0xd8 CHECK(json::to_cbor(json::binary(std::vector{}, 0x42)) == std::vector{0xd8, 0x42, 0x40}); - CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector{}, 0x42)), true, true, json::cbor_tag_handler_t::ignore).get_binary().has_subtype()); - CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector{}, 0x42)), true, true, json::cbor_tag_handler_t::store).get_binary().subtype() == 0x42); + CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector{}, 0x42)), true, true, json::cbor_tag_handler_t::ignore) + .get_binary() + .has_subtype()); + CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector{}, 0x42)), true, true, json::cbor_tag_handler_t::store).get_binary().subtype() == + 0x42); // 0xd9 CHECK(json::to_cbor(json::binary(std::vector{}, 1000)) == std::vector{0xd9, 0x03, 0xe8, 0x40}); - CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector{}, 1000)), true, true, json::cbor_tag_handler_t::ignore).get_binary().has_subtype()); - CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector{}, 1000)), true, true, json::cbor_tag_handler_t::store).get_binary().subtype() == 1000); + CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector{}, 1000)), true, true, json::cbor_tag_handler_t::ignore) + .get_binary() + .has_subtype()); + CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector{}, 1000)), true, true, json::cbor_tag_handler_t::store).get_binary().subtype() == + 1000); // 0xda CHECK(json::to_cbor(json::binary(std::vector{}, 394216)) == std::vector{0xda, 0x00, 0x06, 0x03, 0xe8, 0x40}); - CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector{}, 394216)), true, true, json::cbor_tag_handler_t::ignore).get_binary().has_subtype()); - CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector{}, 394216)), true, true, json::cbor_tag_handler_t::store).get_binary().subtype() == 394216); + CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector{}, 394216)), true, true, json::cbor_tag_handler_t::ignore) + .get_binary() + .has_subtype()); + CHECK( + json::from_cbor(json::to_cbor(json::binary(std::vector{}, 394216)), true, true, json::cbor_tag_handler_t::store).get_binary().subtype() == + 394216); // 0xdb - CHECK(json::to_cbor(json::binary(std::vector{}, 8589934590)) == std::vector{0xdb, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x40}); - CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector{}, 8589934590)), true, true, json::cbor_tag_handler_t::ignore).get_binary().has_subtype()); - CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector{}, 8589934590)), true, true, json::cbor_tag_handler_t::store).get_binary().subtype() == 8589934590); + CHECK(json::to_cbor(json::binary(std::vector{}, 8589934590)) == + std::vector{0xdb, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x40}); + CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector{}, 8589934590)), true, true, json::cbor_tag_handler_t::ignore) + .get_binary() + .has_subtype()); + CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector{}, 8589934590)), true, true, json::cbor_tag_handler_t::store) + .get_binary() + .subtype() == 8589934590); } SECTION("arrays") @@ -2586,8 +2554,12 @@ TEST_CASE("examples from RFC 7049 Appendix A") CHECK(json::to_cbor(json::parse("[1, [2, 3], [4, 5]]")) == std::vector({0x83, 0x01, 0x82, 0x02, 0x03, 0x82, 0x04, 0x05})); CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector({0x83, 0x01, 0x82, 0x02, 0x03, 0x82, 0x04, 0x05}))); - CHECK(json::to_cbor(json::parse("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]")) == std::vector({0x98, 0x19, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x18, 0x18, 0x19})); - CHECK(json::parse("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]") == json::from_cbor(std::vector({0x98, 0x19, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x18, 0x18, 0x19}))); + CHECK(json::to_cbor(json::parse("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]")) == + std::vector({0x98, 0x19, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, + 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x18, 0x18, 0x19})); + CHECK(json::parse("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]") == + json::from_cbor(std::vector({0x98, 0x19, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, + 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x18, 0x18, 0x19}))); // indefinite length arrays CHECK(json::parse("[]") == json::from_cbor(std::vector({0x9f, 0xff}))); @@ -2595,7 +2567,9 @@ TEST_CASE("examples from RFC 7049 Appendix A") CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector({0x9f, 0x01, 0x82, 0x02, 0x03, 0x82, 0x04, 0x05, 0xff}))); CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector({0x83, 0x01, 0x82, 0x02, 0x03, 0x9f, 0x04, 0x05, 0xff}))); CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector({0x83, 0x01, 0x9f, 0x02, 0x03, 0xff, 0x82, 0x04, 0x05}))); - CHECK(json::parse("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]") == json::from_cbor(std::vector({0x9f, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x18, 0x18, 0x19, 0xff}))); + CHECK(json::parse("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]") == + json::from_cbor(std::vector({0x9f, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, + 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x18, 0x18, 0x19, 0xff}))); } SECTION("objects") @@ -2609,13 +2583,19 @@ TEST_CASE("examples from RFC 7049 Appendix A") CHECK(json::to_cbor(json::parse("[\"a\", {\"b\": \"c\"}]")) == std::vector({0x82, 0x61, 0x61, 0xa1, 0x61, 0x62, 0x61, 0x63})); CHECK(json::parse("[\"a\", {\"b\": \"c\"}]") == json::from_cbor(std::vector({0x82, 0x61, 0x61, 0xa1, 0x61, 0x62, 0x61, 0x63}))); - CHECK(json::to_cbor(json::parse("{\"a\": \"A\", \"b\": \"B\", \"c\": \"C\", \"d\": \"D\", \"e\": \"E\"}")) == std::vector({0xa5, 0x61, 0x61, 0x61, 0x41, 0x61, 0x62, 0x61, 0x42, 0x61, 0x63, 0x61, 0x43, 0x61, 0x64, 0x61, 0x44, 0x61, 0x65, 0x61, 0x45})); - CHECK(json::parse("{\"a\": \"A\", \"b\": \"B\", \"c\": \"C\", \"d\": \"D\", \"e\": \"E\"}") == json::from_cbor(std::vector({0xa5, 0x61, 0x61, 0x61, 0x41, 0x61, 0x62, 0x61, 0x42, 0x61, 0x63, 0x61, 0x43, 0x61, 0x64, 0x61, 0x44, 0x61, 0x65, 0x61, 0x45}))); + CHECK(json::to_cbor(json::parse("{\"a\": \"A\", \"b\": \"B\", \"c\": \"C\", \"d\": \"D\", \"e\": \"E\"}")) == + std::vector( + {0xa5, 0x61, 0x61, 0x61, 0x41, 0x61, 0x62, 0x61, 0x42, 0x61, 0x63, 0x61, 0x43, 0x61, 0x64, 0x61, 0x44, 0x61, 0x65, 0x61, 0x45})); + CHECK(json::parse("{\"a\": \"A\", \"b\": \"B\", \"c\": \"C\", \"d\": \"D\", \"e\": \"E\"}") == + json::from_cbor(std::vector( + {0xa5, 0x61, 0x61, 0x61, 0x41, 0x61, 0x62, 0x61, 0x42, 0x61, 0x63, 0x61, 0x43, 0x61, 0x64, 0x61, 0x44, 0x61, 0x65, 0x61, 0x45}))); // indefinite length objects - CHECK(json::parse("{\"a\": 1, \"b\": [2, 3]}") == json::from_cbor(std::vector({0xbf, 0x61, 0x61, 0x01, 0x61, 0x62, 0x9f, 0x02, 0x03, 0xff, 0xff}))); + CHECK(json::parse("{\"a\": 1, \"b\": [2, 3]}") == + json::from_cbor(std::vector({0xbf, 0x61, 0x61, 0x01, 0x61, 0x62, 0x9f, 0x02, 0x03, 0xff, 0xff}))); CHECK(json::parse("[\"a\", {\"b\": \"c\"}]") == json::from_cbor(std::vector({0x82, 0x61, 0x61, 0xbf, 0x61, 0x62, 0x61, 0x63, 0xff}))); - CHECK(json::parse("{\"Fun\": true, \"Amt\": -2}") == json::from_cbor(std::vector({0xbf, 0x63, 0x46, 0x75, 0x6e, 0xf5, 0x63, 0x41, 0x6d, 0x74, 0x21, 0xff}))); + CHECK(json::parse("{\"Fun\": true, \"Amt\": -2}") == + json::from_cbor(std::vector({0xbf, 0x63, 0x46, 0x75, 0x6e, 0xf5, 0x63, 0x41, 0x6d, 0x74, 0x21, 0xff}))); } } @@ -2626,22 +2606,7 @@ TEST_CASE("Tagged values") SECTION("0xC6..0xD4") { - for (const auto b : std::vector{ - 0xC6, - 0xC7, - 0xC8, - 0xC9, - 0xCA, - 0xCB, - 0xCC, - 0xCD, - 0xCE, - 0xCF, - 0xD0, - 0xD1, - 0xD2, - 0xD3, - 0xD4}) + for (const auto b : std::vector{0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4}) { CAPTURE(b); @@ -2829,7 +2794,9 @@ TEST_CASE("Tagged values") // parse error when parsing tagged value json _; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec), "[json.exception.parse_error.112] parse error at byte 9: syntax error while parsing CBOR value: invalid byte: 0xD8", json::parse_error); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec), + "[json.exception.parse_error.112] parse error at byte 9: syntax error while parsing CBOR value: invalid byte: 0xD8", + json::parse_error); // binary without subtype when tags are ignored json jb = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore); diff --git a/tests/src/unit-class_lexer.cpp b/tests/src/unit-class_lexer.cpp index 5fb4357c6f..898fd53a57 100644 --- a/tests/src/unit-class_lexer.cpp +++ b/tests/src/unit-class_lexer.cpp @@ -12,7 +12,8 @@ #include using nlohmann::json; -namespace { +namespace +{ // shortcut to scan a string literal json::lexer::token_type scan_string(const char* s, bool ignore_comments = false); json::lexer::token_type scan_string(const char* s, const bool ignore_comments) diff --git a/tests/src/unit-class_parser.cpp b/tests/src/unit-class_parser.cpp index d47f9d1553..1a4888d826 100644 --- a/tests/src/unit-class_parser.cpp +++ b/tests/src/unit-class_parser.cpp @@ -17,7 +17,8 @@ using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) #include -namespace { +namespace +{ class SaxEventLogger { public: @@ -358,48 +359,156 @@ TEST_CASE("parser class") SECTION("errors") { // error: tab in string - CHECK_THROWS_WITH_AS(parser_helper("\"\t\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t; last read: '\"'", json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\t\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t; last read: '\"'", + json::parse_error&); // error: newline in string - CHECK_THROWS_WITH_AS(parser_helper("\"\n\""), "[json.exception.parse_error.101] parse error at line 2, column 0: syntax error while parsing value - invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\r\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r; last read: '\"'", json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\n\""), + "[json.exception.parse_error.101] parse error at line 2, column 0: syntax error while parsing value - invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\r\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r; last read: '\"'", + json::parse_error&); // error: backspace in string - CHECK_THROWS_WITH_AS(parser_helper("\"\b\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b; last read: '\"'", json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\b\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b; last read: '\"'", + json::parse_error&); // improve code coverage CHECK_THROWS_AS(parser_helper("\uFF01"), json::parse_error&); CHECK_THROWS_AS(parser_helper("[-4:1,]"), json::parse_error&); // unescaped control characters - CHECK_THROWS_WITH_AS(parser_helper("\"\x00\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: missing closing quote; last read: '\"'", json::parse_error&); // NOLINT(bugprone-string-literal-with-embedded-nul) - CHECK_THROWS_WITH_AS(parser_helper("\"\x01\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0001 (SOH) must be escaped to \\u0001; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x02\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0002 (STX) must be escaped to \\u0002; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x03\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0003 (ETX) must be escaped to \\u0003; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x04\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0004 (EOT) must be escaped to \\u0004; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x05\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0005 (ENQ) must be escaped to \\u0005; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x06\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0006 (ACK) must be escaped to \\u0006; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x07\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0007 (BEL) must be escaped to \\u0007; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x08\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x09\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x0a\""), "[json.exception.parse_error.101] parse error at line 2, column 0: syntax error while parsing value - invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x0b\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000B (VT) must be escaped to \\u000B; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x0c\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x0d\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x0e\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000E (SO) must be escaped to \\u000E; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x0f\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000F (SI) must be escaped to \\u000F; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x10\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0010 (DLE) must be escaped to \\u0010; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x11\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0011 (DC1) must be escaped to \\u0011; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x12\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0012 (DC2) must be escaped to \\u0012; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x13\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0013 (DC3) must be escaped to \\u0013; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x14\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0014 (DC4) must be escaped to \\u0014; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x15\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0015 (NAK) must be escaped to \\u0015; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x16\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0016 (SYN) must be escaped to \\u0016; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x17\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0017 (ETB) must be escaped to \\u0017; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x18\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0018 (CAN) must be escaped to \\u0018; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x19\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0019 (EM) must be escaped to \\u0019; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x1a\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001A (SUB) must be escaped to \\u001A; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x1b\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001B (ESC) must be escaped to \\u001B; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x1c\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001C (FS) must be escaped to \\u001C; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x1d\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001D (GS) must be escaped to \\u001D; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x1e\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001E (RS) must be escaped to \\u001E; last read: '\"'", json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\x1f\""), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001F (US) must be escaped to \\u001F; last read: '\"'", json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x00\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: missing closing quote; last read: '\"'", + json::parse_error&); // NOLINT(bugprone-string-literal-with-embedded-nul) + CHECK_THROWS_WITH_AS( + parser_helper("\"\x01\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0001 (SOH) must be escaped to \\u0001; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x02\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0002 (STX) must be escaped to \\u0002; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x03\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0003 (ETX) must be escaped to \\u0003; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x04\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0004 (EOT) must be escaped to \\u0004; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x05\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0005 (ENQ) must be escaped to \\u0005; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x06\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0006 (ACK) must be escaped to \\u0006; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x07\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0007 (BEL) must be escaped to \\u0007; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x08\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x09\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x0a\""), + "[json.exception.parse_error.101] parse error at line 2, column 0: syntax error while parsing value - invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x0b\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000B (VT) must be escaped to \\u000B; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x0c\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x0d\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x0e\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000E (SO) must be escaped to \\u000E; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x0f\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+000F (SI) must be escaped to \\u000F; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x10\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0010 (DLE) must be escaped to \\u0010; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x11\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0011 (DC1) must be escaped to \\u0011; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x12\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0012 (DC2) must be escaped to \\u0012; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x13\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0013 (DC3) must be escaped to \\u0013; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x14\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0014 (DC4) must be escaped to \\u0014; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x15\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0015 (NAK) must be escaped to \\u0015; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x16\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0016 (SYN) must be escaped to \\u0016; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x17\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0017 (ETB) must be escaped to \\u0017; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x18\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0018 (CAN) must be escaped to \\u0018; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x19\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0019 (EM) must be escaped to \\u0019; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x1a\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001A (SUB) must be escaped to \\u001A; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x1b\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001B (ESC) must be escaped to \\u001B; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x1c\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001C (FS) must be escaped to \\u001C; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x1d\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001D (GS) must be escaped to \\u001D; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x1e\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001E (RS) must be escaped to \\u001E; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\x1f\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+001F (US) must be escaped to \\u001F; last read: '\"'", + json::parse_error&); SECTION("additional test for null byte") { @@ -410,7 +519,10 @@ TEST_CASE("parser class") std::string s = "\"1\""; s[1] = '\0'; json _; - CHECK_THROWS_WITH_AS(_ = json::parse(s.begin(), s.end()), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0000 (NUL) must be escaped to \\u0000; last read: '\"'", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse(s.begin(), s.end()), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0000 (NUL) must be escaped to \\u0000; last read: '\"'", + json::parse_error&); } } @@ -581,7 +693,9 @@ TEST_CASE("parser class") SECTION("overflow") { // overflows during parsing yield an exception - CHECK_THROWS_WITH_AS(parser_helper("1.18973e+4932").empty(), "[json.exception.out_of_range.406] number overflow parsing '1.18973e+4932'", json::out_of_range&); + CHECK_THROWS_WITH_AS(parser_helper("1.18973e+4932").empty(), + "[json.exception.out_of_range.406] number overflow parsing '1.18973e+4932'", + json::out_of_range&); } SECTION("invalid numbers") @@ -590,57 +704,74 @@ TEST_CASE("parser class") CHECK_THROWS_AS(parser_helper("+1"), json::parse_error&); CHECK_THROWS_AS(parser_helper("+0"), json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("01"), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - unexpected number literal; expected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-01"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - unexpected number literal; expected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("--1"), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid number; expected digit after '-'; last read: '--'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("1."), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected digit after '.'; last read: '1.'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("1E"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1E'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("1E-"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid number; expected digit after exponent sign; last read: '1E-'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("1.E1"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected digit after '.'; last read: '1.E'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-1E"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '-1E'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-0E#"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '-0E#'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-0E-#"), - "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid number; expected digit after exponent sign; last read: '-0E-#'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-0#"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid literal; last read: '-0#'; expected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-0.0:"), - "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - unexpected ':'; expected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-0.0Z"), - "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid literal; last read: '-0.0Z'; expected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-0E123:"), - "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - unexpected ':'; expected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-0e0-:"), - "[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid number; expected digit after '-'; last read: '-:'; expected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-0e-:"), - "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid number; expected digit after exponent sign; last read: '-0e-:'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-0f"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: '-0f'; expected end of input", - json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("01"), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - unexpected number literal; expected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-01"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - unexpected number literal; expected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("--1"), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid number; expected digit after '-'; last read: '--'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("1."), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected digit after '.'; last read: '1.'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("1E"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1E'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("1E-"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid number; expected digit after exponent sign; last read: '1E-'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("1.E1"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected digit after '.'; last read: '1.E'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-1E"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '-1E'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-0E#"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '-0E#'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-0E-#"), + "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid number; expected digit after exponent sign; last read: '-0E-#'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-0#"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid literal; last read: '-0#'; expected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-0.0:"), + "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - unexpected ':'; expected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-0.0Z"), + "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid literal; last read: '-0.0Z'; expected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-0E123:"), + "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - unexpected ':'; expected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-0e0-:"), + "[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid number; expected digit after '-'; last read: '-:'; expected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-0e-:"), + "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid number; expected digit after exponent sign; last read: '-0e-:'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-0f"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: '-0f'; expected end of input", + json::parse_error&); } } } @@ -910,171 +1041,222 @@ TEST_CASE("parser class") SECTION("parse errors") { // unexpected end of number - CHECK_THROWS_WITH_AS(parser_helper("0."), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected digit after '.'; last read: '0.'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-"), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid number; expected digit after '-'; last read: '-'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("--"), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid number; expected digit after '-'; last read: '--'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-0."), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid number; expected digit after '.'; last read: '-0.'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-."), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid number; expected digit after '-'; last read: '-.'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("-:"), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid number; expected digit after '-'; last read: '-:'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("0.:"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected digit after '.'; last read: '0.:'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("e."), - "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: 'e'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("1e."), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1e.'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("1e/"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1e/'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("1e:"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1e:'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("1E."), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1E.'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("1E/"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1E/'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("1E:"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1E:'", - json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("0."), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected digit after '.'; last read: '0.'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-"), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid number; expected digit after '-'; last read: '-'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("--"), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid number; expected digit after '-'; last read: '--'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-0."), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid number; expected digit after '.'; last read: '-0.'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-."), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid number; expected digit after '-'; last read: '-.'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("-:"), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid number; expected digit after '-'; last read: '-:'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("0.:"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected digit after '.'; last read: '0.:'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("e."), + "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: 'e'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("1e."), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1e.'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("1e/"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1e/'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("1e:"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1e:'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("1E."), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1E.'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("1E/"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1E/'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("1E:"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1E:'", + json::parse_error&); // unexpected end of null - CHECK_THROWS_WITH_AS(parser_helper("n"), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid literal; last read: 'n'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("nu"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid literal; last read: 'nu'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("nul"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'nul'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("nulk"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'nulk'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("nulm"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'nulm'", - json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("n"), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid literal; last read: 'n'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("nu"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid literal; last read: 'nu'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("nul"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'nul'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("nulk"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'nulk'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("nulm"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'nulm'", + json::parse_error&); // unexpected end of true - CHECK_THROWS_WITH_AS(parser_helper("t"), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid literal; last read: 't'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("tr"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid literal; last read: 'tr'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("tru"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'tru'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("trud"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'trud'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("truf"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'truf'", - json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("t"), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid literal; last read: 't'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("tr"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid literal; last read: 'tr'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("tru"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'tru'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("trud"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'trud'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("truf"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'truf'", + json::parse_error&); // unexpected end of false - CHECK_THROWS_WITH_AS(parser_helper("f"), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid literal; last read: 'f'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("fa"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid literal; last read: 'fa'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("fal"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'fal'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("fals"), - "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid literal; last read: 'fals'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("falsd"), - "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid literal; last read: 'falsd'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("falsf"), - "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid literal; last read: 'falsf'", - json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("f"), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid literal; last read: 'f'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("fa"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid literal; last read: 'fa'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("fal"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: 'fal'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("fals"), + "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid literal; last read: 'fals'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("falsd"), + "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid literal; last read: 'falsd'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("falsf"), + "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid literal; last read: 'falsf'", + json::parse_error&); // missing/unexpected end of array - CHECK_THROWS_WITH_AS(parser_helper("["), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("[1"), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing array - unexpected end of input; expected ']'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("[1,"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("[1,]"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected ']'; expected '[', '{', or a literal", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("]"), - "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected ']'; expected '[', '{', or a literal", - json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("["), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("[1"), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing array - unexpected end of input; expected ']'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("[1,"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("[1,]"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected ']'; expected '[', '{', or a literal", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("]"), + "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected ']'; expected '[', '{', or a literal", + json::parse_error&); // missing/unexpected end of object - CHECK_THROWS_WITH_AS(parser_helper("{"), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing object key - unexpected end of input; expected string literal", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("{\"foo\""), - "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing object separator - unexpected end of input; expected ':'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("{\"foo\":"), - "[json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("{\"foo\":}"), - "[json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - unexpected '}'; expected '[', '{', or a literal", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("{\"foo\":1,}"), - "[json.exception.parse_error.101] parse error at line 1, column 10: syntax error while parsing object key - unexpected '}'; expected string literal", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("}"), - "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected '}'; expected '[', '{', or a literal", - json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("{"), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing object key - unexpected end of input; expected string literal", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("{\"foo\""), + "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing object separator - unexpected end of input; expected ':'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("{\"foo\":"), + "[json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("{\"foo\":}"), + "[json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - unexpected '}'; expected '[', '{', or a literal", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("{\"foo\":1,}"), + "[json.exception.parse_error.101] parse error at line 1, column 10: syntax error while parsing object key - unexpected '}'; expected string literal", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("}"), + "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected '}'; expected '[', '{', or a literal", + json::parse_error&); // missing/unexpected end of string - CHECK_THROWS_WITH_AS(parser_helper("\""), - "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: missing closing quote; last read: '\"'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\\\""), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: missing closing quote; last read: '\"\\\"'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\\u\""), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u\"'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\\u0\""), - "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u0\"'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\\u01\""), - "[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u01\"'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\\u012\""), - "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u012\"'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\\u"), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\\u0"), - "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u0'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\\u01"), - "[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u01'", - json::parse_error&); - CHECK_THROWS_WITH_AS(parser_helper("\"\\u012"), - "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u012'", - json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\""), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: missing closing quote; last read: '\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\\\""), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: missing closing quote; last read: '\"\\\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\\u\""), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\\u0\""), + "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u0\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\\u01\""), + "[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u01\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\\u012\""), + "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u012\"'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\\u"), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\\u0"), + "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u0'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\\u01"), + "[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u01'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("\"\\u012"), + "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\u012'", + json::parse_error&); // invalid escapes for (int c = 1; c < 128; ++c) @@ -1110,8 +1292,10 @@ TEST_CASE("parser class") // only check error message if c is not a control character if (c > 0x1f) { - CHECK_THROWS_WITH_STD_STR(parser_helper(s), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid string: forbidden character after backslash; last read: '\"\\" + std::string(1, static_cast(c)) + "'"); + CHECK_THROWS_WITH_STD_STR( + parser_helper(s), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid string: forbidden character after backslash; last read: '\"\\" + + std::string(1, static_cast(c)) + "'"); } break; } @@ -1185,8 +1369,10 @@ TEST_CASE("parser class") // only check error message if c is not a control character if (c > 0x1f) { - CHECK_THROWS_WITH_STD_STR(parser_helper(s1), - "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s1.substr(0, 7) + "'"); + CHECK_THROWS_WITH_STD_STR( + parser_helper(s1), + "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + + s1.substr(0, 7) + "'"); } CAPTURE(s2) @@ -1194,8 +1380,10 @@ TEST_CASE("parser class") // only check error message if c is not a control character if (c > 0x1f) { - CHECK_THROWS_WITH_STD_STR(parser_helper(s2), - "[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s2.substr(0, 6) + "'"); + CHECK_THROWS_WITH_STD_STR( + parser_helper(s2), + "[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + + s2.substr(0, 6) + "'"); } CAPTURE(s3) @@ -1203,8 +1391,10 @@ TEST_CASE("parser class") // only check error message if c is not a control character if (c > 0x1f) { - CHECK_THROWS_WITH_STD_STR(parser_helper(s3), - "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s3.substr(0, 5) + "'"); + CHECK_THROWS_WITH_STD_STR( + parser_helper(s3), + "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + + s3.substr(0, 5) + "'"); } CAPTURE(s4) @@ -1212,8 +1402,10 @@ TEST_CASE("parser class") // only check error message if c is not a control character if (c > 0x1f) { - CHECK_THROWS_WITH_STD_STR(parser_helper(s4), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s4.substr(0, 4) + "'"); + CHECK_THROWS_WITH_STD_STR( + parser_helper(s4), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + + s4.substr(0, 4) + "'"); } } } @@ -1222,17 +1414,23 @@ TEST_CASE("parser class") json _; // missing part of a surrogate pair - CHECK_THROWS_WITH_AS(_ = json::parse("\"\\uD80C\""), "[json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\"'", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse("\"\\uD80C\""), + "[json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\"'", + json::parse_error&); // invalid surrogate pair - CHECK_THROWS_WITH_AS(_ = json::parse("\"\\uD80C\\uD80C\""), - "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\\uD80C'", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::parse("\"\\uD80C\\u0000\""), - "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\\u0000'", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::parse("\"\\uD80C\\uFFFF\""), - "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\\uFFFF'", - json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse("\"\\uD80C\\uD80C\""), + "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\\uD80C'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse("\"\\uD80C\\u0000\""), + "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\\u0000'", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse("\"\\uD80C\\uFFFF\""), + "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\\uFFFF'", + json::parse_error&); } SECTION("parse errors (accept)") @@ -1423,9 +1621,15 @@ TEST_CASE("parser class") SECTION("tests found by mutate++") { // test case to make sure no comma precedes the first key - CHECK_THROWS_WITH_AS(parser_helper("{,\"key\": false}"), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing object key - unexpected ','; expected string literal", json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("{,\"key\": false}"), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing object key - unexpected ','; expected string literal", + json::parse_error&); // test case to make sure an object is properly closed - CHECK_THROWS_WITH_AS(parser_helper("[{\"key\": false true]"), "[json.exception.parse_error.101] parse error at line 1, column 19: syntax error while parsing object - unexpected true literal; expected '}'", json::parse_error&); + CHECK_THROWS_WITH_AS( + parser_helper("[{\"key\": false true]"), + "[json.exception.parse_error.101] parse error at line 1, column 19: syntax error while parsing object - unexpected true literal; expected '}'", + json::parse_error&); // test case to make sure the callback is properly evaluated after reading a key { @@ -1655,9 +1859,14 @@ TEST_CASE("parser class") CHECK(json::parse("{\"foo\": true:", cb, false).is_discarded()); json _; - CHECK_THROWS_WITH_AS(_ = json::parse("{\"foo\": true:", cb), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing object - unexpected ':'; expected '}'", json::parse_error&); - - CHECK_THROWS_WITH_AS(_ = json::parse("1.18973e+4932", cb), "[json.exception.out_of_range.406] number overflow parsing '1.18973e+4932'", json::out_of_range&); + CHECK_THROWS_WITH_AS( + _ = json::parse("{\"foo\": true:", cb), + "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing object - unexpected ':'; expected '}'", + json::parse_error&); + + CHECK_THROWS_WITH_AS(_ = json::parse("1.18973e+4932", cb), + "[json.exception.out_of_range.406] number overflow parsing '1.18973e+4932'", + json::out_of_range&); } SECTION("SAX parser") @@ -1739,7 +1948,13 @@ TEST_CASE("parser class") SECTION("error messages for comments") { json _; - CHECK_THROWS_WITH_AS(_ = json::parse("/a", nullptr, true, true), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid comment; expecting '/' or '*' after '/'; last read: '/a'", json::parse_error); - CHECK_THROWS_WITH_AS(_ = json::parse("/*", nullptr, true, true), "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid comment; missing closing '*/'; last read: '/*'", json::parse_error); + CHECK_THROWS_WITH_AS( + _ = json::parse("/a", nullptr, true, true), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid comment; expecting '/' or '*' after '/'; last read: '/a'", + json::parse_error); + CHECK_THROWS_WITH_AS( + _ = json::parse("/*", nullptr, true, true), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid comment; missing closing '*/'; last read: '/*'", + json::parse_error); } } diff --git a/tests/src/unit-comparison.cpp b/tests/src/unit-comparison.cpp index 1b0042da20..ca8e10a218 100644 --- a/tests/src/unit-comparison.cpp +++ b/tests/src/unit-comparison.cpp @@ -21,7 +21,8 @@ using nlohmann::json; #if JSON_HAS_THREE_WAY_COMPARISON // this can be replaced with the doctest stl extension header in version 2.5 -namespace doctest { +namespace doctest +{ template<> struct StringMaker { @@ -50,7 +51,8 @@ struct StringMaker #endif -namespace { +namespace +{ // helper function to check std::less // see https://en.cppreference.com/w/cpp/utility/functional/less template> @@ -85,33 +87,30 @@ TEST_CASE("lexicographical comparison operators") SECTION("types") { - std::vector j_types = - { - json::value_t::null, - json::value_t::boolean, - json::value_t::number_integer, - json::value_t::number_unsigned, - json::value_t::number_float, - json::value_t::object, - json::value_t::array, - json::value_t::string, - json::value_t::binary, - json::value_t::discarded}; - - std::vector> expected_lt = - { - //0 1 2 3 4 5 6 7 8 9 - {f_, _t, _t, _t, _t, _t, _t, _t, _t, f_}, // 0 - {f_, f_, _t, _t, _t, _t, _t, _t, _t, f_}, // 1 - {f_, f_, f_, f_, f_, _t, _t, _t, _t, f_}, // 2 - {f_, f_, f_, f_, f_, _t, _t, _t, _t, f_}, // 3 - {f_, f_, f_, f_, f_, _t, _t, _t, _t, f_}, // 4 - {f_, f_, f_, f_, f_, f_, _t, _t, _t, f_}, // 5 - {f_, f_, f_, f_, f_, f_, f_, _t, _t, f_}, // 6 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, f_}, // 7 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 8 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 9 - }; + std::vector j_types = {json::value_t::null, + json::value_t::boolean, + json::value_t::number_integer, + json::value_t::number_unsigned, + json::value_t::number_float, + json::value_t::object, + json::value_t::array, + json::value_t::string, + json::value_t::binary, + json::value_t::discarded}; + + std::vector> expected_lt = { + //0 1 2 3 4 5 6 7 8 9 + {f_, _t, _t, _t, _t, _t, _t, _t, _t, f_}, // 0 + {f_, f_, _t, _t, _t, _t, _t, _t, _t, f_}, // 1 + {f_, f_, f_, f_, f_, _t, _t, _t, _t, f_}, // 2 + {f_, f_, f_, f_, f_, _t, _t, _t, _t, f_}, // 3 + {f_, f_, f_, f_, f_, _t, _t, _t, _t, f_}, // 4 + {f_, f_, f_, f_, f_, f_, _t, _t, _t, f_}, // 5 + {f_, f_, f_, f_, f_, f_, f_, _t, _t, f_}, // 6 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, f_}, // 7 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 8 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 9 + }; SECTION("comparison: less") { @@ -138,20 +137,19 @@ TEST_CASE("lexicographical comparison operators") // JSON_HAS_CPP_20 (do not remove; see note at top of file) SECTION("comparison: 3-way") { - std::vector> expected = - { - //0 1 2 3 4 5 6 7 8 9 - {eq, lt, lt, lt, lt, lt, lt, lt, lt, un}, // 0 - {gt, eq, lt, lt, lt, lt, lt, lt, lt, un}, // 1 - {gt, gt, eq, eq, eq, lt, lt, lt, lt, un}, // 2 - {gt, gt, eq, eq, eq, lt, lt, lt, lt, un}, // 3 - {gt, gt, eq, eq, eq, lt, lt, lt, lt, un}, // 4 - {gt, gt, gt, gt, gt, eq, lt, lt, lt, un}, // 5 - {gt, gt, gt, gt, gt, gt, eq, lt, lt, un}, // 6 - {gt, gt, gt, gt, gt, gt, gt, eq, lt, un}, // 7 - {gt, gt, gt, gt, gt, gt, gt, gt, eq, un}, // 8 - {un, un, un, un, un, un, un, un, un, un}, // 9 - }; + std::vector> expected = { + //0 1 2 3 4 5 6 7 8 9 + {eq, lt, lt, lt, lt, lt, lt, lt, lt, un}, // 0 + {gt, eq, lt, lt, lt, lt, lt, lt, lt, un}, // 1 + {gt, gt, eq, eq, eq, lt, lt, lt, lt, un}, // 2 + {gt, gt, eq, eq, eq, lt, lt, lt, lt, un}, // 3 + {gt, gt, eq, eq, eq, lt, lt, lt, lt, un}, // 4 + {gt, gt, gt, gt, gt, eq, lt, lt, lt, un}, // 5 + {gt, gt, gt, gt, gt, gt, eq, lt, lt, un}, // 6 + {gt, gt, gt, gt, gt, gt, gt, eq, lt, un}, // 7 + {gt, gt, gt, gt, gt, gt, gt, gt, eq, un}, // 8 + {un, un, un, un, un, un, un, un, un, un}, // 9 + }; // check expected partial_ordering against expected boolean REQUIRE(expected.size() == expected_lt.size()); @@ -184,114 +182,110 @@ TEST_CASE("lexicographical comparison operators") SECTION("values") { - json j_values = - { - nullptr, - nullptr, // 0 1 - -17, - 42, // 2 3 - 8u, - 13u, // 4 5 - 3.14159, - 23.42, // 6 7 - nan, - nan, // 8 9 - "foo", - "bar", // 10 11 - true, - false, // 12 13 - {1, 2, 3}, - {"one", "two", "three"}, // 14 15 - {{"first", 1}, {"second", 2}}, - {{"a", "A"}, {"b", {"B"}}}, // 16 17 - json::binary({1, 2, 3}), - json::binary({1, 2, 4}), // 18 19 - json(json::value_t::discarded), - json(json::value_t::discarded) // 20 21 - }; - - std::vector> expected_eq = - { - //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 - {_t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 0 - {_t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 1 - {f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 2 - {f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 3 - {f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 4 - {f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 5 - {f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 6 - {f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 7 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 8 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 9 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 10 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 11 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 12 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_}, // 13 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_}, // 14 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_}, // 15 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_}, // 16 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_}, // 17 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_}, // 18 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_}, // 19 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 20 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 21 - }; - - std::vector> expected_lt = - { - //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 - {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_}, // 0 - {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_}, // 1 - {f_, f_, f_, _t, _t, _t, _t, _t, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 2 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 3 - {f_, f_, f_, _t, f_, _t, f_, _t, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 4 - {f_, f_, f_, _t, f_, f_, f_, _t, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 5 - {f_, f_, f_, _t, _t, _t, f_, _t, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 6 - {f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 7 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 8 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 9 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_}, // 10 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_}, // 11 - {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 12 - {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 13 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, _t, f_, f_, _t, _t, f_, f_}, // 14 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_}, // 15 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, f_, f_, _t, _t, f_, f_}, // 16 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, _t, f_, _t, _t, f_, f_}, // 17 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_}, // 18 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 19 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 20 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 21 - }; + json j_values = { + nullptr, + nullptr, // 0 1 + -17, + 42, // 2 3 + 8u, + 13u, // 4 5 + 3.14159, + 23.42, // 6 7 + nan, + nan, // 8 9 + "foo", + "bar", // 10 11 + true, + false, // 12 13 + {1, 2, 3}, + {"one", "two", "three"}, // 14 15 + {{"first", 1}, {"second", 2}}, + {{"a", "A"}, {"b", {"B"}}}, // 16 17 + json::binary({1, 2, 3}), + json::binary({1, 2, 4}), // 18 19 + json(json::value_t::discarded), + json(json::value_t::discarded) // 20 21 + }; + + std::vector> expected_eq = { + //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 + {_t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 0 + {_t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 1 + {f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 2 + {f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 3 + {f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 4 + {f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 5 + {f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 6 + {f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 7 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 8 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 9 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 10 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 11 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 12 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, f_}, // 13 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_}, // 14 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_}, // 15 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_}, // 16 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_}, // 17 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_}, // 18 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_}, // 19 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 20 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 21 + }; + + std::vector> expected_lt = { + //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 + {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_}, // 0 + {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_}, // 1 + {f_, f_, f_, _t, _t, _t, _t, _t, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 2 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 3 + {f_, f_, f_, _t, f_, _t, f_, _t, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 4 + {f_, f_, f_, _t, f_, f_, f_, _t, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 5 + {f_, f_, f_, _t, _t, _t, f_, _t, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 6 + {f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 7 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 8 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 9 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_}, // 10 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_}, // 11 + {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 12 + {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, f_, _t, _t, _t, _t, _t, _t, f_, f_}, // 13 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, _t, f_, f_, _t, _t, f_, f_}, // 14 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_}, // 15 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, f_, f_, _t, _t, f_, f_}, // 16 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, _t, _t, _t, f_, _t, _t, f_, f_}, // 17 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, f_, f_}, // 18 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 19 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 20 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 21 + }; SECTION("compares unordered") { - std::vector> expected = - { - //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 0 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 1 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 2 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 3 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 4 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 5 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 6 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 7 - {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 8 - {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 9 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 10 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 11 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 12 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 13 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 14 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 15 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 16 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 17 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 18 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 19 - {_t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t}, // 20 - {_t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t}, // 21 - }; + std::vector> expected = { + //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 0 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 1 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 2 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 3 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 4 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 5 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 6 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 7 + {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 8 + {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 9 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 10 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 11 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 12 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 13 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 14 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 15 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 16 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 17 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 18 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, _t, _t}, // 19 + {_t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t}, // 20 + {_t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t, _t}, // 21 + }; // check if two values compare unordered as expected REQUIRE(expected.size() == j_values.size()); @@ -310,32 +304,31 @@ TEST_CASE("lexicographical comparison operators") #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON SECTION("compares unordered (inverse)") { - std::vector> expected = - { - //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 0 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 1 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 2 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 3 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 4 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 5 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 6 - {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 7 - {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 8 - {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 9 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 10 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 11 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 12 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 13 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 14 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 15 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 16 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 17 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 18 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 19 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 20 - {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 21 - }; + std::vector> expected = { + //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 0 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 1 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 2 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 3 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 4 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 5 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 6 + {f_, f_, f_, f_, f_, f_, f_, f_, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 7 + {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 8 + {f_, f_, _t, _t, _t, _t, _t, _t, _t, _t, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 9 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 10 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 11 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 12 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 13 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 14 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 15 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 16 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 17 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 18 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 19 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 20 + {f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_, f_}, // 21 + }; // check that two values compare unordered as expected (with legacy-mode enabled) REQUIRE(expected.size() == j_values.size()); @@ -505,32 +498,31 @@ TEST_CASE("lexicographical comparison operators") // JSON_HAS_CPP_20 (do not remove; see note at top of file) SECTION("comparison: 3-way") { - std::vector> expected = - { - //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 - {eq, eq, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, un, un}, // 0 - {eq, eq, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, un, un}, // 1 - {gt, gt, eq, lt, lt, lt, lt, lt, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 2 - {gt, gt, gt, eq, gt, gt, gt, gt, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 3 - {gt, gt, gt, lt, eq, lt, gt, lt, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 4 - {gt, gt, gt, lt, gt, eq, gt, lt, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 5 - {gt, gt, gt, lt, lt, lt, eq, lt, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 6 - {gt, gt, gt, lt, gt, gt, gt, eq, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 7 - {gt, gt, un, un, un, un, un, un, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 8 - {gt, gt, un, un, un, un, un, un, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 9 - {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, eq, gt, gt, gt, gt, gt, gt, gt, lt, lt, un, un}, // 10 - {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, lt, eq, gt, gt, gt, gt, gt, gt, lt, lt, un, un}, // 11 - {gt, gt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, eq, gt, lt, lt, lt, lt, lt, lt, un, un}, // 12 - {gt, gt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, eq, lt, lt, lt, lt, lt, lt, un, un}, // 13 - {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, lt, lt, gt, gt, eq, lt, gt, gt, lt, lt, un, un}, // 14 - {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, lt, lt, gt, gt, gt, eq, gt, gt, lt, lt, un, un}, // 15 - {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, lt, lt, gt, gt, lt, lt, eq, gt, lt, lt, un, un}, // 16 - {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, lt, lt, gt, gt, lt, lt, lt, eq, lt, lt, un, un}, // 17 - {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, eq, lt, un, un}, // 18 - {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, eq, un, un}, // 19 - {un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un}, // 20 - {un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un}, // 21 - }; + std::vector> expected = { + //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 + {eq, eq, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, un, un}, // 0 + {eq, eq, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, un, un}, // 1 + {gt, gt, eq, lt, lt, lt, lt, lt, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 2 + {gt, gt, gt, eq, gt, gt, gt, gt, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 3 + {gt, gt, gt, lt, eq, lt, gt, lt, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 4 + {gt, gt, gt, lt, gt, eq, gt, lt, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 5 + {gt, gt, gt, lt, lt, lt, eq, lt, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 6 + {gt, gt, gt, lt, gt, gt, gt, eq, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 7 + {gt, gt, un, un, un, un, un, un, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 8 + {gt, gt, un, un, un, un, un, un, un, un, lt, lt, gt, gt, lt, lt, lt, lt, lt, lt, un, un}, // 9 + {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, eq, gt, gt, gt, gt, gt, gt, gt, lt, lt, un, un}, // 10 + {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, lt, eq, gt, gt, gt, gt, gt, gt, lt, lt, un, un}, // 11 + {gt, gt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, eq, gt, lt, lt, lt, lt, lt, lt, un, un}, // 12 + {gt, gt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, lt, eq, lt, lt, lt, lt, lt, lt, un, un}, // 13 + {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, lt, lt, gt, gt, eq, lt, gt, gt, lt, lt, un, un}, // 14 + {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, lt, lt, gt, gt, gt, eq, gt, gt, lt, lt, un, un}, // 15 + {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, lt, lt, gt, gt, lt, lt, eq, gt, lt, lt, un, un}, // 16 + {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, lt, lt, gt, gt, lt, lt, lt, eq, lt, lt, un, un}, // 17 + {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, eq, lt, un, un}, // 18 + {gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, gt, eq, un, un}, // 19 + {un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un}, // 20 + {un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un, un}, // 21 + }; // check expected partial_ordering against expected booleans REQUIRE(expected.size() == expected_eq.size()); diff --git a/tests/src/unit-concepts.cpp b/tests/src/unit-concepts.cpp index 629142e18b..d6bf2c9afb 100644 --- a/tests/src/unit-concepts.cpp +++ b/tests/src/unit-concepts.cpp @@ -52,8 +52,7 @@ TEST_CASE("concepts") // X::size_type must return an unsigned integer CHECK((std::is_unsigned::value)); // X::size_type can represent any non-negative value of X::difference_type - CHECK(static_cast((std::numeric_limits::max)()) <= - (std::numeric_limits::max)()); + CHECK(static_cast((std::numeric_limits::max)()) <= (std::numeric_limits::max)()); // the expression "X u" has the post-condition "u.empty()" { diff --git a/tests/src/unit-constructor1.cpp b/tests/src/unit-constructor1.cpp index b8ebdb659b..3d3f1c541e 100644 --- a/tests/src/unit-constructor1.cpp +++ b/tests/src/unit-constructor1.cpp @@ -173,7 +173,12 @@ TEST_CASE("constructors") SECTION("std::multimap") { - std::multimap const o{{"a", json(1)}, {"b", json(1u)}, {"c", json(2.2)}, {"d", json(false)}, {"e", json("string")}, {"f", json()}}; + std::multimap const o{{"a", json(1)}, + {"b", json(1u)}, + {"c", json(2.2)}, + {"d", json(false)}, + {"e", json("string")}, + {"f", json()}}; json const j(o); CHECK(j.type() == json::value_t::object); CHECK(j == j_reference); @@ -181,7 +186,12 @@ TEST_CASE("constructors") SECTION("std::unordered_map") { - std::unordered_map const o{{"a", json(1)}, {"b", json(1u)}, {"c", json(2.2)}, {"d", json(false)}, {"e", json("string")}, {"f", json()}}; + std::unordered_map const o{{"a", json(1)}, + {"b", json(1u)}, + {"c", json(2.2)}, + {"d", json(false)}, + {"e", json("string")}, + {"f", json()}}; json const j(o); CHECK(j.type() == json::value_t::object); CHECK(j == j_reference); @@ -189,7 +199,12 @@ TEST_CASE("constructors") SECTION("std::unordered_multimap") { - std::unordered_multimap const o{{"a", json(1)}, {"b", json(1u)}, {"c", json(2.2)}, {"d", json(false)}, {"e", json("string")}, {"f", json()}}; + std::unordered_multimap const o{{"a", json(1)}, + {"b", json(1u)}, + {"c", json(2.2)}, + {"d", json(false)}, + {"e", json("string")}, + {"f", json()}}; json const j(o); CHECK(j.type() == json::value_t::object); CHECK(j == j_reference); @@ -1083,7 +1098,9 @@ TEST_CASE("constructors") SECTION("object with error") { json _; - CHECK_THROWS_WITH_AS(_ = json::object({{"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}, 13}), "[json.exception.type_error.301] cannot create object from initializer list", json::type_error&); + CHECK_THROWS_WITH_AS(_ = json::object({{"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}, 13}), + "[json.exception.type_error.301] cannot create object from initializer list", + json::type_error&); } SECTION("empty array") @@ -1328,14 +1345,22 @@ TEST_CASE("constructors") { json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}}; json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - CHECK_THROWS_WITH_AS(json(jobject.begin(), jobject2.end()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(jobject2.begin(), jobject.end()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(jobject.begin(), jobject2.end()), + "[json.exception.invalid_iterator.201] iterators are not compatible", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(jobject2.begin(), jobject.end()), + "[json.exception.invalid_iterator.201] iterators are not compatible", + json::invalid_iterator&); } { json const jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}}; json const jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - CHECK_THROWS_WITH_AS(json(jobject.cbegin(), jobject2.cend()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(jobject2.cbegin(), jobject.cend()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(jobject.cbegin(), jobject2.cend()), + "[json.exception.invalid_iterator.201] iterators are not compatible", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(jobject2.cbegin(), jobject.cend()), + "[json.exception.invalid_iterator.201] iterators are not compatible", + json::invalid_iterator&); } } } @@ -1389,14 +1414,22 @@ TEST_CASE("constructors") { json jarray = {1, 2, 3, 4}; json jarray2 = {2, 3, 4, 5}; - CHECK_THROWS_WITH_AS(json(jarray.begin(), jarray2.end()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(jarray2.begin(), jarray.end()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(jarray.begin(), jarray2.end()), + "[json.exception.invalid_iterator.201] iterators are not compatible", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(jarray2.begin(), jarray.end()), + "[json.exception.invalid_iterator.201] iterators are not compatible", + json::invalid_iterator&); } { json const jarray = {1, 2, 3, 4}; json const jarray2 = {2, 3, 4, 5}; - CHECK_THROWS_WITH_AS(json(jarray.cbegin(), jarray2.cend()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(jarray2.cbegin(), jarray.cend()), "[json.exception.invalid_iterator.201] iterators are not compatible", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(jarray.cbegin(), jarray2.cend()), + "[json.exception.invalid_iterator.201] iterators are not compatible", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(jarray2.cbegin(), jarray.cend()), + "[json.exception.invalid_iterator.201] iterators are not compatible", + json::invalid_iterator&); } } } @@ -1409,11 +1442,15 @@ TEST_CASE("constructors") { { json j; - CHECK_THROWS_WITH_AS(json(j.begin(), j.end()), "[json.exception.invalid_iterator.206] cannot construct with iterators from null", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.begin(), j.end()), + "[json.exception.invalid_iterator.206] cannot construct with iterators from null", + json::invalid_iterator&); } { json const j; - CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cend()), "[json.exception.invalid_iterator.206] cannot construct with iterators from null", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cend()), + "[json.exception.invalid_iterator.206] cannot construct with iterators from null", + json::invalid_iterator&); } } @@ -1509,12 +1546,16 @@ TEST_CASE("constructors") { json j = "foo"; CHECK_THROWS_WITH_AS(json(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.begin(), j.begin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } { json const j = "bar"; CHECK_THROWS_WITH_AS(json(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cbegin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } } @@ -1523,12 +1564,16 @@ TEST_CASE("constructors") { json j = false; CHECK_THROWS_WITH_AS(json(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.begin(), j.begin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } { json const j = true; CHECK_THROWS_WITH_AS(json(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cbegin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } } @@ -1537,12 +1582,16 @@ TEST_CASE("constructors") { json j = 17; CHECK_THROWS_WITH_AS(json(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.begin(), j.begin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } { json const j = 17; CHECK_THROWS_WITH_AS(json(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cbegin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } } @@ -1551,12 +1600,16 @@ TEST_CASE("constructors") { json j = 17u; CHECK_THROWS_WITH_AS(json(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.begin(), j.begin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } { json const j = 17u; CHECK_THROWS_WITH_AS(json(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cbegin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } } @@ -1565,12 +1618,16 @@ TEST_CASE("constructors") { json j = 23.42; CHECK_THROWS_WITH_AS(json(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.begin(), j.begin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } { json const j = 23.42; CHECK_THROWS_WITH_AS(json(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(json(j.cbegin(), j.cbegin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } } } diff --git a/tests/src/unit-convenience.cpp b/tests/src/unit-convenience.cpp index f5c372a72d..4621e01113 100644 --- a/tests/src/unit-convenience.cpp +++ b/tests/src/unit-convenience.cpp @@ -14,7 +14,8 @@ using nlohmann::json; #include -namespace { +namespace +{ struct alt_string_iter { alt_string_iter() = default; diff --git a/tests/src/unit-conversions.cpp b/tests/src/unit-conversions.cpp index 6be465bcd7..8c0fd73807 100644 --- a/tests/src/unit-conversions.cpp +++ b/tests/src/unit-conversions.cpp @@ -36,12 +36,8 @@ TEST_CASE("value conversion") { SECTION("get an object (explicit)") { - const json::object_t o_reference = {{"object", json::object()}, - {"array", {1, 2, 3, 4}}, - {"number", 42}, - {"boolean", false}, - {"null", nullptr}, - {"string", "Hello world"}}; + const json::object_t o_reference = + {{"object", json::object()}, {"array", {1, 2, 3, 4}}, {"number", 42}, {"boolean", false}, {"null", nullptr}, {"string", "Hello world"}}; json j(o_reference); SECTION("json::object_t") @@ -52,73 +48,59 @@ TEST_CASE("value conversion") SECTION("std::map") { - const std::map o = - j.get>(); + const std::map o = j.get>(); CHECK(json(o) == j); } SECTION("std::multimap") { - const std::multimap o = - j.get>(); + const std::multimap o = j.get>(); CHECK(json(o) == j); } SECTION("std::unordered_map") { - const std::unordered_map o = - j.get>(); + const std::unordered_map o = j.get>(); CHECK(json(o) == j); } SECTION("std::unordered_multimap") { - const std::unordered_multimap o = - j.get>(); + const std::unordered_multimap o = j.get>(); CHECK(json(o) == j); } SECTION("exception in case of a non-object type") { - CHECK_THROWS_WITH_AS( - json(json::value_t::null).get(), - "[json.exception.type_error.302] type must be object, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::array).get(), - "[json.exception.type_error.302] type must be object, but is array", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::string).get(), - "[json.exception.type_error.302] type must be object, but is string", - json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::null).get(), + "[json.exception.type_error.302] type must be object, but is null", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::array).get(), + "[json.exception.type_error.302] type must be object, but is array", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::string).get(), + "[json.exception.type_error.302] type must be object, but is string", + json::type_error&); CHECK_THROWS_WITH_AS(json(json::value_t::boolean).get(), "[json.exception.type_error.302] type must be object, " "but is boolean", json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_integer).get(), - "[json.exception.type_error.302] type must be object, but is number", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_unsigned).get(), - "[json.exception.type_error.302] type must be object, but is number", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_float).get(), - "[json.exception.type_error.302] type must be object, but is number", - json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_integer).get(), + "[json.exception.type_error.302] type must be object, but is number", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_unsigned).get(), + "[json.exception.type_error.302] type must be object, but is number", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_float).get(), + "[json.exception.type_error.302] type must be object, but is number", + json::type_error&); } } SECTION("get an object (explicit, get_to)") { - const json::object_t o_reference = {{"object", json::object()}, - {"array", {1, 2, 3, 4}}, - {"number", 42}, - {"boolean", false}, - {"null", nullptr}, - {"string", "Hello world"}}; + const json::object_t o_reference = + {{"object", json::object()}, {"array", {1, 2, 3, 4}}, {"number", 42}, {"boolean", false}, {"null", nullptr}, {"string", "Hello world"}}; json j(o_reference); SECTION("json::object_t") @@ -160,12 +142,8 @@ TEST_CASE("value conversion") #if JSON_USE_IMPLICIT_CONVERSIONS SECTION("get an object (implicit)") { - const json::object_t o_reference = {{"object", json::object()}, - {"array", {1, 2, 3, 4}}, - {"number", 42}, - {"boolean", false}, - {"null", nullptr}, - {"string", "Hello world"}}; + const json::object_t o_reference = + {{"object", json::object()}, {"array", {1, 2, 3, 4}}, {"number", 42}, {"boolean", false}, {"null", nullptr}, {"string", "Hello world"}}; json j(o_reference); SECTION("json::object_t") @@ -222,10 +200,9 @@ TEST_CASE("value conversion") const std::forward_list a = j.get>(); CHECK(json(a) == j); - CHECK_THROWS_WITH_AS( - json(json::value_t::null).get>(), - "[json.exception.type_error.302] type must be array, but is null", - json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::null).get>(), + "[json.exception.type_error.302] type must be array, but is null", + json::type_error&); } SECTION("std::vector") @@ -233,10 +210,9 @@ TEST_CASE("value conversion") const std::vector a = j.get>(); CHECK(json(a) == j); - CHECK_THROWS_WITH_AS( - json(json::value_t::null).get>(), - "[json.exception.type_error.302] type must be array, but is null", - json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::null).get>(), + "[json.exception.type_error.302] type must be array, but is null", + json::type_error&); #if !defined(JSON_NOEXCEPTION) SECTION("reserve is called on containers that supports it") @@ -271,38 +247,30 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-array type") { - CHECK_THROWS_WITH_AS( - json(json::value_t::object).get>(), - "[json.exception.type_error.302] type must be array, but is object", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::null).get(), - "[json.exception.type_error.302] type must be array, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::object).get(), - "[json.exception.type_error.302] type must be array, but is object", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::string).get(), - "[json.exception.type_error.302] type must be array, but is string", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::boolean).get(), - "[json.exception.type_error.302] type must be array, but is boolean", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_integer).get(), - "[json.exception.type_error.302] type must be array, but is number", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_unsigned).get(), - "[json.exception.type_error.302] type must be array, but is number", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_float).get(), - "[json.exception.type_error.302] type must be array, but is number", - json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::object).get>(), + "[json.exception.type_error.302] type must be array, but is object", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::null).get(), + "[json.exception.type_error.302] type must be array, but is null", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::object).get(), + "[json.exception.type_error.302] type must be array, but is object", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::string).get(), + "[json.exception.type_error.302] type must be array, but is string", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::boolean).get(), + "[json.exception.type_error.302] type must be array, but is boolean", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_integer).get(), + "[json.exception.type_error.302] type must be array, but is number", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_unsigned).get(), + "[json.exception.type_error.302] type must be array, but is number", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_float).get(), + "[json.exception.type_error.302] type must be array, but is number", + json::type_error&); } } @@ -428,34 +396,28 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-string type") { - CHECK_THROWS_WITH_AS( - json(json::value_t::null).get(), - "[json.exception.type_error.302] type must be string, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::object).get(), - "[json.exception.type_error.302] type must be string, but is object", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::array).get(), - "[json.exception.type_error.302] type must be string, but is array", - json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::null).get(), + "[json.exception.type_error.302] type must be string, but is null", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::object).get(), + "[json.exception.type_error.302] type must be string, but is object", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::array).get(), + "[json.exception.type_error.302] type must be string, but is array", + json::type_error&); CHECK_THROWS_WITH_AS(json(json::value_t::boolean).get(), "[json.exception.type_error.302] type must be string, " "but is boolean", json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_integer).get(), - "[json.exception.type_error.302] type must be string, but is number", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_unsigned).get(), - "[json.exception.type_error.302] type must be string, but is number", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_float).get(), - "[json.exception.type_error.302] type must be string, but is number", - json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_integer).get(), + "[json.exception.type_error.302] type must be string, but is number", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_unsigned).get(), + "[json.exception.type_error.302] type must be string, but is number", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_float).get(), + "[json.exception.type_error.302] type must be string, but is number", + json::type_error&); } #if defined(JSON_HAS_CPP_17) @@ -599,40 +561,34 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-number type") { - CHECK_THROWS_AS(json(json::value_t::string).get(), - json::type_error&); + CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::null).get(), - "[json.exception.type_error.302] type must be boolean, but is null", - json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::null).get(), + "[json.exception.type_error.302] type must be boolean, but is null", + json::type_error&); CHECK_THROWS_WITH_AS(json(json::value_t::object).get(), "[json.exception.type_error.302] type must be boolean, " "but is object", json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::array).get(), - "[json.exception.type_error.302] type must be boolean, but is array", - json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::array).get(), + "[json.exception.type_error.302] type must be boolean, but is array", + json::type_error&); CHECK_THROWS_WITH_AS(json(json::value_t::string).get(), "[json.exception.type_error.302] type must be boolean, " "but is string", json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_integer).get(), - "[json.exception.type_error.302] type must be boolean, but is " - "number", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_unsigned).get(), - "[json.exception.type_error.302] type must be boolean, but is " - "number", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::number_float).get(), - "[json.exception.type_error.302] type must be boolean, but is " - "number", - json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_integer).get(), + "[json.exception.type_error.302] type must be boolean, but is " + "number", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_unsigned).get(), + "[json.exception.type_error.302] type must be boolean, but is " + "number", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::number_float).get(), + "[json.exception.type_error.302] type must be boolean, but is " + "number", + json::type_error&); } } @@ -869,32 +825,25 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-number type") { - CHECK_THROWS_WITH_AS( - json(json::value_t::null).get(), - "[json.exception.type_error.302] type must be number, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::object).get(), - "[json.exception.type_error.302] type must be number, but is object", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::array).get(), - "[json.exception.type_error.302] type must be number, but is array", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::string).get(), - "[json.exception.type_error.302] type must be number, but is string", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::boolean).get(), - "[json.exception.type_error.302] type must be number, but is " - "boolean", - json::type_error&); - - CHECK_NOTHROW( - json(json::value_t::number_float).get()); - CHECK_NOTHROW( - json(json::value_t::number_float).get()); + CHECK_THROWS_WITH_AS(json(json::value_t::null).get(), + "[json.exception.type_error.302] type must be number, but is null", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::object).get(), + "[json.exception.type_error.302] type must be number, but is object", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::array).get(), + "[json.exception.type_error.302] type must be number, but is array", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::string).get(), + "[json.exception.type_error.302] type must be number, but is string", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::boolean).get(), + "[json.exception.type_error.302] type must be number, but is " + "boolean", + json::type_error&); + + CHECK_NOTHROW(json(json::value_t::number_float).get()); + CHECK_NOTHROW(json(json::value_t::number_float).get()); } } @@ -1137,32 +1086,25 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-string type") { - CHECK_THROWS_WITH_AS( - json(json::value_t::null).get(), - "[json.exception.type_error.302] type must be number, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::object).get(), - "[json.exception.type_error.302] type must be number, but is object", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::array).get(), - "[json.exception.type_error.302] type must be number, but is array", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::string).get(), - "[json.exception.type_error.302] type must be number, but is string", - json::type_error&); - CHECK_THROWS_WITH_AS( - json(json::value_t::boolean).get(), - "[json.exception.type_error.302] type must be number, but is " - "boolean", - json::type_error&); - - CHECK_NOTHROW( - json(json::value_t::number_integer).get()); - CHECK_NOTHROW( - json(json::value_t::number_unsigned).get()); + CHECK_THROWS_WITH_AS(json(json::value_t::null).get(), + "[json.exception.type_error.302] type must be number, but is null", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::object).get(), + "[json.exception.type_error.302] type must be number, but is object", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::array).get(), + "[json.exception.type_error.302] type must be number, but is array", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::string).get(), + "[json.exception.type_error.302] type must be number, but is string", + json::type_error&); + CHECK_THROWS_WITH_AS(json(json::value_t::boolean).get(), + "[json.exception.type_error.302] type must be number, but is " + "boolean", + json::type_error&); + + CHECK_NOTHROW(json(json::value_t::number_integer).get()); + CHECK_NOTHROW(json(json::value_t::number_unsigned).get()); } } @@ -1232,69 +1174,31 @@ TEST_CASE("value conversion") const json j_string_const(json::value_t::string); const json j_boolean_const(json::value_t::boolean); - CHECK_THROWS_WITH_AS(j_null.get(), - "[json.exception.type_error.302] type must be binary, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS(j_object.get(), - "[json.exception.type_error.302] type must be binary, but is object", - json::type_error&); - CHECK_THROWS_WITH_AS(j_array.get(), - "[json.exception.type_error.302] type must be binary, but is array", - json::type_error&); - CHECK_THROWS_WITH_AS(j_string.get(), - "[json.exception.type_error.302] type must be binary, but is string", - json::type_error&); - CHECK_THROWS_WITH_AS(j_boolean.get(), - "[json.exception.type_error.302] type must be binary, but is boolean", - json::type_error&); + CHECK_THROWS_WITH_AS(j_null.get(), "[json.exception.type_error.302] type must be binary, but is null", json::type_error&); + CHECK_THROWS_WITH_AS(j_object.get(), "[json.exception.type_error.302] type must be binary, but is object", json::type_error&); + CHECK_THROWS_WITH_AS(j_array.get(), "[json.exception.type_error.302] type must be binary, but is array", json::type_error&); + CHECK_THROWS_WITH_AS(j_string.get(), "[json.exception.type_error.302] type must be binary, but is string", json::type_error&); + CHECK_THROWS_WITH_AS(j_boolean.get(), "[json.exception.type_error.302] type must be binary, but is boolean", json::type_error&); - CHECK_THROWS_WITH_AS(j_null_const.get(), - "[json.exception.type_error.302] type must be binary, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS(j_object_const.get(), - "[json.exception.type_error.302] type must be binary, but is object", - json::type_error&); - CHECK_THROWS_WITH_AS(j_array_const.get(), - "[json.exception.type_error.302] type must be binary, but is array", - json::type_error&); - CHECK_THROWS_WITH_AS(j_string_const.get(), - "[json.exception.type_error.302] type must be binary, but is string", - json::type_error&); + CHECK_THROWS_WITH_AS(j_null_const.get(), "[json.exception.type_error.302] type must be binary, but is null", json::type_error&); + CHECK_THROWS_WITH_AS(j_object_const.get(), "[json.exception.type_error.302] type must be binary, but is object", json::type_error&); + CHECK_THROWS_WITH_AS(j_array_const.get(), "[json.exception.type_error.302] type must be binary, but is array", json::type_error&); + CHECK_THROWS_WITH_AS(j_string_const.get(), "[json.exception.type_error.302] type must be binary, but is string", json::type_error&); CHECK_THROWS_WITH_AS(j_boolean_const.get(), "[json.exception.type_error.302] type must be binary, but is boolean", json::type_error&); - CHECK_THROWS_WITH_AS(j_null.get_binary(), - "[json.exception.type_error.302] type must be binary, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS(j_object.get_binary(), - "[json.exception.type_error.302] type must be binary, but is object", - json::type_error&); - CHECK_THROWS_WITH_AS(j_array.get_binary(), - "[json.exception.type_error.302] type must be binary, but is array", - json::type_error&); - CHECK_THROWS_WITH_AS(j_string.get_binary(), - "[json.exception.type_error.302] type must be binary, but is string", - json::type_error&); - CHECK_THROWS_WITH_AS(j_boolean.get_binary(), - "[json.exception.type_error.302] type must be binary, but is boolean", - json::type_error&); + CHECK_THROWS_WITH_AS(j_null.get_binary(), "[json.exception.type_error.302] type must be binary, but is null", json::type_error&); + CHECK_THROWS_WITH_AS(j_object.get_binary(), "[json.exception.type_error.302] type must be binary, but is object", json::type_error&); + CHECK_THROWS_WITH_AS(j_array.get_binary(), "[json.exception.type_error.302] type must be binary, but is array", json::type_error&); + CHECK_THROWS_WITH_AS(j_string.get_binary(), "[json.exception.type_error.302] type must be binary, but is string", json::type_error&); + CHECK_THROWS_WITH_AS(j_boolean.get_binary(), "[json.exception.type_error.302] type must be binary, but is boolean", json::type_error&); - CHECK_THROWS_WITH_AS(j_null_const.get_binary(), - "[json.exception.type_error.302] type must be binary, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS(j_object_const.get_binary(), - "[json.exception.type_error.302] type must be binary, but is object", - json::type_error&); - CHECK_THROWS_WITH_AS(j_array_const.get_binary(), - "[json.exception.type_error.302] type must be binary, but is array", - json::type_error&); - CHECK_THROWS_WITH_AS(j_string_const.get_binary(), - "[json.exception.type_error.302] type must be binary, but is string", - json::type_error&); - CHECK_THROWS_WITH_AS(j_boolean_const.get_binary(), - "[json.exception.type_error.302] type must be binary, but is boolean", - json::type_error&); + CHECK_THROWS_WITH_AS(j_null_const.get_binary(), "[json.exception.type_error.302] type must be binary, but is null", json::type_error&); + CHECK_THROWS_WITH_AS(j_object_const.get_binary(), "[json.exception.type_error.302] type must be binary, but is object", json::type_error&); + CHECK_THROWS_WITH_AS(j_array_const.get_binary(), "[json.exception.type_error.302] type must be binary, but is array", json::type_error&); + CHECK_THROWS_WITH_AS(j_string_const.get_binary(), "[json.exception.type_error.302] type must be binary, but is string", json::type_error&); + CHECK_THROWS_WITH_AS(j_boolean_const.get_binary(), "[json.exception.type_error.302] type must be binary, but is boolean", json::type_error&); } } @@ -1380,10 +1284,9 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-object type") { - CHECK_THROWS_WITH_AS( - (json().get>()), - "[json.exception.type_error.302] type must be object, but is null", - json::type_error&); + CHECK_THROWS_WITH_AS((json().get>()), + "[json.exception.type_error.302] type must be object, but is null", + json::type_error&); } } @@ -1424,8 +1327,9 @@ TEST_CASE("value conversion") SECTION("std::array is larger than JSON") { std::array arr6 = {{1, 2, 3, 4, 5, 6}}; - CHECK_THROWS_WITH_AS(j1.get_to(arr6), "[json.exception.out_of_range.401] " - "array index 4 is out of range", + CHECK_THROWS_WITH_AS(j1.get_to(arr6), + "[json.exception.out_of_range.401] " + "array index 4 is out of range", json::out_of_range&); } @@ -1541,30 +1445,12 @@ TEST_CASE("value conversion") { // does type really must be an array? or it rather must not be null? // that's what I thought when other test like this one broke - CHECK_THROWS_WITH_AS( - (json().get>()), - "[json.exception.type_error.302] type must be array, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS( - (json().get>()), - "[json.exception.type_error.302] type must be array, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS( - (json().get>()), - "[json.exception.type_error.302] type must be array, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS( - (json().get>()), - "[json.exception.type_error.302] type must be array, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS( - (json().get>()), - "[json.exception.type_error.302] type must be array, but is null", - json::type_error&); - CHECK_THROWS_WITH_AS( - (json().get>()), - "[json.exception.type_error.302] type must be array, but is null", - json::type_error&); + CHECK_THROWS_WITH_AS((json().get>()), "[json.exception.type_error.302] type must be array, but is null", json::type_error&); + CHECK_THROWS_WITH_AS((json().get>()), "[json.exception.type_error.302] type must be array, but is null", json::type_error&); + CHECK_THROWS_WITH_AS((json().get>()), "[json.exception.type_error.302] type must be array, but is null", json::type_error&); + CHECK_THROWS_WITH_AS((json().get>()), "[json.exception.type_error.302] type must be array, but is null", json::type_error&); + CHECK_THROWS_WITH_AS((json().get>()), "[json.exception.type_error.302] type must be array, but is null", json::type_error&); + CHECK_THROWS_WITH_AS((json().get>()), "[json.exception.type_error.302] type must be array, but is null", json::type_error&); } } } diff --git a/tests/src/unit-custom-base-class.cpp b/tests/src/unit-custom-base-class.cpp index 03bb4b2455..f9a4f7af8c 100644 --- a/tests/src/unit-custom-base-class.cpp +++ b/tests/src/unit-custom-base-class.cpp @@ -36,19 +36,17 @@ class json_metadata }; template -using json_with_metadata = - nlohmann::basic_json< - std::map, - std::vector, - std::string, - bool, - std::int64_t, - std::uint64_t, - double, - std::allocator, - nlohmann::adl_serializer, - std::vector, - json_metadata>; +using json_with_metadata = nlohmann::basic_json, + json_metadata>; TEST_CASE("JSON Node Metadata") { @@ -196,18 +194,17 @@ class visitor_adaptor void do_visit(const Ptr& ptr, const Fnc& fnc) const; }; -using json_with_visitor_t = nlohmann::basic_json< - std::map, - std::vector, - std::string, - bool, - std::int64_t, - std::uint64_t, - double, - std::allocator, - nlohmann::adl_serializer, - std::vector, - visitor_adaptor>; +using json_with_visitor_t = nlohmann::basic_json, + visitor_adaptor>; template void visitor_adaptor::visit(const Fnc& fnc) const @@ -261,72 +258,69 @@ TEST_CASE("JSON Visit Node") json["array"].push_back(1); json["array"].push_back(json); - std::set expected{ - "/null - null - null", - "/int - number_integer - -1", - "/uint - number_unsigned - 1", - "/float - number_float - 1.0", - "/boolean - boolean - true", - "/string - string - \"string\"", - "/array/0 - number_integer - 0", - "/array/1 - number_integer - 1", - - "/array/2/null - null - null", - "/array/2/int - number_integer - -1", - "/array/2/uint - number_unsigned - 1", - "/array/2/float - number_float - 1.0", - "/array/2/boolean - boolean - true", - "/array/2/string - string - \"string\"", - "/array/2/array/0 - number_integer - 0", - "/array/2/array/1 - number_integer - 1"}; - - json.visit( - [&](const json_with_visitor_t::json_pointer& p, - const json_with_visitor_t& j) { - std::stringstream str; - str << p.to_string() << " - "; - using value_t = nlohmann::detail::value_t; - switch (j.type()) - { - case value_t::object: - str << "object"; - break; - case value_t::array: - str << "array"; - break; - case value_t::discarded: - str << "discarded"; - break; - case value_t::null: - str << "null"; - break; - case value_t::string: - str << "string"; - break; - case value_t::boolean: - str << "boolean"; - break; - case value_t::number_integer: - str << "number_integer"; - break; - case value_t::number_unsigned: - str << "number_unsigned"; - break; - case value_t::number_float: - str << "number_float"; - break; - case value_t::binary: - str << "binary"; - break; - default: - str << "error"; - break; - } - str << " - " << j.dump(); - CHECK(json.at(p) == j); - INFO(str.str()); - CHECK(expected.count(str.str()) == 1); - expected.erase(str.str()); - }); + std::set expected{"/null - null - null", + "/int - number_integer - -1", + "/uint - number_unsigned - 1", + "/float - number_float - 1.0", + "/boolean - boolean - true", + "/string - string - \"string\"", + "/array/0 - number_integer - 0", + "/array/1 - number_integer - 1", + + "/array/2/null - null - null", + "/array/2/int - number_integer - -1", + "/array/2/uint - number_unsigned - 1", + "/array/2/float - number_float - 1.0", + "/array/2/boolean - boolean - true", + "/array/2/string - string - \"string\"", + "/array/2/array/0 - number_integer - 0", + "/array/2/array/1 - number_integer - 1"}; + + json.visit([&](const json_with_visitor_t::json_pointer& p, const json_with_visitor_t& j) { + std::stringstream str; + str << p.to_string() << " - "; + using value_t = nlohmann::detail::value_t; + switch (j.type()) + { + case value_t::object: + str << "object"; + break; + case value_t::array: + str << "array"; + break; + case value_t::discarded: + str << "discarded"; + break; + case value_t::null: + str << "null"; + break; + case value_t::string: + str << "string"; + break; + case value_t::boolean: + str << "boolean"; + break; + case value_t::number_integer: + str << "number_integer"; + break; + case value_t::number_unsigned: + str << "number_unsigned"; + break; + case value_t::number_float: + str << "number_float"; + break; + case value_t::binary: + str << "binary"; + break; + default: + str << "error"; + break; + } + str << " - " << j.dump(); + CHECK(json.at(p) == j); + INFO(str.str()); + CHECK(expected.count(str.str()) == 1); + expected.erase(str.str()); + }); CHECK(expected.empty()); } diff --git a/tests/src/unit-deserialization.cpp b/tests/src/unit-deserialization.cpp index 5b82ebf294..46280f597d 100644 --- a/tests/src/unit-deserialization.cpp +++ b/tests/src/unit-deserialization.cpp @@ -20,7 +20,8 @@ using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) #include #include -namespace { +namespace +{ struct SaxEventLogger : public nlohmann::json_sax { bool null() override @@ -176,8 +177,7 @@ class proxy_iterator using value_type = typename std::iterator_traits::value_type; using reference = typename std::iterator_traits::reference; using pointer = typename std::iterator_traits::pointer; - using difference_type = - typename std::iterator_traits::difference_type; + using difference_type = typename std::iterator_traits::difference_type; using iterator_category = std::input_iterator_tag; proxy_iterator() = default; @@ -236,8 +236,17 @@ TEST_CASE("deserialization") SaxEventLogger l; CHECK(json::sax_parse(ss3, &l)); CHECK(l.events.size() == 11); - CHECK(l.events == std::vector( - {"start_array()", "string(foo)", "number_unsigned(1)", "number_unsigned(2)", "number_unsigned(3)", "boolean(false)", "start_object()", "key(one)", "number_unsigned(1)", "end_object()", "end_array()"})); + CHECK(l.events == std::vector({"start_array()", + "string(foo)", + "number_unsigned(1)", + "number_unsigned(2)", + "number_unsigned(3)", + "boolean(false)", + "start_object()", + "key(one)", + "number_unsigned(1)", + "end_object()", + "end_array()"})); } SECTION("string literal") @@ -250,8 +259,17 @@ TEST_CASE("deserialization") SaxEventLogger l; CHECK(json::sax_parse(s, &l)); CHECK(l.events.size() == 11); - CHECK(l.events == std::vector( - {"start_array()", "string(foo)", "number_unsigned(1)", "number_unsigned(2)", "number_unsigned(3)", "boolean(false)", "start_object()", "key(one)", "number_unsigned(1)", "end_object()", "end_array()"})); + CHECK(l.events == std::vector({"start_array()", + "string(foo)", + "number_unsigned(1)", + "number_unsigned(2)", + "number_unsigned(3)", + "boolean(false)", + "start_object()", + "key(one)", + "number_unsigned(1)", + "end_object()", + "end_array()"})); } SECTION("string_t") @@ -264,8 +282,17 @@ TEST_CASE("deserialization") SaxEventLogger l; CHECK(json::sax_parse(s, &l)); CHECK(l.events.size() == 11); - CHECK(l.events == std::vector( - {"start_array()", "string(foo)", "number_unsigned(1)", "number_unsigned(2)", "number_unsigned(3)", "boolean(false)", "start_object()", "key(one)", "number_unsigned(1)", "end_object()", "end_array()"})); + CHECK(l.events == std::vector({"start_array()", + "string(foo)", + "number_unsigned(1)", + "number_unsigned(2)", + "number_unsigned(3)", + "boolean(false)", + "start_object()", + "key(one)", + "number_unsigned(1)", + "end_object()", + "end_array()"})); } SECTION("operator<<") @@ -306,7 +333,10 @@ TEST_CASE("deserialization") ss5 << R"(["foo",1,2,3,false,{"one":1})"; json _; - CHECK_THROWS_WITH_AS(_ = json::parse(ss1), "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse(ss1), + "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'", + json::parse_error&); CHECK(!json::accept(ss3)); json j_error; @@ -316,15 +346,27 @@ TEST_CASE("deserialization") SaxEventLogger l; CHECK(!json::sax_parse(ss5, &l)); CHECK(l.events.size() == 11); - CHECK(l.events == std::vector( - {"start_array()", "string(foo)", "number_unsigned(1)", "number_unsigned(2)", "number_unsigned(3)", "boolean(false)", "start_object()", "key(one)", "number_unsigned(1)", "end_object()", "parse_error(29)"})); + CHECK(l.events == std::vector({"start_array()", + "string(foo)", + "number_unsigned(1)", + "number_unsigned(2)", + "number_unsigned(3)", + "boolean(false)", + "start_object()", + "key(one)", + "number_unsigned(1)", + "end_object()", + "parse_error(29)"})); } SECTION("string") { json::string_t const s = R"(["foo",1,2,3,false,{"one":1})"; json _; - CHECK_THROWS_WITH_AS(_ = json::parse(s), "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse(s), + "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'", + json::parse_error&); CHECK(!json::accept(s)); json j_error; @@ -334,8 +376,17 @@ TEST_CASE("deserialization") SaxEventLogger l; CHECK(!json::sax_parse(s, &l)); CHECK(l.events.size() == 11); - CHECK(l.events == std::vector( - {"start_array()", "string(foo)", "number_unsigned(1)", "number_unsigned(2)", "number_unsigned(3)", "boolean(false)", "start_object()", "key(one)", "number_unsigned(1)", "end_object()", "parse_error(29)"})); + CHECK(l.events == std::vector({"start_array()", + "string(foo)", + "number_unsigned(1)", + "number_unsigned(2)", + "number_unsigned(3)", + "boolean(false)", + "start_object()", + "key(one)", + "number_unsigned(1)", + "end_object()", + "parse_error(29)"})); } SECTION("operator<<") @@ -343,7 +394,10 @@ TEST_CASE("deserialization") std::stringstream ss; ss << R"(["foo",1,2,3,false,{"one":1})"; json j; - CHECK_THROWS_WITH_AS(j << ss, "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'", json::parse_error&); + CHECK_THROWS_WITH_AS( + j << ss, + "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'", + json::parse_error&); } SECTION("operator>>") @@ -351,12 +405,18 @@ TEST_CASE("deserialization") std::stringstream ss; ss << R"(["foo",1,2,3,false,{"one":1})"; json j; - CHECK_THROWS_WITH_AS(ss >> j, "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'", json::parse_error&); + CHECK_THROWS_WITH_AS( + ss >> j, + "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'", + json::parse_error&); } SECTION("user-defined string literal") { - CHECK_THROWS_WITH_AS("[\"foo\",1,2,3,false,{\"one\":1}"_json, "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'", json::parse_error&); + CHECK_THROWS_WITH_AS( + "[\"foo\",1,2,3,false,{\"one\":1}"_json, + "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'", + json::parse_error&); } } @@ -658,7 +718,10 @@ TEST_CASE("deserialization") { std::array v = {{'\"', 0x7F, 0xDF, 0x7F}}; json _; - CHECK_THROWS_WITH_AS(_ = json::parse(std::begin(v), std::end(v)), "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '\"\x7f\xdf\x7f'", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse(std::begin(v), std::end(v)), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '\"\x7f\xdf\x7f'", + json::parse_error&); CHECK(!json::accept(std::begin(v), std::end(v))); json j_error; @@ -838,8 +901,7 @@ TEST_CASE("deserialization") SaxEventLogger l; CHECK(!json::sax_parse(std::begin(v), std::end(v), &l)); CHECK(l.events.size() == 4); - CHECK(l.events == std::vector( - {"start_object()", "key()", "number_unsigned(11)", "parse_error(7)"})); + CHECK(l.events == std::vector({"start_object()", "key()", "number_unsigned(11)", "parse_error(7)"})); } } } @@ -851,15 +913,20 @@ TEST_CASE("deserialization") SECTION("BOM only") { json _; - CHECK_THROWS_WITH_AS(_ = json::parse(bom), "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse(bom), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", + json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::parse(std::istringstream(bom)), "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse(std::istringstream(bom)), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", + json::parse_error&); SaxEventLogger l; CHECK(!json::sax_parse(bom, &l)); CHECK(l.events.size() == 1); - CHECK(l.events == std::vector( - {"parse_error(4)"})); + CHECK(l.events == std::vector({"parse_error(4)"})); } SECTION("BOM and content") @@ -872,49 +939,55 @@ TEST_CASE("deserialization") CHECK(json::sax_parse(std::istringstream(bom + "1"), &l1)); CHECK(json::sax_parse(bom + "1", &l2)); CHECK(l1.events.size() == 1); - CHECK(l1.events == std::vector( - {"number_unsigned(1)"})); + CHECK(l1.events == std::vector({"number_unsigned(1)"})); CHECK(l2.events.size() == 1); - CHECK(l2.events == std::vector( - {"number_unsigned(1)"})); + CHECK(l2.events == std::vector({"number_unsigned(1)"})); } SECTION("2 byte of BOM") { json _; - CHECK_THROWS_WITH_AS(_ = json::parse(bom.substr(0, 2)), "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF\xBB'", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse(bom.substr(0, 2)), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF\xBB'", + json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::parse(std::istringstream(bom.substr(0, 2))), "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF\xBB'", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse(std::istringstream(bom.substr(0, 2))), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF\xBB'", + json::parse_error&); SaxEventLogger l1; SaxEventLogger l2; CHECK(!json::sax_parse(std::istringstream(bom.substr(0, 2)), &l1)); CHECK(!json::sax_parse(bom.substr(0, 2), &l2)); CHECK(l1.events.size() == 1); - CHECK(l1.events == std::vector( - {"parse_error(3)"})); + CHECK(l1.events == std::vector({"parse_error(3)"})); CHECK(l2.events.size() == 1); - CHECK(l2.events == std::vector( - {"parse_error(3)"})); + CHECK(l2.events == std::vector({"parse_error(3)"})); } SECTION("1 byte of BOM") { json _; - CHECK_THROWS_WITH_AS(_ = json::parse(bom.substr(0, 1)), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF'", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse(bom.substr(0, 1)), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF'", + json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::parse(std::istringstream(bom.substr(0, 1))), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF'", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse(std::istringstream(bom.substr(0, 1))), + "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF'", + json::parse_error&); SaxEventLogger l1; SaxEventLogger l2; CHECK(!json::sax_parse(std::istringstream(bom.substr(0, 1)), &l1)); CHECK(!json::sax_parse(bom.substr(0, 1), &l2)); CHECK(l1.events.size() == 1); - CHECK(l1.events == std::vector( - {"parse_error(2)"})); + CHECK(l1.events == std::vector({"parse_error(2)"})); CHECK(l2.events.size() == 1); - CHECK(l2.events == std::vector( - {"parse_error(2)"})); + CHECK(l2.events == std::vector({"parse_error(2)"})); } SECTION("variations") @@ -946,8 +1019,7 @@ TEST_CASE("deserialization") SaxEventLogger l; CHECK(json::sax_parse(s + "null", &l)); CHECK(l.events.size() == 1); - CHECK(l.events == std::vector( - {"null()"})); + CHECK(l.events == std::vector({"null()"})); } else { @@ -962,18 +1034,15 @@ TEST_CASE("deserialization") if (i0 != 0) { - CHECK(l.events == std::vector( - {"parse_error(1)"})); + CHECK(l.events == std::vector({"parse_error(1)"})); } else if (i1 != 0) { - CHECK(l.events == std::vector( - {"parse_error(2)"})); + CHECK(l.events == std::vector({"parse_error(2)"})); } else { - CHECK(l.events == std::vector( - {"parse_error(3)"})); + CHECK(l.events == std::vector({"parse_error(3)"})); } } } @@ -1003,23 +1072,43 @@ TEST_CASE("deserialization") json::sax_parse(s, &default_logger); CHECK(default_logger.events.size() == 14); - CHECK(default_logger.events == std::vector( - {"start_array()", "number_unsigned(1)", "start_array()", "string(string)", "number_float(43.12)", "end_array()", "null()", "start_object()", "key(key1)", "boolean(true)", "key(key2)", "boolean(false)", "end_object()", "end_array()"})); + CHECK(default_logger.events == std::vector({"start_array()", + "number_unsigned(1)", + "start_array()", + "string(string)", + "number_float(43.12)", + "end_array()", + "null()", + "start_object()", + "key(key1)", + "boolean(true)", + "key(key2)", + "boolean(false)", + "end_object()", + "end_array()"})); json::sax_parse(s, &exit_after_start_object); CHECK(exit_after_start_object.events.size() == 8); - CHECK(exit_after_start_object.events == std::vector( - {"start_array()", "number_unsigned(1)", "start_array()", "string(string)", "number_float(43.12)", "end_array()", "null()", "start_object()"})); + CHECK( + exit_after_start_object.events == + std::vector( + {"start_array()", "number_unsigned(1)", "start_array()", "string(string)", "number_float(43.12)", "end_array()", "null()", "start_object()"})); json::sax_parse(s, &exit_after_key); CHECK(exit_after_key.events.size() == 9); - CHECK(exit_after_key.events == std::vector( - {"start_array()", "number_unsigned(1)", "start_array()", "string(string)", "number_float(43.12)", "end_array()", "null()", "start_object()", "key(key1)"})); + CHECK(exit_after_key.events == std::vector({"start_array()", + "number_unsigned(1)", + "start_array()", + "string(string)", + "number_float(43.12)", + "end_array()", + "null()", + "start_object()", + "key(key1)"})); json::sax_parse(s, &exit_after_start_array); CHECK(exit_after_start_array.events.size() == 1); - CHECK(exit_after_start_array.events == std::vector( - {"start_array()"})); + CHECK(exit_after_start_array.events == std::vector({"start_array()"})); } SECTION("JSON Lines") @@ -1065,7 +1154,20 @@ TEST_CASE("deserialization") } } -TEST_CASE_TEMPLATE("deserialization of different character types (ASCII)", T, char, unsigned char, signed char, wchar_t, char16_t, char32_t, std::uint8_t, std::int8_t, std::int16_t, std::uint16_t, std::int32_t, std::uint32_t) +TEST_CASE_TEMPLATE("deserialization of different character types (ASCII)", + T, + char, + unsigned char, + signed char, + wchar_t, + char16_t, + char32_t, + std::uint8_t, + std::int8_t, + std::int16_t, + std::uint16_t, + std::int32_t, + std::uint32_t) { std::vector const v = {'t', 'r', 'u', 'e'}; CHECK(json::parse(v) == json(true)); @@ -1080,7 +1182,8 @@ TEST_CASE_TEMPLATE("deserialization of different character types (ASCII)", T, ch TEST_CASE_TEMPLATE("deserialization of different character types (UTF-8)", T, char, unsigned char, std::uint8_t) { // a star emoji - std::vector const v = {'"', static_cast(0xe2u), static_cast(0xadu), static_cast(0x90u), static_cast(0xefu), static_cast(0xb8u), static_cast(0x8fu), '"'}; + std::vector const v = + {'"', static_cast(0xe2u), static_cast(0xadu), static_cast(0x90u), static_cast(0xefu), static_cast(0xb8u), static_cast(0x8fu), '"'}; CHECK(json::parse(v).dump(-1, ' ', true) == "\"\\u2b50\\ufe0f\""); CHECK(json::accept(v)); diff --git a/tests/src/unit-diagnostics.cpp b/tests/src/unit-diagnostics.cpp index 0e172b915e..8c79a54b4d 100644 --- a/tests/src/unit-diagnostics.cpp +++ b/tests/src/unit-diagnostics.cpp @@ -32,7 +32,9 @@ TEST_CASE("Better diagnostics") json j; j["a"]["b"]["c"] = 1; std::string s; - CHECK_THROWS_WITH_AS(s = j["a"]["b"]["c"].get(), "[json.exception.type_error.302] (/a/b/c) type must be string, but is number", json::type_error); + CHECK_THROWS_WITH_AS(s = j["a"]["b"]["c"].get(), + "[json.exception.type_error.302] (/a/b/c) type must be string, but is number", + json::type_error); } SECTION("missing key") @@ -53,14 +55,18 @@ TEST_CASE("Better diagnostics") { json j; j["array"][4] = true; - CHECK_THROWS_WITH_AS(j["array"][4][5], "[json.exception.type_error.305] (/array/4) cannot use operator[] with a numeric argument with boolean", json::type_error); + CHECK_THROWS_WITH_AS(j["array"][4][5], + "[json.exception.type_error.305] (/array/4) cannot use operator[] with a numeric argument with boolean", + json::type_error); } SECTION("wrong iterator") { json j; j["array"] = json::array(); - CHECK_THROWS_WITH_AS(j["array"].erase(j.begin()), "[json.exception.invalid_iterator.202] (/array) iterator does not fit current value", json::invalid_iterator); + CHECK_THROWS_WITH_AS(j["array"].erase(j.begin()), + "[json.exception.invalid_iterator.202] (/array) iterator does not fit current value", + json::invalid_iterator); } SECTION("JSON Pointer escaping") @@ -68,13 +74,18 @@ TEST_CASE("Better diagnostics") json j; j["a/b"]["m~n"] = 1; std::string s; - CHECK_THROWS_WITH_AS(s = j["a/b"]["m~n"].get(), "[json.exception.type_error.302] (/a~1b/m~0n) type must be string, but is number", json::type_error); + CHECK_THROWS_WITH_AS(s = j["a/b"]["m~n"].get(), + "[json.exception.type_error.302] (/a~1b/m~0n) type must be string, but is number", + json::type_error); } SECTION("Parse error") { json _; - CHECK_THROWS_WITH_AS(_ = json::parse(""), "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", json::parse_error); + CHECK_THROWS_WITH_AS( + _ = json::parse(""), + "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", + json::parse_error); } SECTION("Wrong type in update()") @@ -82,7 +93,9 @@ TEST_CASE("Better diagnostics") json j = {{"foo", "bar"}}; json k = {{"bla", 1}}; - CHECK_THROWS_WITH_AS(j.update(k["bla"].begin(), k["bla"].end()), "[json.exception.type_error.312] (/bla) cannot use update() with number", json::type_error); + CHECK_THROWS_WITH_AS(j.update(k["bla"].begin(), k["bla"].end()), + "[json.exception.type_error.312] (/bla) cannot use update() with number", + json::type_error); CHECK_THROWS_WITH_AS(j.update(k["bla"]), "[json.exception.type_error.312] (/bla) cannot use update() with number", json::type_error); } } diff --git a/tests/src/unit-disabled_exceptions.cpp b/tests/src/unit-disabled_exceptions.cpp index 032b0c6ed9..917d73f444 100644 --- a/tests/src/unit-disabled_exceptions.cpp +++ b/tests/src/unit-disabled_exceptions.cpp @@ -46,7 +46,8 @@ TEST_CASE("Tests with disabled exceptions") sax_no_exception sax(j); CHECK(!json::sax_parse("xyz", &sax)); - CHECK(*sax_no_exception::error_string == "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: 'x'"); + CHECK(*sax_no_exception::error_string == + "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: 'x'"); delete sax_no_exception::error_string; // NOLINT(cppcoreguidelines-owning-memory) } } diff --git a/tests/src/unit-element_access1.cpp b/tests/src/unit-element_access1.cpp index 95d05d2a8f..0534c2fc4d 100644 --- a/tests/src/unit-element_access1.cpp +++ b/tests/src/unit-element_access1.cpp @@ -44,12 +44,8 @@ TEST_CASE("element access 1") SECTION("access outside bounds") { - CHECK_THROWS_WITH_AS(j.at(8), - "[json.exception.out_of_range.401] array index 8 is out of range", - json::out_of_range&); - CHECK_THROWS_WITH_AS(j_const.at(8), - "[json.exception.out_of_range.401] array index 8 is out of range", - json::out_of_range&); + CHECK_THROWS_WITH_AS(j.at(8), "[json.exception.out_of_range.401] array index 8 is out of range", json::out_of_range&); + CHECK_THROWS_WITH_AS(j_const.at(8), "[json.exception.out_of_range.401] array index 8 is out of range", json::out_of_range&); } SECTION("access on non-array type") @@ -159,7 +155,9 @@ TEST_CASE("element access 1") json j_nonarray(json::value_t::null); const json j_nonarray_const(j_nonarray); CHECK_NOTHROW(j_nonarray[0]); - CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with null", json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray_const[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with null", + json::type_error&); } SECTION("implicit transformation to properly filled array") @@ -174,48 +172,72 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::boolean); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with boolean", json::type_error&); - CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with boolean", json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with boolean", + json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray_const[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with boolean", + json::type_error&); } SECTION("string") { json j_nonarray(json::value_t::string); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with string", json::type_error&); - CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with string", json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with string", + json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray_const[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with string", + json::type_error&); } SECTION("object") { json j_nonarray(json::value_t::object); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with object", json::type_error&); - CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with object", json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with object", + json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray_const[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with object", + json::type_error&); } SECTION("number (integer)") { json j_nonarray(json::value_t::number_integer); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&); - CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", + json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray_const[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", + json::type_error&); } SECTION("number (unsigned)") { json j_nonarray(json::value_t::number_unsigned); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&); - CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", + json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray_const[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", + json::type_error&); } SECTION("number (floating-point)") { json j_nonarray(json::value_t::number_float); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&); - CHECK_THROWS_WITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", + json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray_const[0], + "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number", + json::type_error&); } } } @@ -539,9 +561,7 @@ TEST_CASE("element access 1") } { json j; - CHECK_THROWS_WITH_AS(j.erase(j.begin()), - "[json.exception.type_error.307] cannot use erase() with null", - json::type_error&); + CHECK_THROWS_WITH_AS(j.erase(j.begin()), "[json.exception.type_error.307] cannot use erase() with null", json::type_error&); } } @@ -823,12 +843,16 @@ TEST_CASE("element access 1") { json j = "foo"; CHECK_THROWS_WITH_AS(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.erase(j.begin(), j.begin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } { json j = "bar"; CHECK_THROWS_WITH_AS(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.erase(j.cbegin(), j.cbegin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } } @@ -837,12 +861,16 @@ TEST_CASE("element access 1") { json j = false; CHECK_THROWS_WITH_AS(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.erase(j.begin(), j.begin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } { json j = true; CHECK_THROWS_WITH_AS(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.erase(j.cbegin(), j.cbegin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } } @@ -851,12 +879,16 @@ TEST_CASE("element access 1") { json j = 17; CHECK_THROWS_WITH_AS(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.erase(j.begin(), j.begin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } { json j = 17; CHECK_THROWS_WITH_AS(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.erase(j.cbegin(), j.cbegin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } } @@ -865,12 +897,16 @@ TEST_CASE("element access 1") { json j = 17u; CHECK_THROWS_WITH_AS(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.erase(j.begin(), j.begin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } { json j = 17u; CHECK_THROWS_WITH_AS(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.erase(j.cbegin(), j.cbegin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } } @@ -879,12 +915,16 @@ TEST_CASE("element access 1") { json j = 23.42; CHECK_THROWS_WITH_AS(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.erase(j.begin(), j.begin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } { json j = 23.42; CHECK_THROWS_WITH_AS(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.erase(j.cbegin(), j.cbegin()), + "[json.exception.invalid_iterator.204] iterators out of range", + json::invalid_iterator&); } } } diff --git a/tests/src/unit-element_access2.cpp b/tests/src/unit-element_access2.cpp index 9b1b4b2eeb..9bdbd7fe93 100644 --- a/tests/src/unit-element_access2.cpp +++ b/tests/src/unit-element_access2.cpp @@ -21,7 +21,14 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { SECTION("object") { - Json j = {{"integer", 1}, {"unsigned", 1u}, {"floating", 42.23}, {"null", nullptr}, {"string", "hello world"}, {"boolean", true}, {"object", Json::object()}, {"array", {1, 2, 3}}}; + Json j = {{"integer", 1}, + {"unsigned", 1u}, + {"floating", 42.23}, + {"null", nullptr}, + {"string", "hello world"}, + {"boolean", true}, + {"object", Json::object()}, + {"array", {1, 2, 3}}}; const Json j_const = j; SECTION("access specified element with bounds checking") @@ -74,7 +81,9 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j #ifdef JSON_HAS_CPP_17 CHECK_THROWS_WITH_AS(j.at(std::string_view("foo")), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&); - CHECK_THROWS_WITH_AS(j_const.at(std::string_view("foo")), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&); + CHECK_THROWS_WITH_AS(j_const.at(std::string_view("foo")), + "[json.exception.out_of_range.403] key 'foo' not found", + typename Json::out_of_range&); #endif } @@ -88,8 +97,12 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with null", typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view(std::string_view("foo"))), "[json.exception.type_error.304] cannot use at() with null", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view(std::string_view("foo"))), "[json.exception.type_error.304] cannot use at() with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view(std::string_view("foo"))), + "[json.exception.type_error.304] cannot use at() with null", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view(std::string_view("foo"))), + "[json.exception.type_error.304] cannot use at() with null", + typename Json::type_error&); #endif } @@ -98,11 +111,17 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j Json j_nonobject(Json::value_t::boolean); const Json j_nonobject_const(j_nonobject); CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with boolean", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with boolean", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), + "[json.exception.type_error.304] cannot use at() with boolean", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with boolean", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with boolean", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with boolean", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with boolean", + typename Json::type_error&); #endif } @@ -111,11 +130,17 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j Json j_nonobject(Json::value_t::string); const Json j_nonobject_const(j_nonobject); CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with string", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with string", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), + "[json.exception.type_error.304] cannot use at() with string", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with string", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with string", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with string", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with string", + typename Json::type_error&); #endif } @@ -127,8 +152,12 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with array", typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with array", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with array", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with array", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with array", + typename Json::type_error&); #endif } @@ -137,11 +166,17 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j Json j_nonobject(Json::value_t::number_integer); const Json j_nonobject_const(j_nonobject); CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), + "[json.exception.type_error.304] cannot use at() with number", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with number", + typename Json::type_error&); #endif } @@ -150,11 +185,17 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j Json j_nonobject(Json::value_t::number_unsigned); const Json j_nonobject_const(j_nonobject); CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), + "[json.exception.type_error.304] cannot use at() with number", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with number", + typename Json::type_error&); #endif } @@ -163,11 +204,17 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j Json j_nonobject(Json::value_t::number_float); const Json j_nonobject_const(j_nonobject); CHECK_THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at("foo"), + "[json.exception.type_error.304] cannot use at() with number", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.at(std::string_view("foo")), + "[json.exception.type_error.304] cannot use at() with number", + typename Json::type_error&); #endif } } @@ -275,12 +322,20 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { Json j_nonobject(Json::value_t::null); const Json j_nonobject_const(Json::value_t::null); - CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); #endif } @@ -288,12 +343,20 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { Json j_nonobject(Json::value_t::boolean); const Json j_nonobject_const(Json::value_t::boolean); - CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with boolean", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with boolean", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with boolean", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with boolean", + typename Json::type_error&); #endif } @@ -301,12 +364,20 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { Json j_nonobject(Json::value_t::string); const Json j_nonobject_const(Json::value_t::string); - CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with string", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with string", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with string", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with string", + typename Json::type_error&); #endif } @@ -314,12 +385,20 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { Json j_nonobject(Json::value_t::array); const Json j_nonobject_const(Json::value_t::array); - CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with array", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with array", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with array", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with array", + typename Json::type_error&); #endif } @@ -327,12 +406,20 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { Json j_nonobject(Json::value_t::number_integer); const Json j_nonobject_const(Json::value_t::number_integer); - CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); #endif } @@ -340,12 +427,20 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { Json j_nonobject(Json::value_t::number_unsigned); const Json j_nonobject_const(Json::value_t::number_unsigned); - CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); #endif } @@ -353,12 +448,20 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { Json j_nonobject(Json::value_t::number_float); const Json j_nonobject_const(Json::value_t::number_float); - CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); #endif } } @@ -400,63 +503,90 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j { Json j_nonobject(Json::value_t::null); const Json j_nonobject_const(Json::value_t::null); - CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); } SECTION("boolean") { Json j_nonobject(Json::value_t::boolean); const Json j_nonobject_const(Json::value_t::boolean); - CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with boolean", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with boolean", + typename Json::type_error&); } SECTION("string") { Json j_nonobject(Json::value_t::string); const Json j_nonobject_const(Json::value_t::string); - CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with string", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with string", + typename Json::type_error&); } SECTION("array") { Json j_nonobject(Json::value_t::array); const Json j_nonobject_const(Json::value_t::array); - CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with array", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with array", + typename Json::type_error&); } SECTION("number (integer)") { Json j_nonobject(Json::value_t::number_integer); const Json j_nonobject_const(Json::value_t::number_integer); - CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); } SECTION("number (unsigned)") { Json j_nonobject(Json::value_t::number_unsigned); const Json j_nonobject_const(Json::value_t::number_unsigned); - CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); } SECTION("number (floating-point)") { Json j_nonobject(Json::value_t::number_float); const Json j_nonobject_const(Json::value_t::number_float); - CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), + "[json.exception.type_error.306] cannot use value() with number", + typename Json::type_error&); } } } } - SECTION("non-const operator[]"){ - {Json j_null; + SECTION("non-const operator[]"){{Json j_null; CHECK(j_null.is_null()); j_null["key"] = 1; CHECK(j_null.is_object()); @@ -610,12 +740,18 @@ SECTION("access specified element") CHECK_NOTHROW(j_nonobject["foo"]); CHECK_NOTHROW(j_nonobject2[typename Json::object_t::key_type("foo")]); - CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], "[json.exception.type_error.305] cannot use operator[] with a string argument with null", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_const_nonobject[typename Json::object_t::key_type("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], + "[json.exception.type_error.305] cannot use operator[] with a string argument with null", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_const_nonobject[typename Json::object_t::key_type("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with null", + typename Json::type_error&); #ifdef JSON_HAS_CPP_17 CHECK_NOTHROW(j_nonobject2[std::string_view("foo")]); - CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with null", + typename Json::type_error&); #endif } @@ -637,8 +773,12 @@ SECTION("access specified element") typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with boolean", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with boolean", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with boolean", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with boolean", + typename Json::type_error&); #endif } @@ -660,8 +800,12 @@ SECTION("access specified element") typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with string", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with string", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with string", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with string", + typename Json::type_error&); #endif } @@ -672,7 +816,9 @@ SECTION("access specified element") CHECK_THROWS_WITH_AS(j_nonobject["foo"], "[json.exception.type_error.305] cannot use operator[] with a string argument with array", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_nonobject[typename Json::object_t::key_type("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with array", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject[typename Json::object_t::key_type("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with array", + typename Json::type_error&); CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], "[json.exception.type_error.305] cannot use operator[] with a string argument with array", typename Json::type_error&); @@ -681,8 +827,12 @@ SECTION("access specified element") typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with array", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with array", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with array", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with array", + typename Json::type_error&); #endif } @@ -704,8 +854,12 @@ SECTION("access specified element") typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with number", + typename Json::type_error&); #endif } @@ -727,8 +881,12 @@ SECTION("access specified element") typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with number", + typename Json::type_error&); #endif } @@ -750,8 +908,12 @@ SECTION("access specified element") typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with number", typename Json::type_error&); - CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with number", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], + "[json.exception.type_error.305] cannot use operator[] with a string argument with number", + typename Json::type_error&); #endif } } @@ -976,7 +1138,9 @@ SECTION("remove specified element") CHECK_THROWS_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with null", typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), + "[json.exception.type_error.307] cannot use erase() with null", + typename Json::type_error&); #endif } @@ -986,7 +1150,9 @@ SECTION("remove specified element") CHECK_THROWS_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with boolean", typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with boolean", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), + "[json.exception.type_error.307] cannot use erase() with boolean", + typename Json::type_error&); #endif } @@ -996,7 +1162,9 @@ SECTION("remove specified element") CHECK_THROWS_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with string", typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with string", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), + "[json.exception.type_error.307] cannot use erase() with string", + typename Json::type_error&); #endif } @@ -1006,7 +1174,9 @@ SECTION("remove specified element") CHECK_THROWS_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with array", typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with array", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), + "[json.exception.type_error.307] cannot use erase() with array", + typename Json::type_error&); #endif } @@ -1016,7 +1186,9 @@ SECTION("remove specified element") CHECK_THROWS_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with number", typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), + "[json.exception.type_error.307] cannot use erase() with number", + typename Json::type_error&); #endif } @@ -1026,7 +1198,9 @@ SECTION("remove specified element") CHECK_THROWS_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with number", typename Json::type_error&); #ifdef JSON_HAS_CPP_17 - CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with number", typename Json::type_error&); + CHECK_THROWS_WITH_AS(j_nonobject.erase(std::string_view("foo")), + "[json.exception.type_error.307] cannot use erase() with number", + typename Json::type_error&); #endif } } @@ -1036,8 +1210,7 @@ SECTION("find an element in an object") { SECTION("existing element") { - for (const auto* key : - {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) + for (const auto* key : {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) { CHECK(j.find(key) != j.end()); CHECK(*j.find(key) == j.at(key)); @@ -1045,8 +1218,7 @@ SECTION("find an element in an object") CHECK(*j_const.find(key) == j_const.at(key)); } #ifdef JSON_HAS_CPP_17 - for (const std::string_view key : - {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) + for (const std::string_view key : {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) { CHECK(j.find(key) != j.end()); CHECK(*j.find(key) == j.at(key)); @@ -1187,15 +1359,13 @@ SECTION("count keys in an object") { SECTION("existing element") { - for (const auto* key : - {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) + for (const auto* key : {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) { CHECK(j.count(key) == 1); CHECK(j_const.count(key) == 1); } #ifdef JSON_HAS_CPP_17 - for (const std::string_view key : - {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) + for (const std::string_view key : {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) { CHECK(j.count(key) == 1); CHECK(j_const.count(key) == 1); @@ -1334,16 +1504,14 @@ SECTION("check existence of key in an object") { SECTION("existing element") { - for (const auto* key : - {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) + for (const auto* key : {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) { CHECK(j.contains(key) == true); CHECK(j_const.contains(key) == true); } #ifdef JSON_HAS_CPP_17 - for (const std::string_view key : - {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) + for (const std::string_view key : {"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"}) { CHECK(j.contains(key) == true); CHECK(j_const.contains(key) == true); @@ -1483,8 +1651,22 @@ TEST_CASE_TEMPLATE("element access 2 (throwing tests)", Json, nlohmann::json, nl { SECTION("object") { - Json j = {{"integer", 1}, {"unsigned", 1u}, {"floating", 42.23}, {"null", nullptr}, {"string", "hello world"}, {"boolean", true}, {"object", Json::object()}, {"array", {1, 2, 3}}}; - const Json j_const = {{"integer", 1}, {"unsigned", 1u}, {"floating", 42.23}, {"null", nullptr}, {"string", "hello world"}, {"boolean", true}, {"object", Json::object()}, {"array", {1, 2, 3}}}; + Json j = {{"integer", 1}, + {"unsigned", 1u}, + {"floating", 42.23}, + {"null", nullptr}, + {"string", "hello world"}, + {"boolean", true}, + {"object", Json::object()}, + {"array", {1, 2, 3}}}; + const Json j_const = {{"integer", 1}, + {"unsigned", 1u}, + {"floating", 42.23}, + {"null", nullptr}, + {"string", "hello world"}, + {"boolean", true}, + {"object", Json::object()}, + {"array", {1, 2, 3}}}; SECTION("access specified element with default value") { @@ -1523,9 +1705,7 @@ TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann // test assumes string_t and object_t::key_type are the same REQUIRE(std::is_same::value); - Json j{ - {"foo", "bar"}, - {"baz", 42}}; + Json j{{"foo", "bar"}, {"baz", 42}}; const char* cpstr = "default"; const char castr[] = "default"; // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) @@ -1534,9 +1714,7 @@ TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann number_integer_t integer = 69; std::size_t size = 69; - SECTION("deduced ValueType"){ - SECTION("literal key"){ - CHECK(j.value("foo", "default") == "bar"); + SECTION("deduced ValueType"){SECTION("literal key"){CHECK(j.value("foo", "default") == "bar"); CHECK(j.value("foo", cpstr) == "bar"); CHECK(j.value("foo", castr) == "bar"); CHECK(j.value("foo", str) == "bar"); @@ -1684,8 +1862,12 @@ SECTION("explicit ValueType") CHECK(j.template value("bar", 47) == 47); CHECK(j.template value("bar", size) == size); - CHECK_THROWS_WITH_AS(Json().template value("foo", "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); - CHECK_THROWS_WITH_AS(Json().template value("foo", str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(Json().template value("foo", "default"), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(Json().template value("foo", str), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); } SECTION("const char * key") @@ -1713,8 +1895,12 @@ SECTION("explicit ValueType") CHECK(j.template value(key_notfound, 47) == 47); CHECK(j.template value(key_notfound, size) == size); - CHECK_THROWS_WITH_AS(Json().template value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); - CHECK_THROWS_WITH_AS(Json().template value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(Json().template value(key, "default"), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(Json().template value(key, str), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); } SECTION("const char(&)[] key") @@ -1742,8 +1928,12 @@ SECTION("explicit ValueType") CHECK(j.template value(key_notfound, 47) == 47); CHECK(j.template value(key_notfound, size) == size); - CHECK_THROWS_WITH_AS(Json().template value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); - CHECK_THROWS_WITH_AS(Json().template value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(Json().template value(key, "default"), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(Json().template value(key, str), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); } SECTION("string_t/object_t::key_type key") @@ -1767,8 +1957,12 @@ SECTION("explicit ValueType") CHECK(j.template value(key_notfound, 0) == 0); CHECK(j.template value(key_notfound, 47) == 47); - CHECK_THROWS_WITH_AS(Json().template value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); - CHECK_THROWS_WITH_AS(Json().template value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(Json().template value(key, "default"), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(Json().template value(key, str), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); } #ifdef JSON_HAS_CPP_17 @@ -1804,8 +1998,12 @@ SECTION("explicit ValueType") CHECK(j.template value(key_notfound, "default") == "default"); - CHECK_THROWS_WITH_AS(Json().template value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); - CHECK_THROWS_WITH_AS(Json().template value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&); + CHECK_THROWS_WITH_AS(Json().template value(key, "default"), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); + CHECK_THROWS_WITH_AS(Json().template value(key, str), + "[json.exception.type_error.306] cannot use value() with null", + typename Json::type_error&); } #endif } diff --git a/tests/src/unit-inspection.cpp b/tests/src/unit-inspection.cpp index f4eb322bb1..f3403f228a 100644 --- a/tests/src/unit-inspection.cpp +++ b/tests/src/unit-inspection.cpp @@ -206,8 +206,7 @@ TEST_CASE("object inspection") SECTION("no indent / indent=-1") { - CHECK(j.dump() == - "{\"array\":[1,2,3,4],\"boolean\":false,\"null\":null,\"number\":42,\"object\":{},\"string\":\"Hello world\"}"); + CHECK(j.dump() == "{\"array\":[1,2,3,4],\"boolean\":false,\"null\":null,\"number\":42,\"object\":{},\"string\":\"Hello world\"}"); CHECK(j.dump() == j.dump(-1)); } @@ -220,14 +219,16 @@ TEST_CASE("object inspection") SECTION("indent=1, space='\t'") { - CHECK(j.dump(1, '\t') == - "{\n\t\"array\": [\n\t\t1,\n\t\t2,\n\t\t3,\n\t\t4\n\t],\n\t\"boolean\": false,\n\t\"null\": null,\n\t\"number\": 42,\n\t\"object\": {},\n\t\"string\": \"Hello world\"\n}"); + CHECK( + j.dump(1, '\t') == + "{\n\t\"array\": [\n\t\t1,\n\t\t2,\n\t\t3,\n\t\t4\n\t],\n\t\"boolean\": false,\n\t\"null\": null,\n\t\"number\": 42,\n\t\"object\": {},\n\t\"string\": \"Hello world\"\n}"); } SECTION("indent=4") { - CHECK(j.dump(4) == - "{\n \"array\": [\n 1,\n 2,\n 3,\n 4\n ],\n \"boolean\": false,\n \"null\": null,\n \"number\": 42,\n \"object\": {},\n \"string\": \"Hello world\"\n}"); + CHECK( + j.dump(4) == + "{\n \"array\": [\n 1,\n 2,\n 3,\n 4\n ],\n \"boolean\": false,\n \"null\": null,\n \"number\": 42,\n \"object\": {},\n \"string\": \"Hello world\"\n}"); } SECTION("indent=x") @@ -291,8 +292,7 @@ TEST_CASE("object inspection") json const value = json::parse(f_unescaped); std::string text = value.dump(4, ' ', true); - std::string expected((std::istreambuf_iterator(f_escaped)), - std::istreambuf_iterator()); + std::string expected((std::istreambuf_iterator(f_escaped)), std::istreambuf_iterator()); CHECK(text == expected); } } @@ -328,8 +328,7 @@ TEST_CASE("object inspection") SECTION("round trips") { - for (const auto& s : - {"3.141592653589793", "1000000000000000010E5"}) + for (const auto& s : {"3.141592653589793", "1000000000000000010E5"}) { json const j1 = json::parse(s); std::string s1 = j1.dump(); diff --git a/tests/src/unit-items.cpp b/tests/src/unit-items.cpp index 40cf5c806e..f913e93a77 100644 --- a/tests/src/unit-items.cpp +++ b/tests/src/unit-items.cpp @@ -718,9 +718,7 @@ TEST_CASE("iterator_wrapper") TEST_CASE("items()") { - SECTION("object"){ - SECTION("value"){ - json j = {{"A", 1}, {"B", 2}}; + SECTION("object"){SECTION("value"){json j = {{"A", 1}, {"B", 2}}; int counter = 1; for (auto i : j.items()) // NOLINT(performance-for-range-copy) diff --git a/tests/src/unit-iterators2.cpp b/tests/src/unit-iterators2.cpp index 116d231ca6..0c8c0e09cb 100644 --- a/tests/src/unit-iterators2.cpp +++ b/tests/src/unit-iterators2.cpp @@ -74,23 +74,47 @@ TEST_CASE("iterators 2") if (j.type() == json::value_t::object) { #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(it1 < it1, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 < it2, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2 < it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 < it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it1_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it2_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c < it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 < it1, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 < it2, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2 < it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 < it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it1_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it2_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c < it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); #else CHECK_THROWS_WITH_AS(it1 < it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 < it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it2 < it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 < it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it1_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it2_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c < it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it1_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it2_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c < it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); #endif } else @@ -111,23 +135,47 @@ TEST_CASE("iterators 2") if (j.type() == json::value_t::object) { #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(it1 <= it1, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 <= it2, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2 <= it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 <= it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it1_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it2_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c <= it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 <= it1, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 <= it2, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2 <= it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 <= it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it1_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it2_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c <= it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); #else CHECK_THROWS_WITH_AS(it1 <= it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 <= it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it2 <= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 <= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it1_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it2_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c <= it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it1_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it2_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c <= it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); #endif } else @@ -149,23 +197,47 @@ TEST_CASE("iterators 2") if (j.type() == json::value_t::object) { #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(it1 > it1, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 > it2, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2 > it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 > it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it1_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it2_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c > it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 > it1, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 > it2, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2 > it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 > it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it1_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it2_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c > it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); #else CHECK_THROWS_WITH_AS(it1 > it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 > it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it2 > it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 > it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it1_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it2_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c > it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it1_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it2_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c > it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); #endif } else @@ -187,23 +259,47 @@ TEST_CASE("iterators 2") if (j.type() == json::value_t::object) { #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(it1 >= it1, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 >= it2, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2 >= it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 >= it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it1_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it2_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c >= it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 >= it1, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 >= it2, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2 >= it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 >= it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it1_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it2_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c >= it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); #else CHECK_THROWS_WITH_AS(it1 >= it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 >= it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it2 >= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 >= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it1_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it2_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c >= it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it1_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it2_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c >= it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); #endif } else @@ -231,10 +327,18 @@ TEST_CASE("iterators 2") #if JSON_DIAGNOSTICS // the output differs in each loop, so we cannot fix a string for the expected exception #else - CHECK_THROWS_WITH_AS(j.begin() == k.begin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.cbegin() == k.cbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.begin() < k.begin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.cbegin() < k.cbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.begin() == k.begin(), + "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.cbegin() == k.cbegin(), + "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.begin() < k.begin(), + "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.cbegin() < k.cbegin(), + "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", + json::invalid_iterator&); #endif } } @@ -498,23 +602,47 @@ TEST_CASE("iterators 2") if (j.type() == json::value_t::object) { #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(it1 < it1, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 < it2, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2 < it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 < it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it1_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it2_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c < it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 < it1, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 < it2, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2 < it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 < it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it1_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it2_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c < it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); #else CHECK_THROWS_WITH_AS(it1 < it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 < it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it2 < it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 < it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it1_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it2_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c < it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c < it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it1_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it2_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c < it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c < it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); #endif } else @@ -535,23 +663,47 @@ TEST_CASE("iterators 2") if (j.type() == json::value_t::object) { #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(it1 <= it1, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 <= it2, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2 <= it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 <= it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it1_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it2_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c <= it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 <= it1, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 <= it2, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2 <= it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 <= it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it1_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it2_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c <= it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); #else CHECK_THROWS_WITH_AS(it1 <= it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 <= it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it2 <= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 <= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it1_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it2_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c <= it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c <= it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it1_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it2_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c <= it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c <= it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); #endif } else @@ -573,23 +725,47 @@ TEST_CASE("iterators 2") if (j.type() == json::value_t::object) { #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(it1 > it1, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 > it2, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2 > it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 > it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it1_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it2_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c > it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 > it1, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 > it2, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2 > it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 > it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it1_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it2_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c > it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); #else CHECK_THROWS_WITH_AS(it1 > it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 > it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it2 > it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 > it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it1_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it2_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c > it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c > it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it1_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it2_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c > it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c > it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); #endif } else @@ -611,23 +787,47 @@ TEST_CASE("iterators 2") if (j.type() == json::value_t::object) { #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(it1 >= it1, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 >= it2, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2 >= it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1 >= it3, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it1_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it2_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c >= it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it3_c, "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 >= it1, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 >= it2, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2 >= it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1 >= it3, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it1_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it2_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c >= it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it3_c, + "[json.exception.invalid_iterator.213] (/5) cannot compare order of object iterators", + json::invalid_iterator&); #else CHECK_THROWS_WITH_AS(it1 >= it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 >= it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it2 >= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); CHECK_THROWS_WITH_AS(it1 >= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it1_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it2_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it2_c >= it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(it1_c >= it3_c, "[json.exception.invalid_iterator.213] cannot compare order of object iterators", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it1_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it2_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it2_c >= it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(it1_c >= it3_c, + "[json.exception.invalid_iterator.213] cannot compare order of object iterators", + json::invalid_iterator&); #endif } else @@ -655,10 +855,18 @@ TEST_CASE("iterators 2") #if JSON_DIAGNOSTICS // the output differs in each loop, so we cannot fix a string for the expected exception #else - CHECK_THROWS_WITH_AS(j.rbegin() == k.rbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.crbegin() == k.crbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.rbegin() < k.rbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j.crbegin() < k.crbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.rbegin() == k.rbegin(), + "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.crbegin() == k.crbegin(), + "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.rbegin() < k.rbegin(), + "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j.crbegin() < k.crbegin(), + "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", + json::invalid_iterator&); #endif } } diff --git a/tests/src/unit-json_patch.cpp b/tests/src/unit-json_patch.cpp index 28ae39fd6e..68655e4d11 100644 --- a/tests/src/unit-json_patch.cpp +++ b/tests/src/unit-json_patch.cpp @@ -667,7 +667,9 @@ TEST_CASE("JSON patch") { json const j; json const patch = {{"op", "add"}, {"path", ""}, {"value", 1}}; - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.104] parse error: JSON patch must be an array of objects", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.104] parse error: JSON patch must be an array of objects", + json::parse_error&); } SECTION("not an array of objects") @@ -675,9 +677,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {"op", "add", "path", "", "value", 1}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.104] parse error: (/0) JSON patch must be an array of objects", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.104] parse error: (/0) JSON patch must be an array of objects", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.104] parse error: JSON patch must be an array of objects", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.104] parse error: JSON patch must be an array of objects", + json::parse_error&); #endif } @@ -697,9 +703,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", 1}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation must have string member 'op'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation must have string member 'op'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation must have string member 'op'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation must have string member 'op'", + json::parse_error&); #endif } @@ -722,9 +732,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "add"}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'add' must have member 'path'", + json::parse_error&); #endif } @@ -733,9 +747,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "add"}, {"path", 1}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have string member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'add' must have string member 'path'", + json::parse_error&); #endif } @@ -744,9 +762,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "add"}, {"path", ""}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'value'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'value'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have member 'value'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'add' must have member 'value'", + json::parse_error&); #endif } @@ -765,9 +787,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "remove"}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'remove' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'remove' must have member 'path'", + json::parse_error&); #endif } @@ -776,9 +802,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "remove"}, {"path", 1}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have string member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'remove' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'remove' must have string member 'path'", + json::parse_error&); #endif } @@ -811,9 +841,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "replace"}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'path'", + json::parse_error&); #endif } @@ -822,9 +856,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "replace"}, {"path", 1}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have string member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'replace' must have string member 'path'", + json::parse_error&); #endif } @@ -833,9 +871,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "replace"}, {"path", ""}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'value'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'value'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'value'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'value'", + json::parse_error&); #endif } @@ -861,9 +903,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "move"}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'move' must have member 'path'", + json::parse_error&); #endif } @@ -872,9 +918,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "move"}, {"path", 1}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'path'", + json::parse_error&); #endif } @@ -884,9 +934,13 @@ TEST_CASE("JSON patch") json const patch = {{{"op", "move"}, {"path", ""}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'from'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'from'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have member 'from'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'move' must have member 'from'", + json::parse_error&); #endif } @@ -896,9 +950,13 @@ TEST_CASE("JSON patch") json const patch = {{{"op", "move"}, {"path", ""}, {"from", 1}}}; CHECK_THROWS_AS(j.patch(patch), json::parse_error&); #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'from'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'from'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'from'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'from'", + json::parse_error&); #endif } @@ -924,9 +982,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "copy"}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'path'", + json::parse_error&); #endif } @@ -935,9 +997,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "copy"}, {"path", 1}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'path'", + json::parse_error&); #endif } @@ -946,9 +1012,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "copy"}, {"path", ""}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'from'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'from'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'from'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'from'", + json::parse_error&); #endif } @@ -957,9 +1027,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "copy"}, {"path", ""}, {"from", 1}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'from'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'from'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'from'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'from'", + json::parse_error&); #endif } @@ -985,9 +1059,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "test"}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'test' must have member 'path'", + json::parse_error&); #endif } @@ -996,9 +1074,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "test"}, {"path", 1}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have string member 'path'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have string member 'path'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'test' must have string member 'path'", + json::parse_error&); #endif } @@ -1007,9 +1089,13 @@ TEST_CASE("JSON patch") json const j; json const patch = {{{"op", "test"}, {"path", ""}}}; #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'value'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'value'", + json::parse_error&); #else - CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have member 'value'", json::parse_error&); + CHECK_THROWS_WITH_AS(j.patch(patch), + "[json.exception.parse_error.105] parse error: operation 'test' must have member 'value'", + json::parse_error&); #endif } } @@ -1216,65 +1302,52 @@ TEST_CASE("JSON patch") { SECTION("add") { - CHECK(R"( {} )"_json.patch( - R"( [{"op": "add", "path": "/foo", "value": "bar"}] )"_json) == R"( {"foo": "bar"} )"_json); + CHECK(R"( {} )"_json.patch(R"( [{"op": "add", "path": "/foo", "value": "bar"}] )"_json) == R"( {"foo": "bar"} )"_json); - CHECK(R"( {"foo": [1, 3]} )"_json.patch( - R"( [{"op": "add", "path": "/foo", "value": "bar"}] )"_json) == R"( {"foo": "bar"} )"_json); + CHECK(R"( {"foo": [1, 3]} )"_json.patch(R"( [{"op": "add", "path": "/foo", "value": "bar"}] )"_json) == R"( {"foo": "bar"} )"_json); - CHECK(R"( {"foo": [{}]} )"_json.patch( - R"( [{"op": "add", "path": "/foo/0/bar", "value": "baz"}] )"_json) == R"( {"foo": [{"bar": "baz"}]} )"_json); + CHECK(R"( {"foo": [{}]} )"_json.patch(R"( [{"op": "add", "path": "/foo/0/bar", "value": "baz"}] )"_json) == R"( {"foo": [{"bar": "baz"}]} )"_json); } SECTION("remove") { - CHECK(R"( {"foo": "bar"} )"_json.patch( - R"( [{"op": "remove", "path": "/foo"}] )"_json) == R"( {} )"_json); + CHECK(R"( {"foo": "bar"} )"_json.patch(R"( [{"op": "remove", "path": "/foo"}] )"_json) == R"( {} )"_json); - CHECK(R"( {"foo": [1, 2, 3]} )"_json.patch( - R"( [{"op": "remove", "path": "/foo/1"}] )"_json) == R"( {"foo": [1, 3]} )"_json); + CHECK(R"( {"foo": [1, 2, 3]} )"_json.patch(R"( [{"op": "remove", "path": "/foo/1"}] )"_json) == R"( {"foo": [1, 3]} )"_json); - CHECK(R"( {"foo": [{"bar": "baz"}]} )"_json.patch( - R"( [{"op": "remove", "path": "/foo/0/bar"}] )"_json) == R"( {"foo": [{}]} )"_json); + CHECK(R"( {"foo": [{"bar": "baz"}]} )"_json.patch(R"( [{"op": "remove", "path": "/foo/0/bar"}] )"_json) == R"( {"foo": [{}]} )"_json); } SECTION("replace") { - CHECK(R"( {"foo": "bar"} )"_json.patch( - R"( [{"op": "replace", "path": "/foo", "value": 1}] )"_json) == R"( {"foo": 1} )"_json); + CHECK(R"( {"foo": "bar"} )"_json.patch(R"( [{"op": "replace", "path": "/foo", "value": 1}] )"_json) == R"( {"foo": 1} )"_json); - CHECK(R"( {"foo": [1, 2, 3]} )"_json.patch( - R"( [{"op": "replace", "path": "/foo/1", "value": 4}] )"_json) == R"( {"foo": [1, 4, 3]} )"_json); + CHECK(R"( {"foo": [1, 2, 3]} )"_json.patch(R"( [{"op": "replace", "path": "/foo/1", "value": 4}] )"_json) == R"( {"foo": [1, 4, 3]} )"_json); - CHECK(R"( {"foo": [{"bar": "baz"}]} )"_json.patch( - R"( [{"op": "replace", "path": "/foo/0/bar", "value": 1}] )"_json) == R"( {"foo": [{"bar": 1}]} )"_json); + CHECK(R"( {"foo": [{"bar": "baz"}]} )"_json.patch(R"( [{"op": "replace", "path": "/foo/0/bar", "value": 1}] )"_json) == + R"( {"foo": [{"bar": 1}]} )"_json); } SECTION("move") { - CHECK(R"( {"foo": [1, 2, 3]} )"_json.patch( - R"( [{"op": "move", "from": "/foo", "path": "/bar"}] )"_json) == R"( {"bar": [1, 2, 3]} )"_json); + CHECK(R"( {"foo": [1, 2, 3]} )"_json.patch(R"( [{"op": "move", "from": "/foo", "path": "/bar"}] )"_json) == R"( {"bar": [1, 2, 3]} )"_json); } SECTION("copy") { - CHECK(R"( {"foo": [1, 2, 3]} )"_json.patch( - R"( [{"op": "copy", "from": "/foo/1", "path": "/bar"}] )"_json) == R"( {"foo": [1, 2, 3], "bar": 2} )"_json); + CHECK(R"( {"foo": [1, 2, 3]} )"_json.patch(R"( [{"op": "copy", "from": "/foo/1", "path": "/bar"}] )"_json) == + R"( {"foo": [1, 2, 3], "bar": 2} )"_json); } SECTION("copy") { - CHECK_NOTHROW(R"( {"foo": "bar"} )"_json.patch( - R"( [{"op": "test", "path": "/foo", "value": "bar"}] )"_json)); + CHECK_NOTHROW(R"( {"foo": "bar"} )"_json.patch(R"( [{"op": "test", "path": "/foo", "value": "bar"}] )"_json)); } } SECTION("Tests from github.com/json-patch/json-patch-tests") { - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/json-patch-tests/spec_tests.json", - TEST_DATA_DIRECTORY "/json-patch-tests/tests.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/json-patch-tests/spec_tests.json", TEST_DATA_DIRECTORY "/json-patch-tests/tests.json"}) { CAPTURE(filename) std::ifstream f(filename); diff --git a/tests/src/unit-json_pointer.cpp b/tests/src/unit-json_pointer.cpp index 4201715578..653846b0f3 100644 --- a/tests/src/unit-json_pointer.cpp +++ b/tests/src/unit-json_pointer.cpp @@ -35,20 +35,14 @@ TEST_CASE("JSON pointers") json::parse_error&); json::json_pointer p; - CHECK_THROWS_WITH_AS(p.top(), - "[json.exception.out_of_range.405] JSON pointer has no parent", - json::out_of_range&); - CHECK_THROWS_WITH_AS(p.pop_back(), - "[json.exception.out_of_range.405] JSON pointer has no parent", - json::out_of_range&); + CHECK_THROWS_WITH_AS(p.top(), "[json.exception.out_of_range.405] JSON pointer has no parent", json::out_of_range&); + CHECK_THROWS_WITH_AS(p.pop_back(), "[json.exception.out_of_range.405] JSON pointer has no parent", json::out_of_range&); SECTION("array index error") { json v = {1, 2, 3, 4}; json::json_pointer const ptr("/10e"); - CHECK_THROWS_WITH_AS(v[ptr], - "[json.exception.out_of_range.404] unresolved reference token '10e'", - json::out_of_range&); + CHECK_THROWS_WITH_AS(v[ptr], "[json.exception.out_of_range.404] unresolved reference token '10e'", json::out_of_range&); } } @@ -149,9 +143,7 @@ TEST_CASE("JSON pointers") // unresolved access json j_primitive = 1; - CHECK_THROWS_WITH_AS(j_primitive["/foo"_json_pointer], - "[json.exception.out_of_range.404] unresolved reference token 'foo'", - json::out_of_range&); + CHECK_THROWS_WITH_AS(j_primitive["/foo"_json_pointer], "[json.exception.out_of_range.404] unresolved reference token 'foo'", json::out_of_range&); CHECK_THROWS_WITH_AS(j_primitive.at("/foo"_json_pointer), "[json.exception.out_of_range.404] unresolved reference token 'foo'", json::out_of_range&); @@ -213,15 +205,11 @@ TEST_CASE("JSON pointers") CHECK(j[json::json_pointer("/m~0n")] == j["m~n"]); // unescaped access - CHECK_THROWS_WITH_AS(j.at(json::json_pointer("/a/b")), - "[json.exception.out_of_range.403] key 'a' not found", - json::out_of_range&); + CHECK_THROWS_WITH_AS(j.at(json::json_pointer("/a/b")), "[json.exception.out_of_range.403] key 'a' not found", json::out_of_range&); // unresolved access const json j_primitive = 1; - CHECK_THROWS_WITH_AS(j_primitive["/foo"_json_pointer], - "[json.exception.out_of_range.404] unresolved reference token 'foo'", - json::out_of_range&); + CHECK_THROWS_WITH_AS(j_primitive["/foo"_json_pointer], "[json.exception.out_of_range.404] unresolved reference token 'foo'", json::out_of_range&); CHECK_THROWS_WITH_AS(j_primitive.at("/foo"_json_pointer), "[json.exception.out_of_range.404] unresolved reference token 'foo'", json::out_of_range&); @@ -324,12 +312,8 @@ TEST_CASE("JSON pointers") "[json.exception.parse_error.109] parse error: array index '+1' is not a number", json::parse_error&); - CHECK_THROWS_WITH_AS(j["/1+1"_json_pointer] = 1, - "[json.exception.out_of_range.404] unresolved reference token '1+1'", - json::out_of_range&); - CHECK_THROWS_WITH_AS(j_const["/1+1"_json_pointer] == 1, - "[json.exception.out_of_range.404] unresolved reference token '1+1'", - json::out_of_range&); + CHECK_THROWS_WITH_AS(j["/1+1"_json_pointer] = 1, "[json.exception.out_of_range.404] unresolved reference token '1+1'", json::out_of_range&); + CHECK_THROWS_WITH_AS(j_const["/1+1"_json_pointer] == 1, "[json.exception.out_of_range.404] unresolved reference token '1+1'", json::out_of_range&); { auto too_large_index = std::to_string((std::numeric_limits::max)()) + "1"; @@ -378,18 +362,12 @@ TEST_CASE("JSON pointers") CHECK(j == json({1, 13, 3, 33, nullptr, 55, 99})); // error when using "-" in const object - CHECK_THROWS_WITH_AS(j_const["/-"_json_pointer], - "[json.exception.out_of_range.402] array index '-' (3) is out of range", - json::out_of_range&); + CHECK_THROWS_WITH_AS(j_const["/-"_json_pointer], "[json.exception.out_of_range.402] array index '-' (3) is out of range", json::out_of_range&); CHECK(!j_const.contains("/-"_json_pointer)); // error when using "-" with at - CHECK_THROWS_WITH_AS(j.at("/-"_json_pointer), - "[json.exception.out_of_range.402] array index '-' (7) is out of range", - json::out_of_range&); - CHECK_THROWS_WITH_AS(j_const.at("/-"_json_pointer), - "[json.exception.out_of_range.402] array index '-' (3) is out of range", - json::out_of_range&); + CHECK_THROWS_WITH_AS(j.at("/-"_json_pointer), "[json.exception.out_of_range.402] array index '-' (7) is out of range", json::out_of_range&); + CHECK_THROWS_WITH_AS(j_const.at("/-"_json_pointer), "[json.exception.out_of_range.402] array index '-' (3) is out of range", json::out_of_range&); CHECK(!j_const.contains("/-"_json_pointer)); } @@ -403,56 +381,44 @@ TEST_CASE("JSON pointers") CHECK(j["/2"_json_pointer] == j[2]); // assign to nonexisting index - CHECK_THROWS_WITH_AS(j.at("/3"_json_pointer), - "[json.exception.out_of_range.401] array index 3 is out of range", - json::out_of_range&); + CHECK_THROWS_WITH_AS(j.at("/3"_json_pointer), "[json.exception.out_of_range.401] array index 3 is out of range", json::out_of_range&); CHECK(!j.contains("/3"_json_pointer)); // assign to nonexisting index (with gap) - CHECK_THROWS_WITH_AS(j.at("/5"_json_pointer), - "[json.exception.out_of_range.401] array index 5 is out of range", - json::out_of_range&); + CHECK_THROWS_WITH_AS(j.at("/5"_json_pointer), "[json.exception.out_of_range.401] array index 5 is out of range", json::out_of_range&); CHECK(!j.contains("/5"_json_pointer)); // assign to "-" - CHECK_THROWS_WITH_AS(j["/-"_json_pointer], - "[json.exception.out_of_range.402] array index '-' (3) is out of range", - json::out_of_range&); - CHECK_THROWS_WITH_AS(j.at("/-"_json_pointer), - "[json.exception.out_of_range.402] array index '-' (3) is out of range", - json::out_of_range&); + CHECK_THROWS_WITH_AS(j["/-"_json_pointer], "[json.exception.out_of_range.402] array index '-' (3) is out of range", json::out_of_range&); + CHECK_THROWS_WITH_AS(j.at("/-"_json_pointer), "[json.exception.out_of_range.402] array index '-' (3) is out of range", json::out_of_range&); CHECK(!j.contains("/-"_json_pointer)); } } SECTION("flatten") { - json j = - { - {"pi", 3.141}, - {"happy", true}, - {"name", "Niels"}, - {"nothing", nullptr}, - {"answer", {{"everything", 42}}}, - {"list", {1, 0, 2}}, - {"object", {{"currency", "USD"}, {"value", 42.99}, {"", "empty string"}, {"/", "slash"}, {"~", "tilde"}, {"~1", "tilde1"}}}}; - - json j_flatten = - { - {"/pi", 3.141}, - {"/happy", true}, - {"/name", "Niels"}, - {"/nothing", nullptr}, - {"/answer/everything", 42}, - {"/list/0", 1}, - {"/list/1", 0}, - {"/list/2", 2}, - {"/object/currency", "USD"}, - {"/object/value", 42.99}, - {"/object/", "empty string"}, - {"/object/~1", "slash"}, - {"/object/~0", "tilde"}, - {"/object/~01", "tilde1"}}; + json j = {{"pi", 3.141}, + {"happy", true}, + {"name", "Niels"}, + {"nothing", nullptr}, + {"answer", {{"everything", 42}}}, + {"list", {1, 0, 2}}, + {"object", {{"currency", "USD"}, {"value", 42.99}, {"", "empty string"}, {"/", "slash"}, {"~", "tilde"}, {"~1", "tilde1"}}}}; + + json j_flatten = {{"/pi", 3.141}, + {"/happy", true}, + {"/name", "Niels"}, + {"/nothing", nullptr}, + {"/answer/everything", 42}, + {"/list/0", 1}, + {"/list/1", 0}, + {"/list/2", 2}, + {"/object/currency", "USD"}, + {"/object/value", 42.99}, + {"/object/", "empty string"}, + {"/object/~1", "slash"}, + {"/object/~0", "tilde"}, + {"/object/~01", "tilde1"}}; // check if flattened result is as expected CHECK(j.flatten() == j_flatten); @@ -461,22 +427,20 @@ TEST_CASE("JSON pointers") CHECK(j_flatten.unflatten() == j); // error for nonobjects - CHECK_THROWS_WITH_AS(json(1).unflatten(), - "[json.exception.type_error.314] only objects can be unflattened", - json::type_error&); + CHECK_THROWS_WITH_AS(json(1).unflatten(), "[json.exception.type_error.314] only objects can be unflattened", json::type_error&); // error for nonprimitve values #if JSON_DIAGNOSTICS - CHECK_THROWS_WITH_AS(json({{"/1", {1, 2, 3}}}).unflatten(), "[json.exception.type_error.315] (/~11) values in object must be primitive", json::type_error&); + CHECK_THROWS_WITH_AS(json({{"/1", {1, 2, 3}}}).unflatten(), + "[json.exception.type_error.315] (/~11) values in object must be primitive", + json::type_error&); #else CHECK_THROWS_WITH_AS(json({{"/1", {1, 2, 3}}}).unflatten(), "[json.exception.type_error.315] values in object must be primitive", json::type_error&); #endif // error for conflicting values json const j_error = {{"", 42}, {"/foo", 17}}; - CHECK_THROWS_WITH_AS(j_error.unflatten(), - "[json.exception.type_error.313] invalid value to unflatten", - json::type_error&); + CHECK_THROWS_WITH_AS(j_error.unflatten(), "[json.exception.type_error.313] invalid value to unflatten", json::type_error&); // explicit roundtrip check CHECK(j.flatten().unflatten() == j); @@ -500,8 +464,7 @@ TEST_CASE("JSON pointers") SECTION("string representation") { - for (const auto* ptr_str : - {"", "/foo", "/foo/0", "/", "/a~1b", "/c%d", "/e^f", "/g|h", "/i\\j", "/k\"l", "/ ", "/m~0n"}) + for (const auto* ptr_str : {"", "/foo", "/foo/0", "/", "/a~1b", "/c%d", "/e^f", "/g|h", "/i\\j", "/k\"l", "/ ", "/m~0n"}) { json::json_pointer const ptr(ptr_str); std::stringstream ss; @@ -533,16 +496,14 @@ TEST_CASE("JSON pointers") SECTION("empty, push, pop and parent") { - const json j = - { - {"", "Hello"}, - {"pi", 3.141}, - {"happy", true}, - {"name", "Niels"}, - {"nothing", nullptr}, - {"answer", {{"everything", 42}}}, - {"list", {1, 0, 2}}, - {"object", {{"currency", "USD"}, {"value", 42.99}, {"", "empty string"}, {"/", "slash"}, {"~", "tilde"}, {"~1", "tilde1"}}}}; + const json j = {{"", "Hello"}, + {"pi", 3.141}, + {"happy", true}, + {"name", "Niels"}, + {"nothing", nullptr}, + {"answer", {{"everything", 42}}}, + {"list", {1, 0, 2}}, + {"object", {{"currency", "USD"}, {"value", 42.99}, {"", "empty string"}, {"/", "slash"}, {"~", "tilde"}, {"~1", "tilde1"}}}}; // empty json_pointer returns the root JSON-object auto ptr = ""_json_pointer; @@ -589,22 +550,19 @@ TEST_CASE("JSON pointers") CHECK(ptr.empty()); CHECK(j[ptr] == j); - CHECK_THROWS_WITH(ptr.pop_back(), - "[json.exception.out_of_range.405] JSON pointer has no parent"); + CHECK_THROWS_WITH(ptr.pop_back(), "[json.exception.out_of_range.405] JSON pointer has no parent"); } SECTION("operators") { - const json j = - { - {"", "Hello"}, - {"pi", 3.141}, - {"happy", true}, - {"name", "Niels"}, - {"nothing", nullptr}, - {"answer", {{"everything", 42}}}, - {"list", {1, 0, 2}}, - {"object", {{"currency", "USD"}, {"value", 42.99}, {"", "empty string"}, {"/", "slash"}, {"~", "tilde"}, {"~1", "tilde1"}}}}; + const json j = {{"", "Hello"}, + {"pi", 3.141}, + {"happy", true}, + {"name", "Niels"}, + {"nothing", nullptr}, + {"answer", {{"everything", 42}}}, + {"list", {1, 0, 2}}, + {"object", {{"currency", "USD"}, {"value", 42.99}, {"", "empty string"}, {"/", "slash"}, {"~", "tilde"}, {"~1", "tilde1"}}}}; // empty json_pointer returns the root JSON-object auto ptr = ""_json_pointer; diff --git a/tests/src/unit-meta.cpp b/tests/src/unit-meta.cpp index ce23e22661..0be2347fe4 100644 --- a/tests/src/unit-meta.cpp +++ b/tests/src/unit-meta.cpp @@ -20,11 +20,7 @@ TEST_CASE("version information") CHECK(j["name"] == "JSON for Modern C++"); CHECK(j["copyright"] == "(C) 2013-2023 Niels Lohmann"); CHECK(j["url"] == "https://github.com/nlohmann/json"); - CHECK(j["version"] == json( - {{"string", "3.11.3"}, - {"major", 3}, - {"minor", 11}, - {"patch", 3}})); + CHECK(j["version"] == json({{"string", "3.11.3"}, {"major", 3}, {"minor", 11}, {"patch", 3}})); CHECK(j.find("platform") != j.end()); CHECK(j.at("compiler").find("family") != j.at("compiler").end()); diff --git a/tests/src/unit-modifiers.cpp b/tests/src/unit-modifiers.cpp index 1430776ef6..84ffe88c36 100644 --- a/tests/src/unit-modifiers.cpp +++ b/tests/src/unit-modifiers.cpp @@ -239,7 +239,9 @@ TEST_CASE("modifiers") { json j = 1; json const k("Hello"); - CHECK_THROWS_WITH_AS(j.push_back(json::object_t::value_type({"one", 1})), "[json.exception.type_error.308] cannot use push_back() with number", json::type_error&); + CHECK_THROWS_WITH_AS(j.push_back(json::object_t::value_type({"one", 1})), + "[json.exception.type_error.308] cannot use push_back() with number", + json::type_error&); } } @@ -467,7 +469,9 @@ TEST_CASE("modifiers") { json j = 1; json const k("Hello"); - CHECK_THROWS_WITH_AS(j += json::object_t::value_type({"one", 1}), "[json.exception.type_error.308] cannot use push_back() with number", json::type_error&); + CHECK_THROWS_WITH_AS(j += json::object_t::value_type({"one", 1}), + "[json.exception.type_error.308] cannot use push_back() with number", + json::type_error&); } } @@ -637,8 +641,12 @@ TEST_CASE("modifiers") { json j_other_array2 = {"first", "second"}; - CHECK_THROWS_WITH_AS(j_array.insert(j_array.end(), j_array.begin(), j_array.end()), "[json.exception.invalid_iterator.211] passed iterators may not belong to container", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j_array.insert(j_array.end(), j_other_array.begin(), j_other_array2.end()), "[json.exception.invalid_iterator.210] iterators do not fit", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j_array.insert(j_array.end(), j_array.begin(), j_array.end()), + "[json.exception.invalid_iterator.211] passed iterators may not belong to container", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j_array.insert(j_array.end(), j_other_array.begin(), j_other_array2.end()), + "[json.exception.invalid_iterator.210] iterators do not fit", + json::invalid_iterator&); } } @@ -663,9 +671,15 @@ TEST_CASE("modifiers") { json const j_other_array2 = {"first", "second"}; - CHECK_THROWS_WITH_AS(j_array.insert(j_object2.begin(), j_object2.end()), "[json.exception.type_error.309] cannot use insert() with array", json::type_error&); - CHECK_THROWS_WITH_AS(j_object1.insert(j_object1.begin(), j_object2.end()), "[json.exception.invalid_iterator.210] iterators do not fit", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j_object1.insert(j_array.begin(), j_array.end()), "[json.exception.invalid_iterator.202] iterators first and last must point to objects", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j_array.insert(j_object2.begin(), j_object2.end()), + "[json.exception.type_error.309] cannot use insert() with array", + json::type_error&); + CHECK_THROWS_WITH_AS(j_object1.insert(j_object1.begin(), j_object2.end()), + "[json.exception.invalid_iterator.210] iterators do not fit", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j_object1.insert(j_array.begin(), j_array.end()), + "[json.exception.invalid_iterator.202] iterators first and last must point to objects", + json::invalid_iterator&); } } @@ -704,11 +718,21 @@ TEST_CASE("modifiers") // pass iterator to a different array json j_another_array = {1, 2}; json j_yet_another_array = {"first", "second"}; - CHECK_THROWS_WITH_AS(j_array.insert(j_another_array.end(), 10), "[json.exception.invalid_iterator.202] iterator does not fit current value", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j_array.insert(j_another_array.end(), j_value), "[json.exception.invalid_iterator.202] iterator does not fit current value", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j_array.insert(j_another_array.end(), 10, 11), "[json.exception.invalid_iterator.202] iterator does not fit current value", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j_array.insert(j_another_array.end(), j_yet_another_array.begin(), j_yet_another_array.end()), "[json.exception.invalid_iterator.202] iterator does not fit current value", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j_array.insert(j_another_array.end(), {1, 2, 3, 4}), "[json.exception.invalid_iterator.202] iterator does not fit current value", json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j_array.insert(j_another_array.end(), 10), + "[json.exception.invalid_iterator.202] iterator does not fit current value", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j_array.insert(j_another_array.end(), j_value), + "[json.exception.invalid_iterator.202] iterator does not fit current value", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j_array.insert(j_another_array.end(), 10, 11), + "[json.exception.invalid_iterator.202] iterator does not fit current value", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j_array.insert(j_another_array.end(), j_yet_another_array.begin(), j_yet_another_array.end()), + "[json.exception.invalid_iterator.202] iterator does not fit current value", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j_array.insert(j_another_array.end(), {1, 2, 3, 4}), + "[json.exception.invalid_iterator.202] iterator does not fit current value", + json::invalid_iterator&); } SECTION("non-array type") @@ -717,10 +741,18 @@ TEST_CASE("modifiers") json j_nonarray = 3; json j_yet_another_array = {"first", "second"}; CHECK_THROWS_WITH_AS(j_nonarray.insert(j_nonarray.end(), 10), "[json.exception.type_error.309] cannot use insert() with number", json::type_error&); - CHECK_THROWS_WITH_AS(j_nonarray.insert(j_nonarray.end(), j_value), "[json.exception.type_error.309] cannot use insert() with number", json::type_error&); - CHECK_THROWS_WITH_AS(j_nonarray.insert(j_nonarray.end(), 10, 11), "[json.exception.type_error.309] cannot use insert() with number", json::type_error&); - CHECK_THROWS_WITH_AS(j_nonarray.insert(j_nonarray.end(), j_yet_another_array.begin(), j_yet_another_array.end()), "[json.exception.type_error.309] cannot use insert() with number", json::type_error&); - CHECK_THROWS_WITH_AS(j_nonarray.insert(j_nonarray.end(), {1, 2, 3, 4}), "[json.exception.type_error.309] cannot use insert() with number", json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray.insert(j_nonarray.end(), j_value), + "[json.exception.type_error.309] cannot use insert() with number", + json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray.insert(j_nonarray.end(), 10, 11), + "[json.exception.type_error.309] cannot use insert() with number", + json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray.insert(j_nonarray.end(), j_yet_another_array.begin(), j_yet_another_array.end()), + "[json.exception.type_error.309] cannot use insert() with number", + json::type_error&); + CHECK_THROWS_WITH_AS(j_nonarray.insert(j_nonarray.end(), {1, 2, 3, 4}), + "[json.exception.type_error.309] cannot use insert() with number", + json::type_error&); } } @@ -774,9 +806,15 @@ TEST_CASE("modifiers") { json const j_other_array2 = {"first", "second"}; - CHECK_THROWS_WITH_AS(j_array.update(j_object2.begin(), j_object2.end()), "[json.exception.type_error.312] cannot use update() with array", json::type_error&); - CHECK_THROWS_WITH_AS(j_object1.update(j_object1.begin(), j_object2.end()), "[json.exception.invalid_iterator.210] iterators do not fit", json::invalid_iterator&); - CHECK_THROWS_WITH_AS(j_object1.update(j_array.begin(), j_array.end()), "[json.exception.type_error.312] cannot use update() with array", json::type_error&); + CHECK_THROWS_WITH_AS(j_array.update(j_object2.begin(), j_object2.end()), + "[json.exception.type_error.312] cannot use update() with array", + json::type_error&); + CHECK_THROWS_WITH_AS(j_object1.update(j_object1.begin(), j_object2.end()), + "[json.exception.invalid_iterator.210] iterators do not fit", + json::invalid_iterator&); + CHECK_THROWS_WITH_AS(j_object1.update(j_array.begin(), j_array.end()), + "[json.exception.type_error.312] cannot use update() with array", + json::type_error&); } } } diff --git a/tests/src/unit-msgpack.cpp b/tests/src/unit-msgpack.cpp index d8635a4ed3..7ed17c4f7c 100644 --- a/tests/src/unit-msgpack.cpp +++ b/tests/src/unit-msgpack.cpp @@ -22,7 +22,8 @@ using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) #include #include -namespace { +namespace +{ class SaxCountdown { public: @@ -90,7 +91,9 @@ class SaxCountdown return events_left-- > 0; } - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static) + bool parse_error(std::size_t /*unused*/, + const std::string& /*unused*/, + const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static) { return false; } @@ -168,8 +171,7 @@ TEST_CASE("MessagePack") CHECK(j.is_number_integer()); // create expected byte vector - std::vector const expected{ - static_cast(i)}; + std::vector const expected{static_cast(i)}; // compare result + size const auto result = json::to_msgpack(j); @@ -288,12 +290,7 @@ TEST_CASE("MessagePack") SECTION("65536..4294967295 (int 32)") { - for (uint32_t i : - { - 65536u, - 77777u, - 1048576u, - 4294967295u}) + for (uint32_t i : {65536u, 77777u, 1048576u, 4294967295u}) { CAPTURE(i) @@ -320,10 +317,8 @@ TEST_CASE("MessagePack") // check individual bytes CHECK(result[0] == 0xce); - uint32_t const restored = (static_cast(result[1]) << 030) + - (static_cast(result[2]) << 020) + - (static_cast(result[3]) << 010) + - static_cast(result[4]); + uint32_t const restored = (static_cast(result[1]) << 030) + (static_cast(result[2]) << 020) + + (static_cast(result[3]) << 010) + static_cast(result[4]); CHECK(restored == i); // roundtrip @@ -334,10 +329,7 @@ TEST_CASE("MessagePack") SECTION("4294967296..9223372036854775807 (int 64)") { - for (uint64_t i : - { - 4294967296LU, - 9223372036854775807LU}) + for (uint64_t i : {4294967296LU, 9223372036854775807LU}) { CAPTURE(i) @@ -368,14 +360,10 @@ TEST_CASE("MessagePack") // check individual bytes CHECK(result[0] == 0xcf); - uint64_t const restored = (static_cast(result[1]) << 070) + - (static_cast(result[2]) << 060) + - (static_cast(result[3]) << 050) + - (static_cast(result[4]) << 040) + - (static_cast(result[5]) << 030) + - (static_cast(result[6]) << 020) + - (static_cast(result[7]) << 010) + - static_cast(result[8]); + uint64_t const restored = (static_cast(result[1]) << 070) + (static_cast(result[2]) << 060) + + (static_cast(result[3]) << 050) + (static_cast(result[4]) << 040) + + (static_cast(result[5]) << 030) + (static_cast(result[6]) << 020) + + (static_cast(result[7]) << 010) + static_cast(result[8]); CHECK(restored == i); // roundtrip @@ -503,10 +491,8 @@ TEST_CASE("MessagePack") // check individual bytes CHECK(result[0] == 0xd2); - uint32_t const restored = (static_cast(result[1]) << 030) + - (static_cast(result[2]) << 020) + - (static_cast(result[3]) << 010) + - static_cast(result[4]); + uint32_t const restored = (static_cast(result[1]) << 030) + (static_cast(result[2]) << 020) + + (static_cast(result[3]) << 010) + static_cast(result[4]); CHECK(static_cast(restored) == i); // roundtrip @@ -551,14 +537,10 @@ TEST_CASE("MessagePack") // check individual bytes CHECK(result[0] == 0xd3); - int64_t const restored = (static_cast(result[1]) << 070) + - (static_cast(result[2]) << 060) + - (static_cast(result[3]) << 050) + - (static_cast(result[4]) << 040) + - (static_cast(result[5]) << 030) + - (static_cast(result[6]) << 020) + - (static_cast(result[7]) << 010) + - static_cast(result[8]); + int64_t const restored = (static_cast(result[1]) << 070) + (static_cast(result[2]) << 060) + + (static_cast(result[3]) << 050) + (static_cast(result[4]) << 040) + + (static_cast(result[5]) << 030) + (static_cast(result[6]) << 020) + + (static_cast(result[7]) << 010) + static_cast(result[8]); CHECK(restored == i); // roundtrip @@ -670,12 +652,7 @@ TEST_CASE("MessagePack") SECTION("65536..4294967295 (uint 32)") { - for (const uint32_t i : - { - 65536u, - 77777u, - 1048576u, - 4294967295u}) + for (const uint32_t i : {65536u, 77777u, 1048576u, 4294967295u}) { CAPTURE(i) @@ -701,10 +678,8 @@ TEST_CASE("MessagePack") // check individual bytes CHECK(result[0] == 0xce); - uint32_t const restored = (static_cast(result[1]) << 030) + - (static_cast(result[2]) << 020) + - (static_cast(result[3]) << 010) + - static_cast(result[4]); + uint32_t const restored = (static_cast(result[1]) << 030) + (static_cast(result[2]) << 020) + + (static_cast(result[3]) << 010) + static_cast(result[4]); CHECK(restored == i); // roundtrip @@ -715,10 +690,7 @@ TEST_CASE("MessagePack") SECTION("4294967296..18446744073709551615 (uint 64)") { - for (const uint64_t i : - { - 4294967296LU, - 18446744073709551615LU}) + for (const uint64_t i : {4294967296LU, 18446744073709551615LU}) { CAPTURE(i) @@ -748,14 +720,10 @@ TEST_CASE("MessagePack") // check individual bytes CHECK(result[0] == 0xcf); - uint64_t const restored = (static_cast(result[1]) << 070) + - (static_cast(result[2]) << 060) + - (static_cast(result[3]) << 050) + - (static_cast(result[4]) << 040) + - (static_cast(result[5]) << 030) + - (static_cast(result[6]) << 020) + - (static_cast(result[7]) << 010) + - static_cast(result[8]); + uint64_t const restored = (static_cast(result[1]) << 070) + (static_cast(result[2]) << 060) + + (static_cast(result[3]) << 050) + (static_cast(result[4]) << 040) + + (static_cast(result[5]) << 030) + (static_cast(result[6]) << 020) + + (static_cast(result[7]) << 010) + static_cast(result[8]); CHECK(restored == i); // roundtrip @@ -771,17 +739,7 @@ TEST_CASE("MessagePack") { double const v = 3.1415925; json const j = v; - std::vector const expected = - { - 0xcb, - 0x40, - 0x09, - 0x21, - 0xfb, - 0x3f, - 0xa6, - 0xde, - 0xfc}; + std::vector const expected = {0xcb, 0x40, 0x09, 0x21, 0xfb, 0x3f, 0xa6, 0xde, 0xfc}; const auto result = json::to_msgpack(j); CHECK(result == expected); @@ -795,13 +753,7 @@ TEST_CASE("MessagePack") { double const v = 1.0; json const j = v; - std::vector const expected = - { - 0xca, - 0x3f, - 0x80, - 0x00, - 0x00}; + std::vector const expected = {0xca, 0x3f, 0x80, 0x00, 0x00}; const auto result = json::to_msgpack(j); CHECK(result == expected); @@ -815,13 +767,7 @@ TEST_CASE("MessagePack") { double const v = 128.1280059814453125; json const j = v; - std::vector const expected = - { - 0xca, - 0x43, - 0x00, - 0x20, - 0xc5}; + std::vector const expected = {0xca, 0x43, 0x00, 0x20, 0xc5}; const auto result = json::to_msgpack(j); CHECK(result == expected); @@ -838,40 +784,8 @@ TEST_CASE("MessagePack") SECTION("N = 0..31") { // explicitly enumerate the first byte for all 32 strings - const std::vector first_bytes = - { - 0xa0, - 0xa1, - 0xa2, - 0xa3, - 0xa4, - 0xa5, - 0xa6, - 0xa7, - 0xa8, - 0xa9, - 0xaa, - 0xab, - 0xac, - 0xad, - 0xae, - 0xaf, - 0xb0, - 0xb1, - 0xb2, - 0xb3, - 0xb4, - 0xb5, - 0xb6, - 0xb7, - 0xb8, - 0xb9, - 0xba, - 0xbb, - 0xbc, - 0xbd, - 0xbe, - 0xbf}; + const std::vector first_bytes = {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf}; for (size_t N = 0; N < first_bytes.size(); ++N) { @@ -942,14 +856,7 @@ TEST_CASE("MessagePack") SECTION("N = 256..65535") { - for (size_t N : - { - 256u, - 999u, - 1025u, - 3333u, - 2048u, - 65535u}) + for (size_t N : {256u, 999u, 1025u, 3333u, 2048u, 65535u}) { CAPTURE(N) @@ -979,11 +886,7 @@ TEST_CASE("MessagePack") SECTION("N = 65536..4294967295") { - for (size_t N : - { - 65536u, - 77777u, - 1048576u}) + for (size_t N : {65536u, 77777u, 1048576u}) { CAPTURE(N) @@ -1133,18 +1036,7 @@ TEST_CASE("MessagePack") SECTION("{\"a\": {\"b\": {\"c\": {}}}}") { json const j = json::parse(R"({"a": {"b": {"c": {}}}})"); - std::vector const expected = - { - 0x81, - 0xa1, - 0x61, - 0x81, - 0xa1, - 0x62, - 0x81, - 0xa1, - 0x63, - 0x80}; + std::vector const expected = {0x81, 0xa1, 0x61, 0x81, 0xa1, 0x62, 0x81, 0xa1, 0x63, 0x80}; const auto result = json::to_msgpack(j); CHECK(result == expected); @@ -1285,14 +1177,7 @@ TEST_CASE("MessagePack") SECTION("N = 256..65535") { - for (std::size_t N : - { - 256u, - 999u, - 1025u, - 3333u, - 2048u, - 65535u}) + for (std::size_t N : {256u, 999u, 1025u, 3333u, 2048u, 65535u}) { CAPTURE(N) @@ -1325,11 +1210,7 @@ TEST_CASE("MessagePack") SECTION("N = 65536..4294967295") { - for (std::size_t N : - { - 65536u, - 77777u, - 1048576u}) + for (std::size_t N : {65536u, 77777u, 1048576u}) { CAPTURE(N) @@ -1402,14 +1283,7 @@ TEST_CASE("MessagePack") SECTION("N = 256..65535") { - for (std::size_t N : - { - 256u, - 999u, - 1025u, - 3333u, - 2048u, - 65535u}) + for (std::size_t N : {256u, 999u, 1025u, 3333u, 2048u, 65535u}) { CAPTURE(N) @@ -1439,11 +1313,7 @@ TEST_CASE("MessagePack") SECTION("N = 65536..4294967295") { - for (std::size_t N : - { - 65536u, - 77777u, - 1048576u}) + for (std::size_t N : {65536u, 77777u, 1048576u}) { CAPTURE(N) @@ -1487,7 +1357,10 @@ TEST_CASE("MessagePack") SECTION("empty byte vector") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector()), "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector()), + "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input", + json::parse_error&); CHECK(json::from_msgpack(std::vector(), true, false).is_discarded()); } @@ -1495,66 +1368,86 @@ TEST_CASE("MessagePack") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0x87})), - "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack string: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xcc})), - "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xcd})), - "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xcd, 0x00})), - "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xce})), - "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xce, 0x00})), - "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xce, 0x00, 0x00})), - "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xce, 0x00, 0x00, 0x00})), - "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xcf})), - "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00})), - "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00})), - "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00})), - "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00})), - "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})), - "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), - "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), - "[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing MessagePack number: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xa5, 0x68, 0x65})), - "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack string: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0x92, 0x01})), - "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack value: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0x81, 0xa1, 0x61})), - "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack value: unexpected end of input", - json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xc4, 0x02})), - "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack binary: unexpected end of input", - json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0x87})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack string: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xcc})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xcd})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xcd, 0x00})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xce})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xce, 0x00})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xce, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xce, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xcf})), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xcf, 0x00})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), + "[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xa5, 0x68, 0x65})), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack string: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0x92, 0x01})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack value: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0x81, 0xa1, 0x61})), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack value: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0xc4, 0x02})), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack binary: unexpected end of input", + json::parse_error&); CHECK(json::from_msgpack(std::vector({0x87}), true, false).is_discarded()); CHECK(json::from_msgpack(std::vector({0xcc}), true, false).is_discarded()); @@ -1584,15 +1477,15 @@ TEST_CASE("MessagePack") SECTION("concrete examples") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xc1})), "[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing MessagePack value: invalid byte: 0xC1", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0xc1})), + "[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing MessagePack value: invalid byte: 0xC1", + json::parse_error&); } SECTION("all unsupported bytes") { - for (auto byte : - { - // never used - 0xc1}) + for (auto byte : {// never used + 0xc1}) { json _; CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({static_cast(byte)})), json::parse_error&); @@ -1604,7 +1497,10 @@ TEST_CASE("MessagePack") SECTION("invalid string in map") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector({0x81, 0xff, 0x01})), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing MessagePack string: expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0xFF", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(std::vector({0x81, 0xff, 0x01})), + "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing MessagePack string: expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0xFF", + json::parse_error&); CHECK(json::from_msgpack(std::vector({0x81, 0xff, 0x01}), true, false).is_discarded()); } @@ -1620,7 +1516,10 @@ TEST_CASE("MessagePack") SECTION("strict mode") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(vec), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack value: expected end of input; last byte: 0xC0", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_msgpack(vec), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack value: expected end of input; last byte: 0xC0", + json::parse_error&); CHECK(json::from_msgpack(vec, true, false).is_discarded()); } } @@ -1716,153 +1615,151 @@ TEST_CASE("MessagePack roundtrips" * doctest::skip()) exclude_packed.insert(TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_simple.json"); exclude_packed.insert(TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_string_unicode.json"); - for (std::string filename : - { - TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json", - TEST_DATA_DIRECTORY "/json.org/1.json", - TEST_DATA_DIRECTORY "/json.org/2.json", - TEST_DATA_DIRECTORY "/json.org/3.json", - TEST_DATA_DIRECTORY "/json.org/4.json", - TEST_DATA_DIRECTORY "/json.org/5.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip01.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip02.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip03.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip04.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip05.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip06.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip07.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip08.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip09.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip10.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip11.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip12.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip13.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip14.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip15.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip16.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip17.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip18.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip19.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip20.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip21.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip22.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip23.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip24.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip25.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip26.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip27.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip28.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip29.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip30.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip31.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip32.json", - TEST_DATA_DIRECTORY "/json_testsuite/sample.json", // kills AppVeyor - TEST_DATA_DIRECTORY "/json_tests/pass1.json", - TEST_DATA_DIRECTORY "/json_tests/pass2.json", - TEST_DATA_DIRECTORY "/json_tests/pass3.json", - TEST_DATA_DIRECTORY "/regression/floats.json", - TEST_DATA_DIRECTORY "/regression/signed_ints.json", - TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", - TEST_DATA_DIRECTORY "/regression/working_file.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_arraysWithSpaces.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty-string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_ending_with_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_heterogeneous.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_1_and_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_leading_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_several_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_trailing_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e+1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_after_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_close_to_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_huge_neg_exp.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_huge_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_int_with_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_minus_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_one.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_neg_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_pos_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_fraction_exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_exp.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_overflow.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_exponent.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_overflow.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_underflow.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_real.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_neg_int.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_pos_int.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_very_big_negative_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_basic.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key_and_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_escaped_null_in_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_extreme_numbers.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_long_strings.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_simple.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_string_unicode.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_with_newlines.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_UTF-16_Surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pair.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pairs.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_allowed_escapes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_and_u_escaped_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_doublequotes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_comments.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_a.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_n.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_control_character.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_noncharacter.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array_with_leading_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_last_surrogates_1_and_2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_newline_uescaped.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+1FFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_null_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_one-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_pi.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_simple_ascii.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_three-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_two-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2028_line_sep.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2029_par_sep.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_uEscape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unescaped_char_delete.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicodeEscapedBackslash.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+2064_invisible_plus.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_escaped_double_quote.json", - // TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf16.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_with_del_character.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_negative_real.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_true.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_string_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_trailing_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_true_in_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_whitespace_array.json"}) + for (std::string filename : {TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json", + TEST_DATA_DIRECTORY "/json.org/1.json", + TEST_DATA_DIRECTORY "/json.org/2.json", + TEST_DATA_DIRECTORY "/json.org/3.json", + TEST_DATA_DIRECTORY "/json.org/4.json", + TEST_DATA_DIRECTORY "/json.org/5.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip01.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip02.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip03.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip04.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip05.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip06.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip07.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip08.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip09.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip10.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip11.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip12.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip13.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip14.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip15.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip16.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip17.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip18.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip19.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip20.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip21.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip22.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip23.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip24.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip25.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip26.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip27.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip28.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip29.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip30.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip31.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip32.json", + TEST_DATA_DIRECTORY "/json_testsuite/sample.json", // kills AppVeyor + TEST_DATA_DIRECTORY "/json_tests/pass1.json", + TEST_DATA_DIRECTORY "/json_tests/pass2.json", + TEST_DATA_DIRECTORY "/json_tests/pass3.json", + TEST_DATA_DIRECTORY "/regression/floats.json", + TEST_DATA_DIRECTORY "/regression/signed_ints.json", + TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", + TEST_DATA_DIRECTORY "/regression/working_file.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_arraysWithSpaces.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty-string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_ending_with_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_heterogeneous.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_1_and_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_leading_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_several_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_trailing_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e+1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_after_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_close_to_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_huge_neg_exp.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_huge_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_int_with_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_minus_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_one.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_neg_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_pos_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_fraction_exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_exp.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_overflow.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_exponent.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_overflow.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_underflow.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_real.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_neg_int.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_pos_int.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_very_big_negative_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_basic.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key_and_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_escaped_null_in_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_extreme_numbers.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_long_strings.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_simple.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_string_unicode.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_with_newlines.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_UTF-16_Surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pair.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pairs.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_allowed_escapes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_and_u_escaped_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_doublequotes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_comments.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_a.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_n.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_control_character.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_noncharacter.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array_with_leading_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_last_surrogates_1_and_2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_newline_uescaped.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+1FFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_null_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_one-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_pi.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_simple_ascii.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_three-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_two-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2028_line_sep.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2029_par_sep.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_uEscape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unescaped_char_delete.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicodeEscapedBackslash.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+2064_invisible_plus.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_escaped_double_quote.json", + // TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf16.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_with_del_character.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_negative_real.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_true.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_string_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_trailing_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_true_in_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_whitespace_array.json"}) { CAPTURE(filename) diff --git a/tests/src/unit-no-mem-leak-on-adl-serialize.cpp b/tests/src/unit-no-mem-leak-on-adl-serialize.cpp index 3ca8b659c7..24d6018eda 100644 --- a/tests/src/unit-no-mem-leak-on-adl-serialize.cpp +++ b/tests/src/unit-no-mem-leak-on-adl-serialize.cpp @@ -18,7 +18,8 @@ struct Foo int b; }; -namespace nlohmann { +namespace nlohmann +{ template<> struct adl_serializer { diff --git a/tests/src/unit-noexcept.cpp b/tests/src/unit-noexcept.cpp index 7aa213fe81..666748e8a2 100644 --- a/tests/src/unit-noexcept.cpp +++ b/tests/src/unit-noexcept.cpp @@ -16,7 +16,8 @@ DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept") using nlohmann::json; -namespace { +namespace +{ enum test { }; diff --git a/tests/src/unit-readme.cpp b/tests/src/unit-readme.cpp index d30a0af9ea..810cdff58a 100644 --- a/tests/src/unit-readme.cpp +++ b/tests/src/unit-readme.cpp @@ -61,15 +61,13 @@ TEST_CASE("README" * doctest::skip()) j["object"] = {{"currency", "USD"}, {"value", 42.99}}; // instead, you could also write (which looks very similar to the JSON above) - json const j2 = - { - {"pi", 3.141}, - {"happy", true}, - {"name", "Niels"}, - {"nothing", nullptr}, - {"answer", {{"everything", 42}}}, - {"list", {1, 0, 2}}, - {"object", {{"currency", "USD"}, {"value", 42.99}}}}; + json const j2 = {{"pi", 3.141}, + {"happy", true}, + {"name", "Niels"}, + {"nothing", nullptr}, + {"answer", {{"everything", 42}}}, + {"list", {1, 0, 2}}, + {"object", {{"currency", "USD"}, {"value", 42.99}}}}; } { diff --git a/tests/src/unit-reference_access.cpp b/tests/src/unit-reference_access.cpp index 024bc363e7..e2738a122f 100644 --- a/tests/src/unit-reference_access.cpp +++ b/tests/src/unit-reference_access.cpp @@ -14,13 +14,11 @@ using nlohmann::json; TEST_CASE("reference access") { // create a JSON value with different types - const json json_types = - { - {"boolean", true}, - {"number", {{"integer", 42}, {"floating-point", 17.23}}}, - {"string", "Hello, world!"}, - {"array", {1, 2, 3, 4, 5}}, - {"null", nullptr}}; + const json json_types = {{"boolean", true}, + {"number", {{"integer", 42}, {"floating-point", 17.23}}}, + {"string", "Hello, world!"}, + {"array", {1, 2, 3, 4, 5}}, + {"null", nullptr}}; SECTION("reference access to object_t") { @@ -246,7 +244,9 @@ TEST_CASE("reference access") //CHECK_THROWS_WITH_AS(value.get_ref(), // "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&); CHECK_NOTHROW(value.get_ref()); - CHECK_THROWS_WITH_AS(value.get_ref(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&); + CHECK_THROWS_WITH_AS(value.get_ref(), + "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", + json::type_error&); } SECTION("reference access to number_float_t") @@ -264,12 +264,24 @@ TEST_CASE("reference access") CHECK(p2 == value.get()); // check if mismatching references throw correctly - CHECK_THROWS_WITH_AS(value.get_ref(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&); - CHECK_THROWS_WITH_AS(value.get_ref(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&); - CHECK_THROWS_WITH_AS(value.get_ref(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&); - CHECK_THROWS_WITH_AS(value.get_ref(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&); - CHECK_THROWS_WITH_AS(value.get_ref(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&); - CHECK_THROWS_WITH_AS(value.get_ref(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&); + CHECK_THROWS_WITH_AS(value.get_ref(), + "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", + json::type_error&); + CHECK_THROWS_WITH_AS(value.get_ref(), + "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", + json::type_error&); + CHECK_THROWS_WITH_AS(value.get_ref(), + "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", + json::type_error&); + CHECK_THROWS_WITH_AS(value.get_ref(), + "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", + json::type_error&); + CHECK_THROWS_WITH_AS(value.get_ref(), + "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", + json::type_error&); + CHECK_THROWS_WITH_AS(value.get_ref(), + "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", + json::type_error&); CHECK_NOTHROW(value.get_ref()); } } diff --git a/tests/src/unit-regression1.cpp b/tests/src/unit-regression1.cpp index a7a515df30..286a18ea86 100644 --- a/tests/src/unit-regression1.cpp +++ b/tests/src/unit-regression1.cpp @@ -43,7 +43,8 @@ using my_json = nlohmann::basic_json; // for #977 ///////////////////////////////////////////////////////////////////// -namespace ns { +namespace ns +{ struct foo { int x; @@ -83,13 +84,15 @@ struct foo_serializer::value>:: }; } // namespace ns -using foo_json = nlohmann::basic_json>; +using foo_json = nlohmann:: + basic_json>; ///////////////////////////////////////////////////////////////////// // for #805 ///////////////////////////////////////////////////////////////////// -namespace { +namespace +{ struct nocopy // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) { nocopy() = default; @@ -187,8 +190,7 @@ TEST_CASE("regression tests 1") static_assert(std::is_same::value, "types must be the same"); - j.push_back(json::object( - {{"game_type", t}})); + j.push_back(json::object({{"game_type", t}})); } SECTION("issue #76 - dump() / parse() not idempotent") @@ -248,8 +250,7 @@ TEST_CASE("regression tests 1") SECTION("issue #89 - nonstandard integer type") { // create JSON class with nonstandard integer number type - using custom_json = - nlohmann::basic_json; + using custom_json = nlohmann::basic_json; custom_json j; j["int_1"] = 1; CHECK(j["int_1"] == 1); @@ -314,11 +315,7 @@ TEST_CASE("regression tests 1") SECTION("issue #100 - failed to iterator json object with reverse_iterator") { - json config = - { - {"111", 111}, - {"112", 112}, - {"113", 113}}; + json config = {{"111", 111}, {"112", 112}, {"113", 113}}; std::stringstream ss; @@ -464,13 +461,11 @@ TEST_CASE("regression tests 1") // create JSON class with nonstandard float number type // float - nlohmann::basic_json const j_float = - 1.23e25f; + nlohmann::basic_json const j_float = 1.23e25f; CHECK(j_float.get() == 1.23e25f); // double - nlohmann::basic_json const j_double = - 1.23e35; + nlohmann::basic_json const j_double = 1.23e35; CHECK(j_double.get() == 1.23e35); // long double @@ -592,10 +587,9 @@ TEST_CASE("regression tests 1") SECTION("issue #283 - value() does not work with _json_pointer types") { - json j = - { - {"object", {{"key1", 1}, {"key2", 2}}}, - }; + json j = { + {"object", {{"key1", 1}, {"key2", 2}}}, + }; int at_integer{j.at("/object/key2"_json_pointer)}; int val_integer = j.value("/object/key2"_json_pointer, 0); @@ -614,10 +608,7 @@ TEST_CASE("regression tests 1") SECTION("issue #306 - Parsing fails without space at end of file") { - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/regression/broken_file.json", - TEST_DATA_DIRECTORY "/regression/working_file.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/regression/broken_file.json", TEST_DATA_DIRECTORY "/regression/working_file.json"}) { CAPTURE(filename) json j; @@ -628,12 +619,10 @@ TEST_CASE("regression tests 1") SECTION("issue #310 - make json_benchmarks no longer working in 2.0.4") { - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/regression/floats.json", - TEST_DATA_DIRECTORY "/regression/signed_ints.json", - TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", - TEST_DATA_DIRECTORY "/regression/small_signed_ints.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/regression/floats.json", + TEST_DATA_DIRECTORY "/regression/signed_ints.json", + TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", + TEST_DATA_DIRECTORY "/regression/small_signed_ints.json"}) { CAPTURE(filename) json j; @@ -716,7 +705,10 @@ TEST_CASE("regression tests 1") { std::ifstream f("file_not_found.json"); json _; - CHECK_THROWS_WITH_AS(_ = json::parse(f), "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse(f), + "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", + json::parse_error&); } SECTION("issue #367 - calling stream at EOF") @@ -730,7 +722,10 @@ TEST_CASE("regression tests 1") // ss is not at EOF; this yielded an error before the fix // (threw basic_string::append). No, it should just throw // a parse error because of the EOF. - CHECK_THROWS_WITH_AS(ss >> j, "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", json::parse_error&); + CHECK_THROWS_WITH_AS( + ss >> j, + "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", + json::parse_error&); } SECTION("issue #367 - behavior of operator>> should more closely resemble that of built-in overloads") @@ -739,7 +734,10 @@ TEST_CASE("regression tests 1") { std::stringstream ss; json j; - CHECK_THROWS_WITH_AS(ss >> j, "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", json::parse_error&); + CHECK_THROWS_WITH_AS( + ss >> j, + "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", + json::parse_error&); } SECTION("(whitespace)") @@ -747,9 +745,10 @@ TEST_CASE("regression tests 1") std::stringstream ss; ss << " "; json j; - CHECK_THROWS_WITH_AS(ss >> j, - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", - json::parse_error&); + CHECK_THROWS_WITH_AS( + ss >> j, + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", + json::parse_error&); } SECTION("one value") @@ -760,7 +759,10 @@ TEST_CASE("regression tests 1") CHECK_NOTHROW(ss >> j); CHECK(j == 111); - CHECK_THROWS_WITH_AS(ss >> j, "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", json::parse_error&); + CHECK_THROWS_WITH_AS( + ss >> j, + "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", + json::parse_error&); } SECTION("one value + whitespace") @@ -771,9 +773,10 @@ TEST_CASE("regression tests 1") CHECK_NOTHROW(ss >> j); CHECK(j == 222); - CHECK_THROWS_WITH_AS(ss >> j, - "[json.exception.parse_error.101] parse error at line 2, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", - json::parse_error&); + CHECK_THROWS_WITH_AS( + ss >> j, + "[json.exception.parse_error.101] parse error at line 2, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", + json::parse_error&); } SECTION("whitespace + one value") @@ -784,7 +787,10 @@ TEST_CASE("regression tests 1") CHECK_NOTHROW(ss >> j); CHECK(j == 333); - CHECK_THROWS_WITH_AS(ss >> j, "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", json::parse_error&); + CHECK_THROWS_WITH_AS( + ss >> j, + "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", + json::parse_error&); } SECTION("three values") @@ -799,7 +805,10 @@ TEST_CASE("regression tests 1") CHECK_NOTHROW(ss >> j); CHECK(j == 333); - CHECK_THROWS_WITH_AS(ss >> j, "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", json::parse_error&); + CHECK_THROWS_WITH_AS( + ss >> j, + "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", + json::parse_error&); } SECTION("literals without whitespace") @@ -816,7 +825,10 @@ TEST_CASE("regression tests 1") CHECK_NOTHROW(ss >> j); CHECK(j == ""); - CHECK_THROWS_WITH_AS(ss >> j, "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", json::parse_error&); + CHECK_THROWS_WITH_AS( + ss >> j, + "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", + json::parse_error&); } SECTION("example from #529") @@ -829,7 +841,10 @@ TEST_CASE("regression tests 1") CHECK_NOTHROW(ss >> j); CHECK(j == json({{"three", 3}})); - CHECK_THROWS_WITH_AS(ss >> j, "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", json::parse_error&); + CHECK_THROWS_WITH_AS( + ss >> j, + "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", + json::parse_error&); } SECTION("second example from #529") @@ -898,7 +913,9 @@ TEST_CASE("regression tests 1") // original test case std::vector const vec{0x65, 0xf5, 0x0a, 0x48, 0x21}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing CBOR string: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec), + "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing CBOR string: unexpected end of input", + json::parse_error&); } SECTION("issue #407 - Heap-buffer-overflow (OSS-Fuzz issue 343)") @@ -907,23 +924,33 @@ TEST_CASE("regression tests 1") // original test case: incomplete float64 std::vector const vec1{0xcb, 0x8f, 0x0a}; - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(vec1), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_msgpack(vec1), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); // related test case: incomplete float32 std::vector const vec2{0xca, 0x8f, 0x0a}; - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(vec2), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_msgpack(vec2), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input", + json::parse_error&); // related test case: incomplete Half-Precision Float (CBOR) std::vector const vec3{0xf9, 0x8f}; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec3), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec3), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); // related test case: incomplete Single-Precision Float (CBOR) std::vector const vec4{0xfa, 0x8f, 0x0a}; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec4), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec4), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); // related test case: incomplete Double-Precision Float (CBOR) std::vector const vec5{0xfb, 0x8f, 0x0a}; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec5), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec5), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input", + json::parse_error&); } SECTION("issue #408 - Heap-buffer-overflow (OSS-Fuzz issue 344)") @@ -932,148 +959,30 @@ TEST_CASE("regression tests 1") // original test case std::vector const vec1{0x87}; - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(vec1), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack string: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_msgpack(vec1), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack string: unexpected end of input", + json::parse_error&); // more test cases for MessagePack - for (auto b : - { - 0x81, - 0x82, - 0x83, - 0x84, - 0x85, - 0x86, - 0x87, - 0x88, - 0x89, - 0x8a, - 0x8b, - 0x8c, - 0x8d, - 0x8e, - 0x8f, // fixmap - 0x91, - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9a, - 0x9b, - 0x9c, - 0x9d, - 0x9e, - 0x9f, // fixarray - 0xa1, - 0xa2, - 0xa3, - 0xa4, - 0xa5, - 0xa6, - 0xa7, - 0xa8, - 0xa9, - 0xaa, - 0xab, - 0xac, - 0xad, - 0xae, - 0xaf, // fixstr - 0xb0, - 0xb1, - 0xb2, - 0xb3, - 0xb4, - 0xb5, - 0xb6, - 0xb7, - 0xb8, - 0xb9, - 0xba, - 0xbb, - 0xbc, - 0xbd, - 0xbe, - 0xbf}) + for (auto b : {0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, + 0x8f, // fixmap + 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, + 0x9f, // fixarray + 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, + 0xaf, // fixstr + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf}) { std::vector const vec(1, static_cast(b)); CHECK_THROWS_AS(_ = json::from_msgpack(vec), json::parse_error&); } // more test cases for CBOR - for (auto b : - { - 0x61, - 0x62, - 0x63, - 0x64, - 0x65, - 0x66, - 0x67, - 0x68, - 0x69, - 0x6a, - 0x6b, - 0x6c, - 0x6d, - 0x6e, - 0x6f, - 0x70, - 0x71, - 0x72, - 0x73, - 0x74, - 0x75, - 0x76, + for (auto b : { + 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, // UTF-8 string - 0x81, - 0x82, - 0x83, - 0x84, - 0x85, - 0x86, - 0x87, - 0x88, - 0x89, - 0x8a, - 0x8b, - 0x8c, - 0x8d, - 0x8e, - 0x8f, - 0x90, - 0x91, - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, + 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, // array - 0xa1, - 0xa2, - 0xa3, - 0xa4, - 0xa5, - 0xa6, - 0xa7, - 0xa8, - 0xa9, - 0xaa, - 0xab, - 0xac, - 0xad, - 0xae, - 0xaf, - 0xb0, - 0xb1, - 0xb2, - 0xb3, - 0xb4, - 0xb5, - 0xb6, + 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7 // map }) { @@ -1083,8 +992,12 @@ TEST_CASE("regression tests 1") // special case: empty input std::vector const vec2; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec2), "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing CBOR value: unexpected end of input", json::parse_error&); - CHECK_THROWS_WITH_AS(_ = json::from_msgpack(vec2), "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec2), + "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing CBOR value: unexpected end of input", + json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_msgpack(vec2), + "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input", + json::parse_error&); } SECTION("issue #411 - Heap-buffer-overflow (OSS-Fuzz issue 366)") @@ -1093,180 +1006,65 @@ TEST_CASE("regression tests 1") // original test case: empty UTF-8 string (indefinite length) std::vector const vec1{0x7f}; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec1), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec1), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input", + json::parse_error&); // related test case: empty array (indefinite length) std::vector const vec2{0x9f}; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec2), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec2), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR value: unexpected end of input", + json::parse_error&); // related test case: empty map (indefinite length) std::vector const vec3{0xbf}; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec3), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec3), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input", + json::parse_error&); } SECTION("issue #412 - Heap-buffer-overflow (OSS-Fuzz issue 367)") { // original test case - std::vector const vec{ - 0xab, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x00, - 0x00, - 0x00, - 0x60, - 0xab, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x98, - 0x00, - 0x00, - 0x00, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0xa0, - 0x9f, - 0x9f, - 0x97, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60, - 0x60}; + std::vector const vec{0xab, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x00, 0x00, 0x00, 0x60, 0xab, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0xa0, 0x9f, 0x9f, 0x97, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x98", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_cbor(vec), + "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x98", + json::parse_error&); // related test case: nonempty UTF-8 string (indefinite length) std::vector const vec1{0x7f, 0x61, 0x61}; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec1), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR string: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec1), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR string: unexpected end of input", + json::parse_error&); // related test case: nonempty array (indefinite length) std::vector const vec2{0x9f, 0x01}; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec2), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec2), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input", + json::parse_error&); // related test case: nonempty map (indefinite length) std::vector const vec3{0xbf, 0x61, 0x61, 0x01}; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec3), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR string: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec3), + "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR string: unexpected end of input", + json::parse_error&); } SECTION("issue #414 - compare with literal 0)") { -#define CHECK_TYPE(v) \ - CHECK((json(v) == (v))); \ - CHECK(((v) == json(v))); \ - CHECK_FALSE((json(v) != (v))); \ +#define CHECK_TYPE(v) \ + CHECK((json(v) == (v))); \ + CHECK(((v) == json(v))); \ + CHECK_FALSE((json(v) != (v))); \ CHECK_FALSE(((v) != json(v))); CHECK_TYPE(nullptr) @@ -1282,110 +1080,24 @@ TEST_CASE("regression tests 1") SECTION("issue #416 - Use-of-uninitialized-value (OSS-Fuzz issue 377)") { // original test case - std::vector const vec1{ - 0x94, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0x3a, - 0x96, - 0x96, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0x71, - 0xb4, - 0xb4, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0x3a, - 0x96, - 0x96, - 0xb4, - 0xb4, - 0xfa, - 0x94, - 0x94, - 0x61, - 0x61, - 0x61, - 0x61, - 0x61, - 0x61, - 0x61, - 0x61, - 0xfa}; + std::vector const vec1{0x94, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0x3a, 0x96, 0x96, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, + 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0x71, 0xb4, 0xb4, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0x3a, + 0x96, 0x96, 0xb4, 0xb4, 0xfa, 0x94, 0x94, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xfa}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec1), "[json.exception.parse_error.113] parse error at byte 13: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xB4", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_cbor(vec1), + "[json.exception.parse_error.113] parse error at byte 13: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xB4", + json::parse_error&); // related test case: double-precision - std::vector const vec2{ - 0x94, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0x3a, - 0x96, - 0x96, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0xb4, - 0x71, - 0xb4, - 0xb4, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0xfa, - 0x3a, - 0x96, - 0x96, - 0xb4, - 0xb4, - 0xfa, - 0x94, - 0x94, - 0x61, - 0x61, - 0x61, - 0x61, - 0x61, - 0x61, - 0x61, - 0x61, - 0xfb}; - CHECK_THROWS_WITH_AS(_ = json::from_cbor(vec2), "[json.exception.parse_error.113] parse error at byte 13: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xB4", json::parse_error&); + std::vector const vec2{0x94, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0x3a, 0x96, 0x96, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, + 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0x71, 0xb4, 0xb4, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0x3a, + 0x96, 0x96, 0xb4, 0xb4, 0xfa, 0x94, 0x94, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xfb}; + CHECK_THROWS_WITH_AS( + _ = json::from_cbor(vec2), + "[json.exception.parse_error.113] parse error at byte 13: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xB4", + json::parse_error&); } SECTION("issue #452 - Heap-buffer-overflow (OSS-Fuzz issue 585)") @@ -1636,8 +1348,8 @@ TEST_CASE("regression tests 1") { { std::ifstream is; - is.exceptions( - is.exceptions() | std::ios_base::failbit | std::ios_base::badbit); // handle different exceptions as 'file not found', 'permission denied' + is.exceptions(is.exceptions() | std::ios_base::failbit | + std::ios_base::badbit); // handle different exceptions as 'file not found', 'permission denied' is.open(TEST_DATA_DIRECTORY "/regression/working_file.json"); json _; @@ -1646,11 +1358,10 @@ TEST_CASE("regression tests 1") { std::ifstream is; - is.exceptions( - is.exceptions() | std::ios_base::failbit | std::ios_base::badbit); // handle different exceptions as 'file not found', 'permission denied' + is.exceptions(is.exceptions() | std::ios_base::failbit | + std::ios_base::badbit); // handle different exceptions as 'file not found', 'permission denied' - is.open(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json.cbor", - std::ios_base::in | std::ios_base::binary); + is.open(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json.cbor", std::ios_base::in | std::ios_base::binary); json _; CHECK_NOTHROW(_ = nlohmann::json::from_cbor(is)); } @@ -1666,7 +1377,8 @@ TEST_CASE("regression tests 1") SECTION("issue #838 - incorrect parse error with binary data in keys") { - std::array key1 = {{103, 92, 117, 48, 48, 48, 55, 92, 114, 215, 126, 214, 95, 92, 34, 174, 40, 71, 38, 174, 40, 71, 38, 223, 134, 247, 127, 0}}; + std::array key1 = { + {103, 92, 117, 48, 48, 48, 55, 92, 114, 215, 126, 214, 95, 92, 34, 174, 40, 71, 38, 174, 40, 71, 38, 223, 134, 247, 127, 0}}; std::string const key1_str(reinterpret_cast(key1.data())); json const j = key1_str; CHECK_THROWS_WITH_AS(j.dump(), "[json.exception.type_error.316] invalid UTF-8 byte at index 10: 0x7E", json::type_error&); @@ -1696,33 +1408,17 @@ TEST_CASE("regression tests 1") auto p1 = R"([{"op": "move", "from": "/one/two/three", "path": "/a/b/c"}])"_json; - CHECK_THROWS_WITH_AS(model.patch(p1), - "[json.exception.out_of_range.403] key 'a' not found", - json::out_of_range&); + CHECK_THROWS_WITH_AS(model.patch(p1), "[json.exception.out_of_range.403] key 'a' not found", json::out_of_range&); auto p2 = R"([{"op": "copy", "from": "/one/two/three", "path": "/a/b/c"}])"_json; - CHECK_THROWS_WITH_AS(model.patch(p2), - "[json.exception.out_of_range.403] key 'a' not found", - json::out_of_range&); + CHECK_THROWS_WITH_AS(model.patch(p2), "[json.exception.out_of_range.403] key 'a' not found", json::out_of_range&); } SECTION("issue #961 - incorrect parsing of indefinite length CBOR strings") { - std::vector const v_cbor = - { - 0x7F, - 0x64, - 'a', - 'b', - 'c', - 'd', - 0x63, - '1', - '2', - '3', - 0xFF}; + std::vector const v_cbor = {0x7F, 0x64, 'a', 'b', 'c', 'd', 0x63, '1', '2', '3', 0xFF}; json j = json::from_cbor(v_cbor); CHECK(j == "abcd123"); } diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index 9f345a5af5..d2b43bdd5b 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -55,7 +55,8 @@ using float_json = nlohmann::basic_json struct adl_serializer { @@ -144,7 +146,8 @@ struct NonDefaultConstructible int x; }; -namespace nlohmann { +namespace nlohmann +{ template<> struct adl_serializer { @@ -429,16 +432,10 @@ TEST_CASE("regression tests 2") using it_type = decltype(p1.begin()); - std::set_difference( - p1.begin(), - p1.end(), - p2.begin(), - p2.end(), - std::inserter(diffs, diffs.end()), - [&](const it_type& e1, const it_type& e2) -> bool { - using comper_pair = std::pair; // Trying to avoid unneeded copy - return comper_pair(e1.key(), e1.value()) < comper_pair(e2.key(), e2.value()); // Using pair comper - }); + std::set_difference(p1.begin(), p1.end(), p2.begin(), p2.end(), std::inserter(diffs, diffs.end()), [&](const it_type& e1, const it_type& e2) -> bool { + using comper_pair = std::pair; // Trying to avoid unneeded copy + return comper_pair(e1.key(), e1.value()) < comper_pair(e2.key(), e2.value()); // Using pair comper + }); CHECK(diffs.size() == 1); // Note the change here, was 2 } @@ -453,12 +450,11 @@ TEST_CASE("regression tests 2") SECTION("issue #1299 - compile error in from_json converting to container " "with std::pair") { - const json j = - { - {"1", {{"a", "testa_1"}, {"b", "testb_1"}}}, - {"2", {{"a", "testa_2"}, {"b", "testb_2"}}}, - {"3", {{"a", "testa_3"}, {"b", "testb_3"}}}, - }; + const json j = { + {"1", {{"a", "testa_1"}, {"b", "testb_1"}}}, + {"2", {{"a", "testa_2"}, {"b", "testb_2"}}}, + {"3", {{"a", "testa_3"}, {"b", "testb_3"}}}, + }; std::map expected{ {"1", {"testa_1", "testb_1"}}, @@ -508,9 +504,11 @@ TEST_CASE("regression tests 2") SECTION("test case in issue #1445") { nlohmann::json dump_test; - const std::array data = - { - {109, 108, 103, 125, -122, -53, 115, 18, 3, 0, 102, 19, 1, 15, -110, 13, -3, -1, -81, 32, 2, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -80, 2, 0, 0, 96, -118, 46, -116, 46, 109, -84, -87, 108, 14, 109, -24, -83, 13, -18, -51, -83, -52, -115, 14, 6, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 3, 0, 0, 0, 35, -74, -73, 55, 57, -128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, -96, -54, -28, -26}}; + const std::array data = {{109, 108, 103, 125, -122, -53, 115, 18, 3, 0, 102, 19, 1, 15, -110, 13, -3, -1, -81, 32, 2, 0, + 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -80, 2, 0, 0, + 96, -118, 46, -116, 46, 109, -84, -87, 108, 14, 109, -24, -83, 13, -18, -51, -83, -52, -115, 14, 6, 32, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 3, 0, 0, 0, 35, -74, -73, 55, 57, -128, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, -96, -54, -28, -26}}; std::string s; for (const int i : data) { @@ -607,14 +605,14 @@ TEST_CASE("regression tests 2") SECTION("issue #2067 - cannot serialize binary data to text JSON") { - const std::array data = {{0x81, 0xA4, 0x64, 0x61, 0x74, 0x61, 0xC4, 0x0F, 0x33, 0x30, 0x30, 0x32, 0x33, 0x34, 0x30, 0x31, 0x30, 0x37, 0x30, 0x35, 0x30, 0x31, 0x30}}; + const std::array data = { + {0x81, 0xA4, 0x64, 0x61, 0x74, 0x61, 0xC4, 0x0F, 0x33, 0x30, 0x30, 0x32, 0x33, 0x34, 0x30, 0x31, 0x30, 0x37, 0x30, 0x35, 0x30, 0x31, 0x30}}; const json j = json::from_msgpack(data.data(), data.size()); - CHECK_NOTHROW( - j.dump(4, // Indent - ' ', // Indent char - false, // Ensure ascii - json::error_handler_t::strict // Error - )); + CHECK_NOTHROW(j.dump(4, // Indent + ' ', // Indent char + false, // Ensure ascii + json::error_handler_t::strict // Error + )); } SECTION("PR #2181 - regression bug with lvalue") @@ -628,18 +626,7 @@ TEST_CASE("regression tests 2") SECTION("issue #2293 - eof doesn't cause parsing to stop") { - const std::vector data = - { - 0x7B, - 0x6F, - 0x62, - 0x6A, - 0x65, - 0x63, - 0x74, - 0x20, - 0x4F, - 0x42}; + const std::vector data = {0x7B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x20, 0x4F, 0x42}; const json result = json::from_cbor(data, true, false); CHECK(result.is_discarded()); } @@ -654,8 +641,7 @@ TEST_CASE("regression tests 2") auto jsonAnimals_parsed = nlohmann::ordered_json::parse(jsonAnimals.dump()); CHECK(jsonAnimals == jsonAnimals_parsed); - const std::vector> intData = {std::make_pair("aaaa", 11), - std::make_pair("bbb", 222)}; + const std::vector> intData = {std::make_pair("aaaa", 11), std::make_pair("bbb", 222)}; nlohmann::ordered_json jsonObj; for (const auto& data : intData) { @@ -785,7 +771,8 @@ TEST_CASE("regression tests 2") sax_no_exception sax(j); CHECK(!json::sax_parse("xyz", &sax)); - CHECK(*sax_no_exception::error_string == "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: 'x'"); + CHECK(*sax_no_exception::error_string == + "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: 'x'"); delete sax_no_exception::error_string; // NOLINT(cppcoreguidelines-owning-memory) } @@ -856,9 +843,11 @@ TEST_CASE("regression tests 2") CHECK(j.dump() == "[1,2,4]"); - j.erase(std::remove_if(j.begin(), j.end(), [](const ordered_json& val) { - return val == 2; - }), + j.erase(std::remove_if(j.begin(), + j.end(), + [](const ordered_json& val) { + return val == 2; + }), j.end()); CHECK(j.dump() == "[1,4]"); @@ -924,9 +913,7 @@ TEST_CASE("regression tests 2") SECTION("issue #3333 - Ambiguous conversion from nlohmann::basic_json<> to custom class") { - const json j{ - {"x", 1}, - {"y", 2}}; + const json j{{"x", 1}, {"y", 2}}; for_3333 p = j; CHECK(p.x == 1); diff --git a/tests/src/unit-serialization.cpp b/tests/src/unit-serialization.cpp index 17fc733754..0a2b67cc4d 100644 --- a/tests/src/unit-serialization.cpp +++ b/tests/src/unit-serialization.cpp @@ -31,8 +31,7 @@ TEST_CASE("serialization") std::stringstream ss; const json j = {"foo", 1, 2, 3, false, {{"one", 1}}}; ss << std::setw(4) << j; - CHECK(ss.str() == - "[\n \"foo\",\n 1,\n 2,\n 3,\n false,\n {\n \"one\": 1\n }\n]"); + CHECK(ss.str() == "[\n \"foo\",\n 1,\n 2,\n 3,\n false,\n {\n \"one\": 1\n }\n]"); } SECTION("given fill") @@ -40,8 +39,7 @@ TEST_CASE("serialization") std::stringstream ss; const json j = {"foo", 1, 2, 3, false, {{"one", 1}}}; ss << std::setw(1) << std::setfill('\t') << j; - CHECK(ss.str() == - "[\n\t\"foo\",\n\t1,\n\t2,\n\t3,\n\tfalse,\n\t{\n\t\t\"one\": 1\n\t}\n]"); + CHECK(ss.str() == "[\n\t\"foo\",\n\t1,\n\t2,\n\t3,\n\tfalse,\n\t{\n\t\t\"one\": 1\n\t}\n]"); } } @@ -61,8 +59,7 @@ TEST_CASE("serialization") const json j = {"foo", 1, 2, 3, false, {{"one", 1}}}; ss.width(4); j >> ss; - CHECK(ss.str() == - "[\n \"foo\",\n 1,\n 2,\n 3,\n false,\n {\n \"one\": 1\n }\n]"); + CHECK(ss.str() == "[\n \"foo\",\n 1,\n 2,\n 3,\n false,\n {\n \"one\": 1\n }\n]"); } SECTION("given fill") @@ -72,8 +69,7 @@ TEST_CASE("serialization") ss.width(1); ss.fill('\t'); j >> ss; - CHECK(ss.str() == - "[\n\t\"foo\",\n\t1,\n\t2,\n\t3,\n\tfalse,\n\t{\n\t\t\"one\": 1\n\t}\n]"); + CHECK(ss.str() == "[\n\t\"foo\",\n\t1,\n\t2,\n\t3,\n\tfalse,\n\t{\n\t\t\"one\": 1\n\t}\n]"); } } @@ -84,7 +80,9 @@ TEST_CASE("serialization") const json j = "ä\xA9ü"; CHECK_THROWS_WITH_AS(j.dump(), "[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9", json::type_error&); - CHECK_THROWS_WITH_AS(j.dump(1, ' ', false, json::error_handler_t::strict), "[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9", json::type_error&); + CHECK_THROWS_WITH_AS(j.dump(1, ' ', false, json::error_handler_t::strict), + "[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9", + json::type_error&); CHECK(j.dump(-1, ' ', false, json::error_handler_t::ignore) == "\"äü\""); CHECK(j.dump(-1, ' ', false, json::error_handler_t::replace) == "\"ä\xEF\xBF\xBDü\""); CHECK(j.dump(-1, ' ', true, json::error_handler_t::replace) == "\"\\u00e4\\ufffd\\u00fc\""); @@ -124,78 +122,96 @@ TEST_CASE("serialization") }; test("\xC2", "\\ufffd"); - test("\xC2\x41\x42", "\\ufffd" - "\x41" - "\x42"); - test("\xC2\xF4", "\\ufffd" - "\\ufffd"); - - test("\xF0\x80\x80\x41", "\\ufffd" - "\\ufffd" - "\\ufffd" - "\x41"); - test("\xF1\x80\x80\x41", "\\ufffd" - "\x41"); - test("\xF2\x80\x80\x41", "\\ufffd" - "\x41"); - test("\xF3\x80\x80\x41", "\\ufffd" - "\x41"); - test("\xF4\x80\x80\x41", "\\ufffd" - "\x41"); - test("\xF5\x80\x80\x41", "\\ufffd" - "\\ufffd" - "\\ufffd" - "\x41"); - - test("\xF0\x90\x80\x41", "\\ufffd" - "\x41"); - test("\xF1\x90\x80\x41", "\\ufffd" - "\x41"); - test("\xF2\x90\x80\x41", "\\ufffd" - "\x41"); - test("\xF3\x90\x80\x41", "\\ufffd" - "\x41"); - test("\xF4\x90\x80\x41", "\\ufffd" - "\\ufffd" - "\\ufffd" - "\x41"); - test("\xF5\x90\x80\x41", "\\ufffd" - "\\ufffd" - "\\ufffd" - "\x41"); - - test("\xC0\xAF\xE0\x80\xBF\xF0\x81\x82\x41", "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\x41"); - test("\xED\xA0\x80\xED\xBF\xBF\xED\xAF\x41", "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\x41"); - test("\xF4\x91\x92\x93\xFF\x41\x80\xBF\x42", "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\x41" - "\\ufffd" - "\\ufffd" - "\x42"); - test("\xE1\x80\xE2\xF0\x91\x92\xF1\xBF\x41", "\\ufffd" - "\\ufffd" - "\\ufffd" - "\\ufffd" - "\x41"); + test("\xC2\x41\x42", + "\\ufffd" + "\x41" + "\x42"); + test("\xC2\xF4", + "\\ufffd" + "\\ufffd"); + + test("\xF0\x80\x80\x41", + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\x41"); + test("\xF1\x80\x80\x41", + "\\ufffd" + "\x41"); + test("\xF2\x80\x80\x41", + "\\ufffd" + "\x41"); + test("\xF3\x80\x80\x41", + "\\ufffd" + "\x41"); + test("\xF4\x80\x80\x41", + "\\ufffd" + "\x41"); + test("\xF5\x80\x80\x41", + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\x41"); + + test("\xF0\x90\x80\x41", + "\\ufffd" + "\x41"); + test("\xF1\x90\x80\x41", + "\\ufffd" + "\x41"); + test("\xF2\x90\x80\x41", + "\\ufffd" + "\x41"); + test("\xF3\x90\x80\x41", + "\\ufffd" + "\x41"); + test("\xF4\x90\x80\x41", + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\x41"); + test("\xF5\x90\x80\x41", + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\x41"); + + test("\xC0\xAF\xE0\x80\xBF\xF0\x81\x82\x41", + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\x41"); + test("\xED\xA0\x80\xED\xBF\xBF\xED\xAF\x41", + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\x41"); + test("\xF4\x91\x92\x93\xFF\x41\x80\xBF\x42", + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\x41" + "\\ufffd" + "\\ufffd" + "\x42"); + test("\xE1\x80\xE2\xF0\x91\x92\xF1\xBF\x41", + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\\ufffd" + "\x41"); } } diff --git a/tests/src/unit-testsuites.cpp b/tests/src/unit-testsuites.cpp index ddd9032c13..33c8253665 100644 --- a/tests/src/unit-testsuites.cpp +++ b/tests/src/unit-testsuites.cpp @@ -20,41 +20,39 @@ TEST_CASE("compliance tests from json.org") SECTION("expected failures") { - for (const auto* filename : - { - //TEST_DATA_DIRECTORY "/json_tests/fail1.json", - TEST_DATA_DIRECTORY "/json_tests/fail2.json", - TEST_DATA_DIRECTORY "/json_tests/fail3.json", - TEST_DATA_DIRECTORY "/json_tests/fail4.json", - TEST_DATA_DIRECTORY "/json_tests/fail5.json", - TEST_DATA_DIRECTORY "/json_tests/fail6.json", - TEST_DATA_DIRECTORY "/json_tests/fail7.json", - TEST_DATA_DIRECTORY "/json_tests/fail8.json", - TEST_DATA_DIRECTORY "/json_tests/fail9.json", - TEST_DATA_DIRECTORY "/json_tests/fail10.json", - TEST_DATA_DIRECTORY "/json_tests/fail11.json", - TEST_DATA_DIRECTORY "/json_tests/fail12.json", - TEST_DATA_DIRECTORY "/json_tests/fail13.json", - TEST_DATA_DIRECTORY "/json_tests/fail14.json", - TEST_DATA_DIRECTORY "/json_tests/fail15.json", - TEST_DATA_DIRECTORY "/json_tests/fail16.json", - TEST_DATA_DIRECTORY "/json_tests/fail17.json", - //TEST_DATA_DIRECTORY "/json_tests/fail18.json", - TEST_DATA_DIRECTORY "/json_tests/fail19.json", - TEST_DATA_DIRECTORY "/json_tests/fail20.json", - TEST_DATA_DIRECTORY "/json_tests/fail21.json", - TEST_DATA_DIRECTORY "/json_tests/fail22.json", - TEST_DATA_DIRECTORY "/json_tests/fail23.json", - TEST_DATA_DIRECTORY "/json_tests/fail24.json", - TEST_DATA_DIRECTORY "/json_tests/fail25.json", - TEST_DATA_DIRECTORY "/json_tests/fail26.json", - TEST_DATA_DIRECTORY "/json_tests/fail27.json", - TEST_DATA_DIRECTORY "/json_tests/fail28.json", - TEST_DATA_DIRECTORY "/json_tests/fail29.json", - TEST_DATA_DIRECTORY "/json_tests/fail30.json", - TEST_DATA_DIRECTORY "/json_tests/fail31.json", - TEST_DATA_DIRECTORY "/json_tests/fail32.json", - TEST_DATA_DIRECTORY "/json_tests/fail33.json"}) + for (const auto* filename : {//TEST_DATA_DIRECTORY "/json_tests/fail1.json", + TEST_DATA_DIRECTORY "/json_tests/fail2.json", + TEST_DATA_DIRECTORY "/json_tests/fail3.json", + TEST_DATA_DIRECTORY "/json_tests/fail4.json", + TEST_DATA_DIRECTORY "/json_tests/fail5.json", + TEST_DATA_DIRECTORY "/json_tests/fail6.json", + TEST_DATA_DIRECTORY "/json_tests/fail7.json", + TEST_DATA_DIRECTORY "/json_tests/fail8.json", + TEST_DATA_DIRECTORY "/json_tests/fail9.json", + TEST_DATA_DIRECTORY "/json_tests/fail10.json", + TEST_DATA_DIRECTORY "/json_tests/fail11.json", + TEST_DATA_DIRECTORY "/json_tests/fail12.json", + TEST_DATA_DIRECTORY "/json_tests/fail13.json", + TEST_DATA_DIRECTORY "/json_tests/fail14.json", + TEST_DATA_DIRECTORY "/json_tests/fail15.json", + TEST_DATA_DIRECTORY "/json_tests/fail16.json", + TEST_DATA_DIRECTORY "/json_tests/fail17.json", + //TEST_DATA_DIRECTORY "/json_tests/fail18.json", + TEST_DATA_DIRECTORY "/json_tests/fail19.json", + TEST_DATA_DIRECTORY "/json_tests/fail20.json", + TEST_DATA_DIRECTORY "/json_tests/fail21.json", + TEST_DATA_DIRECTORY "/json_tests/fail22.json", + TEST_DATA_DIRECTORY "/json_tests/fail23.json", + TEST_DATA_DIRECTORY "/json_tests/fail24.json", + TEST_DATA_DIRECTORY "/json_tests/fail25.json", + TEST_DATA_DIRECTORY "/json_tests/fail26.json", + TEST_DATA_DIRECTORY "/json_tests/fail27.json", + TEST_DATA_DIRECTORY "/json_tests/fail28.json", + TEST_DATA_DIRECTORY "/json_tests/fail29.json", + TEST_DATA_DIRECTORY "/json_tests/fail30.json", + TEST_DATA_DIRECTORY "/json_tests/fail31.json", + TEST_DATA_DIRECTORY "/json_tests/fail32.json", + TEST_DATA_DIRECTORY "/json_tests/fail33.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -68,8 +66,7 @@ TEST_CASE("compliance tests from json.org") // these tests fail above, because the parser does not end on EOF; // they succeed when the operator>> is used, because it does not // have this constraint - for (const auto* filename : - { + for (const auto* filename : { TEST_DATA_DIRECTORY "/json_tests/fail7.json", TEST_DATA_DIRECTORY "/json_tests/fail8.json", TEST_DATA_DIRECTORY "/json_tests/fail10.json", @@ -85,10 +82,7 @@ TEST_CASE("compliance tests from json.org") SECTION("expected passes") { for (const auto* filename : - { - TEST_DATA_DIRECTORY "/json_tests/pass1.json", - TEST_DATA_DIRECTORY "/json_tests/pass2.json", - TEST_DATA_DIRECTORY "/json_tests/pass3.json"}) + {TEST_DATA_DIRECTORY "/json_tests/pass1.json", TEST_DATA_DIRECTORY "/json_tests/pass2.json", TEST_DATA_DIRECTORY "/json_tests/pass3.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -144,8 +138,7 @@ TEST_CASE("compliance tests from nativejson-benchmark") 0.9868011474609375); // https://github.com/miloyip/rapidjson/issues/120 TEST_DOUBLE("[123e34]", 123e34); // Fast Path Cases In Disguise TEST_DOUBLE("[45913141877270640000.0]", 45913141877270640000.0); - TEST_DOUBLE("[2.2250738585072011e-308]", - 2.2250738585072011e-308); + TEST_DOUBLE("[2.2250738585072011e-308]", 2.2250738585072011e-308); //TEST_DOUBLE("[1e-00011111111111]", 0.0); //TEST_DOUBLE("[-1e-00011111111111]", -0.0); TEST_DOUBLE("[1e-214748363]", 0.0); @@ -157,15 +150,12 @@ TEST_CASE("compliance tests from nativejson-benchmark") // abs((2^-1022 - 2^-1074) - 2.2250738585072012e-308) = 3.109754131239141401123495768877590405345064751974375599... ¡Á 10^-324 // abs((2^-1022) - 2.2250738585072012e-308) = 1.830902327173324040642192159804623318305533274168872044... ¡Á 10 ^ -324 // So 2.2250738585072012e-308 should round to 2^-1022 = 2.2250738585072014e-308 - TEST_DOUBLE("[2.2250738585072012e-308]", - 2.2250738585072014e-308); + TEST_DOUBLE("[2.2250738585072012e-308]", 2.2250738585072014e-308); // More closer to normal/subnormal boundary // boundary = 2^-1022 - 2^-1075 = 2.225073858507201136057409796709131975934819546351645648... ¡Á 10^-308 - TEST_DOUBLE("[2.22507385850720113605740979670913197593481954635164564e-308]", - 2.2250738585072009e-308); - TEST_DOUBLE("[2.22507385850720113605740979670913197593481954635164565e-308]", - 2.2250738585072014e-308); + TEST_DOUBLE("[2.22507385850720113605740979670913197593481954635164564e-308]", 2.2250738585072009e-308); + TEST_DOUBLE("[2.22507385850720113605740979670913197593481954635164565e-308]", 2.2250738585072014e-308); // 1.0 is in (1.0 - 2^-54, 1.0 + 2^-53) // 1.0 - 2^-54 = 0.999999999999999944488848768742172978818416595458984375 @@ -199,16 +189,11 @@ TEST_CASE("compliance tests from nativejson-benchmark") TEST_DOUBLE("[1014120480182583464902367222169599999e-5]", 10141204801825834086073718800384.0); TEST_DOUBLE("[1014120480182583464902367222169600001e-5]", 10141204801825835211973625643008.0); - TEST_DOUBLE("[5708990770823838890407843763683279797179383808]", - 5708990770823838890407843763683279797179383808.0); - TEST_DOUBLE("[5708990770823839524233143877797980545530986496]", - 5708990770823839524233143877797980545530986496.0); - TEST_DOUBLE("[5708990770823839207320493820740630171355185152]", - 5708990770823839524233143877797980545530986496.0); - TEST_DOUBLE("[5708990770823839207320493820740630171355185151999e-3]", - 5708990770823838890407843763683279797179383808.0); - TEST_DOUBLE("[5708990770823839207320493820740630171355185152001e-3]", - 5708990770823839524233143877797980545530986496.0); + TEST_DOUBLE("[5708990770823838890407843763683279797179383808]", 5708990770823838890407843763683279797179383808.0); + TEST_DOUBLE("[5708990770823839524233143877797980545530986496]", 5708990770823839524233143877797980545530986496.0); + TEST_DOUBLE("[5708990770823839207320493820740630171355185152]", 5708990770823839524233143877797980545530986496.0); + TEST_DOUBLE("[5708990770823839207320493820740630171355185151999e-3]", 5708990770823838890407843763683279797179383808.0); + TEST_DOUBLE("[5708990770823839207320493820740630171355185152001e-3]", 5708990770823839524233143877797980545530986496.0); { std::string n1e308(312, '0'); // '1' followed by 308 '0' @@ -220,17 +205,16 @@ TEST_CASE("compliance tests from nativejson-benchmark") } // Cover trimming - TEST_DOUBLE( - "[2.22507385850720113605740979670913197593481954635164564802342610972482222202107694551652952390813508" - "7914149158913039621106870086438694594645527657207407820621743379988141063267329253552286881372149012" - "9811224514518898490572223072852551331557550159143974763979834118019993239625482890171070818506906306" - "6665599493827577257201576306269066333264756530000924588831643303777979186961204949739037782970490505" - "1080609940730262937128958950003583799967207254304360284078895771796150945516748243471030702609144621" - "5722898802581825451803257070188608721131280795122334262883686223215037756666225039825343359745688844" - "2390026549819838548794829220689472168983109969836584681402285424333066033985088644580400103493397042" - "7567186443383770486037861622771738545623065874679014086723327636718751234567890123456789012345678901" - "e-308]", - 2.2250738585072014e-308); + TEST_DOUBLE("[2.22507385850720113605740979670913197593481954635164564802342610972482222202107694551652952390813508" + "7914149158913039621106870086438694594645527657207407820621743379988141063267329253552286881372149012" + "9811224514518898490572223072852551331557550159143974763979834118019993239625482890171070818506906306" + "6665599493827577257201576306269066333264756530000924588831643303777979186961204949739037782970490505" + "1080609940730262937128958950003583799967207254304360284078895771796150945516748243471030702609144621" + "5722898802581825451803257070188608721131280795122334262883686223215037756666225039825343359745688844" + "2390026549819838548794829220689472168983109969836584681402285424333066033985088644580400103493397042" + "7567186443383770486037861622771738545623065874679014086723327636718751234567890123456789012345678901" + "e-308]", + 2.2250738585072014e-308); } SECTION("strings") @@ -256,8 +240,7 @@ TEST_CASE("compliance tests from nativejson-benchmark") { // test cases are from https://github.com/miloyip/nativejson-benchmark/tree/master/test/data/roundtrip - for (const auto* filename : - { + for (const auto* filename : { TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip01.json", TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip02.json", TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip03.json", @@ -294,8 +277,7 @@ TEST_CASE("compliance tests from nativejson-benchmark") { CAPTURE(filename) std::ifstream f(filename); - std::string json_string((std::istreambuf_iterator(f)), - (std::istreambuf_iterator())); + std::string json_string((std::istreambuf_iterator(f)), (std::istreambuf_iterator())); CAPTURE(json_string) const json j = json::parse(json_string); @@ -471,104 +453,102 @@ TEST_CASE("nst's JSONTestSuite") { SECTION("y") { - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_arraysWithSpaces.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty-string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_ending_with_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_heterogeneous.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_1_and_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_leading_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_several_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_trailing_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e+1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_after_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_close_to_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_huge_neg_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_int_with_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_minus_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_one.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_neg_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_pos_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_fraction_exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_underflow.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_real.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_neg_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_pos_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_very_big_negative_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_basic.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key_and_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_escaped_null_in_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_extreme_numbers.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_long_strings.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_simple.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_string_unicode.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_with_newlines.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_UTF-16_Surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pair.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pairs.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_allowed_escapes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_and_u_escaped_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_doublequotes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_comments.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_a.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_n.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_control_character.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_noncharacter.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array_with_leading_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_last_surrogates_1_and_2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_newline_uescaped.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+1FFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_null_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_one-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_pi.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_simple_ascii.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_three-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_two-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2028_line_sep.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2029_par_sep.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_uEscape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unescaped_char_delete.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicodeEscapedBackslash.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+2064_invisible_plus.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_escaped_double_quote.json", - // TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf16.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_with_del_character.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_negative_real.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_true.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_string_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_trailing_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_true_in_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_whitespace_array.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_arraysWithSpaces.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty-string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_ending_with_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_heterogeneous.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_1_and_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_leading_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_several_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_array_with_trailing_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e+1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_0e1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_after_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_close_to_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_double_huge_neg_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_int_with_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_minus_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_one.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_negative_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_neg_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_capital_e_pos_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_fraction_exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_underflow.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_simple_real.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_neg_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_too_big_pos_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_very_big_negative_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_basic.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_duplicated_key_and_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_empty_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_escaped_null_in_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_extreme_numbers.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_long_strings.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_simple.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_string_unicode.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_object_with_newlines.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_UTF-16_Surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pair.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_accepted_surrogate_pairs.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_allowed_escapes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_and_u_escaped_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_backslash_doublequotes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_comments.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_a.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_double_escape_n.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_control_character.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_escaped_noncharacter.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_in_array_with_leading_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_last_surrogates_1_and_2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_newline_uescaped.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+1FFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_null_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_one-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_pi.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_simple_ascii.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_three-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_two-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2028_line_sep.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_u+2029_par_sep.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_uEscape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unescaped_char_delete.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicodeEscapedBackslash.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_U+2064_invisible_plus.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_unicode_escaped_double_quote.json", + // TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf16.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_utf8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_string_with_del_character.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_negative_real.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_lonely_true.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_string_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_trailing_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_true_in_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_structure_whitespace_array.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -579,203 +559,201 @@ TEST_CASE("nst's JSONTestSuite") SECTION("n") { - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_1_true_without_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_a_invalid_utf8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_colon_instead_of_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_comma_after_close.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_comma_and_number.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_double_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_double_extra_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_extra_close.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_extra_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_incomplete.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_incomplete_invalid_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_inner_array_no_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_invalid_utf8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_items_separated_by_semicolon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_just_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_just_minus.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_missing_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_newlines_unclosed.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_number_and_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_number_and_several_commas.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_spaces_vertical_tab_formfeed.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_star_inside.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed_trailing_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed_with_new_lines.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed_with_object_inside.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_incomplete_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_incomplete_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_incomplete_true.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_++.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_+1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_+Inf.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-01.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-1.0..json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-2..json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-NaN.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_.-1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_.2e-3.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.1.2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.3e+.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.3e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.e1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0_capital_E+.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0_capital_E.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0e+.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1.0e+.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1.0e-.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1.0e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1_000.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1eE2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_2.e+3.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_2.e-3.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_2.e3.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_9.e+.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_Inf.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_NaN.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_U+FF11_fullwidth_digit_one.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_expression.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_hex_1_digit.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_hex_2_digits.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_infinity.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid+-.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-negative-real.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-utf-8-in-bigger-int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-utf-8-in-exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-utf-8-in-int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_minus_infinity.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_minus_sign_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_minus_space_1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_neg_int_starting_with_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_neg_real_without_int_part.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_neg_with_garbage_at_end.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_real_garbage_after_e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_real_with_invalid_utf8_after_e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_real_without_fractional_part.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_starting_with_dot.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_then_00.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_with_alpha.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_with_alpha_char.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_with_leading_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_bad_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_bracket_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_comma_instead_of_colon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_double_colon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_emoji.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_garbage_at_end.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_key_with_single_quotes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_colon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_semicolon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_no-colon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_non_string_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_non_string_key_but_huge_number_instead.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_pi_in_key_and_trailing_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_repeated_null_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_several_trailing_commas.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_single_quote.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_open.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open_incomplete.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_two_commas_in_a_row.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_unquoted_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_unterminated-value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_with_single_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_single_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape u.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape u1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape u1x.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_UTF-16_incomplete_surrogate.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_UTF8_surrogate_U+D800.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_accentuated_char_no_quotes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_backslash_00.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escape_x.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escaped_backslash_bad.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escaped_ctrl_char_tab.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escaped_emoji.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_incomplete_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_incomplete_escaped_character.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_incomplete_surrogate_escape_invalid.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid-utf-8-in-escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_backslash_esc.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_unicode_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_utf8_after_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_iso_latin_1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_leading_uescaped_thinspace.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_lone_utf8_continuation_byte.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_no_quotes_with_bad_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_overlong_sequence_2_bytes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_overlong_sequence_6_bytes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_overlong_sequence_6_bytes_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_single_doublequote.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_single_quote.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_single_string_no_double_quotes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_start_escape_unclosed.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unescaped_crtl_char.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unescaped_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unescaped_tab.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unicode_CapitalU.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_with_trailing_garbage.json", - //!TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_100000_opening_arrays.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_3C.3E.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_3Cnull3E.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_U+2060_word_joined.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_UTF8_BOM_no_data.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_with_extra_array_close.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_with_unclosed_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_ascii-unicode-identifier.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_capitalized_True.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_close_unopened_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_comma_instead_of_closing_brace.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_double_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_end_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_incomplete_UTF8_BOM.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_lone-invalid-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_lone-open-bracket.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_no_data.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_null-byte-outside-string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_number_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_followed_by_closing_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_unclosed_no_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_with_comment.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_apostrophe.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_comma.json", - //!TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_open_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_open_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_close_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_open_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_open_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_string_with_apostrophes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_open.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_single_point.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_single_star.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_trailing_#.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_uescaped_LF_before_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array_partial_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array_unfinished_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array_unfinished_true.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unicode-identifier.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_whitespace_U+2060_word_joiner.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_whitespace_formfeed.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_1_true_without_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_a_invalid_utf8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_colon_instead_of_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_comma_after_close.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_comma_and_number.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_double_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_double_extra_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_extra_close.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_extra_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_incomplete.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_incomplete_invalid_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_inner_array_no_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_invalid_utf8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_items_separated_by_semicolon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_just_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_just_minus.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_missing_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_newlines_unclosed.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_number_and_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_number_and_several_commas.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_spaces_vertical_tab_formfeed.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_star_inside.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed_trailing_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed_with_new_lines.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_unclosed_with_object_inside.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_incomplete_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_incomplete_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_incomplete_true.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_++.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_+1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_+Inf.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-01.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-1.0..json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-2..json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_-NaN.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_.-1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_.2e-3.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.1.2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.3e+.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.3e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0.e1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0_capital_E+.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0_capital_E.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0e+.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_0e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1.0e+.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1.0e-.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1.0e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1_000.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_1eE2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_2.e+3.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_2.e-3.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_2.e3.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_9.e+.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_Inf.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_NaN.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_U+FF11_fullwidth_digit_one.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_expression.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_hex_1_digit.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_hex_2_digits.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_infinity.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid+-.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-negative-real.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-utf-8-in-bigger-int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-utf-8-in-exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_invalid-utf-8-in-int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_minus_infinity.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_minus_sign_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_minus_space_1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_neg_int_starting_with_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_neg_real_without_int_part.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_neg_with_garbage_at_end.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_real_garbage_after_e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_real_with_invalid_utf8_after_e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_real_without_fractional_part.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_starting_with_dot.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_then_00.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_with_alpha.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_with_alpha_char.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_number_with_leading_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_bad_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_bracket_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_comma_instead_of_colon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_double_colon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_emoji.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_garbage_at_end.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_key_with_single_quotes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_colon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_semicolon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_missing_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_no-colon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_non_string_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_non_string_key_but_huge_number_instead.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_pi_in_key_and_trailing_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_repeated_null_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_several_trailing_commas.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_single_quote.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_open.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open_incomplete.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_two_commas_in_a_row.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_unquoted_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_unterminated-value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_with_single_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_single_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape u.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape u1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape u1x.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_1_surrogate_then_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_UTF-16_incomplete_surrogate.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_UTF8_surrogate_U+D800.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_accentuated_char_no_quotes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_backslash_00.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escape_x.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escaped_backslash_bad.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escaped_ctrl_char_tab.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_escaped_emoji.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_incomplete_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_incomplete_escaped_character.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_incomplete_surrogate_escape_invalid.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid-utf-8-in-escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_backslash_esc.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_unicode_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_invalid_utf8_after_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_iso_latin_1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_leading_uescaped_thinspace.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_lone_utf8_continuation_byte.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_no_quotes_with_bad_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_overlong_sequence_2_bytes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_overlong_sequence_6_bytes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_overlong_sequence_6_bytes_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_single_doublequote.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_single_quote.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_single_string_no_double_quotes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_start_escape_unclosed.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unescaped_crtl_char.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unescaped_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unescaped_tab.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_unicode_CapitalU.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_with_trailing_garbage.json", + //!TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_100000_opening_arrays.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_3C.3E.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_3Cnull3E.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_U+2060_word_joined.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_UTF8_BOM_no_data.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_with_extra_array_close.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_with_unclosed_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_ascii-unicode-identifier.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_capitalized_True.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_close_unopened_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_comma_instead_of_closing_brace.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_double_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_end_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_incomplete_UTF8_BOM.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_lone-invalid-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_lone-open-bracket.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_no_data.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_null-byte-outside-string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_number_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_followed_by_closing_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_unclosed_no_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_with_comment.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_apostrophe.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_comma.json", + //!TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_open_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_open_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_array_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_close_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_open_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_open_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_object_string_with_apostrophes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_open_open.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_single_point.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_single_star.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_trailing_#.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_uescaped_LF_before_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array_partial_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array_unfinished_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_array_unfinished_true.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unclosed_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_unicode-identifier.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_whitespace_U+2060_word_joiner.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_whitespace_formfeed.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -789,24 +767,22 @@ TEST_CASE("nst's JSONTestSuite") // these tests fail above, because the parser does not end on EOF; // they succeed when the operator>> is used, because it does not // have this constraint - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_comma_after_close.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_extra_close.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_open.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open_incomplete.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_with_extra_array_close.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_close_unopened_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_double_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_number_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_followed_by_closing_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_trailing_#.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_comma_after_close.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_array_extra_close.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_open.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_trailing_comment_slash_open_incomplete.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_object_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_string_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_array_with_extra_array_close.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_close_unopened_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_double_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_number_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_followed_by_closing_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_object_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/n_structure_trailing_#.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -817,17 +793,15 @@ TEST_CASE("nst's JSONTestSuite") SECTION("i -> y") { - for (const auto* filename : - { - // we do not pose a limit on nesting - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_structure_500_nested_arrays.json", - // we silently ignore BOMs - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_structure_UTF-8_BOM_empty_object.json", - // we accept and forward non-characters - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+10FFFE_nonchar.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+1FFFE_nonchar.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+FDD0_nonchar.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+FFFE_nonchar.json"}) + for (const auto* filename : {// we do not pose a limit on nesting + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_structure_500_nested_arrays.json", + // we silently ignore BOMs + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_structure_UTF-8_BOM_empty_object.json", + // we accept and forward non-characters + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+10FFFE_nonchar.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+1FFFE_nonchar.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+FDD0_nonchar.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_unicode_U+FFFE_nonchar.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -839,13 +813,11 @@ TEST_CASE("nst's JSONTestSuite") // numbers that overflow during parsing SECTION("i/y -> n (out of range)") { - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_number_neg_int_huge_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_number_pos_double_huge_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_huge_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_overflow.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_overflow.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_number_neg_int_huge_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_number_pos_double_huge_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_huge_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_neg_overflow.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/y_number_real_pos_overflow.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -856,21 +828,19 @@ TEST_CASE("nst's JSONTestSuite") SECTION("i -> n") { - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_object_key_lone_2nd_surrogate.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_1st_surrogate_but_2nd_missing.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_1st_valid_surrogate_2nd_invalid.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_UTF-16_invalid_lonely_surrogate.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_UTF-16_invalid_surrogate.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_UTF-8_invalid_sequence.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_incomplete_surrogate_and_escape_valid.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_incomplete_surrogate_pair.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_incomplete_surrogates_escape_valid.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_inverted_surrogates_U+1D11E.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_lone_second_surrogate.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_not_in_unicode_range.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_truncated-utf-8.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_object_key_lone_2nd_surrogate.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_1st_surrogate_but_2nd_missing.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_1st_valid_surrogate_2nd_invalid.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_UTF-16_invalid_lonely_surrogate.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_UTF-16_invalid_surrogate.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_UTF-8_invalid_sequence.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_incomplete_surrogate_and_escape_valid.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_incomplete_surrogate_pair.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_incomplete_surrogates_escape_valid.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_inverted_surrogates_U+1D11E.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_lone_second_surrogate.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_not_in_unicode_range.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite/test_parsing/i_string_truncated-utf-8.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -887,103 +857,101 @@ TEST_CASE("nst's JSONTestSuite (2)") { SECTION("y") { - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_arraysWithSpaces.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_empty-string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_ending_with_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_heterogeneous.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_1_and_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_leading_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_several_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_trailing_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_0e+1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_0e1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_after_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_double_close_to_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_int_with_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_minus_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_negative_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_negative_one.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_negative_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_capital_e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_capital_e_neg_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_capital_e_pos_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_fraction_exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_neg_exp.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_pos_exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_simple_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_simple_real.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_basic.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_duplicated_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_duplicated_key_and_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_empty_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_escaped_null_in_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_extreme_numbers.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_long_strings.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_simple.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_string_unicode.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_with_newlines.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_accepted_surrogate_pair.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_accepted_surrogate_pairs.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_allowed_escapes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_backslash_and_u_escaped_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_backslash_doublequotes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_comments.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_double_escape_a.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_double_escape_n.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_escaped_control_character.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_escaped_noncharacter.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_in_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_in_array_with_leading_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_last_surrogates_1_and_2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_nbsp_uescaped.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_null_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_one-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_pi.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_reservedCharacterInUTF-8_U+1BFFF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_simple_ascii.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_three-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_two-byte-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_u+2028_line_sep.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_u+2029_par_sep.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_uEscape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_uescaped_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unescaped_char_delete.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicodeEscapedBackslash.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+10FFFE_nonchar.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+1FFFE_nonchar.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+2064_invisible_plus.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+FDD0_nonchar.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+FFFE_nonchar.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_escaped_double_quote.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_utf8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_with_del_character.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_negative_real.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_true.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_string_empty.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_trailing_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_true_in_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_whitespace_array.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_arraysWithSpaces.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_empty-string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_ending_with_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_heterogeneous.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_1_and_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_leading_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_several_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_array_with_trailing_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_0e+1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_0e1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_after_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_double_close_to_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_int_with_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_minus_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_negative_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_negative_one.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_negative_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_capital_e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_capital_e_neg_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_capital_e_pos_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_fraction_exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_neg_exp.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_real_pos_exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_simple_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_number_simple_real.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_basic.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_duplicated_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_duplicated_key_and_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_empty_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_escaped_null_in_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_extreme_numbers.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_long_strings.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_simple.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_string_unicode.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_object_with_newlines.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_accepted_surrogate_pair.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_accepted_surrogate_pairs.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_allowed_escapes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_backslash_and_u_escaped_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_backslash_doublequotes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_comments.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_double_escape_a.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_double_escape_n.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_escaped_control_character.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_escaped_noncharacter.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_in_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_in_array_with_leading_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_last_surrogates_1_and_2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_nbsp_uescaped.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_null_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_one-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_pi.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_reservedCharacterInUTF-8_U+1BFFF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_simple_ascii.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_three-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_two-byte-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_u+2028_line_sep.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_u+2029_par_sep.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_uEscape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_uescaped_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unescaped_char_delete.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicodeEscapedBackslash.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+10FFFE_nonchar.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+1FFFE_nonchar.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+2064_invisible_plus.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+FDD0_nonchar.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_U+FFFE_nonchar.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_unicode_escaped_double_quote.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_utf8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_string_with_del_character.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_negative_real.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_lonely_true.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_string_empty.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_trailing_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_true_in_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/y_structure_whitespace_array.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -996,194 +964,192 @@ TEST_CASE("nst's JSONTestSuite (2)") SECTION("n") { - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_1_true_without_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_a_invalid_utf8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_colon_instead_of_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_comma_after_close.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_comma_and_number.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_double_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_double_extra_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_extra_close.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_extra_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_incomplete.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_incomplete_invalid_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_inner_array_no_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_invalid_utf8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_items_separated_by_semicolon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_just_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_just_minus.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_missing_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_newlines_unclosed.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_number_and_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_number_and_several_commas.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_spaces_vertical_tab_formfeed.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_star_inside.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed_trailing_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed_with_new_lines.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed_with_object_inside.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_incomplete_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_incomplete_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_incomplete_true.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_multidigit_number_then_00.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_++.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_+1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_+Inf.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-01.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-1.0..json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-2..json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-NaN.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_.-1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_.2e-3.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.1.2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.3e+.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.3e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.e1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0_capital_E+.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0_capital_E.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0e+.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1.0e+.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1.0e-.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1.0e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1_000.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1eE2.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_2.e+3.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_2.e-3.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_2.e3.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_9.e+.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_Inf.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_NaN.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_U+FF11_fullwidth_digit_one.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_expression.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_hex_1_digit.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_hex_2_digits.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_infinity.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid+-.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-negative-real.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-utf-8-in-bigger-int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-utf-8-in-exponent.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-utf-8-in-int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_minus_infinity.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_minus_sign_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_minus_space_1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_neg_int_starting_with_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_neg_real_without_int_part.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_neg_with_garbage_at_end.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_real_garbage_after_e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_real_with_invalid_utf8_after_e.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_real_without_fractional_part.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_starting_with_dot.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_with_alpha.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_with_alpha_char.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_with_leading_zero.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_bad_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_bracket_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_comma_instead_of_colon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_double_colon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_emoji.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_garbage_at_end.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_key_with_single_quotes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_lone_continuation_byte_in_key_and_trailing_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_colon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_semicolon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_no-colon.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_non_string_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_non_string_key_but_huge_number_instead.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_repeated_null_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_several_trailing_commas.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_single_quote.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment_open.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment_slash_open.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment_slash_open_incomplete.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_two_commas_in_a_row.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_unquoted_key.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_unterminated-value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_with_single_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_single_space.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape_u.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape_u1.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape_u1x.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_accentuated_char_no_quotes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_backslash_00.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escape_x.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escaped_backslash_bad.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escaped_ctrl_char_tab.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escaped_emoji.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_escaped_character.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_surrogate.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_surrogate_escape_invalid.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid-utf-8-in-escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid_backslash_esc.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid_unicode_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid_utf8_after_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_leading_uescaped_thinspace.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_no_quotes_with_bad_escape.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_single_doublequote.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_single_quote.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_single_string_no_double_quotes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_start_escape_unclosed.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unescaped_crtl_char.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unescaped_newline.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unescaped_tab.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unicode_CapitalU.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_U+2060_word_joined.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_UTF8_BOM_no_data.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_angle_bracket_..json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_angle_bracket_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_array_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_array_with_extra_array_close.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_array_with_unclosed_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_ascii-unicode-identifier.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_capitalized_True.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_close_unopened_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_comma_instead_of_closing_brace.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_double_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_end_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_incomplete_UTF8_BOM.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_lone-invalid-utf-8.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_lone-open-bracket.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_no_data.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_null-byte-outside-string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_number_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_followed_by_closing_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_unclosed_no_value.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_with_comment.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_with_trailing_garbage.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_apostrophe.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_open_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_open_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_close_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_comma.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_open_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_open_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_string_with_apostrophes.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_open.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_single_eacute.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_single_star.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_trailing_#.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_uescaped_LF_before_string.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array_partial_null.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array_unfinished_false.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array_unfinished_true.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_object.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unicode-identifier.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_whitespace_U+2060_word_joiner.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_whitespace_formfeed.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_1_true_without_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_a_invalid_utf8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_colon_instead_of_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_comma_after_close.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_comma_and_number.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_double_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_double_extra_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_extra_close.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_extra_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_incomplete.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_incomplete_invalid_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_inner_array_no_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_invalid_utf8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_items_separated_by_semicolon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_just_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_just_minus.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_missing_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_newlines_unclosed.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_number_and_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_number_and_several_commas.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_spaces_vertical_tab_formfeed.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_star_inside.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed_trailing_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed_with_new_lines.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_array_unclosed_with_object_inside.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_incomplete_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_incomplete_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_incomplete_true.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_multidigit_number_then_00.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_++.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_+1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_+Inf.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-01.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-1.0..json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-2..json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_-NaN.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_.-1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_.2e-3.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.1.2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.3e+.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.3e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0.e1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0_capital_E+.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0_capital_E.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0e+.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_0e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1.0e+.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1.0e-.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1.0e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1_000.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_1eE2.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_2.e+3.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_2.e-3.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_2.e3.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_9.e+.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_Inf.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_NaN.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_U+FF11_fullwidth_digit_one.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_expression.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_hex_1_digit.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_hex_2_digits.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_infinity.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid+-.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-negative-real.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-utf-8-in-bigger-int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-utf-8-in-exponent.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_invalid-utf-8-in-int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_minus_infinity.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_minus_sign_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_minus_space_1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_neg_int_starting_with_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_neg_real_without_int_part.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_neg_with_garbage_at_end.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_real_garbage_after_e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_real_with_invalid_utf8_after_e.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_real_without_fractional_part.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_starting_with_dot.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_with_alpha.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_with_alpha_char.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_number_with_leading_zero.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_bad_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_bracket_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_comma_instead_of_colon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_double_colon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_emoji.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_garbage_at_end.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_key_with_single_quotes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_lone_continuation_byte_in_key_and_trailing_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_colon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_semicolon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_missing_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_no-colon.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_non_string_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_non_string_key_but_huge_number_instead.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_repeated_null_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_several_trailing_commas.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_single_quote.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment_open.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment_slash_open.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_trailing_comment_slash_open_incomplete.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_two_commas_in_a_row.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_unquoted_key.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_unterminated-value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_with_single_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_object_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_single_space.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape_u.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape_u1.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_1_surrogate_then_escape_u1x.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_accentuated_char_no_quotes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_backslash_00.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escape_x.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escaped_backslash_bad.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escaped_ctrl_char_tab.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_escaped_emoji.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_escaped_character.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_surrogate.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_incomplete_surrogate_escape_invalid.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid-utf-8-in-escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid_backslash_esc.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid_unicode_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_invalid_utf8_after_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_leading_uescaped_thinspace.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_no_quotes_with_bad_escape.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_single_doublequote.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_single_quote.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_single_string_no_double_quotes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_start_escape_unclosed.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unescaped_crtl_char.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unescaped_newline.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unescaped_tab.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_unicode_CapitalU.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_string_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_U+2060_word_joined.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_UTF8_BOM_no_data.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_angle_bracket_..json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_angle_bracket_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_array_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_array_with_extra_array_close.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_array_with_unclosed_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_ascii-unicode-identifier.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_capitalized_True.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_close_unopened_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_comma_instead_of_closing_brace.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_double_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_end_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_incomplete_UTF8_BOM.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_lone-invalid-utf-8.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_lone-open-bracket.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_no_data.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_null-byte-outside-string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_number_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_followed_by_closing_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_unclosed_no_value.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_with_comment.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_object_with_trailing_garbage.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_apostrophe.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_open_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_open_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_close_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_comma.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_open_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_open_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_object_string_with_apostrophes.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_open.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_single_eacute.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_single_star.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_trailing_#.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_uescaped_LF_before_string.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array_partial_null.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array_unfinished_false.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_array_unfinished_true.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unclosed_object.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_unicode-identifier.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_whitespace_U+2060_word_joiner.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_whitespace_formfeed.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -1196,10 +1162,8 @@ TEST_CASE("nst's JSONTestSuite (2)") SECTION("n (previously overflowed)") { - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_100000_opening_arrays.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_object.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_100000_opening_arrays.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/n_structure_open_array_object.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -1209,43 +1173,41 @@ TEST_CASE("nst's JSONTestSuite (2)") SECTION("i -> y") { - for (const auto* filename : - { - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_double_huge_neg_exp.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_huge_exp.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_neg_int_huge_exp.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_pos_double_huge_exp.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_neg_overflow.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_pos_overflow.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_underflow.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_too_big_neg_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_too_big_pos_int.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_very_big_negative_int.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_object_key_lone_2nd_surrogate.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_1st_surrogate_but_2nd_missing.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_1st_valid_surrogate_2nd_invalid.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF-16LE_with_BOM.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF-8_invalid_sequence.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF8_surrogate_U+D800.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogate_and_escape_valid.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogate_pair.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogates_escape_valid.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_lonely_surrogate.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_surrogate.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_utf-8.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_inverted_surrogates_U+1D11E.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_iso_latin_1.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_lone_second_surrogate.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_lone_utf8_continuation_byte.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_not_in_unicode_range.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_2_bytes.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_6_bytes.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_6_bytes_null.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_truncated-utf-8.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_utf16BE_no_BOM.json", - //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_utf16LE_no_BOM.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_structure_500_nested_arrays.json", - TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_structure_UTF-8_BOM_empty_object.json"}) + for (const auto* filename : {TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_double_huge_neg_exp.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_huge_exp.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_neg_int_huge_exp.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_pos_double_huge_exp.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_neg_overflow.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_pos_overflow.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_real_underflow.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_too_big_neg_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_too_big_pos_int.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_very_big_negative_int.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_object_key_lone_2nd_surrogate.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_1st_surrogate_but_2nd_missing.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_1st_valid_surrogate_2nd_invalid.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF-16LE_with_BOM.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF-8_invalid_sequence.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_UTF8_surrogate_U+D800.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogate_and_escape_valid.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogate_pair.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_incomplete_surrogates_escape_valid.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_lonely_surrogate.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_surrogate.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_invalid_utf-8.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_inverted_surrogates_U+1D11E.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_iso_latin_1.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_lone_second_surrogate.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_lone_utf8_continuation_byte.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_not_in_unicode_range.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_2_bytes.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_6_bytes.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_overlong_sequence_6_bytes_null.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_truncated-utf-8.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_utf16BE_no_BOM.json", + //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_utf16LE_no_BOM.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_structure_500_nested_arrays.json", + TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_structure_UTF-8_BOM_empty_object.json"}) { CAPTURE(filename) std::ifstream f(filename); @@ -1258,8 +1220,7 @@ TEST_CASE("nst's JSONTestSuite (2)") SECTION("i -> n") { - for (const auto* filename : - { + for (const auto* filename : { //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_double_huge_neg_exp.json", TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_huge_exp.json", TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_neg_int_huge_exp.json", @@ -1308,7 +1269,8 @@ TEST_CASE("nst's JSONTestSuite (2)") } } -namespace { +namespace +{ std::string trim(const std::string& str); // from https://stackoverflow.com/a/25829178/266378 diff --git a/tests/src/unit-to_chars.cpp b/tests/src/unit-to_chars.cpp index 258d690536..a059e49528 100644 --- a/tests/src/unit-to_chars.cpp +++ b/tests/src/unit-to_chars.cpp @@ -15,7 +15,8 @@ #include using nlohmann::detail::dtoa_impl::reinterpret_bits; -namespace { +namespace +{ float make_float(uint32_t sign_bit, uint32_t biased_exponent, uint32_t significand) { assert(sign_bit == 0 || sign_bit == 1); @@ -60,9 +61,7 @@ float make_float(uint64_t f, int e) e--; } - const uint64_t biased_exponent = (e == kDenormalExponent && (f & kHiddenBit) == 0) - ? 0 - : static_cast(e + kExponentBias); + const uint64_t biased_exponent = (e == kDenormalExponent && (f & kHiddenBit) == 0) ? 0 : static_cast(e + kExponentBias); const uint64_t bits = (f & kSignificandMask) | (biased_exponent << kPhysicalSignificandSize); return reinterpret_bits(static_cast(bits)); @@ -112,9 +111,7 @@ double make_double(uint64_t f, int e) e--; } - const uint64_t biased_exponent = (e == kDenormalExponent && (f & kHiddenBit) == 0) - ? 0 - : static_cast(e + kExponentBias); + const uint64_t biased_exponent = (e == kDenormalExponent && (f & kHiddenBit) == 0) ? 0 : static_cast(e + kExponentBias); const uint64_t bits = (f & kSignificandMask) | (biased_exponent << kPhysicalSignificandSize); return reinterpret_bits(bits); diff --git a/tests/src/unit-ubjson.cpp b/tests/src/unit-ubjson.cpp index 3d3ad6cb66..1aa5b15ffa 100644 --- a/tests/src/unit-ubjson.cpp +++ b/tests/src/unit-ubjson.cpp @@ -17,7 +17,8 @@ using nlohmann::json; #include #include -namespace { +namespace +{ class SaxCountdown { public: @@ -85,7 +86,9 @@ class SaxCountdown return events_left-- > 0; } - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static) + bool parse_error(std::size_t /*unused*/, + const std::string& /*unused*/, + const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static) { return false; } @@ -195,14 +198,10 @@ TEST_CASE("UBJSON") // check individual bytes CHECK(result[0] == 'L'); - int64_t const restored = (static_cast(result[1]) << 070) + - (static_cast(result[2]) << 060) + - (static_cast(result[3]) << 050) + - (static_cast(result[4]) << 040) + - (static_cast(result[5]) << 030) + - (static_cast(result[6]) << 020) + - (static_cast(result[7]) << 010) + - static_cast(result[8]); + int64_t const restored = (static_cast(result[1]) << 070) + (static_cast(result[2]) << 060) + + (static_cast(result[3]) << 050) + (static_cast(result[4]) << 040) + + (static_cast(result[5]) << 030) + (static_cast(result[6]) << 020) + + (static_cast(result[7]) << 010) + static_cast(result[8]); CHECK(restored == i); // roundtrip @@ -247,10 +246,8 @@ TEST_CASE("UBJSON") // check individual bytes CHECK(result[0] == 'l'); - int32_t const restored = (static_cast(result[1]) << 030) + - (static_cast(result[2]) << 020) + - (static_cast(result[3]) << 010) + - static_cast(result[4]); + int32_t const restored = (static_cast(result[1]) << 030) + (static_cast(result[2]) << 020) + + (static_cast(result[3]) << 010) + static_cast(result[4]); CHECK(restored == i); // roundtrip @@ -453,11 +450,7 @@ TEST_CASE("UBJSON") SECTION("65536..2147483647 (int32)") { - for (uint32_t i : - { - 65536u, - 77777u, - 1048576u}) + for (uint32_t i : {65536u, 77777u, 1048576u}) { CAPTURE(i) @@ -484,10 +477,8 @@ TEST_CASE("UBJSON") // check individual bytes CHECK(result[0] == 'l'); - uint32_t const restored = (static_cast(result[1]) << 030) + - (static_cast(result[2]) << 020) + - (static_cast(result[3]) << 010) + - static_cast(result[4]); + uint32_t const restored = (static_cast(result[1]) << 030) + (static_cast(result[2]) << 020) + + (static_cast(result[3]) << 010) + static_cast(result[4]); CHECK(restored == i); // roundtrip @@ -530,14 +521,10 @@ TEST_CASE("UBJSON") // check individual bytes CHECK(result[0] == 'L'); - uint64_t const restored = (static_cast(result[1]) << 070) + - (static_cast(result[2]) << 060) + - (static_cast(result[3]) << 050) + - (static_cast(result[4]) << 040) + - (static_cast(result[5]) << 030) + - (static_cast(result[6]) << 020) + - (static_cast(result[7]) << 010) + - static_cast(result[8]); + uint64_t const restored = (static_cast(result[1]) << 070) + (static_cast(result[2]) << 060) + + (static_cast(result[3]) << 050) + (static_cast(result[4]) << 040) + + (static_cast(result[5]) << 030) + (static_cast(result[6]) << 020) + + (static_cast(result[7]) << 010) + static_cast(result[8]); CHECK(restored == i); // roundtrip @@ -654,11 +641,7 @@ TEST_CASE("UBJSON") SECTION("65536..2147483647 (int32)") { - for (uint32_t i : - { - 65536u, - 77777u, - 1048576u}) + for (uint32_t i : {65536u, 77777u, 1048576u}) { CAPTURE(i) @@ -684,10 +667,8 @@ TEST_CASE("UBJSON") // check individual bytes CHECK(result[0] == 'l'); - uint32_t const restored = (static_cast(result[1]) << 030) + - (static_cast(result[2]) << 020) + - (static_cast(result[3]) << 010) + - static_cast(result[4]); + uint32_t const restored = (static_cast(result[1]) << 030) + (static_cast(result[2]) << 020) + + (static_cast(result[3]) << 010) + static_cast(result[4]); CHECK(restored == i); // roundtrip @@ -729,14 +710,10 @@ TEST_CASE("UBJSON") // check individual bytes CHECK(result[0] == 'L'); - uint64_t const restored = (static_cast(result[1]) << 070) + - (static_cast(result[2]) << 060) + - (static_cast(result[3]) << 050) + - (static_cast(result[4]) << 040) + - (static_cast(result[5]) << 030) + - (static_cast(result[6]) << 020) + - (static_cast(result[7]) << 010) + - static_cast(result[8]); + uint64_t const restored = (static_cast(result[1]) << 070) + (static_cast(result[2]) << 060) + + (static_cast(result[3]) << 050) + (static_cast(result[4]) << 040) + + (static_cast(result[5]) << 030) + (static_cast(result[6]) << 020) + + (static_cast(result[7]) << 010) + static_cast(result[8]); CHECK(restored == i); // roundtrip @@ -752,17 +729,7 @@ TEST_CASE("UBJSON") { double v = 3.1415925; json const j = v; - std::vector expected = - { - 'D', - 0x40, - 0x09, - 0x21, - 0xfb, - 0x3f, - 0xa6, - 0xde, - 0xfc}; + std::vector expected = {'D', 0x40, 0x09, 0x21, 0xfb, 0x3f, 0xa6, 0xde, 0xfc}; const auto result = json::to_ubjson(j); CHECK(result == expected); @@ -777,7 +744,8 @@ TEST_CASE("UBJSON") { SECTION("unsigned integer number") { - 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'}; + 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_ubjson(vec); CHECK(j.is_number_unsigned()); CHECK(j.dump() == "12345678901234567890"); @@ -785,7 +753,8 @@ TEST_CASE("UBJSON") SECTION("signed integer number") { - 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'}; + 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_ubjson(vec); CHECK(j.is_number_integer()); CHECK(j.dump() == "-123456789012345678"); @@ -793,7 +762,8 @@ TEST_CASE("UBJSON") SECTION("floating-point number") { - 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'}; + 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_ubjson(vec); CHECK(j.is_number_float()); CHECK(j.dump() == "3.141592653589793"); @@ -810,11 +780,20 @@ TEST_CASE("UBJSON") json _; std::vector const vec2 = {'H', 'i', 2, '1', 'A', '3'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vec2), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A", json::parse_error); + CHECK_THROWS_WITH_AS( + _ = json::from_ubjson(vec2), + "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A", + json::parse_error); std::vector const vec3 = {'H', 'i', 2, '1', '.'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vec3), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1.", json::parse_error); + CHECK_THROWS_WITH_AS( + _ = json::from_ubjson(vec3), + "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1.", + json::parse_error); std::vector const vec4 = {'H', 2, '1', '0'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vec4), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x02", json::parse_error); + CHECK_THROWS_WITH_AS( + _ = json::from_ubjson(vec4), + "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x02", + json::parse_error); } SECTION("serialization") @@ -825,7 +804,8 @@ TEST_CASE("UBJSON") // number will be serialized to high-precision number const auto vec = json::to_ubjson(j); - std::vector expected = {'H', 'i', 0x14, '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'}; + std::vector expected = {'H', 'i', 0x14, '1', '1', '1', '1', '1', '1', '1', '1', '1', + '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'}; CHECK(vec == expected); // roundtrip @@ -907,14 +887,7 @@ TEST_CASE("UBJSON") SECTION("N = 256..32767") { - for (size_t N : - { - 256u, - 999u, - 1025u, - 3333u, - 2048u, - 32767u}) + for (size_t N : {256u, 999u, 1025u, 3333u, 2048u, 32767u}) { CAPTURE(N) @@ -945,11 +918,7 @@ TEST_CASE("UBJSON") SECTION("N = 65536..2147483647") { - for (size_t N : - { - 65536u, - 77777u, - 1048576u}) + for (size_t N : {65536u, 77777u, 1048576u}) { CAPTURE(N) @@ -1073,14 +1042,7 @@ TEST_CASE("UBJSON") SECTION("N = 256..32767") { - for (std::size_t N : - { - 256u, - 999u, - 1025u, - 3333u, - 2048u, - 32767u}) + for (std::size_t N : {256u, 999u, 1025u, 3333u, 2048u, 32767u}) { CAPTURE(N) @@ -1114,11 +1076,7 @@ TEST_CASE("UBJSON") SECTION("N = 32768..2147483647") { - for (std::size_t N : - { - 32768u, - 77777u, - 1048576u}) + for (std::size_t N : {32768u, 77777u, 1048576u}) { CAPTURE(N) @@ -1549,25 +1507,7 @@ TEST_CASE("UBJSON") SECTION("size=false type=false") { json const j = json::parse(R"({"a": {"b": {"c": {}}}})"); - std::vector expected = - { - '{', - 'i', - 1, - 'a', - '{', - 'i', - 1, - 'b', - '{', - 'i', - 1, - 'c', - '{', - '}', - '}', - '}', - '}'}; + std::vector expected = {'{', 'i', 1, 'a', '{', 'i', 1, 'b', '{', 'i', 1, 'c', '{', '}', '}', '}', '}'}; const auto result = json::to_ubjson(j); CHECK(result == expected); @@ -1579,33 +1519,8 @@ TEST_CASE("UBJSON") SECTION("size=true type=false") { json const j = json::parse(R"({"a": {"b": {"c": {}}}})"); - std::vector expected = - { - '{', - '#', - 'i', - 1, - 'i', - 1, - 'a', - '{', - '#', - 'i', - 1, - 'i', - 1, - 'b', - '{', - '#', - 'i', - 1, - 'i', - 1, - 'c', - '{', - '#', - 'i', - 0}; + std::vector expected = {'{', '#', 'i', 1, 'i', 1, 'a', '{', '#', 'i', 1, 'i', 1, + 'b', '{', '#', 'i', 1, 'i', 1, 'c', '{', '#', 'i', 0}; const auto result = json::to_ubjson(j, true); CHECK(result == expected); @@ -1617,36 +1532,8 @@ TEST_CASE("UBJSON") SECTION("size=true type=true") { json const j = json::parse(R"({"a": {"b": {"c": {}}}})"); - std::vector expected = - { - '{', - '$', - '{', - '#', - 'i', - 1, - 'i', - 1, - 'a', - '$', - '{', - '#', - 'i', - 1, - 'i', - 1, - 'b', - '$', - '{', - '#', - 'i', - 1, - 'i', - 1, - 'c', - '#', - 'i', - 0}; + std::vector expected = {'{', '$', '{', '#', 'i', 1, 'i', 1, 'a', '$', '{', '#', 'i', 1, + 'i', 1, 'b', '$', '{', '#', 'i', 1, 'i', 1, 'c', '#', 'i', 0}; const auto result = json::to_ubjson(j, true, true); CHECK(result == expected); @@ -1672,7 +1559,10 @@ TEST_CASE("UBJSON") SECTION("strict mode") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vec), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: expected end of input; last byte: 0x5A", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_ubjson(vec), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: expected end of input; last byte: 0x5A", + json::parse_error&); } } @@ -1685,9 +1575,10 @@ TEST_CASE("UBJSON") CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&); json j; - nlohmann::detail::json_sax_dom_callback_parser scp(j, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept { - return true; - }); + nlohmann::detail::json_sax_dom_callback_parser scp(j, + [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept { + return true; + }); CHECK_THROWS_AS(_ = json::sax_parse(v_ubjson, &scp, json::input_format_t::ubjson), json::out_of_range&); } @@ -1698,9 +1589,10 @@ TEST_CASE("UBJSON") CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&); json j; - nlohmann::detail::json_sax_dom_callback_parser scp(j, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept { - return true; - }); + nlohmann::detail::json_sax_dom_callback_parser scp(j, + [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept { + return true; + }); CHECK_THROWS_AS(_ = json::sax_parse(v_ubjson, &scp, json::input_format_t::ubjson), json::out_of_range&); } } @@ -1807,8 +1699,10 @@ TEST_CASE("UBJSON") std::vector const v_U = {'[', '#', 'i', 2, 'U', 0xFF, 'U', 0xFF}; std::vector const v_I = {'[', '#', 'i', 2, 'I', 0x7F, 0xFF, 'I', 0x7F, 0xFF}; std::vector const v_l = {'[', '#', 'i', 2, 'l', 0x7F, 0xFF, 0xFF, 0xFF, 'l', 0x7F, 0xFF, 0xFF, 0xFF}; - std::vector const v_L = {'[', '#', 'i', 2, 'L', 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 'L', 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; - std::vector const v_D = {'[', '#', 'i', 2, 'D', 0x40, 0x09, 0x21, 0xfb, 0x4d, 0x12, 0xd8, 0x4a, 'D', 0x40, 0x09, 0x21, 0xfb, 0x4d, 0x12, 0xd8, 0x4a}; + std::vector const v_L = {'[', '#', 'i', 2, 'L', 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 'L', 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + std::vector const v_D = {'[', '#', 'i', 2, 'D', 0x40, 0x09, 0x21, 0xfb, 0x4d, 0x12, + 0xd8, 0x4a, 'D', 0x40, 0x09, 0x21, 0xfb, 0x4d, 0x12, 0xd8, 0x4a}; std::vector const v_S = {'[', '#', 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'}; std::vector const v_C = {'[', '#', 'i', 2, 'C', 'a', 'C', 'a'}; @@ -1851,8 +1745,10 @@ TEST_CASE("UBJSON") std::vector const v_U = {'[', '$', 'U', '#', 'i', 2, 0xFF, 0xFF}; std::vector const v_I = {'[', '$', 'I', '#', 'i', 2, 0x7F, 0xFF, 0x7F, 0xFF}; std::vector const v_l = {'[', '$', 'l', '#', 'i', 2, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF}; - std::vector const v_L = {'[', '$', 'L', '#', 'i', 2, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; - std::vector const v_D = {'[', '$', 'D', '#', 'i', 2, 0x40, 0x09, 0x21, 0xfb, 0x4d, 0x12, 0xd8, 0x4a, 0x40, 0x09, 0x21, 0xfb, 0x4d, 0x12, 0xd8, 0x4a}; + std::vector const v_L = {'[', '$', 'L', '#', 'i', 2, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + std::vector const v_D = {'[', '$', 'D', '#', 'i', 2, 0x40, 0x09, 0x21, 0xfb, 0x4d, + 0x12, 0xd8, 0x4a, 0x40, 0x09, 0x21, 0xfb, 0x4d, 0x12, 0xd8, 0x4a}; std::vector const v_S = {'[', '$', 'S', '#', 'i', 2, 'i', 1, 'a', 'i', 1, 'a'}; std::vector const v_C = {'[', '$', 'C', '#', 'i', 2, 'a', 'a'}; @@ -1893,7 +1789,9 @@ TEST_CASE("UBJSON") SECTION("empty byte vector") { json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(std::vector()), "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(std::vector()), + "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); } SECTION("char") @@ -1902,14 +1800,19 @@ TEST_CASE("UBJSON") { std::vector const v = {'C'}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON char: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON char: unexpected end of input", + json::parse_error&); } SECTION("byte out of range") { std::vector const v = {'C', 130}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON char: byte after 'C' must be in range 0x00..0x7F; last byte: 0x82", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_ubjson(v), + "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON char: byte after 'C' must be in range 0x00..0x7F; last byte: 0x82", + json::parse_error&); } } @@ -1919,14 +1822,19 @@ TEST_CASE("UBJSON") { std::vector const v = {'S'}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); } SECTION("invalid byte") { std::vector const v = {'S', '1', 'a'}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON string: expected length type specification (U, i, I, l, L); last byte: 0x31", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_ubjson(v), + "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON string: expected length type specification (U, i, I, l, L); last byte: 0x31", + json::parse_error&); } } @@ -1936,7 +1844,10 @@ TEST_CASE("UBJSON") { std::vector const v = {'[', '$', 'i', 2}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x02", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_ubjson(v), + "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x02", + json::parse_error&); } } @@ -1944,15 +1855,21 @@ TEST_CASE("UBJSON") { std::vector const vS = {'S'}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vS), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vS, true, false).is_discarded()); std::vector const v = {'S', 'i', '2', 'a'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing UBJSON string: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), + "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing UBJSON string: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(v, true, false).is_discarded()); std::vector const vC = {'C'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vC), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON char: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vC), + "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON char: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vC, true, false).is_discarded()); } @@ -1960,27 +1877,40 @@ TEST_CASE("UBJSON") { std::vector const vU = {'[', '#', 'U'}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vU), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vU), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vU, true, false).is_discarded()); std::vector const vi = {'[', '#', 'i'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vi), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vi), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vi, true, false).is_discarded()); std::vector const vI = {'[', '#', 'I'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vI), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vI), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vI, true, false).is_discarded()); std::vector const vl = {'[', '#', 'l'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vl), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vl), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vl, true, false).is_discarded()); std::vector const vL = {'[', '#', 'L'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vL), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vL), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vL, true, false).is_discarded()); std::vector const v0 = {'[', '#', 'T', ']'}; - 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: 0x54", json::parse_error&); + 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: 0x54", + json::parse_error&); CHECK(json::from_ubjson(v0, true, false).is_discarded()); } @@ -1988,15 +1918,21 @@ TEST_CASE("UBJSON") { std::vector const v0 = {'[', '$'}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v0), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing UBJSON type: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v0), + "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing UBJSON type: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(v0, true, false).is_discarded()); std::vector const vi = {'[', '$', '#'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vi), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vi), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vi, true, false).is_discarded()); std::vector const vT = {'[', '$', 'T'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vT), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vT), + "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vT, true, false).is_discarded()); } @@ -2004,15 +1940,21 @@ TEST_CASE("UBJSON") { std::vector const vST = {'[', '$', 'i', '#', 'i', 2, 1}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vST), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vST), + "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON number: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vST, true, false).is_discarded()); std::vector const vS = {'[', '#', 'i', 2, 'i', 1}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vS), + "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vS, true, false).is_discarded()); std::vector const v = {'[', 'i', 2, 'i', 1}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), + "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(v, true, false).is_discarded()); } @@ -2020,35 +1962,52 @@ TEST_CASE("UBJSON") { std::vector const vST = {'{', '$', 'i', '#', 'i', 2, 'i', 1, 'a', 1}; json _; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vST), "[json.exception.parse_error.110] parse error at byte 11: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vST), + "[json.exception.parse_error.110] parse error at byte 11: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vST, true, false).is_discarded()); std::vector const vT = {'{', '$', 'i', 'i', 1, 'a', 1}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vT), "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x69", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::from_ubjson(vT), + "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x69", + json::parse_error&); CHECK(json::from_ubjson(vT, true, false).is_discarded()); std::vector const vS = {'{', '#', 'i', 2, 'i', 1, 'a', 'i', 1}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vS), + "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vS, true, false).is_discarded()); std::vector const v = {'{', 'i', 1, 'a', 'i', 1}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), + "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(v, true, false).is_discarded()); std::vector const v2 = {'{', 'i', 1, 'a', 'i', 1, 'i'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v2), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v2), + "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON number: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(v2, true, false).is_discarded()); std::vector const v3 = {'{', 'i', 1, 'a'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v3), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v3), + "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(v3, true, false).is_discarded()); std::vector const vST1 = {'{', '$', 'd', '#', 'i', 2, 'i', 1, 'a'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vST1), "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing UBJSON number: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vST1), + "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing UBJSON number: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vST1, true, false).is_discarded()); std::vector const vST2 = {'{', '#', 'i', 2, 'i', 1, 'a'}; - CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vST2), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON value: unexpected end of input", json::parse_error&); + CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vST2), + "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON value: unexpected end of input", + json::parse_error&); CHECK(json::from_ubjson(vST2, true, false).is_discarded()); } } @@ -2088,7 +2047,8 @@ TEST_CASE("UBJSON") SECTION("array of L") { json const j = {5000000000, -5000000000}; - std::vector expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05, 0xF2, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0xD5, 0xFA, 0x0E, 0x00}; + std::vector expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0x00, 0x00, 0x01, 0x2A, + 0x05, 0xF2, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0xD5, 0xFA, 0x0E, 0x00}; CHECK(json::to_ubjson(j, true, true) == expected); } } @@ -2134,8 +2094,10 @@ TEST_CASE("UBJSON") SECTION("array of L") { json const j = {5000000000u, 5000000001u}; - std::vector expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05, 0xF2, 0x01}; - std::vector expected_size = {'[', '#', 'i', 2, 'L', 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05, 0xF2, 0x00, 'L', 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05, 0xF2, 0x01}; + std::vector expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0x00, 0x00, 0x01, 0x2A, + 0x05, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05, 0xF2, 0x01}; + std::vector expected_size = {'[', '#', 'i', 2, 'L', 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05, + 0xF2, 0x00, 'L', 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05, 0xF2, 0x01}; CHECK(json::to_ubjson(j, true, true) == expected); CHECK(json::to_ubjson(j, true) == expected_size); } @@ -2164,7 +2126,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { json const j = {"foo", "bar", "baz"}; std::vector const v = {'[', 'S', 'i', 3, 'f', 'o', 'o', 'S', 'i', 3, 'b', 'a', 'r', 'S', 'i', 3, 'b', 'a', 'z', ']'}; - 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', ']'}; + 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', ']'}; CHECK(json::to_ubjson(j) == v); CHECK(json::from_ubjson(v) == j); CHECK(json::from_ubjson(v2) == j); @@ -2173,96 +2136,19 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") SECTION("Boolean Types") { json const j = {{"authorized", true}, {"verified", false}}; - std::vector const v = {'{', 'i', 10, 'a', 'u', 't', 'h', 'o', 'r', 'i', 'z', 'e', 'd', 'T', 'i', 8, 'v', 'e', 'r', 'i', 'f', 'i', 'e', 'd', 'F', '}'}; + std::vector const v = {'{', 'i', 10, 'a', 'u', 't', 'h', 'o', 'r', 'i', 'z', 'e', 'd', + 'T', 'i', 8, 'v', 'e', 'r', 'i', 'f', 'i', 'e', 'd', 'F', '}'}; CHECK(json::to_ubjson(j) == v); CHECK(json::from_ubjson(v) == j); } SECTION("Numeric Types") { - json const j = - { - {"int8", 16}, - {"uint8", 255}, - {"int16", 32767}, - {"int32", 2147483647}, - {"int64", 9223372036854775807}, - {"float64", 113243.7863123}}; - std::vector const v = {'{', - 'i', - 7, - 'f', - 'l', - 'o', - 'a', - 't', - '6', - '4', - 'D', - 0x40, - 0xfb, - 0xa5, - 0xbc, - 0x94, - 0xbc, - 0x34, - 0xcf, - 'i', - 5, - 'i', - 'n', - 't', - '1', - '6', - 'I', - 0x7f, - 0xff, - 'i', - 5, - 'i', - 'n', - 't', - '3', - '2', - 'l', - 0x7f, - 0xff, - 0xff, - 0xff, - 'i', - 5, - 'i', - 'n', - 't', - '6', - '4', - 'L', - 0x7f, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 'i', - 4, - 'i', - 'n', - 't', - '8', - 'i', - 16, - 'i', - 5, - 'u', - 'i', - 'n', - 't', - '8', - 'U', - 0xff, - '}'}; + json const j = {{"int8", 16}, {"uint8", 255}, {"int16", 32767}, {"int32", 2147483647}, {"int64", 9223372036854775807}, {"float64", 113243.7863123}}; + std::vector const v = {'{', 'i', 7, 'f', 'l', 'o', 'a', 't', '6', '4', 'D', 0x40, 0xfb, 0xa5, 0xbc, 0x94, 0xbc, 0x34, 0xcf, + 'i', 5, 'i', 'n', 't', '1', '6', 'I', 0x7f, 0xff, 'i', 5, 'i', 'n', 't', '3', '2', 'l', 0x7f, + 0xff, 0xff, 0xff, 'i', 5, 'i', 'n', 't', '6', '4', 'L', 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 'i', 4, 'i', 'n', 't', '8', 'i', 16, 'i', 5, 'u', 'i', 'n', 't', '8', 'U', 0xff, '}'}; CHECK(json::to_ubjson(j) == v); CHECK(json::from_ubjson(v) == j); } @@ -2308,7 +2194,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the float has been replaced by a double json const j = {nullptr, true, false, 4782345193, 153.132, "ham"}; - std::vector const v = {'[', 'Z', 'T', 'F', 'L', 0x00, 0x00, 0x00, 0x01, 0x1D, 0x0C, 0xCB, 0xE9, 'D', 0x40, 0x63, 0x24, 0x39, 0x58, 0x10, 0x62, 0x4e, 'S', 'i', 3, 'h', 'a', 'm', ']'}; + std::vector const v = {'[', 'Z', 'T', 'F', 'L', 0x00, 0x00, 0x00, 0x01, 0x1D, 0x0C, 0xCB, 0xE9, 'D', 0x40, + 0x63, 0x24, 0x39, 0x58, 0x10, 0x62, 0x4e, 'S', 'i', 3, 'h', 'a', 'm', ']'}; CHECK(json::to_ubjson(j) == v); CHECK(json::from_ubjson(v) == j); } @@ -2317,7 +2204,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the float has been replaced by a double json const j = {nullptr, true, false, 4782345193, 153.132, "ham"}; - std::vector const v = {'[', '#', 'i', 6, 'Z', 'T', 'F', 'L', 0x00, 0x00, 0x00, 0x01, 0x1D, 0x0C, 0xCB, 0xE9, 'D', 0x40, 0x63, 0x24, 0x39, 0x58, 0x10, 0x62, 0x4e, 'S', 'i', 3, 'h', 'a', 'm'}; + std::vector const v = {'[', '#', 'i', 6, 'Z', 'T', 'F', 'L', 0x00, 0x00, 0x00, 0x01, 0x1D, 0x0C, 0xCB, 0xE9, + 'D', 0x40, 0x63, 0x24, 0x39, 0x58, 0x10, 0x62, 0x4e, 'S', 'i', 3, 'h', 'a', 'm'}; CHECK(json::to_ubjson(j, true) == v); CHECK(json::from_ubjson(v) == j); } @@ -2326,7 +2214,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the float has been replaced by a double json const j = {nullptr, true, false, 4782345193, 153.132, "ham"}; - std::vector const v = {'[', '#', 'i', 6, 'Z', 'T', 'F', 'L', 0x00, 0x00, 0x00, 0x01, 0x1D, 0x0C, 0xCB, 0xE9, 'D', 0x40, 0x63, 0x24, 0x39, 0x58, 0x10, 0x62, 0x4e, 'S', 'i', 3, 'h', 'a', 'm'}; + std::vector const v = {'[', '#', 'i', 6, 'Z', 'T', 'F', 'L', 0x00, 0x00, 0x00, 0x01, 0x1D, 0x0C, 0xCB, 0xE9, + 'D', 0x40, 0x63, 0x24, 0x39, 0x58, 0x10, 0x62, 0x4e, 'S', 'i', 3, 'h', 'a', 'm'}; CHECK(json::to_ubjson(j, true, true) == v); CHECK(json::from_ubjson(v) == j); } @@ -2336,30 +2225,33 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { SECTION("size=false type=false") { - json const j = - { - {"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; - std::vector const v = {'{', 'i', 4, 'p', 'o', 's', 't', '{', 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, 'r', 'k', 'a', 'l', 'l', 'a', 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ', 't', 'o', 't', 'a', 'l', 'l', 'y', ' ', 'a', 'g', 'r', 'e', 'e', '!', 'i', 2, 'i', 'd', 'I', 0x04, 0x71, 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'L', 0x00, 0x00, 0x01, 0x3D, 0xB1, 0x78, 0x66, 0x60, '}', '}'}; + json const j = {{"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; + std::vector const v = {'{', 'i', 4, 'p', 'o', 's', 't', '{', 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, 'r', + 'k', 'a', 'l', 'l', 'a', 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ', 't', 'o', 't', 'a', + 'l', 'l', 'y', ' ', 'a', 'g', 'r', 'e', 'e', '!', 'i', 2, 'i', 'd', 'I', 0x04, 0x71, 'i', 9, 't', + 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'L', 0x00, 0x00, 0x01, 0x3D, 0xB1, 0x78, 0x66, 0x60, '}', '}'}; CHECK(json::to_ubjson(j) == v); CHECK(json::from_ubjson(v) == j); } SECTION("size=true type=false") { - json const j = - { - {"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; - std::vector const v = {'{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '{', '#', 'i', 4, 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, 'r', 'k', 'a', 'l', 'l', 'a', 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ', 't', 'o', 't', 'a', 'l', 'l', 'y', ' ', 'a', 'g', 'r', 'e', 'e', '!', 'i', 2, 'i', 'd', 'I', 0x04, 0x71, 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'L', 0x00, 0x00, 0x01, 0x3D, 0xB1, 0x78, 0x66, 0x60}; + json const j = {{"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; + std::vector const v = {'{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '{', '#', 'i', 4, 'i', 6, 'a', 'u', 't', 'h', 'o', + 'r', 'S', 'i', 6, 'r', 'k', 'a', 'l', 'l', 'a', 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ', + 't', 'o', 't', 'a', 'l', 'l', 'y', ' ', 'a', 'g', 'r', 'e', 'e', '!', 'i', 2, 'i', 'd', 'I', 0x04, 0x71, + 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'L', 0x00, 0x00, 0x01, 0x3D, 0xB1, 0x78, 0x66, 0x60}; CHECK(json::to_ubjson(j, true) == v); CHECK(json::from_ubjson(v) == j); } SECTION("size=true type=true") { - json const j = - { - {"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; - std::vector const v = {'{', '$', '{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '#', 'i', 4, 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, 'r', 'k', 'a', 'l', 'l', 'a', 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ', 't', 'o', 't', 'a', 'l', 'l', 'y', ' ', 'a', 'g', 'r', 'e', 'e', '!', 'i', 2, 'i', 'd', 'I', 0x04, 0x71, 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'L', 0x00, 0x00, 0x01, 0x3D, 0xB1, 0x78, 0x66, 0x60}; + json const j = {{"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}}; + std::vector const v = {'{', '$', '{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '#', 'i', 4, 'i', 6, 'a', 'u', 't', 'h', + 'o', 'r', 'S', 'i', 6, 'r', 'k', 'a', 'l', 'l', 'a', 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', + ' ', 't', 'o', 't', 'a', 'l', 'l', 'y', ' ', 'a', 'g', 'r', 'e', 'e', '!', 'i', 2, 'i', 'd', 'I', 0x04, + 0x71, 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'L', 0x00, 0x00, 0x01, 0x3D, 0xB1, 0x78, 0x66, 0x60}; CHECK(json::to_ubjson(j, true, true) == v); CHECK(json::from_ubjson(v) == j); } @@ -2373,53 +2265,9 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the floats have been replaced by doubles json const j = {29.97, 31.13, 67.0, 2.113, 23.888}; - std::vector const v = {'[', - 'D', - 0x40, - 0x3d, - 0xf8, - 0x51, - 0xeb, - 0x85, - 0x1e, - 0xb8, - 'D', - 0x40, - 0x3f, - 0x21, - 0x47, - 0xae, - 0x14, - 0x7a, - 0xe1, - 'D', - 0x40, - 0x50, - 0xc0, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 'D', - 0x40, - 0x00, - 0xe7, - 0x6c, - 0x8b, - 0x43, - 0x95, - 0x81, - 'D', - 0x40, - 0x37, - 0xe3, - 0x53, - 0xf7, - 0xce, - 0xd9, - 0x17, - ']'}; + std::vector const v = {'[', 'D', 0x40, 0x3d, 0xf8, 0x51, 0xeb, 0x85, 0x1e, 0xb8, 'D', 0x40, 0x3f, 0x21, 0x47, 0xae, + 0x14, 0x7a, 0xe1, 'D', 0x40, 0x50, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 'D', 0x40, 0x00, 0xe7, + 0x6c, 0x8b, 0x43, 0x95, 0x81, 'D', 0x40, 0x37, 0xe3, 0x53, 0xf7, 0xce, 0xd9, 0x17, ']'}; CHECK(json::to_ubjson(j) == v); CHECK(json::from_ubjson(v) == j); } @@ -2428,7 +2276,9 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the floats have been replaced by doubles json const j = {29.97, 31.13, 67.0, 2.113, 23.888}; - std::vector const v = {'[', '#', 'i', 5, 'D', 0x40, 0x3d, 0xf8, 0x51, 0xeb, 0x85, 0x1e, 0xb8, 'D', 0x40, 0x3f, 0x21, 0x47, 0xae, 0x14, 0x7a, 0xe1, 'D', 0x40, 0x50, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 'D', 0x40, 0x00, 0xe7, 0x6c, 0x8b, 0x43, 0x95, 0x81, 'D', 0x40, 0x37, 0xe3, 0x53, 0xf7, 0xce, 0xd9, 0x17}; + std::vector const v = {'[', '#', 'i', 5, 'D', 0x40, 0x3d, 0xf8, 0x51, 0xeb, 0x85, 0x1e, 0xb8, 'D', 0x40, 0x3f, 0x21, + 0x47, 0xae, 0x14, 0x7a, 0xe1, 'D', 0x40, 0x50, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 'D', 0x40, 0x00, + 0xe7, 0x6c, 0x8b, 0x43, 0x95, 0x81, 'D', 0x40, 0x37, 0xe3, 0x53, 0xf7, 0xce, 0xd9, 0x17}; CHECK(json::to_ubjson(j, true) == v); CHECK(json::from_ubjson(v) == j); } @@ -2437,7 +2287,9 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the floats have been replaced by doubles json const j = {29.97, 31.13, 67.0, 2.113, 23.888}; - std::vector const v = {'[', '$', 'D', '#', 'i', 5, 0x40, 0x3d, 0xf8, 0x51, 0xeb, 0x85, 0x1e, 0xb8, 0x40, 0x3f, 0x21, 0x47, 0xae, 0x14, 0x7a, 0xe1, 0x40, 0x50, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xe7, 0x6c, 0x8b, 0x43, 0x95, 0x81, 0x40, 0x37, 0xe3, 0x53, 0xf7, 0xce, 0xd9, 0x17}; + std::vector const v = {'[', '$', 'D', '#', 'i', 5, 0x40, 0x3d, 0xf8, 0x51, 0xeb, 0x85, 0x1e, 0xb8, 0x40, 0x3f, + 0x21, 0x47, 0xae, 0x14, 0x7a, 0xe1, 0x40, 0x50, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, + 0xe7, 0x6c, 0x8b, 0x43, 0x95, 0x81, 0x40, 0x37, 0xe3, 0x53, 0xf7, 0xce, 0xd9, 0x17}; CHECK(json::to_ubjson(j, true, true) == v); CHECK(json::from_ubjson(v) == j); } @@ -2449,51 +2301,9 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the floats have been replaced by doubles json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}}; - std::vector const v = {'{', - 'i', - 3, - 'a', - 'l', - 't', - 'D', - 0x40, - 0x50, - 0xc0, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 'i', - 3, - 'l', - 'a', - 't', - 'D', - 0x40, - 0x3d, - 0xf9, - 0xdb, - 0x22, - 0xd0, - 0xe5, - 0x60, - 'i', - 4, - 'l', - 'o', - 'n', - 'g', - 'D', - 0x40, - 0x3f, - 0x21, - 0x89, - 0x37, - 0x4b, - 0xc6, - 0xa8, - '}'}; + std::vector const v = {'{', 'i', 3, 'a', 'l', 't', 'D', 0x40, 0x50, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, + 'i', 3, 'l', 'a', 't', 'D', 0x40, 0x3d, 0xf9, 0xdb, 0x22, 0xd0, 0xe5, 0x60, 'i', + 4, 'l', 'o', 'n', 'g', 'D', 0x40, 0x3f, 0x21, 0x89, 0x37, 0x4b, 0xc6, 0xa8, '}'}; CHECK(json::to_ubjson(j) == v); CHECK(json::from_ubjson(v) == j); } @@ -2502,7 +2312,9 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the floats have been replaced by doubles json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}}; - std::vector const v = {'{', '#', 'i', 3, 'i', 3, 'a', 'l', 't', 'D', 0x40, 0x50, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 'i', 3, 'l', 'a', 't', 'D', 0x40, 0x3d, 0xf9, 0xdb, 0x22, 0xd0, 0xe5, 0x60, 'i', 4, 'l', 'o', 'n', 'g', 'D', 0x40, 0x3f, 0x21, 0x89, 0x37, 0x4b, 0xc6, 0xa8}; + std::vector const v = {'{', '#', 'i', 3, 'i', 3, 'a', 'l', 't', 'D', 0x40, 0x50, 0xc0, 0x00, 0x00, 0x00, + 0x00, 0x00, 'i', 3, 'l', 'a', 't', 'D', 0x40, 0x3d, 0xf9, 0xdb, 0x22, 0xd0, 0xe5, 0x60, + 'i', 4, 'l', 'o', 'n', 'g', 'D', 0x40, 0x3f, 0x21, 0x89, 0x37, 0x4b, 0xc6, 0xa8}; CHECK(json::to_ubjson(j, true) == v); CHECK(json::from_ubjson(v) == j); } @@ -2511,7 +2323,9 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") { // note the floats have been replaced by doubles json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}}; - std::vector const v = {'{', '$', 'D', '#', 'i', 3, 'i', 3, 'a', 'l', 't', 0x40, 0x50, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 'i', 3, 'l', 'a', 't', 0x40, 0x3d, 0xf9, 0xdb, 0x22, 0xd0, 0xe5, 0x60, 'i', 4, 'l', 'o', 'n', 'g', 0x40, 0x3f, 0x21, 0x89, 0x37, 0x4b, 0xc6, 0xa8}; + std::vector const v = {'{', '$', 'D', '#', 'i', 3, 'i', 3, 'a', 'l', 't', 0x40, 0x50, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0x00, 'i', 3, 'l', 'a', 't', 0x40, 0x3d, 0xf9, 0xdb, 0x22, 0xd0, 0xe5, 0x60, + 'i', 4, 'l', 'o', 'n', 'g', 0x40, 0x3f, 0x21, 0x89, 0x37, 0x4b, 0xc6, 0xa8}; CHECK(json::to_ubjson(j, true, true) == v); CHECK(json::from_ubjson(v) == j); } @@ -2527,7 +2341,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") SECTION("Object") { - 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'}; + 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(json::from_ubjson(v) == json({{"name", nullptr}, {"password", nullptr}, {"email", nullptr}})); } } @@ -2538,24 +2353,7 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") TEST_CASE("all UBJSON first bytes") { // these bytes will fail immediately with exception parse_error.112 - std::set supported = - { - 'T', - 'F', - 'Z', - 'U', - 'i', - 'I', - 'l', - 'L', - 'd', - 'D', - 'C', - 'S', - '[', - '{', - 'N', - 'H'}; + std::set supported = {'T', 'F', 'Z', 'U', 'i', 'I', 'l', 'L', 'd', 'D', 'C', 'S', '[', '{', 'N', 'H'}; for (auto i = 0; i < 256; ++i) { @@ -2588,50 +2386,48 @@ TEST_CASE("UBJSON roundtrips" * doctest::skip()) { SECTION("input from self-generated UBJSON files") { - for (std::string filename : - { - TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json", - TEST_DATA_DIRECTORY "/json.org/1.json", - TEST_DATA_DIRECTORY "/json.org/2.json", - TEST_DATA_DIRECTORY "/json.org/3.json", - TEST_DATA_DIRECTORY "/json.org/4.json", - TEST_DATA_DIRECTORY "/json.org/5.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip01.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip02.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip03.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip04.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip05.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip06.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip07.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip08.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip09.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip10.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip11.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip12.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip13.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip14.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip15.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip16.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip17.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip18.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip19.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip20.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip21.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip22.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip23.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip24.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip25.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip26.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip27.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip28.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip29.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip30.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip31.json", - TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip32.json", - TEST_DATA_DIRECTORY "/json_testsuite/sample.json", - TEST_DATA_DIRECTORY "/json_tests/pass1.json", - TEST_DATA_DIRECTORY "/json_tests/pass2.json", - TEST_DATA_DIRECTORY "/json_tests/pass3.json"}) + for (std::string filename : {TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json", + TEST_DATA_DIRECTORY "/json.org/1.json", + TEST_DATA_DIRECTORY "/json.org/2.json", + TEST_DATA_DIRECTORY "/json.org/3.json", + TEST_DATA_DIRECTORY "/json.org/4.json", + TEST_DATA_DIRECTORY "/json.org/5.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip01.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip02.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip03.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip04.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip05.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip06.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip07.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip08.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip09.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip10.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip11.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip12.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip13.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip14.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip15.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip16.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip17.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip18.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip19.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip20.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip21.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip22.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip23.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip24.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip25.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip26.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip27.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip28.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip29.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip30.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip31.json", + TEST_DATA_DIRECTORY "/json_roundtrip/roundtrip32.json", + TEST_DATA_DIRECTORY "/json_testsuite/sample.json", + TEST_DATA_DIRECTORY "/json_tests/pass1.json", + TEST_DATA_DIRECTORY "/json_tests/pass2.json", + TEST_DATA_DIRECTORY "/json_tests/pass3.json"}) { CAPTURE(filename) diff --git a/tests/src/unit-udt.cpp b/tests/src/unit-udt.cpp index 6709813ecc..b3995ffd1c 100644 --- a/tests/src/unit-udt.cpp +++ b/tests/src/unit-udt.cpp @@ -23,7 +23,8 @@ using namespace nlohmann::literals; // NOLINT(google-build-using-namespace) #include #include -namespace udt { +namespace udt +{ enum class country { china, @@ -92,7 +93,8 @@ struct contact_book } // namespace udt // to_json methods -namespace udt { +namespace udt +{ // templates because of the custom_json tests (see below) template static void to_json(BasicJsonType& j, age a) @@ -169,19 +171,18 @@ static bool operator==(const person& lhs, const person& rhs) static bool operator==(const contact& lhs, const contact& rhs) { - return std::tie(lhs.m_person, lhs.m_address) == - std::tie(rhs.m_person, rhs.m_address); + return std::tie(lhs.m_person, lhs.m_address) == std::tie(rhs.m_person, rhs.m_address); } static bool operator==(const contact_book& lhs, const contact_book& rhs) { - return std::tie(lhs.m_book_name, lhs.m_contacts) == - std::tie(rhs.m_book_name, rhs.m_contacts); + return std::tie(lhs.m_book_name, lhs.m_contacts) == std::tie(rhs.m_book_name, rhs.m_contacts); } } // namespace udt // from_json methods -namespace udt { +namespace udt +{ template static void from_json(const BasicJsonType& j, age& a) { @@ -198,11 +199,7 @@ template static void from_json(const BasicJsonType& j, country& c) { const auto str = j.template get(); - const std::map m = - { - {"中华人民共和国", country::china}, - {"France", country::france}, - {"Российская Федерация", country::russia}}; + const std::map m = {{"中华人民共和国", country::china}, {"France", country::france}, {"Российская Федерация", country::russia}}; const auto it = m.find(str); // TODO(nlohmann) test exceptions @@ -238,8 +235,7 @@ static void from_json(const nlohmann::json& j, contact_book& cb) TEST_CASE("basic usage" * doctest::test_suite("udt")) { // a bit narcissistic maybe :) ? - const udt::age a{ - 23}; + const udt::age a{23}; const udt::name n{"theo"}; const udt::country c{udt::country::france}; const udt::person sfinae_addict{a, n, c}; @@ -255,8 +251,7 @@ TEST_CASE("basic usage" * doctest::test_suite("udt")) CHECK(json(c) == json("France")); CHECK(json(sfinae_addict) == R"({"name":"theo", "age":23, "country":"France"})"_json); CHECK(json("Paris") == json(addr)); - CHECK(json(cpp_programmer) == - R"({"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"})"_json); + CHECK(json(cpp_programmer) == R"({"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"})"_json); CHECK( json(book) == @@ -271,15 +266,13 @@ TEST_CASE("basic usage" * doctest::test_suite("udt")) { const auto parsed_book = big_json.get(); const auto book_name = big_json["name"].get(); - const auto contacts = - big_json["contacts"].get>(); + const auto contacts = big_json["contacts"].get>(); const auto contact_json = big_json["contacts"].at(0); const auto contact = contact_json.get(); const auto person = contact_json["person"].get(); const auto address = contact_json["address"].get(); const auto age = contact_json["person"]["age"].get(); - const auto country = - contact_json["person"]["country"].get(); + const auto country = contact_json["person"]["country"].get(); const auto name = contact_json["person"]["name"].get(); CHECK(age == a); @@ -334,7 +327,8 @@ TEST_CASE("basic usage" * doctest::test_suite("udt")) } } -namespace udt { +namespace udt +{ struct legacy_type { std::string number{}; @@ -345,7 +339,8 @@ struct legacy_type }; } // namespace udt -namespace nlohmann { +namespace nlohmann +{ template struct adl_serializer> { @@ -441,7 +436,8 @@ TEST_CASE("adl_serializer specialization" * doctest::test_suite("udt")) } } -namespace nlohmann { +namespace nlohmann +{ template<> struct adl_serializer> { @@ -473,7 +469,8 @@ TEST_CASE("even supported types can be specialized" * doctest::test_suite("udt") CHECK((f == std::vector{4.0, 5.0, 6.0})); } -namespace nlohmann { +namespace nlohmann +{ template struct adl_serializer> { @@ -540,12 +537,7 @@ template struct pod_serializer { // use adl for non-pods, or scalar types - template< - typename BasicJsonType, - typename U = T, - typename std::enable_if< - !(std::is_pod::value && std::is_class::value), - int>::type = 0> + template::value && std::is_class::value), int>::type = 0> static void from_json(const BasicJsonType& j, U& t) { using nlohmann::from_json; @@ -576,12 +568,7 @@ struct pod_serializer std::memcpy(&t, bytes, sizeof(value)); } - template< - typename BasicJsonType, - typename U = T, - typename std::enable_if< - !(std::is_pod::value && std::is_class::value), - int>::type = 0> + template::value && std::is_class::value), int>::type = 0> static void to_json(BasicJsonType& j, const T& t) { using nlohmann::to_json; @@ -598,7 +585,8 @@ struct pod_serializer } }; -namespace udt { +namespace udt +{ struct small_pod { int begin; @@ -629,8 +617,7 @@ static void from_json(const BasicJsonType& j, non_pod& np) static bool operator==(small_pod lhs, small_pod rhs) noexcept { - return std::tie(lhs.begin, lhs.middle, lhs.end) == - std::tie(rhs.begin, rhs.middle, rhs.end); + return std::tie(lhs.begin, lhs.middle, lhs.end) == std::tie(rhs.begin, rhs.middle, rhs.end); } static bool operator==(const non_pod& lhs, const non_pod& rhs) noexcept @@ -646,8 +633,7 @@ static std::ostream& operator<<(std::ostream& os, small_pod l) TEST_CASE("custom serializer for pods" * doctest::test_suite("udt")) { - using custom_json = - nlohmann::basic_json; + using custom_json = nlohmann::basic_json; auto p = udt::small_pod{42, '/', 42}; custom_json const j = p; @@ -781,7 +767,8 @@ TEST_CASE("different basic_json types conversions") } } -namespace { +namespace +{ struct incomplete; // std::is_constructible is broken on macOS' libc++ @@ -801,7 +788,8 @@ TEST_CASE("an incomplete type does not trigger a compiler error in non-evaluated static_assert(!is_constructible_patched::value, ""); } -namespace { +namespace +{ class Evil { public: @@ -839,7 +827,8 @@ TEST_CASE("Issue #1237") static_assert(!std::is_convertible::value, ""); } -namespace { +namespace +{ class no_iterator_type { public: diff --git a/tests/src/unit-udt_macro.cpp b/tests/src/unit-udt_macro.cpp index ea275432bc..7db36cb37c 100644 --- a/tests/src/unit-udt_macro.cpp +++ b/tests/src/unit-udt_macro.cpp @@ -13,7 +13,8 @@ #include using nlohmann::json; -namespace persons { +namespace persons +{ class person_with_private_data { private: @@ -157,32 +158,9 @@ class person_with_private_alphabet public: bool operator==(const person_with_private_alphabet& other) const { - return a == other.a && - b == other.b && - c == other.c && - d == other.d && - e == other.e && - f == other.f && - g == other.g && - h == other.h && - i == other.i && - j == other.j && - k == other.k && - l == other.l && - m == other.m && - n == other.n && - o == other.o && - p == other.p && - q == other.q && - r == other.r && - s == other.s && - t == other.t && - u == other.u && - v == other.v && - w == other.w && - x == other.x && - y == other.y && - z == other.z; + return a == other.a && b == other.b && c == other.c && d == other.d && e == other.e && f == other.f && g == other.g && h == other.h && i == other.i && + j == other.j && k == other.k && l == other.l && m == other.m && n == other.n && o == other.o && p == other.p && q == other.q && r == other.r && + s == other.s && t == other.t && u == other.u && v == other.v && w == other.w && x == other.x && y == other.y && z == other.z; } private: @@ -220,32 +198,9 @@ class person_with_public_alphabet public: bool operator==(const person_with_public_alphabet& other) const { - return a == other.a && - b == other.b && - c == other.c && - d == other.d && - e == other.e && - f == other.f && - g == other.g && - h == other.h && - i == other.i && - j == other.j && - k == other.k && - l == other.l && - m == other.m && - n == other.n && - o == other.o && - p == other.p && - q == other.q && - r == other.r && - s == other.s && - t == other.t && - u == other.u && - v == other.v && - w == other.w && - x == other.x && - y == other.y && - z == other.z; + return a == other.a && b == other.b && c == other.c && d == other.d && e == other.e && f == other.f && g == other.g && h == other.h && i == other.i && + j == other.j && k == other.k && l == other.l && m == other.m && n == other.n && o == other.o && p == other.p && q == other.q && r == other.r && + s == other.s && t == other.t && u == other.u && v == other.v && w == other.w && x == other.x && y == other.y && z == other.z; } int a = 0; @@ -318,7 +273,11 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(person_without_default_constru } // namespace persons -TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE", T, persons::person_with_private_data, persons::person_without_private_data_1, persons::person_without_private_data_2) +TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE", + T, + persons::person_with_private_data, + persons::person_without_private_data_1, + persons::person_without_private_data_2) { SECTION("person") { @@ -341,7 +300,10 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRU } } -TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT", T, persons::person_with_private_data_2, persons::person_without_private_data_3) +TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT", + T, + persons::person_with_private_data_2, + persons::person_without_private_data_3) { SECTION("person with default values") { @@ -373,7 +335,11 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRU } } -TEST_CASE_TEMPLATE("Serialization/deserialization of classes with 26 public/private member variables via NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE", T, persons::person_with_private_alphabet, persons::person_with_public_alphabet) +TEST_CASE_TEMPLATE( + "Serialization/deserialization of classes with 26 public/private member variables via NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE", + T, + persons::person_with_private_alphabet, + persons::person_with_public_alphabet) { SECTION("alphabet") { @@ -443,7 +409,11 @@ TEST_CASE_TEMPLATE("Serialization/deserialization of classes with 26 public/priv } } -TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE", T, persons::person_without_default_constructor_1, persons::person_without_default_constructor_2) +TEST_CASE_TEMPLATE( + "Serialization of non-default-constructible classes via NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE", + T, + persons::person_without_default_constructor_1, + persons::person_without_default_constructor_2) { SECTION("person") { @@ -453,9 +423,7 @@ TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHM CHECK(json(person).dump() == "{\"age\":1,\"name\":\"Erik\"}"); // serialization of a container with objects - std::vector const two_persons{ - {"Erik", 1}, - {"Kyle", 2}}; + std::vector const two_persons{{"Erik", 1}, {"Kyle", 2}}; CHECK(json(two_persons).dump() == "[{\"age\":1,\"name\":\"Erik\"},{\"age\":2,\"name\":\"Kyle\"}]"); } } diff --git a/tests/src/unit-unicode1.cpp b/tests/src/unit-unicode1.cpp index 1a1b08508d..849c4a097f 100644 --- a/tests/src/unit-unicode1.cpp +++ b/tests/src/unit-unicode1.cpp @@ -85,19 +85,40 @@ TEST_CASE("Unicode (1/5)" * doctest::skip()) { json _; - CHECK_THROWS_WITH_AS(_ = json::parse("\"\\uDC00\\uDC00\""), "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '\"\\uDC00'", json::parse_error&); - - CHECK_THROWS_WITH_AS(_ = json::parse("\"\\uD7FF\\uDC00\""), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '\"\\uD7FF\\uDC00'", json::parse_error&); - - CHECK_THROWS_WITH_AS(_ = json::parse("\"\\uD800]\""), "[json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800]'", json::parse_error&); - - CHECK_THROWS_WITH_AS(_ = json::parse("\"\\uD800\\v\""), "[json.exception.parse_error.101] parse error at line 1, column 9: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800\\v'", json::parse_error&); - - CHECK_THROWS_WITH_AS(_ = json::parse("\"\\uD800\\u123\""), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\uD800\\u123\"'", json::parse_error&); - - CHECK_THROWS_WITH_AS(_ = json::parse("\"\\uD800\\uDBFF\""), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800\\uDBFF'", json::parse_error&); - - CHECK_THROWS_WITH_AS(_ = json::parse("\"\\uD800\\uE000\""), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800\\uE000'", json::parse_error&); + CHECK_THROWS_WITH_AS( + _ = json::parse("\"\\uDC00\\uDC00\""), + "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '\"\\uDC00'", + json::parse_error&); + + CHECK_THROWS_WITH_AS( + _ = json::parse("\"\\uD7FF\\uDC00\""), + "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '\"\\uD7FF\\uDC00'", + json::parse_error&); + + CHECK_THROWS_WITH_AS( + _ = json::parse("\"\\uD800]\""), + "[json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800]'", + json::parse_error&); + + CHECK_THROWS_WITH_AS( + _ = json::parse("\"\\uD800\\v\""), + "[json.exception.parse_error.101] parse error at line 1, column 9: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800\\v'", + json::parse_error&); + + CHECK_THROWS_WITH_AS( + _ = json::parse("\"\\uD800\\u123\""), + "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\uD800\\u123\"'", + json::parse_error&); + + CHECK_THROWS_WITH_AS( + _ = json::parse("\"\\uD800\\uDBFF\""), + "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800\\uDBFF'", + json::parse_error&); + + CHECK_THROWS_WITH_AS( + _ = json::parse("\"\\uD800\\uE000\""), + "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800\\uE000'", + json::parse_error&); } } @@ -222,7 +243,8 @@ TEST_CASE("Unicode (1/5)" * doctest::skip()) } } -namespace { +namespace +{ void roundtrip(bool success_expected, const std::string& s); void roundtrip(bool success_expected, const std::string& s) @@ -353,13 +375,17 @@ TEST_CASE("Markus Kuhn's UTF-8 decoder capability and stress test") roundtrip(false, "\x80\xbf\x80\xbf\x80\xbf\x80"); // 3.1.9 Sequence of all 64 possible continuation bytes (0x80-0xbf) - roundtrip(false, "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"); + roundtrip( + false, + "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"); } SECTION("3.2 Lonely start characters") { // 3.2.1 All 32 first bytes of 2-byte sequences (0xc0-0xdf) - roundtrip(false, "\xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf \xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd7 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf"); + roundtrip( + false, + "\xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf \xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd7 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf"); // 3.2.2 All 16 first bytes of 3-byte sequences (0xe0-0xef) roundtrip(false, "\xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee \xef"); // 3.2.3 All 8 first bytes of 4-byte sequences (0xf0-0xf7) diff --git a/tests/src/unit-unicode2.cpp b/tests/src/unit-unicode2.cpp index 5e9bb361fe..e14612c182 100644 --- a/tests/src/unit-unicode2.cpp +++ b/tests/src/unit-unicode2.cpp @@ -24,7 +24,8 @@ using nlohmann::json; DOCTEST_CLANG_SUPPRESS_WARNING_PUSH DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors") -namespace { +namespace +{ extern size_t calls; size_t calls = 0; diff --git a/tests/src/unit-unicode3.cpp b/tests/src/unit-unicode3.cpp index 6044574375..1c92236cc8 100644 --- a/tests/src/unit-unicode3.cpp +++ b/tests/src/unit-unicode3.cpp @@ -24,7 +24,8 @@ using nlohmann::json; DOCTEST_CLANG_SUPPRESS_WARNING_PUSH DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors") -namespace { +namespace +{ extern size_t calls; size_t calls = 0; diff --git a/tests/src/unit-unicode4.cpp b/tests/src/unit-unicode4.cpp index 851b8a5153..20305e5d49 100644 --- a/tests/src/unit-unicode4.cpp +++ b/tests/src/unit-unicode4.cpp @@ -24,7 +24,8 @@ using nlohmann::json; DOCTEST_CLANG_SUPPRESS_WARNING_PUSH DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors") -namespace { +namespace +{ extern size_t calls; size_t calls = 0; diff --git a/tests/src/unit-unicode5.cpp b/tests/src/unit-unicode5.cpp index 1967fc2eb1..0c79a5bef7 100644 --- a/tests/src/unit-unicode5.cpp +++ b/tests/src/unit-unicode5.cpp @@ -24,7 +24,8 @@ using nlohmann::json; DOCTEST_CLANG_SUPPRESS_WARNING_PUSH DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors") -namespace { +namespace +{ extern size_t calls; size_t calls = 0; diff --git a/tests/src/unit-user_defined_input.cpp b/tests/src/unit-user_defined_input.cpp index f9c096a9d9..f3c537404f 100644 --- a/tests/src/unit-user_defined_input.cpp +++ b/tests/src/unit-user_defined_input.cpp @@ -13,7 +13,8 @@ using nlohmann::json; #include -namespace { +namespace +{ TEST_CASE("Use arbitrary stdlib container") { std::string raw_data = "[1,2,3,4]"; diff --git a/tests/src/unit-wstring.cpp b/tests/src/unit-wstring.cpp index 7469fcee20..e13e626879 100644 --- a/tests/src/unit-wstring.cpp +++ b/tests/src/unit-wstring.cpp @@ -13,7 +13,8 @@ using nlohmann::json; // ICPC errors out on multibyte character sequences in source files #ifndef __INTEL_COMPILER -namespace { +namespace +{ bool wstring_is_utf16(); bool wstring_is_utf16() {