:art: use Clang-Format
diff --git a/.clang-format b/.clang-format
index a7fdf1a..a62584e 100644
--- a/.clang-format
+++ b/.clang-format
@@ -46,7 +46,7 @@
ColumnLimit: 160
CompactNamespaces: false
ConstructorInitializerIndentWidth: 2
-Cpp11BracedListStyle: true
+Cpp11BracedListStyle: false
PointerAlignment: Left
FixNamespaceComments: true
#IndentCaseBlocks: false
@@ -92,3 +92,6 @@
Priority: 3
- Regex: '.*'
Priority: 4
+
+Macros:
+ - JSON_PRIVATE_UNLESS_TESTED=private
diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml
index acf2e23..ad35aa9 100644
--- a/.github/workflows/ubuntu.yml
+++ b/.github/workflows/ubuntu.yml
@@ -43,10 +43,20 @@
ci_static_analysis:
runs-on: ubuntu-latest
- container: silkeh/clang:dev
+ container: ghcr.io/nlohmann/json-ci:v2.4.0
strategy:
matrix:
- target: [ci_cppcheck, ci_test_valgrind, ci_test_amalgamation, ci_test_single_header, ci_single_binaries, ci_infer]
+ target: [ci_cppcheck, ci_test_valgrind, ci_test_single_header, ci_single_binaries, ci_infer]
+ steps:
+ - uses: actions/checkout@v3
+ - name: Run CMake
+ run: cmake -S . -B build -DJSON_CI=On
+ - name: Build
+ run: cmake --build build --target ${{ matrix.target }}
+
+ ci_test_amalgamation:
+ runs-on: ubuntu-latest
+ container: silkeh/clang:dev
steps:
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
@@ -54,7 +64,7 @@
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
- run: cmake --build build --target ${{ matrix.target }}
+ run: cmake --build build --target ci_test_amalgamation
ci_static_analysis_ubuntu:
runs-on: ubuntu-latest
diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp
index d3af3b9..122a544 100644
--- a/include/nlohmann/detail/conversions/from_json.hpp
+++ b/include/nlohmann/detail/conversions/from_json.hpp
@@ -252,7 +252,7 @@
std::array<T, sizeof...(Idx)>
from_json_inplace_array_impl(BasicJsonType&& j, identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
{
- return {{std::forward<BasicJsonType>(j).at(Idx).template get<T>()...}};
+ return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
}
template<typename BasicJsonType, typename T, std::size_t N>
@@ -353,7 +353,7 @@
template<typename BasicJsonType, class A1, class A2>
std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
{
- return {std::forward<BasicJsonType>(j).at(0).template get<A1>(), std::forward<BasicJsonType>(j).at(1).template get<A2>()};
+ return { std::forward<BasicJsonType>(j).at(0).template get<A1>(), std::forward<BasicJsonType>(j).at(1).template get<A2>() };
}
template<typename BasicJsonType, typename A1, typename A2>
diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp
index f1dabf4..6ecc6e0 100644
--- a/include/nlohmann/detail/conversions/to_chars.hpp
+++ b/include/nlohmann/detail/conversions/to_chars.hpp
@@ -75,7 +75,7 @@
JSON_ASSERT(x.e == y.e);
JSON_ASSERT(x.f >= y.f);
- return {x.f - y.f, x.e};
+ return { x.f - y.f, x.e };
}
/*!
@@ -136,11 +136,11 @@
// Effectively we only need to add the highest bit in p_lo to p_hi (and
// Q_hi + 1 does not overflow).
- Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up
+ Q += std::uint64_t{ 1 } << (64u - 32u - 1u); // round, ties up
const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
- return {h, x.e + y.e + 64};
+ return { h, x.e + y.e + 64 };
}
/*!
@@ -171,7 +171,7 @@
JSON_ASSERT(delta >= 0);
JSON_ASSERT(((x.f << delta) >> delta) == x.f);
- return {x.f << delta, target_exponent};
+ return { x.f << delta, target_exponent };
}
};
@@ -206,7 +206,7 @@
constexpr int kPrecision = std::numeric_limits<FloatType>::digits; // = p (includes the hidden bit)
constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
constexpr int kMinExp = 1 - kBias;
- constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
+ constexpr std::uint64_t kHiddenBit = std::uint64_t{ 1 } << (kPrecision - 1); // = 2^(p-1)
using bits_type = typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t>::type;
@@ -249,7 +249,7 @@
// Determine w- = m- such that e_(w-) = e_(w+).
const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e);
- return {diyfp::normalize(v), w_minus, w_plus};
+ return { diyfp::normalize(v), w_minus, w_plus };
}
// Given normalized diyfp w, Grisu needs to find a (normalized) cached
@@ -379,28 +379,28 @@
constexpr int kCachedPowersMinDecExp = -300;
constexpr int kCachedPowersDecStep = 8;
- static constexpr std::array<cached_power, 79> 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<cached_power, 79> 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)
@@ -548,7 +548,7 @@
// = ((p1 ) * 2^-e + (p2 )) * 2^e
// = p1 + p2 * 2^e
- const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
+ const diyfp one(std::uint64_t{ 1 } << -M_plus.e, M_plus.e);
auto p1 = static_cast<std::uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
@@ -613,7 +613,7 @@
// Note:
// Since rest and delta share the same exponent e, it suffices to
// compare the significands.
- const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
+ const std::uint64_t rest = (std::uint64_t{ p1 } << -one.e) + p2;
if (rest <= delta)
{
// V = buffer * 10^n, with M- <= V <= M+.
@@ -629,7 +629,7 @@
//
// 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e
//
- const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
+ const std::uint64_t ten_n = std::uint64_t{ pow10 } << -one.e;
grisu2_round(buffer, length, dist, delta, rest, ten_n);
return;
diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp
index 4fd3d86..f69205e 100644
--- a/include/nlohmann/detail/conversions/to_json.hpp
+++ b/include/nlohmann/detail/conversions/to_json.hpp
@@ -392,20 +392,20 @@
enable_if_t<std::is_constructible<BasicJsonType, T1>::value && std::is_constructible<BasicJsonType, T2>::value, int> = 0>
inline void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
{
- j = {p.first, p.second};
+ j = { p.first, p.second };
}
// for https://github.com/nlohmann/json/pull/1134
template<typename BasicJsonType, typename T, enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0>
inline void to_json(BasicJsonType& j, const T& b)
{
- j = {{b.key(), b.value()}};
+ j = { { b.key(), b.value() } };
}
template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
inline void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/)
{
- j = {std::get<Idx>(t)...};
+ j = { std::get<Idx>(t)... };
}
template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value, int> = 0>
diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp
index ac4014b..98e4153 100644
--- a/include/nlohmann/detail/exceptions.hpp
+++ b/include/nlohmann/detail/exceptions.hpp
@@ -51,8 +51,8 @@
JSON_HEDLEY_NON_NULL(3)
exception(int id_, const char* what_arg)
: id(id_)
- , m(what_arg)
- {} // NOLINT(bugprone-throw-keyword-missing)
+ , m(what_arg) // NOLINT(bugprone-throw-keyword-missing)
+ {}
static std::string name(const std::string& ename, int id_)
{
@@ -150,7 +150,7 @@
static parse_error create(int id_, const position_t& pos, const std::string& what_arg, BasicJsonContext context)
{
const std::string w = concat(exception::name("parse_error", id_), "parse error", position_string(pos), ": ", exception::diagnostics(context), what_arg);
- return {id_, pos.chars_read_total, w.c_str()};
+ return { id_, pos.chars_read_total, w.c_str() };
}
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
@@ -162,7 +162,7 @@
": ",
exception::diagnostics(context),
what_arg);
- return {id_, byte_, w.c_str()};
+ return { id_, byte_, w.c_str() };
}
/*!
@@ -197,7 +197,7 @@
static invalid_iterator create(int id_, const std::string& what_arg, BasicJsonContext context)
{
const std::string w = concat(exception::name("invalid_iterator", id_), exception::diagnostics(context), what_arg);
- return {id_, w.c_str()};
+ return { id_, w.c_str() };
}
private:
@@ -216,7 +216,7 @@
static type_error create(int id_, const std::string& what_arg, BasicJsonContext context)
{
const std::string w = concat(exception::name("type_error", id_), exception::diagnostics(context), what_arg);
- return {id_, w.c_str()};
+ return { id_, w.c_str() };
}
private:
@@ -235,7 +235,7 @@
static out_of_range create(int id_, const std::string& what_arg, BasicJsonContext context)
{
const std::string w = concat(exception::name("out_of_range", id_), exception::diagnostics(context), what_arg);
- return {id_, w.c_str()};
+ return { id_, w.c_str() };
}
private:
@@ -254,7 +254,7 @@
static other_error create(int id_, const std::string& what_arg, BasicJsonContext context)
{
const std::string w = concat(exception::name("other_error", id_), exception::diagnostics(context), what_arg);
- return {id_, w.c_str()};
+ return { id_, w.c_str() };
}
private:
diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp
index 4d7316f..91ac83d 100644
--- a/include/nlohmann/detail/input/binary_reader.hpp
+++ b/include/nlohmann/detail/input/binary_reader.hpp
@@ -340,12 +340,12 @@
default: // anything else not supported (yet)
{
- std::array<char, 3> cr{{}};
- static_cast<void>((std::snprintf)(cr.data(),
+ std::array<char, 3> cr{ {} };
+ static_cast<void>((std::snprintf)(cr.data(), // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
cr.size(),
"%.2hhX",
- static_cast<unsigned char>(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
- const std::string cr_str{cr.data()};
+ static_cast<unsigned char>(element_type)));
+ 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));
@@ -2970,10 +2970,10 @@
*/
std::string get_token_string() const
{
- std::array<char, 3> cr{{}};
+ std::array<char, 3> cr{ {} };
static_cast<void>(
(std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
- return std::string{cr.data()};
+ return std::string{ cr.data() };
}
/*!
@@ -3041,22 +3041,22 @@
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
- make_array<bjd_type>(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"})
+ make_array<bjd_type>(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_;
+ // 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_;
using bjd_type = std::pair<char_int_type, string_t>;
// NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)
diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp
index ae38ce4..7e104d0 100644
--- a/include/nlohmann/detail/input/input_adapters.hpp
+++ b/include/nlohmann/detail/input/input_adapters.hpp
@@ -338,7 +338,7 @@
}
/// a buffer for UTF-8 bytes
- std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
+ std::array<std::char_traits<char>::int_type, 4> utf8_bytes = { { 0, 0, 0, 0 } };
/// index to the utf8_codes array for the next valid byte
std::size_t utf8_bytes_index = 0;
diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp
index 864f4a1..966969f 100644
--- a/include/nlohmann/detail/input/json_sax.hpp
+++ b/include/nlohmann/detail/input/json_sax.hpp
@@ -568,7 +568,7 @@
// container
if (!keep_stack.back())
{
- return {false, nullptr};
+ return { false, nullptr };
}
// create value
@@ -580,20 +580,20 @@
// do not handle this value if we just learnt it shall be discarded
if (!keep)
{
- return {false, nullptr};
+ return { false, nullptr };
}
if (ref_stack.empty())
{
root = std::move(value);
- return {true, &root};
+ return { true, &root };
}
// skip this value if we already decided to skip the parent
// (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
if (!ref_stack.back())
{
- return {false, nullptr};
+ return { false, nullptr };
}
// we now only expect arrays and objects
@@ -603,7 +603,7 @@
if (ref_stack.back()->is_array())
{
ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
- return {true, &(ref_stack.back()->m_data.m_value.array->back())};
+ return { true, &(ref_stack.back()->m_data.m_value.array->back()) };
}
// object
@@ -615,12 +615,12 @@
if (!store_element)
{
- return {false, nullptr};
+ return { false, nullptr };
}
JSON_ASSERT(object_element);
*object_element = std::move(value);
- return {true, object_element};
+ return { true, object_element };
}
/// the parsed JSON value
diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp
index a132e2c..32ad58e 100644
--- a/include/nlohmann/detail/input/lexer.hpp
+++ b/include/nlohmann/detail/input/lexer.hpp
@@ -173,7 +173,7 @@
JSON_ASSERT(current == 'u');
int codepoint = 0;
- const auto factors = {12u, 8u, 4u, 0u};
+ const auto factors = { 12u, 8u, 4u, 0u };
for (const auto factor : factors)
{
get();
@@ -745,7 +745,7 @@
case 0xDE:
case 0xDF:
{
- if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF})))
+ if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({ 0x80, 0xBF })))
{
return token_type::parse_error;
}
@@ -755,7 +755,7 @@
// U+0800..U+0FFF: bytes E0 A0..BF 80..BF
case 0xE0:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0xA0, 0xBF, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -779,7 +779,7 @@
case 0xEE:
case 0xEF:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0xBF, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -789,7 +789,7 @@
// U+D000..U+D7FF: bytes ED 80..9F 80..BF
case 0xED:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0x9F, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -799,7 +799,7 @@
// U+10000..U+3FFFF F0 90..BF 80..BF 80..BF
case 0xF0:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -811,7 +811,7 @@
case 0xF2:
case 0xF3:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -821,7 +821,7 @@
// U+100000..U+10FFFF F4 80..8F 80..BF 80..BF
case 0xF4:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -1453,9 +1453,9 @@
if (static_cast<unsigned char>(c) <= '\x1F')
{
// escape control characters
- std::array<char, 9> cs{{}};
- static_cast<void>((
- std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+ std::array<char, 9> cs{ {} };
+ static_cast<void>(( // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+ std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c)));
result += cs.data();
}
else
@@ -1549,22 +1549,24 @@
case 't':
{
std::array<char_type, 4> true_literal = {
- {static_cast<char_type>('t'), static_cast<char_type>('r'), static_cast<char_type>('u'), static_cast<char_type>('e')}};
+ { static_cast<char_type>('t'), static_cast<char_type>('r'), static_cast<char_type>('u'), static_cast<char_type>('e') }
+ };
return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
}
case 'f':
{
- std::array<char_type, 5> false_literal = {{static_cast<char_type>('f'),
- static_cast<char_type>('a'),
- static_cast<char_type>('l'),
- static_cast<char_type>('s'),
- static_cast<char_type>('e')}};
+ std::array<char_type, 5> false_literal = { { static_cast<char_type>('f'),
+ static_cast<char_type>('a'),
+ static_cast<char_type>('l'),
+ static_cast<char_type>('s'),
+ static_cast<char_type>('e') } };
return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
}
case 'n':
{
std::array<char_type, 4> null_literal = {
- {static_cast<char_type>('n'), static_cast<char_type>('u'), static_cast<char_type>('l'), static_cast<char_type>('l')}};
+ { static_cast<char_type>('n'), static_cast<char_type>('u'), static_cast<char_type>('l'), static_cast<char_type>('l') }
+ };
return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
}
diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp
index bb612d7..da27f6c 100644
--- a/include/nlohmann/detail/iterators/iter_impl.hpp
+++ b/include/nlohmann/detail/iterators/iter_impl.hpp
@@ -192,12 +192,11 @@
}
JSON_PRIVATE_UNLESS_TESTED :
- /*!
+ /*!
@brief set the iterator to the first value
@pre The iterator is initialized; i.e. `m_object != nullptr`.
*/
- void
- set_begin() noexcept
+ void set_begin() noexcept
{
JSON_ASSERT(m_object != nullptr);
@@ -746,8 +745,8 @@
}
JSON_PRIVATE_UNLESS_TESTED :
- /// associated JSON instance
- pointer m_object = nullptr;
+ /// associated JSON instance
+ pointer m_object = nullptr;
/// the actual iterator of the associated instance
internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it{};
};
diff --git a/include/nlohmann/detail/iterators/primitive_iterator.hpp b/include/nlohmann/detail/iterators/primitive_iterator.hpp
index 4c651a2..ab82623 100644
--- a/include/nlohmann/detail/iterators/primitive_iterator.hpp
+++ b/include/nlohmann/detail/iterators/primitive_iterator.hpp
@@ -34,8 +34,8 @@
static constexpr difference_type end_value = begin_value + 1;
JSON_PRIVATE_UNLESS_TESTED :
- /// iterator as signed integer type
- difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
+ /// iterator as signed integer type
+ difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
public:
constexpr difference_type get_value() const noexcept
diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp
index 5f3cde8..9b6e243 100644
--- a/include/nlohmann/detail/json_pointer.hpp
+++ b/include/nlohmann/detail/json_pointer.hpp
@@ -242,7 +242,8 @@
return static_cast<size_type>(res);
}
- JSON_PRIVATE_UNLESS_TESTED : json_pointer top() const
+ JSON_PRIVATE_UNLESS_TESTED :
+ json_pointer top() const
{
if (JSON_HEDLEY_UNLIKELY(empty()))
{
@@ -250,7 +251,7 @@
}
json_pointer result = *this;
- result.reference_tokens = {reference_tokens[0]};
+ result.reference_tokens = { reference_tokens[0] };
return result;
}
diff --git a/include/nlohmann/detail/meta/cpp_future.hpp b/include/nlohmann/detail/meta/cpp_future.hpp
index 57e8430..b9f6f62 100644
--- a/include/nlohmann/detail/meta/cpp_future.hpp
+++ b/include/nlohmann/detail/meta/cpp_future.hpp
@@ -167,7 +167,7 @@
template<typename T, typename... Args>
inline constexpr std::array<T, sizeof...(Args)> make_array(Args&&... args)
{
- return std::array<T, sizeof...(Args)>{{static_cast<T>(std::forward<Args>(args))...}};
+ return std::array<T, sizeof...(Args)>{ { static_cast<T>(std::forward<Args>(args))... } };
}
} // namespace detail
diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp
index 8c0137e..0c478f7 100644
--- a/include/nlohmann/detail/output/binary_writer.hpp
+++ b/include/nlohmann/detail/output/binary_writer.hpp
@@ -789,7 +789,7 @@
return ubjson_prefix(v, use_bjdata) == first_prefix;
});
- std::vector<CharType> bjdx = {'[', '{', 'S', 'H', 'T', 'F', 'N', 'Z'}; // excluded markers in bjdata optimized type
+ std::vector<CharType> bjdx = { '[', '{', 'S', 'H', 'T', 'F', 'N', 'Z' }; // excluded markers in bjdata optimized type
if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
{
@@ -887,7 +887,7 @@
return ubjson_prefix(v, use_bjdata) == first_prefix;
});
- std::vector<CharType> bjdx = {'[', '{', 'S', 'H', 'T', 'F', 'N', 'Z'}; // excluded markers in bjdata optimized type
+ std::vector<CharType> bjdx = { '[', '{', 'S', 'H', 'T', 'F', 'N', 'Z' }; // excluded markers in bjdata optimized type
if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
{
@@ -1579,17 +1579,8 @@
*/
bool write_bjdata_ndarray(const typename BasicJsonType::object_t& value, const bool use_count, const bool use_type)
{
- std::map<string_t, CharType> 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<string_t, CharType> 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<string_t>(value.at(key)));
diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp
index d7ac8d7..137a471 100644
--- a/include/nlohmann/detail/output/serializer.hpp
+++ b/include/nlohmann/detail/output/serializer.hpp
@@ -365,7 +365,7 @@
}
JSON_PRIVATE_UNLESS_TESTED :
- /*!
+ /*!
@brief dump escaped string
Escape a string by replacing certain special characters by a sequence of an
@@ -379,8 +379,7 @@
@complexity Linear in the length of string @a s.
*/
- void
- dump_escaped(const string_t& s, const bool ensure_ascii)
+ void dump_escaped(const string_t& s, const bool ensure_ascii)
{
std::uint32_t codepoint{};
std::uint8_t state = UTF8_ACCEPT;
@@ -706,18 +705,21 @@
int> = 0>
void dump_integer(NumberType x)
{
- static constexpr std::array<std::array<char, 2>, 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<std::array<char, 2>, 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)
@@ -887,7 +889,7 @@
*/
static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept
{
- static const std::array<std::uint8_t, 400> utf8d = {{
+ static const std::array<std::uint8_t, 400> 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,
@@ -916,7 +918,7 @@
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];
@@ -960,7 +962,7 @@
output_adapter_t<char> o = nullptr;
/// a (hopefully) large enough character buffer
- std::array<char, 64> number_buffer{{}};
+ std::array<char, 64> number_buffer{ {} };
/// the locale
const std::lconv* loc = nullptr;
@@ -970,7 +972,7 @@
const char decimal_point = '\0';
/// string buffer
- std::array<char, 512> string_buffer{{}};
+ std::array<char, 512> string_buffer{ {} };
/// the indentation character
const char indent_char;
diff --git a/include/nlohmann/detail/string_escape.hpp b/include/nlohmann/detail/string_escape.hpp
index 41addc9..6a400ed 100644
--- a/include/nlohmann/detail/string_escape.hpp
+++ b/include/nlohmann/detail/string_escape.hpp
@@ -48,8 +48,8 @@
template<typename StringType>
inline StringType escape(StringType s)
{
- replace_substring(s, StringType{"~"}, StringType{"~0"});
- replace_substring(s, StringType{"/"}, StringType{"~1"});
+ replace_substring(s, StringType{ "~" }, StringType{ "~0" });
+ replace_substring(s, StringType{ "/" }, StringType{ "~1" });
return s;
}
@@ -63,8 +63,8 @@
template<typename StringType>
static void unescape(StringType& s)
{
- replace_substring(s, StringType{"~1"}, StringType{"/"});
- replace_substring(s, StringType{"~0"}, StringType{"~"});
+ replace_substring(s, StringType{ "~1" }, StringType{ "/" });
+ replace_substring(s, StringType{ "~0" }, StringType{ "~" });
}
} // namespace detail
diff --git a/include/nlohmann/detail/value_t.hpp b/include/nlohmann/detail/value_t.hpp
index eb7bcca..3579320 100644
--- a/include/nlohmann/detail/value_t.hpp
+++ b/include/nlohmann/detail/value_t.hpp
@@ -83,7 +83,7 @@
inline bool operator<(const value_t lhs, const value_t rhs) noexcept
#endif
{
- static constexpr std::array<std::uint8_t, 9> order = {{
+ static constexpr std::array<std::uint8_t, 9> order = { {
0 /* null */,
3 /* object */,
4 /* array */,
@@ -93,7 +93,7 @@
2 /* unsigned */,
2 /* float */,
6 /* binary */
- }};
+ } };
const auto l_index = static_cast<std::size_t>(lhs);
const auto r_index = static_cast<std::size_t>(rhs);
diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp
index 8746e75..873ba70 100644
--- a/include/nlohmann/json.hpp
+++ b/include/nlohmann/json.hpp
@@ -126,8 +126,8 @@
using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>;
JSON_PRIVATE_UNLESS_TESTED :
- // convenience aliases for types residing in namespace detail;
- using lexer = ::nlohmann::detail::lexer_base<basic_json>;
+ // convenience aliases for types residing in namespace detail;
+ using lexer = ::nlohmann::detail::lexer_base<basic_json>;
template<typename InputAdapterType>
static ::nlohmann::detail::parser<basic_json, InputAdapterType>
@@ -155,7 +155,8 @@
template<typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
- JSON_PRIVATE_UNLESS_TESTED : using serializer = ::nlohmann::detail::serializer<basic_json>;
+ JSON_PRIVATE_UNLESS_TESTED :
+ using serializer = ::nlohmann::detail::serializer<basic_json>;
public:
using value_t = detail::value_t;
@@ -271,25 +272,25 @@
#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"}};
+ result["compiler"] = { { "family", "unknown" }, { "version", "unknown" } };
#endif
#if defined(_MSVC_LANG)
@@ -383,7 +384,7 @@
////////////////////////
JSON_PRIVATE_UNLESS_TESTED :
- /*!
+ /*!
@brief a JSON value
The actual storage for a JSON value of the @ref basic_json class. This
@@ -408,7 +409,7 @@
@since version 1.0.0
*/
- union json_value
+ union json_value
{
/// object (stored with pointer to save storage)
object_t* object;
@@ -1022,7 +1023,7 @@
/// @brief construct an array with count copies of given value
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/
basic_json(size_type cnt, const basic_json& val)
- : m_data{cnt, val}
+ : m_data{ cnt, val }
{
set_parents();
assert_invariant();
@@ -3210,7 +3211,7 @@
it.m_it.object_iterator = res.first;
// return pair of iterator and boolean
- return {it, res.second};
+ return { it, res.second };
}
/// Helper for insertion of an iterator
@@ -3599,13 +3600,12 @@
return (default_result);
JSON_PRIVATE_UNLESS_TESTED :
- // returns true if:
- // - any operand is NaN and the other operand is of number type
- // - any operand is discarded
- // in legacy mode, discarded values are considered ordered if
- // an operation is computed as an odd number of inverses of others
- static bool
- compares_unordered(const_reference lhs, const_reference rhs, bool inverse = false) noexcept
+ // returns true if:
+ // - any operand is NaN and the other operand is of number type
+ // - any operand is discarded
+ // in legacy mode, discarded values are considered ordered if
+ // an operation is computed as an odd number of inverses of others
+ 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()))
@@ -4106,11 +4106,11 @@
}
JSON_PRIVATE_UNLESS_TESTED :
- //////////////////////
- // member variables //
- //////////////////////
+ //////////////////////
+ // member variables //
+ //////////////////////
- struct data
+ struct data
{
/// the type of the current element
value_t m_type = value_t::null;
@@ -4872,7 +4872,7 @@
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;
}
@@ -4899,14 +4899,14 @@
{
// add operations in reverse order to avoid invalid
// indices
- result.insert(result.begin() + end_index, object({{"op", "remove"}, {"path", detail::concat(path, '/', std::to_string(i))}}));
+ result.insert(result.begin() + end_index, object({ { "op", "remove" }, { "path", detail::concat(path, '/', std::to_string(i)) } }));
++i;
}
// 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;
}
@@ -4930,7 +4930,7 @@
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 } }));
}
}
@@ -4941,7 +4941,7 @@
{
// 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() } });
}
}
@@ -4959,7 +4959,7 @@
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;
}
}
diff --git a/include/nlohmann/ordered_map.hpp b/include/nlohmann/ordered_map.hpp
index 3cc4e97..11353ec 100644
--- a/include/nlohmann/ordered_map.hpp
+++ b/include/nlohmann/ordered_map.hpp
@@ -46,14 +46,14 @@
: Container{}
{}
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc)))
- : Container{alloc}
+ : Container{ alloc }
{}
template<class It>
ordered_map(It first, It last, const Allocator& alloc = Allocator())
- : Container{first, last, alloc}
+ : Container{ first, last, alloc }
{}
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator())
- : Container{init, alloc}
+ : Container{ init, alloc }
{}
std::pair<iterator, bool> emplace(const key_type& key, T&& t)
@@ -62,11 +62,11 @@
{
if (m_compare(it->first, key))
{
- return {it, false};
+ return { it, false };
}
}
Container::emplace_back(key, std::forward<T>(t));
- return {std::prev(this->end()), true};
+ return { std::prev(this->end()), true };
}
template<class KeyType, detail::enable_if_t<detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
@@ -76,11 +76,11 @@
{
if (m_compare(it->first, key))
{
- return {it, false};
+ return { it, false };
}
}
Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
- return {std::prev(this->end()), true};
+ return { std::prev(this->end()), true };
}
T& operator[](const key_type& key)
@@ -169,7 +169,7 @@
for (auto next = it; ++next != this->end(); ++it)
{
it->~value_type(); // Destroy but keep allocation
- new (&*it) value_type{std::move(*next)};
+ new (&*it) value_type{ std::move(*next) };
}
Container::pop_back();
return 1;
@@ -189,7 +189,7 @@
for (auto next = it; ++next != this->end(); ++it)
{
it->~value_type(); // Destroy but keep allocation
- new (&*it) value_type{std::move(*next)};
+ new (&*it) value_type{ std::move(*next) };
}
Container::pop_back();
return 1;
@@ -235,8 +235,8 @@
for (auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
{
- it->~value_type(); // destroy but keep allocation
- new (&*it) value_type{std::move(*std::next(it, elements_affected))}; // "move" next element to it
+ it->~value_type(); // destroy but keep allocation
+ new (&*it) value_type{ std::move(*std::next(it, elements_affected)) }; // "move" next element to it
}
// [ a, b, c, d, h, i, j, h, i, j ]
@@ -329,11 +329,11 @@
{
if (m_compare(it->first, value.first))
{
- return {it, false};
+ return { it, false };
}
}
Container::push_back(value);
- return {--this->end(), true};
+ return { --this->end(), true };
}
template<typename InputIt>
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index 5ff5df8..fb96708 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -213,6 +213,7 @@
// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
+#include <utility> // declval, pair
// #include <nlohmann/detail/meta/detected.hpp>
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
@@ -2024,8 +2025,6 @@
#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */
-#include <utility> // 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
@@ -6107,7 +6106,7 @@
template<typename T, typename... Args>
inline constexpr std::array<T, sizeof...(Args)> make_array(Args&&... args)
{
- return std::array<T, sizeof...(Args)>{{static_cast<T>(std::forward<Args>(args))...}};
+ return std::array<T, sizeof...(Args)>{ { static_cast<T>(std::forward<Args>(args))... } };
}
} // namespace detail
@@ -7272,8 +7271,8 @@
template<typename StringType>
inline StringType escape(StringType s)
{
- replace_substring(s, StringType{"~"}, StringType{"~0"});
- replace_substring(s, StringType{"/"}, StringType{"~1"});
+ replace_substring(s, StringType{ "~" }, StringType{ "~0" });
+ replace_substring(s, StringType{ "/" }, StringType{ "~1" });
return s;
}
@@ -7287,8 +7286,8 @@
template<typename StringType>
static void unescape(StringType& s)
{
- replace_substring(s, StringType{"~1"}, StringType{"/"});
- replace_substring(s, StringType{"~0"}, StringType{"~"});
+ replace_substring(s, StringType{ "~1" }, StringType{ "/" });
+ replace_substring(s, StringType{ "~0" }, StringType{ "~" });
}
} // namespace detail
@@ -7379,7 +7378,7 @@
inline bool operator<(const value_t lhs, const value_t rhs) noexcept
#endif
{
- static constexpr std::array<std::uint8_t, 9> order = {{
+ static constexpr std::array<std::uint8_t, 9> order = { {
0 /* null */,
3 /* object */,
4 /* array */,
@@ -7389,7 +7388,7 @@
2 /* unsigned */,
2 /* float */,
6 /* binary */
- }};
+ } };
const auto l_index = static_cast<std::size_t>(lhs);
const auto r_index = static_cast<std::size_t>(rhs);
@@ -7444,8 +7443,8 @@
JSON_HEDLEY_NON_NULL(3)
exception(int id_, const char* what_arg)
: id(id_)
- , m(what_arg)
- {} // NOLINT(bugprone-throw-keyword-missing)
+ , m(what_arg) // NOLINT(bugprone-throw-keyword-missing)
+ {}
static std::string name(const std::string& ename, int id_)
{
@@ -7543,7 +7542,7 @@
static parse_error create(int id_, const position_t& pos, const std::string& what_arg, BasicJsonContext context)
{
const std::string w = concat(exception::name("parse_error", id_), "parse error", position_string(pos), ": ", exception::diagnostics(context), what_arg);
- return {id_, pos.chars_read_total, w.c_str()};
+ return { id_, pos.chars_read_total, w.c_str() };
}
template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
@@ -7555,7 +7554,7 @@
": ",
exception::diagnostics(context),
what_arg);
- return {id_, byte_, w.c_str()};
+ return { id_, byte_, w.c_str() };
}
/*!
@@ -7590,7 +7589,7 @@
static invalid_iterator create(int id_, const std::string& what_arg, BasicJsonContext context)
{
const std::string w = concat(exception::name("invalid_iterator", id_), exception::diagnostics(context), what_arg);
- return {id_, w.c_str()};
+ return { id_, w.c_str() };
}
private:
@@ -7609,7 +7608,7 @@
static type_error create(int id_, const std::string& what_arg, BasicJsonContext context)
{
const std::string w = concat(exception::name("type_error", id_), exception::diagnostics(context), what_arg);
- return {id_, w.c_str()};
+ return { id_, w.c_str() };
}
private:
@@ -7628,7 +7627,7 @@
static out_of_range create(int id_, const std::string& what_arg, BasicJsonContext context)
{
const std::string w = concat(exception::name("out_of_range", id_), exception::diagnostics(context), what_arg);
- return {id_, w.c_str()};
+ return { id_, w.c_str() };
}
private:
@@ -7647,7 +7646,7 @@
static other_error create(int id_, const std::string& what_arg, BasicJsonContext context)
{
const std::string w = concat(exception::name("other_error", id_), exception::diagnostics(context), what_arg);
- return {id_, w.c_str()};
+ return { id_, w.c_str() };
}
private:
@@ -7945,7 +7944,7 @@
std::array<T, sizeof...(Idx)>
from_json_inplace_array_impl(BasicJsonType&& j, identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
{
- return {{std::forward<BasicJsonType>(j).at(Idx).template get<T>()...}};
+ return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
}
template<typename BasicJsonType, typename T, std::size_t N>
@@ -8046,7 +8045,7 @@
template<typename BasicJsonType, class A1, class A2>
std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
{
- return {std::forward<BasicJsonType>(j).at(0).template get<A1>(), std::forward<BasicJsonType>(j).at(1).template get<A2>()};
+ return { std::forward<BasicJsonType>(j).at(0).template get<A1>(), std::forward<BasicJsonType>(j).at(1).template get<A2>() };
}
template<typename BasicJsonType, typename A1, typename A2>
@@ -8806,20 +8805,20 @@
enable_if_t<std::is_constructible<BasicJsonType, T1>::value && std::is_constructible<BasicJsonType, T2>::value, int> = 0>
inline void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
{
- j = {p.first, p.second};
+ j = { p.first, p.second };
}
// for https://github.com/nlohmann/json/pull/1134
template<typename BasicJsonType, typename T, enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0>
inline void to_json(BasicJsonType& j, const T& b)
{
- j = {{b.key(), b.value()}};
+ j = { { b.key(), b.value() } };
}
template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
inline void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/)
{
- j = {std::get<Idx>(t)...};
+ j = { std::get<Idx>(t)... };
}
template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value, int> = 0>
@@ -9503,7 +9502,7 @@
}
/// a buffer for UTF-8 bytes
- std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
+ std::array<std::char_traits<char>::int_type, 4> utf8_bytes = { { 0, 0, 0, 0 } };
/// index to the utf8_codes array for the next valid byte
std::size_t utf8_bytes_index = 0;
@@ -10233,7 +10232,7 @@
// container
if (!keep_stack.back())
{
- return {false, nullptr};
+ return { false, nullptr };
}
// create value
@@ -10245,20 +10244,20 @@
// do not handle this value if we just learnt it shall be discarded
if (!keep)
{
- return {false, nullptr};
+ return { false, nullptr };
}
if (ref_stack.empty())
{
root = std::move(value);
- return {true, &root};
+ return { true, &root };
}
// skip this value if we already decided to skip the parent
// (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
if (!ref_stack.back())
{
- return {false, nullptr};
+ return { false, nullptr };
}
// we now only expect arrays and objects
@@ -10268,7 +10267,7 @@
if (ref_stack.back()->is_array())
{
ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
- return {true, &(ref_stack.back()->m_data.m_value.array->back())};
+ return { true, &(ref_stack.back()->m_data.m_value.array->back()) };
}
// object
@@ -10280,12 +10279,12 @@
if (!store_element)
{
- return {false, nullptr};
+ return { false, nullptr };
}
JSON_ASSERT(object_element);
*object_element = std::move(value);
- return {true, object_element};
+ return { true, object_element };
}
/// the parsed JSON value
@@ -10564,7 +10563,7 @@
JSON_ASSERT(current == 'u');
int codepoint = 0;
- const auto factors = {12u, 8u, 4u, 0u};
+ const auto factors = { 12u, 8u, 4u, 0u };
for (const auto factor : factors)
{
get();
@@ -11136,7 +11135,7 @@
case 0xDE:
case 0xDF:
{
- if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF})))
+ if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({ 0x80, 0xBF })))
{
return token_type::parse_error;
}
@@ -11146,7 +11145,7 @@
// U+0800..U+0FFF: bytes E0 A0..BF 80..BF
case 0xE0:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0xA0, 0xBF, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -11170,7 +11169,7 @@
case 0xEE:
case 0xEF:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0xBF, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -11180,7 +11179,7 @@
// U+D000..U+D7FF: bytes ED 80..9F 80..BF
case 0xED:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0x9F, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -11190,7 +11189,7 @@
// U+10000..U+3FFFF F0 90..BF 80..BF 80..BF
case 0xF0:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -11202,7 +11201,7 @@
case 0xF2:
case 0xF3:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -11212,7 +11211,7 @@
// U+100000..U+10FFFF F4 80..8F 80..BF 80..BF
case 0xF4:
{
- if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF}))))
+ if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({ 0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF }))))
{
return token_type::parse_error;
}
@@ -11844,9 +11843,9 @@
if (static_cast<unsigned char>(c) <= '\x1F')
{
// escape control characters
- std::array<char, 9> cs{{}};
- static_cast<void>((
- std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+ std::array<char, 9> cs{ {} };
+ static_cast<void>(( // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+ std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c)));
result += cs.data();
}
else
@@ -11940,22 +11939,24 @@
case 't':
{
std::array<char_type, 4> true_literal = {
- {static_cast<char_type>('t'), static_cast<char_type>('r'), static_cast<char_type>('u'), static_cast<char_type>('e')}};
+ { static_cast<char_type>('t'), static_cast<char_type>('r'), static_cast<char_type>('u'), static_cast<char_type>('e') }
+ };
return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
}
case 'f':
{
- std::array<char_type, 5> false_literal = {{static_cast<char_type>('f'),
- static_cast<char_type>('a'),
- static_cast<char_type>('l'),
- static_cast<char_type>('s'),
- static_cast<char_type>('e')}};
+ std::array<char_type, 5> false_literal = { { static_cast<char_type>('f'),
+ static_cast<char_type>('a'),
+ static_cast<char_type>('l'),
+ static_cast<char_type>('s'),
+ static_cast<char_type>('e') } };
return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
}
case 'n':
{
std::array<char_type, 4> null_literal = {
- {static_cast<char_type>('n'), static_cast<char_type>('u'), static_cast<char_type>('l'), static_cast<char_type>('l')}};
+ { static_cast<char_type>('n'), static_cast<char_type>('u'), static_cast<char_type>('l'), static_cast<char_type>('l') }
+ };
return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
}
@@ -12470,12 +12471,12 @@
default: // anything else not supported (yet)
{
- std::array<char, 3> cr{{}};
- static_cast<void>((std::snprintf)(cr.data(),
+ std::array<char, 3> cr{ {} };
+ static_cast<void>((std::snprintf)(cr.data(), // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
cr.size(),
"%.2hhX",
- static_cast<unsigned char>(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
- const std::string cr_str{cr.data()};
+ static_cast<unsigned char>(element_type)));
+ 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));
@@ -15100,10 +15101,10 @@
*/
std::string get_token_string() const
{
- std::array<char, 3> cr{{}};
+ std::array<char, 3> cr{ {} };
static_cast<void>(
(std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
- return std::string{cr.data()};
+ return std::string{ cr.data() };
}
/*!
@@ -15171,22 +15172,22 @@
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
- make_array<bjd_type>(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"})
+ make_array<bjd_type>(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_;
+ // 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_;
using bjd_type = std::pair<char_int_type, string_t>;
// NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)
@@ -15787,8 +15788,8 @@
static constexpr difference_type end_value = begin_value + 1;
JSON_PRIVATE_UNLESS_TESTED :
- /// iterator as signed integer type
- difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
+ /// iterator as signed integer type
+ difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
public:
constexpr difference_type get_value() const noexcept
@@ -16107,12 +16108,11 @@
}
JSON_PRIVATE_UNLESS_TESTED :
- /*!
+ /*!
@brief set the iterator to the first value
@pre The iterator is initialized; i.e. `m_object != nullptr`.
*/
- void
- set_begin() noexcept
+ void set_begin() noexcept
{
JSON_ASSERT(m_object != nullptr);
@@ -16661,8 +16661,8 @@
}
JSON_PRIVATE_UNLESS_TESTED :
- /// associated JSON instance
- pointer m_object = nullptr;
+ /// associated JSON instance
+ pointer m_object = nullptr;
/// the actual iterator of the associated instance
internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it{};
};
@@ -17090,7 +17090,8 @@
return static_cast<size_type>(res);
}
- JSON_PRIVATE_UNLESS_TESTED : json_pointer top() const
+ JSON_PRIVATE_UNLESS_TESTED :
+ json_pointer top() const
{
if (JSON_HEDLEY_UNLIKELY(empty()))
{
@@ -17098,7 +17099,7 @@
}
json_pointer result = *this;
- result.reference_tokens = {reference_tokens[0]};
+ result.reference_tokens = { reference_tokens[0] };
return result;
}
@@ -18828,7 +18829,7 @@
return ubjson_prefix(v, use_bjdata) == first_prefix;
});
- std::vector<CharType> bjdx = {'[', '{', 'S', 'H', 'T', 'F', 'N', 'Z'}; // excluded markers in bjdata optimized type
+ std::vector<CharType> bjdx = { '[', '{', 'S', 'H', 'T', 'F', 'N', 'Z' }; // excluded markers in bjdata optimized type
if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
{
@@ -18926,7 +18927,7 @@
return ubjson_prefix(v, use_bjdata) == first_prefix;
});
- std::vector<CharType> bjdx = {'[', '{', 'S', 'H', 'T', 'F', 'N', 'Z'}; // excluded markers in bjdata optimized type
+ std::vector<CharType> bjdx = { '[', '{', 'S', 'H', 'T', 'F', 'N', 'Z' }; // excluded markers in bjdata optimized type
if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
{
@@ -19618,17 +19619,8 @@
*/
bool write_bjdata_ndarray(const typename BasicJsonType::object_t& value, const bool use_count, const bool use_type)
{
- std::map<string_t, CharType> 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<string_t, CharType> 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<string_t>(value.at(key)));
@@ -19939,7 +19931,7 @@
JSON_ASSERT(x.e == y.e);
JSON_ASSERT(x.f >= y.f);
- return {x.f - y.f, x.e};
+ return { x.f - y.f, x.e };
}
/*!
@@ -20000,11 +19992,11 @@
// Effectively we only need to add the highest bit in p_lo to p_hi (and
// Q_hi + 1 does not overflow).
- Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up
+ Q += std::uint64_t{ 1 } << (64u - 32u - 1u); // round, ties up
const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
- return {h, x.e + y.e + 64};
+ return { h, x.e + y.e + 64 };
}
/*!
@@ -20035,7 +20027,7 @@
JSON_ASSERT(delta >= 0);
JSON_ASSERT(((x.f << delta) >> delta) == x.f);
- return {x.f << delta, target_exponent};
+ return { x.f << delta, target_exponent };
}
};
@@ -20070,7 +20062,7 @@
constexpr int kPrecision = std::numeric_limits<FloatType>::digits; // = p (includes the hidden bit)
constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
constexpr int kMinExp = 1 - kBias;
- constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
+ constexpr std::uint64_t kHiddenBit = std::uint64_t{ 1 } << (kPrecision - 1); // = 2^(p-1)
using bits_type = typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t>::type;
@@ -20113,7 +20105,7 @@
// Determine w- = m- such that e_(w-) = e_(w+).
const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e);
- return {diyfp::normalize(v), w_minus, w_plus};
+ return { diyfp::normalize(v), w_minus, w_plus };
}
// Given normalized diyfp w, Grisu needs to find a (normalized) cached
@@ -20243,28 +20235,28 @@
constexpr int kCachedPowersMinDecExp = -300;
constexpr int kCachedPowersDecStep = 8;
- static constexpr std::array<cached_power, 79> 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<cached_power, 79> 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)
@@ -20412,7 +20404,7 @@
// = ((p1 ) * 2^-e + (p2 )) * 2^e
// = p1 + p2 * 2^e
- const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
+ const diyfp one(std::uint64_t{ 1 } << -M_plus.e, M_plus.e);
auto p1 = static_cast<std::uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
@@ -20477,7 +20469,7 @@
// Note:
// Since rest and delta share the same exponent e, it suffices to
// compare the significands.
- const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
+ const std::uint64_t rest = (std::uint64_t{ p1 } << -one.e) + p2;
if (rest <= delta)
{
// V = buffer * 10^n, with M- <= V <= M+.
@@ -20493,7 +20485,7 @@
//
// 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e
//
- const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
+ const std::uint64_t ten_n = std::uint64_t{ pow10 } << -one.e;
grisu2_round(buffer, length, dist, delta, rest, ten_n);
return;
@@ -21258,7 +21250,7 @@
}
JSON_PRIVATE_UNLESS_TESTED :
- /*!
+ /*!
@brief dump escaped string
Escape a string by replacing certain special characters by a sequence of an
@@ -21272,8 +21264,7 @@
@complexity Linear in the length of string @a s.
*/
- void
- dump_escaped(const string_t& s, const bool ensure_ascii)
+ void dump_escaped(const string_t& s, const bool ensure_ascii)
{
std::uint32_t codepoint{};
std::uint8_t state = UTF8_ACCEPT;
@@ -21599,18 +21590,21 @@
int> = 0>
void dump_integer(NumberType x)
{
- static constexpr std::array<std::array<char, 2>, 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<std::array<char, 2>, 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)
@@ -21780,7 +21774,7 @@
*/
static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept
{
- static const std::array<std::uint8_t, 400> utf8d = {{
+ static const std::array<std::uint8_t, 400> 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,
@@ -21809,7 +21803,7 @@
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];
@@ -21853,7 +21847,7 @@
output_adapter_t<char> o = nullptr;
/// a (hopefully) large enough character buffer
- std::array<char, 64> number_buffer{{}};
+ std::array<char, 64> number_buffer{ {} };
/// the locale
const std::lconv* loc = nullptr;
@@ -21863,7 +21857,7 @@
const char decimal_point = '\0';
/// string buffer
- std::array<char, 512> string_buffer{{}};
+ std::array<char, 512> string_buffer{ {} };
/// the indentation character
const char indent_char;
@@ -21933,14 +21927,14 @@
: Container{}
{}
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc)))
- : Container{alloc}
+ : Container{ alloc }
{}
template<class It>
ordered_map(It first, It last, const Allocator& alloc = Allocator())
- : Container{first, last, alloc}
+ : Container{ first, last, alloc }
{}
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator())
- : Container{init, alloc}
+ : Container{ init, alloc }
{}
std::pair<iterator, bool> emplace(const key_type& key, T&& t)
@@ -21949,11 +21943,11 @@
{
if (m_compare(it->first, key))
{
- return {it, false};
+ return { it, false };
}
}
Container::emplace_back(key, std::forward<T>(t));
- return {std::prev(this->end()), true};
+ return { std::prev(this->end()), true };
}
template<class KeyType, detail::enable_if_t<detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
@@ -21963,11 +21957,11 @@
{
if (m_compare(it->first, key))
{
- return {it, false};
+ return { it, false };
}
}
Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
- return {std::prev(this->end()), true};
+ return { std::prev(this->end()), true };
}
T& operator[](const key_type& key)
@@ -22056,7 +22050,7 @@
for (auto next = it; ++next != this->end(); ++it)
{
it->~value_type(); // Destroy but keep allocation
- new (&*it) value_type{std::move(*next)};
+ new (&*it) value_type{ std::move(*next) };
}
Container::pop_back();
return 1;
@@ -22076,7 +22070,7 @@
for (auto next = it; ++next != this->end(); ++it)
{
it->~value_type(); // Destroy but keep allocation
- new (&*it) value_type{std::move(*next)};
+ new (&*it) value_type{ std::move(*next) };
}
Container::pop_back();
return 1;
@@ -22122,8 +22116,8 @@
for (auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
{
- it->~value_type(); // destroy but keep allocation
- new (&*it) value_type{std::move(*std::next(it, elements_affected))}; // "move" next element to it
+ it->~value_type(); // destroy but keep allocation
+ new (&*it) value_type{ std::move(*std::next(it, elements_affected)) }; // "move" next element to it
}
// [ a, b, c, d, h, i, j, h, i, j ]
@@ -22216,11 +22210,11 @@
{
if (m_compare(it->first, value.first))
{
- return {it, false};
+ return { it, false };
}
}
Container::push_back(value);
- return {--this->end(), true};
+ return { --this->end(), true };
}
template<typename InputIt>
@@ -22307,8 +22301,8 @@
using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>;
JSON_PRIVATE_UNLESS_TESTED :
- // convenience aliases for types residing in namespace detail;
- using lexer = ::nlohmann::detail::lexer_base<basic_json>;
+ // convenience aliases for types residing in namespace detail;
+ using lexer = ::nlohmann::detail::lexer_base<basic_json>;
template<typename InputAdapterType>
static ::nlohmann::detail::parser<basic_json, InputAdapterType>
@@ -22336,7 +22330,8 @@
template<typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
- JSON_PRIVATE_UNLESS_TESTED : using serializer = ::nlohmann::detail::serializer<basic_json>;
+ JSON_PRIVATE_UNLESS_TESTED :
+ using serializer = ::nlohmann::detail::serializer<basic_json>;
public:
using value_t = detail::value_t;
@@ -22452,25 +22447,25 @@
#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"}};
+ result["compiler"] = { { "family", "unknown" }, { "version", "unknown" } };
#endif
#if defined(_MSVC_LANG)
@@ -22564,7 +22559,7 @@
////////////////////////
JSON_PRIVATE_UNLESS_TESTED :
- /*!
+ /*!
@brief a JSON value
The actual storage for a JSON value of the @ref basic_json class. This
@@ -22589,7 +22584,7 @@
@since version 1.0.0
*/
- union json_value
+ union json_value
{
/// object (stored with pointer to save storage)
object_t* object;
@@ -23203,7 +23198,7 @@
/// @brief construct an array with count copies of given value
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/
basic_json(size_type cnt, const basic_json& val)
- : m_data{cnt, val}
+ : m_data{ cnt, val }
{
set_parents();
assert_invariant();
@@ -25391,7 +25386,7 @@
it.m_it.object_iterator = res.first;
// return pair of iterator and boolean
- return {it, res.second};
+ return { it, res.second };
}
/// Helper for insertion of an iterator
@@ -25780,13 +25775,12 @@
return (default_result);
JSON_PRIVATE_UNLESS_TESTED :
- // returns true if:
- // - any operand is NaN and the other operand is of number type
- // - any operand is discarded
- // in legacy mode, discarded values are considered ordered if
- // an operation is computed as an odd number of inverses of others
- static bool
- compares_unordered(const_reference lhs, const_reference rhs, bool inverse = false) noexcept
+ // returns true if:
+ // - any operand is NaN and the other operand is of number type
+ // - any operand is discarded
+ // in legacy mode, discarded values are considered ordered if
+ // an operation is computed as an odd number of inverses of others
+ 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()))
@@ -26287,11 +26281,11 @@
}
JSON_PRIVATE_UNLESS_TESTED :
- //////////////////////
- // member variables //
- //////////////////////
+ //////////////////////
+ // member variables //
+ //////////////////////
- struct data
+ struct data
{
/// the type of the current element
value_t m_type = value_t::null;
@@ -27053,7 +27047,7 @@
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;
}
@@ -27080,14 +27074,14 @@
{
// add operations in reverse order to avoid invalid
// indices
- result.insert(result.begin() + end_index, object({{"op", "remove"}, {"path", detail::concat(path, '/', std::to_string(i))}}));
+ result.insert(result.begin() + end_index, object({ { "op", "remove" }, { "path", detail::concat(path, '/', std::to_string(i)) } }));
++i;
}
// 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;
}
@@ -27111,7 +27105,7 @@
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 } }));
}
}
@@ -27122,7 +27116,7 @@
{
// 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() } });
}
}
@@ -27140,7 +27134,7 @@
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;
}
}
diff --git a/single_include/nlohmann/json_fwd.hpp b/single_include/nlohmann/json_fwd.hpp
index ccf06a3..7f1a379 100644
--- a/single_include/nlohmann/json_fwd.hpp
+++ b/single_include/nlohmann/json_fwd.hpp
@@ -24,8 +24,6 @@
// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
-
-
// This file contains all macro definitions affecting or depending on the ABI
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
@@ -103,7 +101,6 @@
} // namespace nlohmann
#endif
-
/*!
@brief namespace for Niels Lohmann
@see https://github.com/nlohmann
diff --git a/tests/abi/config/custom.cpp b/tests/abi/config/custom.cpp
index c643713..7ecaeb5 100644
--- a/tests/abi/config/custom.cpp
+++ b/tests/abi/config/custom.cpp
@@ -27,7 +27,7 @@
std::string expected = "nlohmann::basic_json";
// fallback for Clang
- const std::string ns{STRINGIZE(NLOHMANN_JSON_NAMESPACE) "::basic_json"};
+ const std::string ns{ STRINGIZE(NLOHMANN_JSON_NAMESPACE) "::basic_json" };
CHECK(namespace_name<nlohmann::json>(ns) == expected);
}
diff --git a/tests/abi/config/default.cpp b/tests/abi/config/default.cpp
index ae7b9be..e15c016 100644
--- a/tests/abi/config/default.cpp
+++ b/tests/abi/config/default.cpp
@@ -33,7 +33,7 @@
expected += "_" STRINGIZE(NLOHMANN_JSON_VERSION_PATCH) "::basic_json";
// fallback for Clang
- const std::string ns{STRINGIZE(NLOHMANN_JSON_NAMESPACE) "::basic_json"};
+ const std::string ns{ STRINGIZE(NLOHMANN_JSON_NAMESPACE) "::basic_json" };
CHECK(namespace_name<nlohmann::json>(ns) == expected);
}
diff --git a/tests/abi/config/noversion.cpp b/tests/abi/config/noversion.cpp
index 97d9808..a395fd2 100644
--- a/tests/abi/config/noversion.cpp
+++ b/tests/abi/config/noversion.cpp
@@ -32,7 +32,7 @@
expected += "::basic_json";
// fallback for Clang
- const std::string ns{STRINGIZE(NLOHMANN_JSON_NAMESPACE) "::basic_json"};
+ const std::string ns{ STRINGIZE(NLOHMANN_JSON_NAMESPACE) "::basic_json" };
CHECK(namespace_name<nlohmann::json>(ns) == expected);
}
diff --git a/tests/abi/diag/diag_off.cpp b/tests/abi/diag/diag_off.cpp
index cd0d178..0867fa3 100644
--- a/tests/abi/diag/diag_off.cpp
+++ b/tests/abi/diag/diag_off.cpp
@@ -25,6 +25,6 @@
void json_at_diag_off()
{
using nlohmann::json;
- json j = json{{"foo", json::object()}};
+ json j = json{ { "foo", json::object() } };
j.at(json::json_pointer("/foo/bar"));
}
diff --git a/tests/abi/diag/diag_on.cpp b/tests/abi/diag/diag_on.cpp
index 197a2c0..599bc2b 100644
--- a/tests/abi/diag/diag_on.cpp
+++ b/tests/abi/diag/diag_on.cpp
@@ -25,6 +25,6 @@
void json_at_diag_on()
{
using nlohmann::json;
- json j = json{{"foo", json::object()}};
+ json j = json{ { "foo", json::object() } };
j.at(json::json_pointer("/foo/bar"));
}
diff --git a/tests/benchmarks/src/benchmarks.cpp b/tests/benchmarks/src/benchmarks.cpp
index bc50a9a..cd4a224 100644
--- a/tests/benchmarks/src/benchmarks.cpp
+++ b/tests/benchmarks/src/benchmarks.cpp
@@ -162,8 +162,8 @@
++it;
}
- json::binary_t bin{in};
- json j{{"type", "binary"}, {"data", bin}};
+ json::binary_t bin{ in };
+ json j{ { "type", "binary" }, { "data", bin } };
while (state.KeepRunning())
{
diff --git a/tests/cuda_example/json_cuda.cu b/tests/cuda_example/json_cuda.cu
index 6575966..605dc8a 100644
--- a/tests/cuda_example/json_cuda.cu
+++ b/tests/cuda_example/json_cuda.cu
@@ -10,7 +10,7 @@
int main()
{
- nlohmann::ordered_json json = {"Test"};
+ nlohmann::ordered_json json = { "Test" };
json.dump();
// regression for #3013 (ordered_json::reset() compile error with nvcc)
diff --git a/tests/src/unit-32bit.cpp b/tests/src/unit-32bit.cpp
index eceb978..e003951 100644
--- a/tests/src/unit-32bit.cpp
+++ b/tests/src/unit-32bit.cpp
@@ -106,8 +106,8 @@
{
SECTION("optimized array: negative size")
{
- std::vector<uint8_t> const vM = {'[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']'};
- std::vector<uint8_t> const vMX = {'[', '$', 'U', '#', '[', 'M', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 'U', 0x01, ']'};
+ std::vector<uint8_t> const vM = { '[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']' };
+ std::vector<uint8_t> const vMX = { '[', '$', 'U', '#', '[', 'M', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 'U', 0x01, ']' };
json _;
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM),
@@ -123,8 +123,8 @@
SECTION("optimized array: integer value overflow")
{
- std::vector<uint8_t> const vL = {'[', '#', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F};
- std::vector<uint8_t> const vM = {'[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']'};
+ std::vector<uint8_t> const vL = { '[', '#', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F };
+ std::vector<uint8_t> const vM = { '[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']' };
json _;
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vL),
diff --git a/tests/src/unit-algorithms.cpp b/tests/src/unit-algorithms.cpp
index 1a9049f..f7e9234 100644
--- a/tests/src/unit-algorithms.cpp
+++ b/tests/src/unit-algorithms.cpp
@@ -14,8 +14,8 @@
TEST_CASE("algorithms")
{
- json j_array = {13, 29, 3, {{"one", 1}, {"two", 2}}, true, false, {1, 2, 3}, "foo", "baz"};
- json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = { 13, 29, 3, { { "one", 1 }, { "two", 2 } }, true, false, { 1, 2, 3 }, "foo", "baz" };
+ json j_object = { { "one", 1 }, { "two", 2 } };
SECTION("non-modifying sequence operations")
{
@@ -76,7 +76,7 @@
std::for_each(j_array.begin(), j_array.end(), add17);
- CHECK(j_array[6] == json({1, 2, 3, 17}));
+ CHECK(j_array[6] == json({ 1, 2, 3, 17 }));
}
}
@@ -97,10 +97,10 @@
SECTION("std::mismatch")
{
- json j_array2 = {13, 29, 3, {{"one", 1}, {"two", 2}, {"three", 3}}, true, false, {1, 2, 3}, "foo", "baz"};
+ json j_array2 = { 13, 29, 3, { { "one", 1 }, { "two", 2 }, { "three", 3 } }, true, false, { 1, 2, 3 }, "foo", "baz" };
auto res = std::mismatch(j_array.begin(), j_array.end(), j_array2.begin());
- CHECK(*res.first == json({{"one", 1}, {"two", 2}}));
- CHECK(*res.second == json({{"one", 1}, {"two", 2}, {"three", 3}}));
+ CHECK(*res.first == json({ { "one", 1 }, { "two", 2 } }));
+ CHECK(*res.second == json({ { "one", 1 }, { "two", 2 }, { "three", 3 } }));
}
SECTION("std::equal")
@@ -115,7 +115,7 @@
SECTION("using user-defined comparison")
{
// compare objects only by size of its elements
- json j_array2 = {13, 29, 3, {"Hello", "World"}, true, false, {{"one", 1}, {"two", 2}, {"three", 3}}, "foo", "baz"};
+ json j_array2 = { 13, 29, 3, { "Hello", "World" }, true, false, { { "one", 1 }, { "two", 2 }, { "three", 3 } }, "foo", "baz" };
CHECK(!std::equal(j_array.begin(), j_array.end(), j_array2.begin()));
CHECK(std::equal(j_array.begin(), j_array.end(), j_array2.begin(), [](const json& a, const json& b) {
return (a.size() == b.size());
@@ -159,13 +159,13 @@
SECTION("std::reverse")
{
std::reverse(j_array.begin(), j_array.end());
- CHECK(j_array == json({"baz", "foo", {1, 2, 3}, false, true, {{"one", 1}, {"two", 2}}, 3, 29, 13}));
+ CHECK(j_array == json({ "baz", "foo", { 1, 2, 3 }, false, true, { { "one", 1 }, { "two", 2 } }, 3, 29, 13 }));
}
SECTION("std::rotate")
{
std::rotate(j_array.begin(), j_array.begin() + 1, j_array.end());
- CHECK(j_array == json({29, 3, {{"one", 1}, {"two", 2}}, true, false, {1, 2, 3}, "foo", "baz", 13}));
+ CHECK(j_array == json({ 29, 3, { { "one", 1 }, { "two", 2 } }, true, false, { 1, 2, 3 }, "foo", "baz", 13 }));
}
SECTION("std::partition")
@@ -184,23 +184,23 @@
{
SECTION("with standard comparison")
{
- json j = {13, 29, 3, {{"one", 1}, {"two", 2}}, true, false, {1, 2, 3}, "foo", "baz", nullptr};
+ json j = { 13, 29, 3, { { "one", 1 }, { "two", 2 } }, true, false, { 1, 2, 3 }, "foo", "baz", nullptr };
std::sort(j.begin(), j.end());
- CHECK(j == json({nullptr, false, true, 3, 13, 29, {{"one", 1}, {"two", 2}}, {1, 2, 3}, "baz", "foo"}));
+ CHECK(j == json({ nullptr, false, true, 3, 13, 29, { { "one", 1 }, { "two", 2 } }, { 1, 2, 3 }, "baz", "foo" }));
}
SECTION("with user-defined comparison")
{
- json j = {3, {{"one", 1}, {"two", 2}}, {1, 2, 3}, nullptr};
+ json j = { 3, { { "one", 1 }, { "two", 2 } }, { 1, 2, 3 }, nullptr };
std::sort(j.begin(), j.end(), [](const json& a, const json& b) {
return a.size() < b.size();
});
- CHECK(j == json({nullptr, 3, {{"one", 1}, {"two", 2}}, {1, 2, 3}}));
+ CHECK(j == json({ nullptr, 3, { { "one", 1 }, { "two", 2 } }, { 1, 2, 3 } }));
}
SECTION("sorting an object")
{
- json j({{"one", 1}, {"two", 2}});
+ 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&);
@@ -209,9 +209,9 @@
SECTION("std::partial_sort")
{
- json j = {13, 29, 3, {{"one", 1}, {"two", 2}}, true, false, {1, 2, 3}, "foo", "baz", nullptr};
+ json j = { 13, 29, 3, { { "one", 1 }, { "two", 2 } }, true, false, { 1, 2, 3 }, "foo", "baz", nullptr };
std::partial_sort(j.begin(), j.begin() + 4, j.end());
- CHECK(j == json({nullptr, false, true, 3, {{"one", 1}, {"two", 2}}, 29, {1, 2, 3}, "foo", "baz", 13}));
+ CHECK(j == json({ nullptr, false, true, 3, { { "one", 1 }, { "two", 2 } }, 29, { 1, 2, 3 }, "foo", "baz", 13 }));
}
}
@@ -220,53 +220,53 @@
SECTION("std::merge")
{
{
- json j1 = {2, 4, 6, 8};
- json j2 = {1, 2, 3, 5, 7};
+ json j1 = { 2, 4, 6, 8 };
+ json j2 = { 1, 2, 3, 5, 7 };
json j3;
std::merge(j1.begin(), j1.end(), j2.begin(), j2.end(), std::back_inserter(j3));
- CHECK(j3 == json({1, 2, 2, 3, 4, 5, 6, 7, 8}));
+ CHECK(j3 == json({ 1, 2, 2, 3, 4, 5, 6, 7, 8 }));
}
}
SECTION("std::set_difference")
{
- json j1 = {1, 2, 3, 4, 5, 6, 7, 8};
- json j2 = {1, 2, 3, 5, 7};
+ json j1 = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ json j2 = { 1, 2, 3, 5, 7 };
json j3;
std::set_difference(j1.begin(), j1.end(), j2.begin(), j2.end(), std::back_inserter(j3));
- CHECK(j3 == json({4, 6, 8}));
+ CHECK(j3 == json({ 4, 6, 8 }));
}
SECTION("std::set_intersection")
{
- json j1 = {1, 2, 3, 4, 5, 6, 7, 8};
- json j2 = {1, 2, 3, 5, 7};
+ json j1 = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ json j2 = { 1, 2, 3, 5, 7 };
json j3;
std::set_intersection(j1.begin(), j1.end(), j2.begin(), j2.end(), std::back_inserter(j3));
- CHECK(j3 == json({1, 2, 3, 5, 7}));
+ CHECK(j3 == json({ 1, 2, 3, 5, 7 }));
}
SECTION("std::set_union")
{
- json j1 = {2, 4, 6, 8};
- json j2 = {1, 2, 3, 5, 7};
+ json j1 = { 2, 4, 6, 8 };
+ json j2 = { 1, 2, 3, 5, 7 };
json j3;
std::set_union(j1.begin(), j1.end(), j2.begin(), j2.end(), std::back_inserter(j3));
- CHECK(j3 == json({1, 2, 3, 4, 5, 6, 7, 8}));
+ CHECK(j3 == json({ 1, 2, 3, 4, 5, 6, 7, 8 }));
}
SECTION("std::set_symmetric_difference")
{
- json j1 = {2, 4, 6, 8};
- json j2 = {1, 2, 3, 5, 7};
+ json j1 = { 2, 4, 6, 8 };
+ json j2 = { 1, 2, 3, 5, 7 };
json j3;
std::set_symmetric_difference(j1.begin(), j1.end(), j2.begin(), j2.end(), std::back_inserter(j3));
- CHECK(j3 == json({1, 3, 4, 5, 6, 7, 8}));
+ CHECK(j3 == json({ 1, 3, 4, 5, 6, 7, 8 }));
}
}
@@ -275,29 +275,29 @@
std::make_heap(j_array.begin(), j_array.end());
CHECK(std::is_heap(j_array.begin(), j_array.end()));
std::sort_heap(j_array.begin(), j_array.end());
- CHECK(j_array == json({false, true, 3, 13, 29, {{"one", 1}, {"two", 2}}, {1, 2, 3}, "baz", "foo"}));
+ CHECK(j_array == json({ false, true, 3, 13, 29, { { "one", 1 }, { "two", 2 } }, { 1, 2, 3 }, "baz", "foo" }));
}
SECTION("iota")
{
SECTION("int")
{
- json json_arr = {0, 5, 2, 4, 10, 20, 30, 40, 50, 1};
+ json json_arr = { 0, 5, 2, 4, 10, 20, 30, 40, 50, 1 };
std::iota(json_arr.begin(), json_arr.end(), 0);
- CHECK(json_arr == json({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}));
+ CHECK(json_arr == json({ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }));
}
SECTION("double")
{
- json json_arr = {0.5, 1.5, 1.3, 4.1, 10.2, 20.5, 30.6, 40.1, 50.22, 1.5};
+ json json_arr = { 0.5, 1.5, 1.3, 4.1, 10.2, 20.5, 30.6, 40.1, 50.22, 1.5 };
std::iota(json_arr.begin(), json_arr.end(), 0.5);
- CHECK(json_arr == json({0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5}));
+ CHECK(json_arr == json({ 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5 }));
}
SECTION("char")
{
- json json_arr = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', '0', '1'};
+ json json_arr = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', '0', '1' };
std::iota(json_arr.begin(), json_arr.end(), '0');
- CHECK(json_arr == json({'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}));
+ CHECK(json_arr == json({ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }));
}
}
@@ -306,7 +306,7 @@
SECTION("copy without if")
{
json dest_arr;
- const json source_arr = {1, 2, 3, 4};
+ const json source_arr = { 1, 2, 3, 4 };
std::copy(source_arr.begin(), source_arr.end(), std::back_inserter(dest_arr));
@@ -315,30 +315,30 @@
SECTION("copy if")
{
json dest_arr;
- const json source_arr = {0, 3, 6, 9, 12, 15, 20};
+ const json source_arr = { 0, 3, 6, 9, 12, 15, 20 };
std::copy_if(source_arr.begin(), source_arr.end(), std::back_inserter(dest_arr), [](const json& _value) {
return _value.get<int>() % 3 == 0;
});
- CHECK(dest_arr == json({0, 3, 6, 9, 12, 15}));
+ CHECK(dest_arr == json({ 0, 3, 6, 9, 12, 15 }));
}
SECTION("copy n")
{
- const json source_arr = {0, 1, 2, 3, 4, 5, 6, 7};
+ const json source_arr = { 0, 1, 2, 3, 4, 5, 6, 7 };
json dest_arr;
const unsigned char numToCopy = 2;
std::copy_n(source_arr.begin(), numToCopy, std::back_inserter(dest_arr));
- CHECK(dest_arr == json{0, 1});
+ CHECK(dest_arr == json{ 0, 1 });
}
SECTION("copy n chars")
{
- const json source_arr = {'1', '2', '3', '4', '5', '6', '7'};
+ const json source_arr = { '1', '2', '3', '4', '5', '6', '7' };
json dest_arr;
const unsigned char numToCopy = 4;
std::copy_n(source_arr.begin(), numToCopy, std::back_inserter(dest_arr));
- CHECK(dest_arr == json{'1', '2', '3', '4'});
+ CHECK(dest_arr == json{ '1', '2', '3', '4' });
}
}
}
diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp
index 98a8ac6..c2f76c4 100644
--- a/tests/src/unit-allocator.cpp
+++ b/tests/src/unit-allocator.cpp
@@ -169,7 +169,7 @@
SECTION("basic_json(const CompatibleObjectType&)")
{
next_construct_fails = false;
- const std::map<std::string, std::string> v{{"foo", "bar"}};
+ const std::map<std::string, std::string> v{ { "foo", "bar" } };
CHECK_NOTHROW(my_json(v));
next_construct_fails = true;
CHECK_THROWS_AS(my_json(v), std::bad_alloc&);
@@ -179,7 +179,7 @@
SECTION("basic_json(const CompatibleArrayType&)")
{
next_construct_fails = false;
- const std::vector<std::string> v{"foo", "bar", "baz"};
+ const std::vector<std::string> v{ "foo", "bar", "baz" };
CHECK_NOTHROW(my_json(v));
next_construct_fails = true;
CHECK_THROWS_AS(my_json(v), std::bad_alloc&);
diff --git a/tests/src/unit-alt-string.cpp b/tests/src/unit-alt-string.cpp
index 4c31f83..98aaad8 100644
--- a/tests/src/unit-alt-string.cpp
+++ b/tests/src/unit-alt-string.cpp
@@ -154,7 +154,7 @@
alt_string substr(std::size_t pos = 0, std::size_t count = npos) const
{
const std::string s = str_impl.substr(pos, count);
- return {s.data(), s.size()};
+ return { s.data(), s.size() };
}
alt_string& replace(std::size_t pos, std::size_t count, const alt_string& str)
@@ -222,14 +222,14 @@
{
alt_json doc;
- doc["list"] = {1, 0, 2};
+ doc["list"] = { 1, 0, 2 };
alt_string dump = doc.dump();
CHECK(dump == R"({"list":[1,0,2]})");
}
{
alt_json doc;
- doc["object"] = {{"currency", "USD"}, {"value", 42.99}};
+ doc["object"] = { { "currency", "USD" }, { "value", 42.99 } };
alt_string dump = doc.dump();
CHECK(dump == R"({"object":{"currency":"USD","value":42.99}})");
}
diff --git a/tests/src/unit-binary_formats.cpp b/tests/src/unit-binary_formats.cpp
index 615b431..c63d3a2 100644
--- a/tests/src/unit-binary_formats.cpp
+++ b/tests/src/unit-binary_formats.cpp
@@ -142,7 +142,7 @@
const auto bjdata_1_size = json::to_bjdata(j).size();
const auto bjdata_2_size = json::to_bjdata(j, true).size();
const auto bjdata_3_size = json::to_bjdata(j, true, true).size();
- const auto bson_size = json::to_bson({{"", j}}).size(); // wrap array in object for BSON
+ const auto bson_size = json::to_bson({ { "", j } }).size(); // wrap array in object for BSON
const auto cbor_size = json::to_cbor(j).size();
const auto msgpack_size = json::to_msgpack(j).size();
const auto ubjson_1_size = json::to_ubjson(j).size();
diff --git a/tests/src/unit-bjdata.cpp b/tests/src/unit-bjdata.cpp
index dec0a14..6d1a789 100644
--- a/tests/src/unit-bjdata.cpp
+++ b/tests/src/unit-bjdata.cpp
@@ -215,7 +215,7 @@
std::vector<std::uint8_t> const data;
auto ia = nlohmann::detail::input_adapter(data);
// NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
- nlohmann::detail::binary_reader<json, decltype(ia)> const br{std::move(ia), json::input_format_t::bjdata};
+ nlohmann::detail::binary_reader<json, decltype(ia)> const br{ std::move(ia), json::input_format_t::bjdata };
CHECK(std::is_sorted(br.bjd_optimized_type_markers.begin(), br.bjd_optimized_type_markers.end()));
CHECK(std::is_sorted(br.bjd_types_map.begin(), br.bjd_types_map.end()));
@@ -234,7 +234,7 @@
SECTION("null")
{
json const j = nullptr;
- std::vector<uint8_t> const expected = {'Z'};
+ std::vector<uint8_t> const expected = { 'Z' };
const auto result = json::to_bjdata(j);
CHECK(result == expected);
@@ -248,7 +248,7 @@
SECTION("true")
{
json const j = true;
- std::vector<uint8_t> const expected = {'T'};
+ std::vector<uint8_t> const expected = { 'T' };
const auto result = json::to_bjdata(j);
CHECK(result == expected);
@@ -260,7 +260,7 @@
SECTION("false")
{
json const j = false;
- std::vector<uint8_t> const expected = {'F'};
+ std::vector<uint8_t> const expected = { 'F' };
const auto result = json::to_bjdata(j);
CHECK(result == expected);
@@ -334,12 +334,7 @@
SECTION("-2147483648..-32769 (int32)")
{
std::vector<int32_t> const numbers{
- -32769,
- -100000,
- -1000000,
- -10000000,
- -100000000,
- -1000000000,
+ -32769, -100000, -1000000, -10000000, -100000000, -1000000000,
-2147483647 - 1, // https://stackoverflow.com/a/29356002/266378
};
for (const auto i : numbers)
@@ -416,7 +411,7 @@
SECTION("-9263 (int16)")
{
json const j = -9263;
- std::vector<uint8_t> const expected = {'I', 0xd1, 0xdb};
+ std::vector<uint8_t> const expected = { 'I', 0xd1, 0xdb };
// compare result + size
const auto result = json::to_bjdata(j);
@@ -572,7 +567,7 @@
SECTION("32768..65535 (uint16)")
{
- for (const uint32_t i : {32768u, 55555u, 65535u})
+ for (const uint32_t i : { 32768u, 55555u, 65535u })
{
CAPTURE(i)
@@ -608,7 +603,7 @@
SECTION("65536..2147483647 (int32)")
{
- for (const uint32_t i : {65536u, 77777u, 2147483647u})
+ for (const uint32_t i : { 65536u, 77777u, 2147483647u })
{
CAPTURE(i)
@@ -647,7 +642,7 @@
SECTION("2147483648..4294967295 (uint32)")
{
- for (const uint32_t i : {2147483648u, 3333333333u, 4294967295u})
+ for (const uint32_t i : { 2147483648u, 3333333333u, 4294967295u })
{
CAPTURE(i)
@@ -686,7 +681,7 @@
SECTION("4294967296..9223372036854775807 (int64)")
{
- std::vector<uint64_t> const v = {4294967296LU, 9223372036854775807LU};
+ std::vector<uint64_t> const v = { 4294967296LU, 9223372036854775807LU };
for (const uint64_t i : v)
{
CAPTURE(i)
@@ -732,7 +727,7 @@
SECTION("9223372036854775808..18446744073709551615 (uint64)")
{
- std::vector<uint64_t> const v = {9223372036854775808ull, 18446744073709551615ull};
+ std::vector<uint64_t> const v = { 9223372036854775808ull, 18446744073709551615ull };
for (const uint64_t i : v)
{
CAPTURE(i)
@@ -791,7 +786,7 @@
CHECK(j.is_number_unsigned());
// create expected byte vector
- std::vector<uint8_t> const expected{'i', static_cast<uint8_t>(i)};
+ std::vector<uint8_t> const expected{ 'i', static_cast<uint8_t>(i) };
// compare result + size
const auto result = json::to_bjdata(j);
@@ -822,7 +817,7 @@
CHECK(j.is_number_unsigned());
// create expected byte vector
- std::vector<uint8_t> const expected{'U', static_cast<uint8_t>(i)};
+ std::vector<uint8_t> const expected{ 'U', static_cast<uint8_t>(i) };
// compare result + size
const auto result = json::to_bjdata(j);
@@ -877,7 +872,7 @@
SECTION("32768..65535 (uint16)")
{
- for (const uint32_t i : {32768u, 55555u, 65535u})
+ for (const uint32_t i : { 32768u, 55555u, 65535u })
{
CAPTURE(i)
@@ -911,7 +906,7 @@
}
SECTION("65536..2147483647 (int32)")
{
- for (const uint32_t i : {65536u, 77777u, 2147483647u})
+ for (const uint32_t i : { 65536u, 77777u, 2147483647u })
{
CAPTURE(i)
@@ -949,7 +944,7 @@
SECTION("2147483648..4294967295 (uint32)")
{
- for (const uint32_t i : {2147483648u, 3333333333u, 4294967295u})
+ for (const uint32_t i : { 2147483648u, 3333333333u, 4294967295u })
{
CAPTURE(i)
@@ -987,7 +982,7 @@
SECTION("4294967296..9223372036854775807 (int64)")
{
- std::vector<uint64_t> const v = {4294967296ul, 9223372036854775807ul};
+ std::vector<uint64_t> const v = { 4294967296ul, 9223372036854775807ul };
for (const uint64_t i : v)
{
CAPTURE(i)
@@ -1032,7 +1027,7 @@
SECTION("9223372036854775808..18446744073709551615 (uint64)")
{
- std::vector<uint64_t> const v = {9223372036854775808ull, 18446744073709551615ull};
+ std::vector<uint64_t> const v = { 9223372036854775808ull, 18446744073709551615ull };
for (const uint64_t i : v)
{
CAPTURE(i)
@@ -1081,7 +1076,7 @@
{
double v = 3.1415925;
json const j = v;
- std::vector<uint8_t> const expected = {'D', 0xfc, 0xde, 0xa6, 0x3f, 0xfb, 0x21, 0x09, 0x40};
+ std::vector<uint8_t> const expected = { 'D', 0xfc, 0xde, 0xa6, 0x3f, 0xfb, 0x21, 0x09, 0x40 };
const auto result = json::to_bjdata(j);
CHECK(result == expected);
@@ -1096,11 +1091,11 @@
{
SECTION("simple half floats")
{
- CHECK(json::parse("0.0") == json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x00})));
- CHECK(json::parse("-0.0") == json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x80})));
- CHECK(json::parse("1.0") == json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x3c})));
- CHECK(json::parse("1.5") == json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x3e})));
- CHECK(json::parse("65504.0") == json::from_bjdata(std::vector<uint8_t>({'h', 0xff, 0x7b})));
+ CHECK(json::parse("0.0") == json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0x00 })));
+ CHECK(json::parse("-0.0") == json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0x80 })));
+ CHECK(json::parse("1.0") == json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0x3c })));
+ CHECK(json::parse("1.5") == json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0x3e })));
+ CHECK(json::parse("65504.0") == json::from_bjdata(std::vector<uint8_t>({ 'h', 0xff, 0x7b })));
}
SECTION("errors")
@@ -1108,7 +1103,7 @@
SECTION("no byte follows")
{
json _;
- std::vector<uint8_t> const vec0 = {'h'};
+ std::vector<uint8_t> 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",
@@ -1119,7 +1114,7 @@
SECTION("only one byte follows")
{
json _;
- std::vector<uint8_t> const vec1 = {'h', 0x00};
+ std::vector<uint8_t> 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",
@@ -1135,22 +1130,22 @@
{
SECTION("0 (0 00000 0000000000)")
{
- json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x00}));
- json::number_float_t d{j};
+ json const j = json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0x00 }));
+ json::number_float_t d{ j };
CHECK(d == 0.0);
}
SECTION("-0 (1 00000 0000000000)")
{
- json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x80}));
- json::number_float_t d{j};
+ json const j = json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0x80 }));
+ json::number_float_t d{ j };
CHECK(d == -0.0);
}
SECTION("2**-24 (0 00000 0000000001)")
{
- json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x01, 0x00}));
- json::number_float_t d{j};
+ json const j = json::from_bjdata(std::vector<uint8_t>({ 'h', 0x01, 0x00 }));
+ json::number_float_t d{ j };
CHECK(d == std::pow(2.0, -24.0));
}
}
@@ -1159,16 +1154,16 @@
{
SECTION("infinity (0 11111 0000000000)")
{
- json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x7c}));
- json::number_float_t d{j};
+ json const j = json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0x7c }));
+ json::number_float_t d{ j };
CHECK(d == std::numeric_limits<json::number_float_t>::infinity());
CHECK(j.dump() == "null");
}
SECTION("-infinity (1 11111 0000000000)")
{
- json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0xfc}));
- json::number_float_t d{j};
+ json const j = json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0xfc }));
+ json::number_float_t d{ j };
CHECK(d == -std::numeric_limits<json::number_float_t>::infinity());
CHECK(j.dump() == "null");
}
@@ -1178,38 +1173,38 @@
{
SECTION("1 (0 01111 0000000000)")
{
- json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x3c}));
- json::number_float_t d{j};
+ json const j = json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0x3c }));
+ json::number_float_t d{ j };
CHECK(d == 1);
}
SECTION("-2 (1 10000 0000000000)")
{
- json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0xc0}));
- json::number_float_t d{j};
+ json const j = json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0xc0 }));
+ json::number_float_t d{ j };
CHECK(d == -2);
}
SECTION("65504 (0 11110 1111111111)")
{
- json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0xff, 0x7b}));
- json::number_float_t d{j};
+ json const j = json::from_bjdata(std::vector<uint8_t>({ 'h', 0xff, 0x7b }));
+ json::number_float_t d{ j };
CHECK(d == 65504);
}
}
SECTION("infinity")
{
- json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x7c}));
- json::number_float_t const d{j};
+ json const j = json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0x7c }));
+ json::number_float_t const d{ j };
CHECK_FALSE(std::isfinite(d));
CHECK(j.dump() == "null");
}
SECTION("NaN")
{
- json const j = json::from_bjdata(std::vector<uint8_t>({'h', 0x00, 0x7e}));
- json::number_float_t const d{j};
+ json const j = json::from_bjdata(std::vector<uint8_t>({ 'h', 0x00, 0x7e }));
+ json::number_float_t const d{ j };
CHECK(std::isnan(d));
CHECK(j.dump() == "null");
}
@@ -1219,8 +1214,8 @@
{
SECTION("unsigned integer number")
{
- std::vector<uint8_t> 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<uint8_t> 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");
@@ -1228,8 +1223,8 @@
SECTION("signed integer number")
{
- std::vector<uint8_t> 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<uint8_t> 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");
@@ -1237,8 +1232,8 @@
SECTION("floating-point number")
{
- std::vector<uint8_t> 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<uint8_t> 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");
@@ -1247,24 +1242,24 @@
SECTION("errors")
{
// error while parsing length
- std::vector<uint8_t> const vec0 = {'H', 'i'};
+ std::vector<uint8_t> const vec0 = { 'H', 'i' };
CHECK(json::from_bjdata(vec0, true, false).is_discarded());
// error while parsing string
- std::vector<uint8_t> const vec1 = {'H', 'i', '1'};
+ std::vector<uint8_t> const vec1 = { 'H', 'i', '1' };
CHECK(json::from_bjdata(vec1, true, false).is_discarded());
json _;
- std::vector<uint8_t> const vec2 = {'H', 'i', 2, '1', 'A', '3'};
+ std::vector<uint8_t> const vec2 = { 'H', 'i', 2, '1', 'A', '3' };
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(vec2),
"[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing BJData high-precision number: invalid number text: 1A",
json::parse_error);
- std::vector<uint8_t> const vec3 = {'H', 'i', 2, '1', '.'};
+ std::vector<uint8_t> const vec3 = { 'H', 'i', 2, '1', '.' };
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(vec3),
"[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing BJData high-precision number: invalid number text: 1.",
json::parse_error);
- std::vector<uint8_t> const vec4 = {'H', 2, '1', '0'};
+ std::vector<uint8_t> 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",
@@ -1346,7 +1341,7 @@
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)
@@ -1377,7 +1372,7 @@
SECTION("N = 32768..65535")
{
- for (const size_t N : {32768u, 55555u, 65535u})
+ for (const size_t N : { 32768u, 55555u, 65535u })
{
CAPTURE(N)
@@ -1408,7 +1403,7 @@
SECTION("N = 65536..2147483647")
{
- for (const size_t N : {65536u, 77777u, 1048576u})
+ for (const size_t N : { 65536u, 77777u, 1048576u })
{
CAPTURE(N)
@@ -1532,7 +1527,7 @@
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)
@@ -1566,7 +1561,7 @@
SECTION("N = 32768..65535")
{
- for (const std::size_t N : {32768u, 55555u, 65535u})
+ for (const std::size_t N : { 32768u, 55555u, 65535u })
{
CAPTURE(N)
@@ -1600,7 +1595,7 @@
SECTION("N = 65536..2147483647")
{
- for (const std::size_t N : {65536u, 77777u, 1048576u})
+ for (const std::size_t N : { 65536u, 77777u, 1048576u })
{
CAPTURE(N)
@@ -1699,7 +1694,7 @@
SECTION("size=false type=false")
{
json const j = json::array();
- std::vector<uint8_t> const expected = {'[', ']'};
+ std::vector<uint8_t> const expected = { '[', ']' };
const auto result = json::to_bjdata(j);
CHECK(result == expected);
@@ -1711,7 +1706,7 @@
SECTION("size=true type=false")
{
json const j = json::array();
- std::vector<uint8_t> const expected = {'[', '#', 'i', 0};
+ std::vector<uint8_t> const expected = { '[', '#', 'i', 0 };
const auto result = json::to_bjdata(j, true);
CHECK(result == expected);
@@ -1723,7 +1718,7 @@
SECTION("size=true type=true")
{
json const j = json::array();
- std::vector<uint8_t> const expected = {'[', '#', 'i', 0};
+ std::vector<uint8_t> const expected = { '[', '#', 'i', 0 };
const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected);
@@ -1737,8 +1732,8 @@
{
SECTION("size=false type=false")
{
- json const j = {nullptr};
- std::vector<uint8_t> const expected = {'[', 'Z', ']'};
+ json const j = { nullptr };
+ std::vector<uint8_t> const expected = { '[', 'Z', ']' };
const auto result = json::to_bjdata(j);
CHECK(result == expected);
@@ -1749,8 +1744,8 @@
SECTION("size=true type=false")
{
- json const j = {nullptr};
- std::vector<uint8_t> const expected = {'[', '#', 'i', 1, 'Z'};
+ json const j = { nullptr };
+ std::vector<uint8_t> const expected = { '[', '#', 'i', 1, 'Z' };
const auto result = json::to_bjdata(j, true);
CHECK(result == expected);
@@ -1761,8 +1756,8 @@
SECTION("size=true type=true")
{
- json const j = {nullptr};
- std::vector<uint8_t> const expected = {'[', '#', 'i', 1, 'Z'};
+ json const j = { nullptr };
+ std::vector<uint8_t> const expected = { '[', '#', 'i', 1, 'Z' };
const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected);
@@ -1777,7 +1772,7 @@
SECTION("size=false type=false")
{
json const j = json::parse("[1,2,3,4,5]");
- std::vector<uint8_t> const expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4, 'i', 5, ']'};
+ std::vector<uint8_t> const expected = { '[', 'i', 1, 'i', 2, 'i', 3, 'i', 4, 'i', 5, ']' };
const auto result = json::to_bjdata(j);
CHECK(result == expected);
@@ -1789,7 +1784,7 @@
SECTION("size=true type=false")
{
json const j = json::parse("[1,2,3,4,5]");
- std::vector<uint8_t> const expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, 'i', 3, 'i', 4, 'i', 5};
+ std::vector<uint8_t> const expected = { '[', '#', 'i', 5, 'i', 1, 'i', 2, 'i', 3, 'i', 4, 'i', 5 };
const auto result = json::to_bjdata(j, true);
CHECK(result == expected);
@@ -1801,7 +1796,7 @@
SECTION("size=true type=true")
{
json const j = json::parse("[1,2,3,4,5]");
- std::vector<uint8_t> const expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3, 4, 5};
+ std::vector<uint8_t> const expected = { '[', '$', 'i', '#', 'i', 5, 1, 2, 3, 4, 5 };
const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected);
@@ -1816,7 +1811,7 @@
SECTION("size=false type=false")
{
json const j = json::parse("[[[[]]]]");
- std::vector<uint8_t> const expected = {'[', '[', '[', '[', ']', ']', ']', ']'};
+ std::vector<uint8_t> const expected = { '[', '[', '[', '[', ']', ']', ']', ']' };
const auto result = json::to_bjdata(j);
CHECK(result == expected);
@@ -1828,7 +1823,7 @@
SECTION("size=true type=false")
{
json const j = json::parse("[[[[]]]]");
- std::vector<uint8_t> const expected = {'[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 0};
+ std::vector<uint8_t> const expected = { '[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 0 };
const auto result = json::to_bjdata(j, true);
CHECK(result == expected);
@@ -1840,7 +1835,7 @@
SECTION("size=true type=true")
{
json const j = json::parse("[[[[]]]]");
- std::vector<uint8_t> const expected = {'[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 0};
+ std::vector<uint8_t> const expected = { '[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 0 };
const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected);
@@ -1962,7 +1957,7 @@
SECTION("size=false type=false")
{
json const j = json::object();
- std::vector<uint8_t> const expected = {'{', '}'};
+ std::vector<uint8_t> const expected = { '{', '}' };
const auto result = json::to_bjdata(j);
CHECK(result == expected);
@@ -1974,7 +1969,7 @@
SECTION("size=true type=false")
{
json const j = json::object();
- std::vector<uint8_t> const expected = {'{', '#', 'i', 0};
+ std::vector<uint8_t> const expected = { '{', '#', 'i', 0 };
const auto result = json::to_bjdata(j, true);
CHECK(result == expected);
@@ -1986,7 +1981,7 @@
SECTION("size=true type=true")
{
json const j = json::object();
- std::vector<uint8_t> const expected = {'{', '#', 'i', 0};
+ std::vector<uint8_t> const expected = { '{', '#', 'i', 0 };
const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected);
@@ -2000,8 +1995,8 @@
{
SECTION("size=false type=false")
{
- json const j = {{"", nullptr}};
- std::vector<uint8_t> const expected = {'{', 'i', 0, 'Z', '}'};
+ json const j = { { "", nullptr } };
+ std::vector<uint8_t> const expected = { '{', 'i', 0, 'Z', '}' };
const auto result = json::to_bjdata(j);
CHECK(result == expected);
@@ -2012,8 +2007,8 @@
SECTION("size=true type=false")
{
- json const j = {{"", nullptr}};
- std::vector<uint8_t> const expected = {'{', '#', 'i', 1, 'i', 0, 'Z'};
+ json const j = { { "", nullptr } };
+ std::vector<uint8_t> const expected = { '{', '#', 'i', 1, 'i', 0, 'Z' };
const auto result = json::to_bjdata(j, true);
CHECK(result == expected);
@@ -2028,7 +2023,7 @@
SECTION("size=false type=false")
{
json const j = json::parse(R"({"a": {"b": {"c": {}}}})");
- std::vector<uint8_t> const expected = {'{', 'i', 1, 'a', '{', 'i', 1, 'b', '{', 'i', 1, 'c', '{', '}', '}', '}', '}'};
+ std::vector<uint8_t> const expected = { '{', 'i', 1, 'a', '{', 'i', 1, 'b', '{', 'i', 1, 'c', '{', '}', '}', '}', '}' };
const auto result = json::to_bjdata(j);
CHECK(result == expected);
@@ -2040,8 +2035,8 @@
SECTION("size=true type=false")
{
json const j = json::parse(R"({"a": {"b": {"c": {}}}})");
- std::vector<uint8_t> const expected = {'{', '#', 'i', 1, 'i', 1, 'a', '{', '#', 'i', 1, 'i', 1,
- 'b', '{', '#', 'i', 1, 'i', 1, 'c', '{', '#', 'i', 0};
+ std::vector<uint8_t> 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);
@@ -2053,8 +2048,8 @@
SECTION("size=true type=true ignore object type marker")
{
json const j = json::parse(R"({"a": {"b": {"c": {}}}})");
- std::vector<uint8_t> const expected = {'{', '#', 'i', 1, 'i', 1, 'a', '{', '#', 'i', 1, 'i', 1,
- 'b', '{', '#', 'i', 1, 'i', 1, 'c', '{', '#', 'i', 0};
+ std::vector<uint8_t> 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);
@@ -2070,7 +2065,7 @@
{
SECTION("strict mode")
{
- std::vector<uint8_t> const vec = {'Z', 'Z'};
+ std::vector<uint8_t> const vec = { 'Z', 'Z' };
SECTION("non-strict mode")
{
const auto result = json::from_bjdata(vec, false);
@@ -2092,98 +2087,98 @@
{
SECTION("start_array()")
{
- std::vector<uint8_t> const v = {'[', 'T', 'F', ']'};
+ std::vector<uint8_t> const v = { '[', 'T', 'F', ']' };
SaxCountdown scp(0);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("start_object()")
{
- std::vector<uint8_t> const v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'};
+ std::vector<uint8_t> const v = { '{', 'i', 3, 'f', 'o', 'o', 'F', '}' };
SaxCountdown scp(0);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("key() in object")
{
- std::vector<uint8_t> const v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'};
+ std::vector<uint8_t> const v = { '{', 'i', 3, 'f', 'o', 'o', 'F', '}' };
SaxCountdown scp(1);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("start_array(len)")
{
- std::vector<uint8_t> const v = {'[', '#', 'i', '2', 'T', 'F'};
+ std::vector<uint8_t> const v = { '[', '#', 'i', '2', 'T', 'F' };
SaxCountdown scp(0);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("start_object(len)")
{
- std::vector<uint8_t> const v = {'{', '#', 'i', '1', 3, 'f', 'o', 'o', 'F'};
+ std::vector<uint8_t> const v = { '{', '#', 'i', '1', 3, 'f', 'o', 'o', 'F' };
SaxCountdown scp(0);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("key() in object with length")
{
- std::vector<uint8_t> const v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'};
+ std::vector<uint8_t> const v = { '{', 'i', 3, 'f', 'o', 'o', 'F', '}' };
SaxCountdown scp(1);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("start_array() in ndarray _ArraySize_")
{
- std::vector<uint8_t> const v = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 2, 1, 1, 2};
+ std::vector<uint8_t> const v = { '[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 2, 1, 1, 2 };
SaxCountdown scp(2);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("number_integer() in ndarray _ArraySize_")
{
- std::vector<uint8_t> const v = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 1, 1, 2};
+ std::vector<uint8_t> const v = { '[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 1, 1, 2 };
SaxCountdown scp(3);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("key() in ndarray _ArrayType_")
{
- std::vector<uint8_t> const v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4};
+ std::vector<uint8_t> const v = { '[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4 };
SaxCountdown scp(6);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("string() in ndarray _ArrayType_")
{
- std::vector<uint8_t> const v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4};
+ std::vector<uint8_t> const v = { '[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4 };
SaxCountdown scp(7);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("key() in ndarray _ArrayData_")
{
- std::vector<uint8_t> const v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4};
+ std::vector<uint8_t> const v = { '[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4 };
SaxCountdown scp(8);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("string() in ndarray _ArrayData_")
{
- std::vector<uint8_t> const v = {'[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4};
+ std::vector<uint8_t> const v = { '[', '$', 'U', '#', '[', '$', 'U', '#', 'i', 2, 2, 2, 1, 2, 3, 4 };
SaxCountdown scp(9);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("string() in ndarray _ArrayType_")
{
- std::vector<uint8_t> const v = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 3, 2, 6, 5, 4, 3, 2, 1};
+ std::vector<uint8_t> const v = { '[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 3, 2, 6, 5, 4, 3, 2, 1 };
SaxCountdown scp(11);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
SECTION("start_array() in ndarray _ArrayData_")
{
- std::vector<uint8_t> const v = {'[', '$', 'U', '#', '[', 'i', 2, 'i', 3, ']', 6, 5, 4, 3, 2, 1};
+ std::vector<uint8_t> const v = { '[', '$', 'U', '#', '[', 'i', 2, 'i', 3, ']', 6, 5, 4, 3, 2, 1 };
SaxCountdown scp(13);
CHECK_FALSE(json::sax_parse(v, &scp, json::input_format_t::bjdata));
}
@@ -2194,14 +2189,14 @@
SECTION("strings")
{
// create a single-character string for all number types
- std::vector<uint8_t> s_i = {'S', 'i', 1, 'a'};
- std::vector<uint8_t> const s_U = {'S', 'U', 1, 'a'};
- std::vector<uint8_t> const s_I = {'S', 'I', 1, 0, 'a'};
- std::vector<uint8_t> const s_u = {'S', 'u', 1, 0, 'a'};
- std::vector<uint8_t> const s_l = {'S', 'l', 1, 0, 0, 0, 'a'};
- std::vector<uint8_t> const s_m = {'S', 'm', 1, 0, 0, 0, 'a'};
- std::vector<uint8_t> const s_L = {'S', 'L', 1, 0, 0, 0, 0, 0, 0, 0, 'a'};
- std::vector<uint8_t> const s_M = {'S', 'M', 1, 0, 0, 0, 0, 0, 0, 0, 'a'};
+ std::vector<uint8_t> s_i = { 'S', 'i', 1, 'a' };
+ std::vector<uint8_t> const s_U = { 'S', 'U', 1, 'a' };
+ std::vector<uint8_t> const s_I = { 'S', 'I', 1, 0, 'a' };
+ std::vector<uint8_t> const s_u = { 'S', 'u', 1, 0, 'a' };
+ std::vector<uint8_t> const s_l = { 'S', 'l', 1, 0, 0, 0, 'a' };
+ std::vector<uint8_t> const s_m = { 'S', 'm', 1, 0, 0, 0, 'a' };
+ std::vector<uint8_t> const s_L = { 'S', 'L', 1, 0, 0, 0, 0, 0, 0, 0, 'a' };
+ std::vector<uint8_t> const s_M = { 'S', 'M', 1, 0, 0, 0, 0, 0, 0, 0, 'a' };
// check if string is parsed correctly to "a"
CHECK(json::from_bjdata(s_i) == "a");
@@ -2229,11 +2224,11 @@
SECTION("float")
{
// float32
- std::vector<uint8_t> const v_d = {'d', 0xd0, 0x0f, 0x49, 0x40};
+ std::vector<uint8_t> const v_d = { 'd', 0xd0, 0x0f, 0x49, 0x40 };
CHECK(json::from_bjdata(v_d) == 3.14159f);
// float64
- std::vector<uint8_t> const v_D = {'D', 0x6e, 0x86, 0x1b, 0xf0, 0xf9, 0x21, 0x09, 0x40};
+ std::vector<uint8_t> const v_D = { 'D', 0x6e, 0x86, 0x1b, 0xf0, 0xf9, 0x21, 0x09, 0x40 };
CHECK(json::from_bjdata(v_D) == 3.14159);
// float32 is serialized as float64 as the library does not support float32
@@ -2246,41 +2241,41 @@
SECTION("optimized version (length only)")
{
// create vector with two elements of the same type
- std::vector<uint8_t> const v_TU = {'[', '#', 'U', 2, 'T', 'T'};
- std::vector<uint8_t> const v_T = {'[', '#', 'i', 2, 'T', 'T'};
- std::vector<uint8_t> const v_F = {'[', '#', 'i', 2, 'F', 'F'};
- std::vector<uint8_t> const v_Z = {'[', '#', 'i', 2, 'Z', 'Z'};
- std::vector<uint8_t> const v_i = {'[', '#', 'i', 2, 'i', 0x7F, 'i', 0x7F};
- std::vector<uint8_t> const v_U = {'[', '#', 'i', 2, 'U', 0xFF, 'U', 0xFF};
- std::vector<uint8_t> const v_I = {'[', '#', 'i', 2, 'I', 0xFF, 0x7F, 'I', 0xFF, 0x7F};
- std::vector<uint8_t> const v_u = {'[', '#', 'i', 2, 'u', 0x0F, 0xA7, 'u', 0x0F, 0xA7};
- std::vector<uint8_t> const v_l = {'[', '#', 'i', 2, 'l', 0xFF, 0xFF, 0xFF, 0x7F, 'l', 0xFF, 0xFF, 0xFF, 0x7F};
- std::vector<uint8_t> const v_m = {'[', '#', 'i', 2, 'm', 0xFF, 0xC9, 0x9A, 0xBB, 'm', 0xFF, 0xC9, 0x9A, 0xBB};
- std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> const v_S = {'[', '#', 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'};
- std::vector<uint8_t> const v_C = {'[', '#', 'i', 2, 'C', 'a', 'C', 'a'};
+ std::vector<uint8_t> const v_TU = { '[', '#', 'U', 2, 'T', 'T' };
+ std::vector<uint8_t> const v_T = { '[', '#', 'i', 2, 'T', 'T' };
+ std::vector<uint8_t> const v_F = { '[', '#', 'i', 2, 'F', 'F' };
+ std::vector<uint8_t> const v_Z = { '[', '#', 'i', 2, 'Z', 'Z' };
+ std::vector<uint8_t> const v_i = { '[', '#', 'i', 2, 'i', 0x7F, 'i', 0x7F };
+ std::vector<uint8_t> const v_U = { '[', '#', 'i', 2, 'U', 0xFF, 'U', 0xFF };
+ std::vector<uint8_t> const v_I = { '[', '#', 'i', 2, 'I', 0xFF, 0x7F, 'I', 0xFF, 0x7F };
+ std::vector<uint8_t> const v_u = { '[', '#', 'i', 2, 'u', 0x0F, 0xA7, 'u', 0x0F, 0xA7 };
+ std::vector<uint8_t> const v_l = { '[', '#', 'i', 2, 'l', 0xFF, 0xFF, 0xFF, 0x7F, 'l', 0xFF, 0xFF, 0xFF, 0x7F };
+ std::vector<uint8_t> const v_m = { '[', '#', 'i', 2, 'm', 0xFF, 0xC9, 0x9A, 0xBB, 'm', 0xFF, 0xC9, 0x9A, 0xBB };
+ std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> const v_S = { '[', '#', 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a' };
+ std::vector<uint8_t> const v_C = { '[', '#', 'i', 2, 'C', 'a', 'C', 'a' };
// check if vector is parsed correctly
- CHECK(json::from_bjdata(v_TU) == json({true, true}));
- CHECK(json::from_bjdata(v_T) == json({true, true}));
- CHECK(json::from_bjdata(v_F) == json({false, false}));
- CHECK(json::from_bjdata(v_Z) == json({nullptr, nullptr}));
- CHECK(json::from_bjdata(v_i) == json({127, 127}));
- CHECK(json::from_bjdata(v_U) == json({255, 255}));
- CHECK(json::from_bjdata(v_I) == json({32767, 32767}));
- CHECK(json::from_bjdata(v_u) == json({42767, 42767}));
- CHECK(json::from_bjdata(v_l) == json({2147483647, 2147483647}));
- CHECK(json::from_bjdata(v_m) == json({3147483647, 3147483647}));
- CHECK(json::from_bjdata(v_L) == json({9223372036854775807, 9223372036854775807}));
- CHECK(json::from_bjdata(v_M) == json({10223372036854775807ull, 10223372036854775807ull}));
- CHECK(json::from_bjdata(v_D) == json({3.1415926, 3.1415926}));
- CHECK(json::from_bjdata(v_S) == json({"a", "a"}));
- CHECK(json::from_bjdata(v_C) == json({"a", "a"}));
+ CHECK(json::from_bjdata(v_TU) == json({ true, true }));
+ CHECK(json::from_bjdata(v_T) == json({ true, true }));
+ CHECK(json::from_bjdata(v_F) == json({ false, false }));
+ CHECK(json::from_bjdata(v_Z) == json({ nullptr, nullptr }));
+ CHECK(json::from_bjdata(v_i) == json({ 127, 127 }));
+ CHECK(json::from_bjdata(v_U) == json({ 255, 255 }));
+ CHECK(json::from_bjdata(v_I) == json({ 32767, 32767 }));
+ CHECK(json::from_bjdata(v_u) == json({ 42767, 42767 }));
+ CHECK(json::from_bjdata(v_l) == json({ 2147483647, 2147483647 }));
+ CHECK(json::from_bjdata(v_m) == json({ 3147483647, 3147483647 }));
+ CHECK(json::from_bjdata(v_L) == json({ 9223372036854775807, 9223372036854775807 }));
+ CHECK(json::from_bjdata(v_M) == json({ 10223372036854775807ull, 10223372036854775807ull }));
+ CHECK(json::from_bjdata(v_D) == json({ 3.1415926, 3.1415926 }));
+ CHECK(json::from_bjdata(v_S) == json({ "a", "a" }));
+ CHECK(json::from_bjdata(v_C) == json({ "a", "a" }));
// roundtrip: output should be optimized
CHECK(json::to_bjdata(json::from_bjdata(v_T), true) == v_T);
@@ -2302,36 +2297,36 @@
SECTION("optimized version (type and length)")
{
// create vector with two elements of the same type
- std::vector<uint8_t> const v_i = {'[', '$', 'i', '#', 'i', 2, 0x7F, 0x7F};
- std::vector<uint8_t> const v_U = {'[', '$', 'U', '#', 'i', 2, 0xFF, 0xFF};
- std::vector<uint8_t> const v_I = {'[', '$', 'I', '#', 'i', 2, 0xFF, 0x7F, 0xFF, 0x7F};
- std::vector<uint8_t> const v_u = {'[', '$', 'u', '#', 'i', 2, 0x0F, 0xA7, 0x0F, 0xA7};
- std::vector<uint8_t> const v_l = {'[', '$', 'l', '#', 'i', 2, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F};
- std::vector<uint8_t> const v_m = {'[', '$', 'm', '#', 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB};
- std::vector<uint8_t> const v_L = {'[', '$', 'L', '#', 'i', 2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F};
- std::vector<uint8_t> const v_M = {'[', '$', 'M', '#', 'i', 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3,
- 0xB6, 0xE0, 0x8D, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D};
- std::vector<uint8_t> const v_D = {'[', '$', 'D', '#', 'i', 2, 0x4a, 0xd8, 0x12, 0x4d, 0xfb,
- 0x21, 0x09, 0x40, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40};
- std::vector<uint8_t> const v_S = {'[', '#', 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'};
- std::vector<uint8_t> const v_C = {'[', '$', 'C', '#', 'i', 2, 'a', 'a'};
+ std::vector<uint8_t> const v_i = { '[', '$', 'i', '#', 'i', 2, 0x7F, 0x7F };
+ std::vector<uint8_t> const v_U = { '[', '$', 'U', '#', 'i', 2, 0xFF, 0xFF };
+ std::vector<uint8_t> const v_I = { '[', '$', 'I', '#', 'i', 2, 0xFF, 0x7F, 0xFF, 0x7F };
+ std::vector<uint8_t> const v_u = { '[', '$', 'u', '#', 'i', 2, 0x0F, 0xA7, 0x0F, 0xA7 };
+ std::vector<uint8_t> const v_l = { '[', '$', 'l', '#', 'i', 2, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F };
+ std::vector<uint8_t> const v_m = { '[', '$', 'm', '#', 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB };
+ std::vector<uint8_t> const v_L = { '[', '$', 'L', '#', 'i', 2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F };
+ std::vector<uint8_t> const v_M = { '[', '$', 'M', '#', 'i', 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3,
+ 0xB6, 0xE0, 0x8D, 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D };
+ std::vector<uint8_t> const v_D = { '[', '$', 'D', '#', 'i', 2, 0x4a, 0xd8, 0x12, 0x4d, 0xfb,
+ 0x21, 0x09, 0x40, 0x4a, 0xd8, 0x12, 0x4d, 0xfb, 0x21, 0x09, 0x40 };
+ std::vector<uint8_t> const v_S = { '[', '#', 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a' };
+ std::vector<uint8_t> const v_C = { '[', '$', 'C', '#', 'i', 2, 'a', 'a' };
// check if vector is parsed correctly
- CHECK(json::from_bjdata(v_i) == json({127, 127}));
- CHECK(json::from_bjdata(v_U) == json({255, 255}));
- CHECK(json::from_bjdata(v_I) == json({32767, 32767}));
- CHECK(json::from_bjdata(v_u) == json({42767, 42767}));
- CHECK(json::from_bjdata(v_l) == json({2147483647, 2147483647}));
- CHECK(json::from_bjdata(v_m) == json({3147483647, 3147483647}));
- CHECK(json::from_bjdata(v_L) == json({9223372036854775807, 9223372036854775807}));
- CHECK(json::from_bjdata(v_M) == json({10223372036854775807ull, 10223372036854775807ull}));
- CHECK(json::from_bjdata(v_D) == json({3.1415926, 3.1415926}));
- CHECK(json::from_bjdata(v_S) == json({"a", "a"}));
- CHECK(json::from_bjdata(v_C) == json({"a", "a"}));
+ CHECK(json::from_bjdata(v_i) == json({ 127, 127 }));
+ CHECK(json::from_bjdata(v_U) == json({ 255, 255 }));
+ CHECK(json::from_bjdata(v_I) == json({ 32767, 32767 }));
+ CHECK(json::from_bjdata(v_u) == json({ 42767, 42767 }));
+ CHECK(json::from_bjdata(v_l) == json({ 2147483647, 2147483647 }));
+ CHECK(json::from_bjdata(v_m) == json({ 3147483647, 3147483647 }));
+ CHECK(json::from_bjdata(v_L) == json({ 9223372036854775807, 9223372036854775807 }));
+ CHECK(json::from_bjdata(v_M) == json({ 10223372036854775807ull, 10223372036854775807ull }));
+ CHECK(json::from_bjdata(v_D) == json({ 3.1415926, 3.1415926 }));
+ CHECK(json::from_bjdata(v_S) == json({ "a", "a" }));
+ CHECK(json::from_bjdata(v_C) == json({ "a", "a" }));
// roundtrip: output should be optimized
- std::vector<uint8_t> const v_empty = {'[', '#', 'i', 0};
+ std::vector<uint8_t> const v_empty = { '[', '#', 'i', 0 };
CHECK(json::to_bjdata(json::from_bjdata(v_i), true, true) == v_i);
CHECK(json::to_bjdata(json::from_bjdata(v_U), true, true) == v_U);
CHECK(json::to_bjdata(json::from_bjdata(v_I), true, true) == v_I);
@@ -2348,83 +2343,86 @@
SECTION("optimized ndarray (type and vector-size as optimized 1D array)")
{
// create vector with two elements of the same type
- std::vector<uint8_t> const v_0 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 1, 0};
- std::vector<uint8_t> const v_1 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 1, 2, 0x7F, 0x7F};
- std::vector<uint8_t> const v_i = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0x7F, 0x7F};
- std::vector<uint8_t> const v_U = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF};
- std::vector<uint8_t> const v_I = {'[', '$', 'I', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0x7F, 0xFF, 0x7F};
- std::vector<uint8_t> const v_u = {'[', '$', 'u', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0x0F, 0xA7, 0x0F, 0xA7};
- std::vector<uint8_t> const v_l = {'[', '$', 'l', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F};
- std::vector<uint8_t> const v_m = {'[', '$', 'm', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB};
- std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> const v_S = {'[', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'};
- std::vector<uint8_t> const v_C = {'[', '$', 'C', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 'a', 'a'};
+ std::vector<uint8_t> const v_0 = { '[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 1, 0 };
+ std::vector<uint8_t> const v_1 = { '[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 1, 2, 0x7F, 0x7F };
+ std::vector<uint8_t> const v_i = { '[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0x7F, 0x7F };
+ std::vector<uint8_t> const v_U = { '[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF };
+ std::vector<uint8_t> const v_I = { '[', '$', 'I', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0x7F, 0xFF, 0x7F };
+ std::vector<uint8_t> const v_u = { '[', '$', 'u', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0x0F, 0xA7, 0x0F, 0xA7 };
+ std::vector<uint8_t> const v_l = { '[', '$', 'l', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F };
+ std::vector<uint8_t> const v_m = { '[', '$', 'm', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB };
+ std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> const v_S = { '[', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a' };
+ std::vector<uint8_t> const v_C = { '[', '$', 'C', '#', '[', '$', 'i', '#', 'i', 2, 1, 2, 'a', 'a' };
// check if vector is parsed correctly
CHECK(json::from_bjdata(v_0) == json::array());
- CHECK(json::from_bjdata(v_1) == json({127, 127}));
- CHECK(json::from_bjdata(v_i) == json({127, 127}));
- CHECK(json::from_bjdata(v_U) == json({255, 255}));
- CHECK(json::from_bjdata(v_I) == json({32767, 32767}));
- CHECK(json::from_bjdata(v_u) == json({42767, 42767}));
- CHECK(json::from_bjdata(v_l) == json({2147483647, 2147483647}));
- CHECK(json::from_bjdata(v_m) == json({3147483647, 3147483647}));
- CHECK(json::from_bjdata(v_L) == json({9223372036854775807, 9223372036854775807}));
- CHECK(json::from_bjdata(v_M) == json({10223372036854775807ull, 10223372036854775807ull}));
- CHECK(json::from_bjdata(v_D) == json({3.1415926, 3.1415926}));
- CHECK(json::from_bjdata(v_S) == json({"a", "a"}));
- CHECK(json::from_bjdata(v_C) == json({"a", "a"}));
+ CHECK(json::from_bjdata(v_1) == json({ 127, 127 }));
+ CHECK(json::from_bjdata(v_i) == json({ 127, 127 }));
+ CHECK(json::from_bjdata(v_U) == json({ 255, 255 }));
+ CHECK(json::from_bjdata(v_I) == json({ 32767, 32767 }));
+ CHECK(json::from_bjdata(v_u) == json({ 42767, 42767 }));
+ CHECK(json::from_bjdata(v_l) == json({ 2147483647, 2147483647 }));
+ CHECK(json::from_bjdata(v_m) == json({ 3147483647, 3147483647 }));
+ CHECK(json::from_bjdata(v_L) == json({ 9223372036854775807, 9223372036854775807 }));
+ CHECK(json::from_bjdata(v_M) == json({ 10223372036854775807ull, 10223372036854775807ull }));
+ CHECK(json::from_bjdata(v_D) == json({ 3.1415926, 3.1415926 }));
+ CHECK(json::from_bjdata(v_S) == json({ "a", "a" }));
+ CHECK(json::from_bjdata(v_C) == json({ "a", "a" }));
}
SECTION("optimized ndarray (type and vector-size ndarray with JData annotations)")
{
// create vector with 0, 1, 2 elements of the same type
- std::vector<uint8_t> const v_e = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 1, 0xFE, 0xFF};
- std::vector<uint8_t> const v_U = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
- std::vector<uint8_t> const v_i = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
- std::vector<uint8_t> const v_u = {'[', '$', 'u', '#', '[', '$', 'i', '#', 'i', 2, 2, 3,
- 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00};
- std::vector<uint8_t> const v_I = {'[', '$', 'I', '#', '[', '$', 'i', '#', 'i', 2, 2, 3,
- 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00};
- std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> const v_C = {'[', '$', 'C', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 'a', 'b', 'c', 'd', 'e', 'f'};
+ std::vector<uint8_t> const v_e = { '[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 1, 0xFE, 0xFF };
+ std::vector<uint8_t> const v_U = { '[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+ std::vector<uint8_t> const v_i = { '[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+ std::vector<uint8_t> const v_u = { '[', '$', 'u', '#', '[', '$', 'i', '#', 'i', 2, 2, 3,
+ 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00 };
+ std::vector<uint8_t> const v_I = { '[', '$', 'I', '#', '[', '$', 'i', '#', 'i', 2, 2, 3,
+ 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00 };
+ std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> const v_C = { '[', '$', 'C', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 'a', 'b', 'c', 'd', 'e', 'f' };
// check if vector is parsed correctly
- CHECK(json::from_bjdata(v_e) == json({{"_ArrayData_", {254, 255}}, {"_ArraySize_", {2, 1}}, {"_ArrayType_", "uint8"}}));
- CHECK(json::from_bjdata(v_U) == json({{"_ArrayData_", {1, 2, 3, 4, 5, 6}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "uint8"}}));
- CHECK(json::from_bjdata(v_i) == json({{"_ArrayData_", {1, 2, 3, 4, 5, 6}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "int8"}}));
- CHECK(json::from_bjdata(v_i) == json({{"_ArrayData_", {1, 2, 3, 4, 5, 6}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "int8"}}));
- CHECK(json::from_bjdata(v_u) == json({{"_ArrayData_", {1, 2, 3, 4, 5, 6}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "uint16"}}));
- CHECK(json::from_bjdata(v_I) == json({{"_ArrayData_", {1, 2, 3, 4, 5, 6}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "int16"}}));
- CHECK(json::from_bjdata(v_m) == json({{"_ArrayData_", {1, 2, 3, 4, 5, 6}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "uint32"}}));
- CHECK(json::from_bjdata(v_l) == json({{"_ArrayData_", {1, 2, 3, 4, 5, 6}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "int32"}}));
- CHECK(json::from_bjdata(v_M) == json({{"_ArrayData_", {1, 2, 3, 4, 5, 6}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "uint64"}}));
- CHECK(json::from_bjdata(v_L) == json({{"_ArrayData_", {1, 2, 3, 4, 5, 6}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "int64"}}));
- CHECK(json::from_bjdata(v_d) == json({{"_ArrayData_", {1.f, 2.f, 3.f, 4.f, 5.f, 6.f}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "single"}}));
- CHECK(json::from_bjdata(v_D) == json({{"_ArrayData_", {1., 2., 3., 4., 5., 6.}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "double"}}));
- CHECK(json::from_bjdata(v_C) == json({{"_ArrayData_", {'a', 'b', 'c', 'd', 'e', 'f'}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "char"}}));
+ CHECK(json::from_bjdata(v_e) == json({ { "_ArrayData_", { 254, 255 } }, { "_ArraySize_", { 2, 1 } }, { "_ArrayType_", "uint8" } }));
+ CHECK(json::from_bjdata(v_U) == json({ { "_ArrayData_", { 1, 2, 3, 4, 5, 6 } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "uint8" } }));
+ CHECK(json::from_bjdata(v_i) == json({ { "_ArrayData_", { 1, 2, 3, 4, 5, 6 } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "int8" } }));
+ CHECK(json::from_bjdata(v_i) == json({ { "_ArrayData_", { 1, 2, 3, 4, 5, 6 } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "int8" } }));
+ CHECK(json::from_bjdata(v_u) == json({ { "_ArrayData_", { 1, 2, 3, 4, 5, 6 } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "uint16" } }));
+ CHECK(json::from_bjdata(v_I) == json({ { "_ArrayData_", { 1, 2, 3, 4, 5, 6 } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "int16" } }));
+ CHECK(json::from_bjdata(v_m) == json({ { "_ArrayData_", { 1, 2, 3, 4, 5, 6 } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "uint32" } }));
+ CHECK(json::from_bjdata(v_l) == json({ { "_ArrayData_", { 1, 2, 3, 4, 5, 6 } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "int32" } }));
+ CHECK(json::from_bjdata(v_M) == json({ { "_ArrayData_", { 1, 2, 3, 4, 5, 6 } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "uint64" } }));
+ CHECK(json::from_bjdata(v_L) == json({ { "_ArrayData_", { 1, 2, 3, 4, 5, 6 } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "int64" } }));
+ CHECK(json::from_bjdata(v_d) ==
+ json({ { "_ArrayData_", { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "single" } }));
+ CHECK(json::from_bjdata(v_D) ==
+ json({ { "_ArrayData_", { 1., 2., 3., 4., 5., 6. } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "double" } }));
+ CHECK(json::from_bjdata(v_C) ==
+ json({ { "_ArrayData_", { 'a', 'b', 'c', 'd', 'e', 'f' } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "char" } }));
// roundtrip: output should be optimized
CHECK(json::to_bjdata(json::from_bjdata(v_e), true, true) == v_e);
@@ -2444,78 +2442,78 @@
SECTION("optimized ndarray (type and vector-size as 1D array)")
{
// create vector with two elements of the same type
- std::vector<uint8_t> const v_0 = {'[', '$', 'i', '#', '[', ']'};
- std::vector<uint8_t> const v_E = {'[', '$', 'i', '#', '[', 'i', 2, 'i', 0, ']'};
- std::vector<uint8_t> const v_i = {'[', '$', 'i', '#', '[', 'i', 1, 'i', 2, ']', 0x7F, 0x7F};
- std::vector<uint8_t> const v_U = {'[', '$', 'U', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF};
- std::vector<uint8_t> const v_I = {'[', '$', 'I', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0x7F, 0xFF, 0x7F};
- std::vector<uint8_t> const v_u = {'[', '$', 'u', '#', '[', 'i', 1, 'i', 2, ']', 0x0F, 0xA7, 0x0F, 0xA7};
- std::vector<uint8_t> const v_l = {'[', '$', 'l', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F};
- std::vector<uint8_t> const v_m = {'[', '$', 'm', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB};
- std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> const v_S = {'[', '#', '[', 'i', 1, 'i', 2, ']', 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'};
- std::vector<uint8_t> const v_C = {'[', '$', 'C', '#', '[', 'i', 1, 'i', 2, ']', 'a', 'a'};
- std::vector<uint8_t> const v_R = {'[', '#', '[', 'i', 2, ']', 'i', 6, 'U', 7};
+ std::vector<uint8_t> const v_0 = { '[', '$', 'i', '#', '[', ']' };
+ std::vector<uint8_t> const v_E = { '[', '$', 'i', '#', '[', 'i', 2, 'i', 0, ']' };
+ std::vector<uint8_t> const v_i = { '[', '$', 'i', '#', '[', 'i', 1, 'i', 2, ']', 0x7F, 0x7F };
+ std::vector<uint8_t> const v_U = { '[', '$', 'U', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF };
+ std::vector<uint8_t> const v_I = { '[', '$', 'I', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0x7F, 0xFF, 0x7F };
+ std::vector<uint8_t> const v_u = { '[', '$', 'u', '#', '[', 'i', 1, 'i', 2, ']', 0x0F, 0xA7, 0x0F, 0xA7 };
+ std::vector<uint8_t> const v_l = { '[', '$', 'l', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F };
+ std::vector<uint8_t> const v_m = { '[', '$', 'm', '#', '[', 'i', 1, 'i', 2, ']', 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB };
+ std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> const v_S = { '[', '#', '[', 'i', 1, 'i', 2, ']', 'S', 'i', 1, 'a', 'S', 'i', 1, 'a' };
+ std::vector<uint8_t> const v_C = { '[', '$', 'C', '#', '[', 'i', 1, 'i', 2, ']', 'a', 'a' };
+ std::vector<uint8_t> const v_R = { '[', '#', '[', 'i', 2, ']', 'i', 6, 'U', 7 };
// check if vector is parsed correctly
CHECK(json::from_bjdata(v_0) == json::array());
CHECK(json::from_bjdata(v_E) == json::array());
- CHECK(json::from_bjdata(v_i) == json({127, 127}));
- CHECK(json::from_bjdata(v_U) == json({255, 255}));
- CHECK(json::from_bjdata(v_I) == json({32767, 32767}));
- CHECK(json::from_bjdata(v_u) == json({42767, 42767}));
- CHECK(json::from_bjdata(v_l) == json({2147483647, 2147483647}));
- CHECK(json::from_bjdata(v_m) == json({3147483647, 3147483647}));
- CHECK(json::from_bjdata(v_L) == json({9223372036854775807, 9223372036854775807}));
- CHECK(json::from_bjdata(v_M) == json({10223372036854775807ull, 10223372036854775807ull}));
- CHECK(json::from_bjdata(v_D) == json({3.1415926, 3.1415926}));
- CHECK(json::from_bjdata(v_S) == json({"a", "a"}));
- CHECK(json::from_bjdata(v_C) == json({"a", "a"}));
- CHECK(json::from_bjdata(v_R) == json({6, 7}));
+ CHECK(json::from_bjdata(v_i) == json({ 127, 127 }));
+ CHECK(json::from_bjdata(v_U) == json({ 255, 255 }));
+ CHECK(json::from_bjdata(v_I) == json({ 32767, 32767 }));
+ CHECK(json::from_bjdata(v_u) == json({ 42767, 42767 }));
+ CHECK(json::from_bjdata(v_l) == json({ 2147483647, 2147483647 }));
+ CHECK(json::from_bjdata(v_m) == json({ 3147483647, 3147483647 }));
+ CHECK(json::from_bjdata(v_L) == json({ 9223372036854775807, 9223372036854775807 }));
+ CHECK(json::from_bjdata(v_M) == json({ 10223372036854775807ull, 10223372036854775807ull }));
+ CHECK(json::from_bjdata(v_D) == json({ 3.1415926, 3.1415926 }));
+ CHECK(json::from_bjdata(v_S) == json({ "a", "a" }));
+ CHECK(json::from_bjdata(v_C) == json({ "a", "a" }));
+ CHECK(json::from_bjdata(v_R) == json({ 6, 7 }));
}
SECTION("optimized ndarray (type and vector-size as size-optimized array)")
{
// create vector with two elements of the same type
- std::vector<uint8_t> const v_i = {'[', '$', 'i', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0x7F, 0x7F};
- std::vector<uint8_t> const v_U = {'[', '$', 'U', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF};
- std::vector<uint8_t> const v_I = {'[', '$', 'I', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0x7F, 0xFF, 0x7F};
- std::vector<uint8_t> const v_u = {'[', '$', 'u', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0x0F, 0xA7, 0x0F, 0xA7};
- std::vector<uint8_t> const v_l = {'[', '$', 'l', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F};
- std::vector<uint8_t> const v_m = {'[', '$', 'm', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB};
- std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> const v_S = {'[', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'};
- std::vector<uint8_t> const v_C = {'[', '$', 'C', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 'a', 'a'};
+ std::vector<uint8_t> const v_i = { '[', '$', 'i', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0x7F, 0x7F };
+ std::vector<uint8_t> const v_U = { '[', '$', 'U', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF };
+ std::vector<uint8_t> const v_I = { '[', '$', 'I', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0x7F, 0xFF, 0x7F };
+ std::vector<uint8_t> const v_u = { '[', '$', 'u', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0x0F, 0xA7, 0x0F, 0xA7 };
+ std::vector<uint8_t> const v_l = { '[', '$', 'l', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F };
+ std::vector<uint8_t> const v_m = { '[', '$', 'm', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0xFF, 0xC9, 0x9A, 0xBB };
+ std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> const v_S = { '[', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a' };
+ std::vector<uint8_t> const v_C = { '[', '$', 'C', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, 'a', 'a' };
// check if vector is parsed correctly
- CHECK(json::from_bjdata(v_i) == json({127, 127}));
- CHECK(json::from_bjdata(v_U) == json({255, 255}));
- CHECK(json::from_bjdata(v_I) == json({32767, 32767}));
- CHECK(json::from_bjdata(v_u) == json({42767, 42767}));
- CHECK(json::from_bjdata(v_l) == json({2147483647, 2147483647}));
- CHECK(json::from_bjdata(v_m) == json({3147483647, 3147483647}));
- CHECK(json::from_bjdata(v_L) == json({9223372036854775807, 9223372036854775807}));
- CHECK(json::from_bjdata(v_M) == json({10223372036854775807ull, 10223372036854775807ull}));
- CHECK(json::from_bjdata(v_D) == json({3.1415926, 3.1415926}));
- CHECK(json::from_bjdata(v_S) == json({"a", "a"}));
- CHECK(json::from_bjdata(v_C) == json({"a", "a"}));
+ CHECK(json::from_bjdata(v_i) == json({ 127, 127 }));
+ CHECK(json::from_bjdata(v_U) == json({ 255, 255 }));
+ CHECK(json::from_bjdata(v_I) == json({ 32767, 32767 }));
+ CHECK(json::from_bjdata(v_u) == json({ 42767, 42767 }));
+ CHECK(json::from_bjdata(v_l) == json({ 2147483647, 2147483647 }));
+ CHECK(json::from_bjdata(v_m) == json({ 3147483647, 3147483647 }));
+ CHECK(json::from_bjdata(v_L) == json({ 9223372036854775807, 9223372036854775807 }));
+ CHECK(json::from_bjdata(v_M) == json({ 10223372036854775807ull, 10223372036854775807ull }));
+ CHECK(json::from_bjdata(v_D) == json({ 3.1415926, 3.1415926 }));
+ CHECK(json::from_bjdata(v_S) == json({ "a", "a" }));
+ CHECK(json::from_bjdata(v_C) == json({ "a", "a" }));
}
SECTION("invalid ndarray annotations remains as object")
{
// check if invalid ND array annotations stay as object
- json j_type = json({{"_ArrayData_", {1, 2, 3, 4, 5, 6}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "invalidtype"}});
- json j_size = json({{"_ArrayData_", {1, 2, 3, 4, 5}}, {"_ArraySize_", {2, 3}}, {"_ArrayType_", "uint8"}});
+ json j_type = json({ { "_ArrayData_", { 1, 2, 3, 4, 5, 6 } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "invalidtype" } });
+ json j_size = json({ { "_ArrayData_", { 1, 2, 3, 4, 5 } }, { "_ArraySize_", { 2, 3 } }, { "_ArrayType_", "uint8" } });
// roundtrip: output should stay as object
CHECK(json::from_bjdata(json::to_bjdata(j_type), true, true) == j_type);
@@ -2538,7 +2536,7 @@
{
SECTION("eof after C byte")
{
- std::vector<uint8_t> const v = {'C'};
+ std::vector<uint8_t> 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",
@@ -2547,7 +2545,7 @@
SECTION("byte out of range")
{
- std::vector<uint8_t> const v = {'C', 130};
+ std::vector<uint8_t> const v = { 'C', 130 };
json _;
CHECK_THROWS_WITH(
_ = json::from_bjdata(v),
@@ -2559,7 +2557,7 @@
{
SECTION("eof after S byte")
{
- std::vector<uint8_t> const v = {'S'};
+ std::vector<uint8_t> 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",
@@ -2568,7 +2566,7 @@
SECTION("invalid byte")
{
- std::vector<uint8_t> const v = {'S', '1', 'a'};
+ std::vector<uint8_t> const v = { 'S', '1', 'a' };
json _;
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(v),
@@ -2579,9 +2577,9 @@
SECTION("parse bjdata markers in ubjson")
{
// create a single-character string for all number types
- std::vector<uint8_t> const s_u = {'S', 'u', 1, 0, 'a'};
- std::vector<uint8_t> const s_m = {'S', 'm', 1, 0, 0, 0, 'a'};
- std::vector<uint8_t> const s_M = {'S', 'M', 1, 0, 0, 0, 0, 0, 0, 0, 'a'};
+ std::vector<uint8_t> const s_u = { 'S', 'u', 1, 0, 'a' };
+ std::vector<uint8_t> const s_m = { 'S', 'm', 1, 0, 0, 0, 'a' };
+ std::vector<uint8_t> const s_M = { 'S', 'M', 1, 0, 0, 0, 0, 0, 0, 0, 'a' };
json _;
// check if string is parsed correctly to "a"
@@ -2604,7 +2602,7 @@
{
SECTION("optimized array: no size following type")
{
- std::vector<uint8_t> const v = {'[', '$', 'i', 2};
+ std::vector<uint8_t> const v = { '[', '$', 'i', 2 };
json _;
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(v),
@@ -2614,18 +2612,18 @@
SECTION("optimized array: negative size")
{
- std::vector<uint8_t> const v1 = {'[', '#', 'i', 0xF1};
- std::vector<uint8_t> const v2 = {'[', '$', 'I', '#', 'i', 0xF2};
- std::vector<uint8_t> const v3 = {'[', '$', 'I', '#', '[', 'i', 0xF4, 'i', 0x02, ']'};
- std::vector<uint8_t> const v4 = {'[', '$', 0xF6, '#', 'i', 0xF7};
- std::vector<uint8_t> const v5 = {'[', '$', 'I', '#', '[', 'i', 0xF5, 'i', 0xF1, ']'};
- std::vector<uint8_t> const v6 = {'[', '#', '[', 'i', 0xF3, 'i', 0x02, ']'};
+ std::vector<uint8_t> const v1 = { '[', '#', 'i', 0xF1 };
+ std::vector<uint8_t> const v2 = { '[', '$', 'I', '#', 'i', 0xF2 };
+ std::vector<uint8_t> const v3 = { '[', '$', 'I', '#', '[', 'i', 0xF4, 'i', 0x02, ']' };
+ std::vector<uint8_t> const v4 = { '[', '$', 0xF6, '#', 'i', 0xF7 };
+ std::vector<uint8_t> const v5 = { '[', '$', 'I', '#', '[', 'i', 0xF5, 'i', 0xF1, ']' };
+ std::vector<uint8_t> const v6 = { '[', '#', '[', 'i', 0xF3, 'i', 0x02, ']' };
- std::vector<uint8_t> const vI = {'[', '#', 'I', 0x00, 0xF1};
- std::vector<uint8_t> const vl = {'[', '#', 'l', 0x00, 0x00, 0x00, 0xF2};
- std::vector<uint8_t> const vL = {'[', '#', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF3};
- std::vector<uint8_t> const vM = {'[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']'};
- std::vector<uint8_t> const vMX = {'[', '$', 'U', '#', '[', 'M', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 'U', 0x01, ']'};
+ std::vector<uint8_t> const vI = { '[', '#', 'I', 0x00, 0xF1 };
+ std::vector<uint8_t> const vl = { '[', '#', 'l', 0x00, 0x00, 0x00, 0xF2 };
+ std::vector<uint8_t> const vL = { '[', '#', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF3 };
+ std::vector<uint8_t> const vM = { '[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']' };
+ std::vector<uint8_t> const vMX = { '[', '$', 'U', '#', '[', 'M', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 'U', 0x01, ']' };
json _;
CHECK_THROWS_WITH_AS(
@@ -2708,8 +2706,8 @@
SECTION("optimized array: integer value overflow")
{
#if SIZE_MAX == 0xffffffff
- std::vector<uint8_t> const vL = {'[', '#', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F};
- std::vector<uint8_t> const vM = {'[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']'};
+ std::vector<uint8_t> const vL = { '[', '#', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F };
+ std::vector<uint8_t> const vM = { '[', '$', 'M', '#', '[', 'I', 0x00, 0x20, 'M', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xFF, ']' };
json _;
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vL),
@@ -2726,10 +2724,10 @@
SECTION("do not accept NTFZ markers in ndarray optimized type (with count)")
{
json _;
- std::vector<uint8_t> const v_N = {'[', '$', 'N', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2};
- std::vector<uint8_t> const v_T = {'[', '$', 'T', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2};
- std::vector<uint8_t> const v_F = {'[', '$', 'F', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2};
- std::vector<uint8_t> const v_Z = {'[', '$', 'Z', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2};
+ std::vector<uint8_t> const v_N = { '[', '$', 'N', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2 };
+ std::vector<uint8_t> const v_T = { '[', '$', 'T', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2 };
+ std::vector<uint8_t> const v_F = { '[', '$', 'F', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2 };
+ std::vector<uint8_t> const v_Z = { '[', '$', 'Z', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2 };
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(v_N),
@@ -2759,10 +2757,10 @@
SECTION("do not accept NTFZ markers in ndarray optimized type (without count)")
{
json _;
- std::vector<uint8_t> const v_N = {'[', '$', 'N', '#', '[', 'i', 1, 'i', 2, ']'};
- std::vector<uint8_t> const v_T = {'[', '$', 'T', '#', '[', 'i', 1, 'i', 2, ']'};
- std::vector<uint8_t> const v_F = {'[', '$', 'F', '#', '[', 'i', 1, 'i', 2, ']'};
- std::vector<uint8_t> const v_Z = {'[', '$', 'Z', '#', '[', 'i', 1, 'i', 2, ']'};
+ std::vector<uint8_t> const v_N = { '[', '$', 'N', '#', '[', 'i', 1, 'i', 2, ']' };
+ std::vector<uint8_t> const v_T = { '[', '$', 'T', '#', '[', 'i', 1, 'i', 2, ']' };
+ std::vector<uint8_t> const v_F = { '[', '$', 'F', '#', '[', 'i', 1, 'i', 2, ']' };
+ std::vector<uint8_t> const v_Z = { '[', '$', 'Z', '#', '[', 'i', 1, 'i', 2, ']' };
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(v_N),
@@ -2792,20 +2790,20 @@
SECTION("strings")
{
- std::vector<uint8_t> const vS = {'S'};
+ std::vector<uint8_t> const vS = { 'S' };
json _;
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vS),
"[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing BJData value: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vS, true, false).is_discarded());
- std::vector<uint8_t> const v = {'S', 'i', '2', 'a'};
+ std::vector<uint8_t> const v = { 'S', 'i', '2', 'a' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v),
"[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing BJData string: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(v, true, false).is_discarded());
- std::vector<uint8_t> const vC = {'C'};
+ std::vector<uint8_t> 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&);
@@ -2814,56 +2812,56 @@
SECTION("sizes")
{
- std::vector<uint8_t> const vU = {'[', '#', 'U'};
+ std::vector<uint8_t> const vU = { '[', '#', 'U' };
json _;
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vU),
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vU, true, false).is_discarded());
- std::vector<uint8_t> const vi = {'[', '#', 'i'};
+ std::vector<uint8_t> const vi = { '[', '#', 'i' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vi),
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vi, true, false).is_discarded());
- std::vector<uint8_t> const vI = {'[', '#', 'I'};
+ std::vector<uint8_t> const vI = { '[', '#', 'I' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vI),
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vI, true, false).is_discarded());
- std::vector<uint8_t> const vu = {'[', '#', 'u'};
+ std::vector<uint8_t> const vu = { '[', '#', 'u' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vu),
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vu, true, false).is_discarded());
- std::vector<uint8_t> const vl = {'[', '#', 'l'};
+ std::vector<uint8_t> const vl = { '[', '#', 'l' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vl),
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vl, true, false).is_discarded());
- std::vector<uint8_t> const vm = {'[', '#', 'm'};
+ std::vector<uint8_t> const vm = { '[', '#', 'm' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vm),
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vm, true, false).is_discarded());
- std::vector<uint8_t> const vL = {'[', '#', 'L'};
+ std::vector<uint8_t> const vL = { '[', '#', 'L' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vL),
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vL, true, false).is_discarded());
- std::vector<uint8_t> const vM = {'[', '#', 'M'};
+ std::vector<uint8_t> const vM = { '[', '#', 'M' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM),
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vM, true, false).is_discarded());
- std::vector<uint8_t> const v0 = {'[', '#', 'T', ']'};
+ std::vector<uint8_t> 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");
@@ -2873,28 +2871,28 @@
SECTION("parse bjdata markers as array size in ubjson")
{
json _;
- std::vector<uint8_t> const vu = {'[', '#', 'u'};
+ std::vector<uint8_t> const vu = { '[', '#', 'u' };
CHECK_THROWS_WITH_AS(
_ = json::from_ubjson(vu),
"[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x75",
json::parse_error&);
CHECK(json::from_ubjson(vu, true, false).is_discarded());
- std::vector<uint8_t> const vm = {'[', '#', 'm'};
+ std::vector<uint8_t> const vm = { '[', '#', 'm' };
CHECK_THROWS_WITH_AS(
_ = json::from_ubjson(vm),
"[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x6D",
json::parse_error&);
CHECK(json::from_ubjson(vm, true, false).is_discarded());
- std::vector<uint8_t> const vM = {'[', '#', 'M'};
+ std::vector<uint8_t> const vM = { '[', '#', 'M' };
CHECK_THROWS_WITH_AS(
_ = json::from_ubjson(vM),
"[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x4D",
json::parse_error&);
CHECK(json::from_ubjson(vM, true, false).is_discarded());
- std::vector<uint8_t> const v0 = {'[', '#', '['};
+ std::vector<uint8_t> 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",
@@ -2904,26 +2902,26 @@
SECTION("types")
{
- std::vector<uint8_t> const v0 = {'[', '$'};
+ std::vector<uint8_t> const v0 = { '[', '$' };
json _;
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v0),
"[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing BJData type: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(v0, true, false).is_discarded());
- std::vector<uint8_t> const vi = {'[', '$', '#'};
+ std::vector<uint8_t> const vi = { '[', '$', '#' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vi),
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData value: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vi, true, false).is_discarded());
- std::vector<uint8_t> const vU = {'[', '$', 'U'};
+ std::vector<uint8_t> const vU = { '[', '$', 'U' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vU),
"[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing BJData value: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vU, true, false).is_discarded());
- std::vector<uint8_t> const v1 = {'[', '$', '['};
+ std::vector<uint8_t> 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",
@@ -2933,20 +2931,20 @@
SECTION("arrays")
{
- std::vector<uint8_t> const vST = {'[', '$', 'i', '#', 'i', 2, 1};
+ std::vector<uint8_t> const vST = { '[', '$', 'i', '#', 'i', 2, 1 };
json _;
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vST),
"[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vST, true, false).is_discarded());
- std::vector<uint8_t> const vS = {'[', '#', 'i', 2, 'i', 1};
+ std::vector<uint8_t> const vS = { '[', '#', 'i', 2, 'i', 1 };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vS),
"[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing BJData value: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vS, true, false).is_discarded());
- std::vector<uint8_t> const v = {'[', 'i', 2, 'i', 1};
+ std::vector<uint8_t> 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&);
@@ -2955,7 +2953,7 @@
SECTION("ndarrays")
{
- std::vector<uint8_t> const vST = {'[', '$', 'i', '#', '[', '$', 'i', '#'};
+ std::vector<uint8_t> const vST = { '[', '$', 'i', '#', '[', '$', 'i', '#' };
json _;
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(vST),
@@ -2963,123 +2961,123 @@
json::parse_error&);
CHECK(json::from_bjdata(vST, true, false).is_discarded());
- std::vector<uint8_t> const v = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1, 2};
+ std::vector<uint8_t> const v = { '[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1, 2 };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v),
"[json.exception.parse_error.110] parse error at byte 13: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(v, true, false).is_discarded());
- std::vector<uint8_t> const vS0 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1};
+ std::vector<uint8_t> const vS0 = { '[', '$', 'i', '#', '[', '$', 'i', '#', 'i', 2, 1 };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vS0),
"[json.exception.parse_error.110] parse error at byte 12: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vS0, true, false).is_discarded());
- std::vector<uint8_t> const vS = {'[', '$', 'i', '#', '[', '#', 'i', 2, 1, 2, 1};
+ std::vector<uint8_t> const vS = { '[', '$', 'i', '#', '[', '#', 'i', 2, 1, 2, 1 };
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(vS),
"[json.exception.parse_error.113] parse error at byte 9: syntax error while parsing BJData size: expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x01",
json::parse_error&);
CHECK(json::from_bjdata(vS, true, false).is_discarded());
- std::vector<uint8_t> const vT = {'[', '$', 'i', '#', '[', 'i', 2, 'i'};
+ std::vector<uint8_t> const vT = { '[', '$', 'i', '#', '[', 'i', 2, 'i' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vT),
"[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vT, true, false).is_discarded());
- std::vector<uint8_t> const vT0 = {'[', '$', 'i', '#', '[', 'i'};
+ std::vector<uint8_t> const vT0 = { '[', '$', 'i', '#', '[', 'i' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vT0),
"[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vT0, true, false).is_discarded());
- std::vector<uint8_t> const vu = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'u', 1, 0};
+ std::vector<uint8_t> const vu = { '[', '$', 'i', '#', '[', '$', 'i', '#', 'u', 1, 0 };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vu),
"[json.exception.parse_error.110] parse error at byte 12: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vu, true, false).is_discarded());
- std::vector<uint8_t> const vm = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'm', 1, 0, 0, 0};
+ std::vector<uint8_t> const vm = { '[', '$', 'i', '#', '[', '$', 'i', '#', 'm', 1, 0, 0, 0 };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vm),
"[json.exception.parse_error.110] parse error at byte 14: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vm, true, false).is_discarded());
- std::vector<uint8_t> const vM = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'M', 1, 0, 0, 0, 0, 0, 0, 0};
+ std::vector<uint8_t> const vM = { '[', '$', 'i', '#', '[', '$', 'i', '#', 'M', 1, 0, 0, 0, 0, 0, 0, 0 };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vM),
"[json.exception.parse_error.110] parse error at byte 18: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vM, true, false).is_discarded());
- std::vector<uint8_t> const vU = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 1, 2, 3, 4, 5};
+ std::vector<uint8_t> const vU = { '[', '$', 'U', '#', '[', '$', 'i', '#', 'i', 2, 2, 3, 1, 2, 3, 4, 5 };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vU),
"[json.exception.parse_error.110] parse error at byte 18: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vU, true, false).is_discarded());
- std::vector<uint8_t> const vT1 = {'[', '$', 'T', '#', '[', '$', 'i', '#', 'i', 2, 2, 3};
+ std::vector<uint8_t> const vT1 = { '[', '$', 'T', '#', '[', '$', 'i', '#', 'i', 2, 2, 3 };
CHECK(json::from_bjdata(vT1, true, false).is_discarded());
- std::vector<uint8_t> const vh = {'[', '$', 'h', '#', '[', '$', 'i', '#', 'i', 2, 2, 3};
+ std::vector<uint8_t> const vh = { '[', '$', 'h', '#', '[', '$', 'i', '#', 'i', 2, 2, 3 };
CHECK(json::from_bjdata(vh, true, false).is_discarded());
- std::vector<uint8_t> const vR = {'[', '$', 'i', '#', '[', 'i', 1, '[', ']', ']', 1};
+ std::vector<uint8_t> 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(json::from_bjdata(vR, true, false).is_discarded());
- std::vector<uint8_t> const vRo = {'[', '$', 'i', '#', '[', 'i', 0, '{', '}', ']', 1};
+ std::vector<uint8_t> const vRo = { '[', '$', 'i', '#', '[', 'i', 0, '{', '}', ']', 1 };
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(vRo),
"[json.exception.parse_error.113] parse error at byte 8: syntax error while parsing BJData size: expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x7B",
json::parse_error&);
CHECK(json::from_bjdata(vRo, true, false).is_discarded());
- std::vector<uint8_t> const vR1 = {'[', '$', 'i', '#', '[', '[', 'i', 1, ']', ']', 1};
+ std::vector<uint8_t> 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(json::from_bjdata(vR1, true, false).is_discarded());
- std::vector<uint8_t> const vR2 = {'[', '$', 'i', '#', '[', '#', '[', 'i', 1, ']', ']', 1};
+ std::vector<uint8_t> const vR2 = { '[', '$', 'i', '#', '[', '#', '[', 'i', 1, ']', ']', 1 };
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(vR2),
"[json.exception.parse_error.113] parse error at byte 11: syntax error while parsing BJData size: expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x5D",
json::parse_error&);
CHECK(json::from_bjdata(vR2, true, false).is_discarded());
- std::vector<uint8_t> const vR3 = {'[', '#', '[', 'i', '2', 'i', 2, ']'};
+ std::vector<uint8_t> const vR3 = { '[', '#', '[', 'i', '2', 'i', 2, ']' };
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(vR3),
"[json.exception.parse_error.112] parse error at byte 8: syntax error while parsing BJData size: ndarray requires both type and size",
json::parse_error&);
CHECK(json::from_bjdata(vR3, true, false).is_discarded());
- std::vector<uint8_t> const vR4 = {'[', '$', 'i', '#', '[', '$', 'i', '#', '[', 'i', 1, ']', 1};
+ std::vector<uint8_t> const vR4 = { '[', '$', 'i', '#', '[', '$', 'i', '#', '[', 'i', 1, ']', 1 };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vR4),
"[json.exception.parse_error.110] parse error at byte 14: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vR4, true, false).is_discarded());
- std::vector<uint8_t> const vR5 = {'[', '$', 'i', '#', '[', '[', '[', ']', ']', ']'};
+ std::vector<uint8_t> 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(json::from_bjdata(vR5, true, false).is_discarded());
- std::vector<uint8_t> const vR6 = {'[', '$', 'i', '#', '[', '$', 'i', '#', '[', 'i', '2', 'i', 2, ']'};
+ std::vector<uint8_t> const vR6 = { '[', '$', 'i', '#', '[', '$', 'i', '#', '[', 'i', '2', 'i', 2, ']' };
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(vR6),
"[json.exception.parse_error.112] parse error at byte 14: syntax error while parsing BJData size: ndarray can not be recursive",
json::parse_error&);
CHECK(json::from_bjdata(vR6, true, false).is_discarded());
- std::vector<uint8_t> const vH = {'[', 'H', '[', '#', '[', '$', 'i', '#', '[', 'i', '2', 'i', 2, ']'};
+ std::vector<uint8_t> 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",
@@ -3089,63 +3087,63 @@
SECTION("objects")
{
- std::vector<uint8_t> const vST = {'{', '$', 'i', '#', 'i', 2, 'i', 1, 'a', 1};
+ std::vector<uint8_t> const vST = { '{', '$', 'i', '#', 'i', 2, 'i', 1, 'a', 1 };
json _;
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vST),
"[json.exception.parse_error.110] parse error at byte 11: syntax error while parsing BJData value: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vST, true, false).is_discarded());
- std::vector<uint8_t> const vT = {'{', '$', 'i', 'i', 1, 'a', 1};
+ std::vector<uint8_t> const vT = { '{', '$', 'i', 'i', 1, 'a', 1 };
CHECK_THROWS_WITH(
_ = json::from_bjdata(vT),
"[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing BJData size: expected '#' after type information; last byte: 0x69");
CHECK(json::from_bjdata(vT, true, false).is_discarded());
- std::vector<uint8_t> const vS = {'{', '#', 'i', 2, 'i', 1, 'a', 'i', 1};
+ std::vector<uint8_t> const vS = { '{', '#', 'i', 2, 'i', 1, 'a', 'i', 1 };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vS),
"[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing BJData value: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vS, true, false).is_discarded());
- std::vector<uint8_t> const v = {'{', 'i', 1, 'a', 'i', 1};
+ std::vector<uint8_t> const v = { '{', 'i', 1, 'a', 'i', 1 };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v),
"[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing BJData value: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(v, true, false).is_discarded());
- std::vector<uint8_t> const v2 = {'{', 'i', 1, 'a', 'i', 1, 'i'};
+ std::vector<uint8_t> const v2 = { '{', 'i', 1, 'a', 'i', 1, 'i' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v2),
"[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(v2, true, false).is_discarded());
- std::vector<uint8_t> const v3 = {'{', 'i', 1, 'a'};
+ std::vector<uint8_t> const v3 = { '{', 'i', 1, 'a' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(v3),
"[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing BJData value: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(v3, true, false).is_discarded());
- std::vector<uint8_t> const vST1 = {'{', '$', 'd', '#', 'i', 2, 'i', 1, 'a'};
+ std::vector<uint8_t> const vST1 = { '{', '$', 'd', '#', 'i', 2, 'i', 1, 'a' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vST1),
"[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing BJData number: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vST1, true, false).is_discarded());
- std::vector<uint8_t> const vST2 = {'{', '#', 'i', 2, 'i', 1, 'a'};
+ std::vector<uint8_t> const vST2 = { '{', '#', 'i', 2, 'i', 1, 'a' };
CHECK_THROWS_WITH_AS(_ = json::from_bjdata(vST2),
"[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing BJData value: unexpected end of input",
json::parse_error&);
CHECK(json::from_bjdata(vST2, true, false).is_discarded());
- std::vector<uint8_t> const vO = {'{', '#', '[', 'i', 2, 'i', 1, ']', 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'i', 2};
+ std::vector<uint8_t> const vO = { '{', '#', '[', 'i', 2, 'i', 1, ']', 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'i', 2 };
CHECK_THROWS_WITH_AS(
_ = json::from_bjdata(vO),
"[json.exception.parse_error.112] parse error at byte 8: syntax error while parsing BJData size: ndarray requires both type and size",
json::parse_error&);
CHECK(json::from_bjdata(vO, true, false).is_discarded());
- std::vector<uint8_t> const vO2 = {'{', '$', 'i', '#', '[', 'i', 2, 'i', 1, ']', 'i', 1, 'a', 1, 'i', 1, 'b', 2};
+ std::vector<uint8_t> 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",
@@ -3160,51 +3158,51 @@
{
SECTION("array of i")
{
- json const j = {1, -1};
- std::vector<uint8_t> const expected = {'[', '$', 'i', '#', 'i', 2, 1, 0xff};
+ json const j = { 1, -1 };
+ std::vector<uint8_t> const expected = { '[', '$', 'i', '#', 'i', 2, 1, 0xff };
CHECK(json::to_bjdata(j, true, true) == expected);
}
SECTION("array of U")
{
- json const j = {200, 201};
- std::vector<uint8_t> const expected = {'[', '$', 'U', '#', 'i', 2, 0xC8, 0xC9};
+ json const j = { 200, 201 };
+ std::vector<uint8_t> const expected = { '[', '$', 'U', '#', 'i', 2, 0xC8, 0xC9 };
CHECK(json::to_bjdata(j, true, true) == expected);
}
SECTION("array of I")
{
- json const j = {30000, -30000};
- std::vector<uint8_t> const expected = {'[', '$', 'I', '#', 'i', 2, 0x30, 0x75, 0xd0, 0x8a};
+ json const j = { 30000, -30000 };
+ std::vector<uint8_t> const expected = { '[', '$', 'I', '#', 'i', 2, 0x30, 0x75, 0xd0, 0x8a };
CHECK(json::to_bjdata(j, true, true) == expected);
}
SECTION("array of u")
{
- json const j = {50000, 50001};
- std::vector<uint8_t> const expected = {'[', '$', 'u', '#', 'i', 2, 0x50, 0xC3, 0x51, 0xC3};
+ json const j = { 50000, 50001 };
+ std::vector<uint8_t> const expected = { '[', '$', 'u', '#', 'i', 2, 0x50, 0xC3, 0x51, 0xC3 };
CHECK(json::to_bjdata(j, true, true) == expected);
}
SECTION("array of l")
{
- json const j = {70000, -70000};
- std::vector<uint8_t> const expected = {'[', '$', 'l', '#', 'i', 2, 0x70, 0x11, 0x01, 0x00, 0x90, 0xEE, 0xFE, 0xFF};
+ json const j = { 70000, -70000 };
+ std::vector<uint8_t> const expected = { '[', '$', 'l', '#', 'i', 2, 0x70, 0x11, 0x01, 0x00, 0x90, 0xEE, 0xFE, 0xFF };
CHECK(json::to_bjdata(j, true, true) == expected);
}
SECTION("array of m")
{
- json const j = {3147483647, 3147483648};
- std::vector<uint8_t> const expected = {'[', '$', 'm', '#', 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0x00, 0xCA, 0x9A, 0xBB};
+ json const j = { 3147483647, 3147483648 };
+ std::vector<uint8_t> const expected = { '[', '$', 'm', '#', 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0x00, 0xCA, 0x9A, 0xBB };
CHECK(json::to_bjdata(j, true, true) == expected);
}
SECTION("array of L")
{
- json const j = {5000000000, -5000000000};
- std::vector<uint8_t> const expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0xF2, 0x05, 0x2A, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFA, 0xD5, 0xFE, 0xFF, 0xFF, 0xFF};
+ json const j = { 5000000000, -5000000000 };
+ std::vector<uint8_t> 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);
}
}
@@ -3213,76 +3211,76 @@
{
SECTION("array of i")
{
- json const j = {1u, 2u};
- std::vector<uint8_t> const expected = {'[', '$', 'i', '#', 'i', 2, 1, 2};
- std::vector<uint8_t> const expected_size = {'[', '#', 'i', 2, 'i', 1, 'i', 2};
+ json const j = { 1u, 2u };
+ std::vector<uint8_t> const expected = { '[', '$', 'i', '#', 'i', 2, 1, 2 };
+ std::vector<uint8_t> const expected_size = { '[', '#', 'i', 2, 'i', 1, 'i', 2 };
CHECK(json::to_bjdata(j, true, true) == expected);
CHECK(json::to_bjdata(j, true) == expected_size);
}
SECTION("array of U")
{
- json const j = {200u, 201u};
- std::vector<uint8_t> const expected = {'[', '$', 'U', '#', 'i', 2, 0xC8, 0xC9};
- std::vector<uint8_t> const expected_size = {'[', '#', 'i', 2, 'U', 0xC8, 'U', 0xC9};
+ json const j = { 200u, 201u };
+ std::vector<uint8_t> const expected = { '[', '$', 'U', '#', 'i', 2, 0xC8, 0xC9 };
+ std::vector<uint8_t> const expected_size = { '[', '#', 'i', 2, 'U', 0xC8, 'U', 0xC9 };
CHECK(json::to_bjdata(j, true, true) == expected);
CHECK(json::to_bjdata(j, true) == expected_size);
}
SECTION("array of I")
{
- json const j = {30000u, 30001u};
- std::vector<uint8_t> const expected = {'[', '$', 'I', '#', 'i', 2, 0x30, 0x75, 0x31, 0x75};
- std::vector<uint8_t> const expected_size = {'[', '#', 'i', 2, 'I', 0x30, 0x75, 'I', 0x31, 0x75};
+ json const j = { 30000u, 30001u };
+ std::vector<uint8_t> const expected = { '[', '$', 'I', '#', 'i', 2, 0x30, 0x75, 0x31, 0x75 };
+ std::vector<uint8_t> const expected_size = { '[', '#', 'i', 2, 'I', 0x30, 0x75, 'I', 0x31, 0x75 };
CHECK(json::to_bjdata(j, true, true) == expected);
CHECK(json::to_bjdata(j, true) == expected_size);
}
SECTION("array of u")
{
- json const j = {50000u, 50001u};
- std::vector<uint8_t> const expected = {'[', '$', 'u', '#', 'i', 2, 0x50, 0xC3, 0x51, 0xC3};
- std::vector<uint8_t> const expected_size = {'[', '#', 'i', 2, 'u', 0x50, 0xC3, 'u', 0x51, 0xC3};
+ json const j = { 50000u, 50001u };
+ std::vector<uint8_t> const expected = { '[', '$', 'u', '#', 'i', 2, 0x50, 0xC3, 0x51, 0xC3 };
+ std::vector<uint8_t> const expected_size = { '[', '#', 'i', 2, 'u', 0x50, 0xC3, 'u', 0x51, 0xC3 };
CHECK(json::to_bjdata(j, true, true) == expected);
CHECK(json::to_bjdata(j, true) == expected_size);
}
SECTION("array of l")
{
- json const j = {70000u, 70001u};
- std::vector<uint8_t> const expected = {'[', '$', 'l', '#', 'i', 2, 0x70, 0x11, 0x01, 0x00, 0x71, 0x11, 0x01, 0x00};
- std::vector<uint8_t> const expected_size = {'[', '#', 'i', 2, 'l', 0x70, 0x11, 0x01, 0x00, 'l', 0x71, 0x11, 0x01, 0x00};
+ json const j = { 70000u, 70001u };
+ std::vector<uint8_t> const expected = { '[', '$', 'l', '#', 'i', 2, 0x70, 0x11, 0x01, 0x00, 0x71, 0x11, 0x01, 0x00 };
+ std::vector<uint8_t> const expected_size = { '[', '#', 'i', 2, 'l', 0x70, 0x11, 0x01, 0x00, 'l', 0x71, 0x11, 0x01, 0x00 };
CHECK(json::to_bjdata(j, true, true) == expected);
CHECK(json::to_bjdata(j, true) == expected_size);
}
SECTION("array of m")
{
- json const j = {3147483647u, 3147483648u};
- std::vector<uint8_t> const expected = {'[', '$', 'm', '#', 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0x00, 0xCA, 0x9A, 0xBB};
- std::vector<uint8_t> const expected_size = {'[', '#', 'i', 2, 'm', 0xFF, 0xC9, 0x9A, 0xBB, 'm', 0x00, 0xCA, 0x9A, 0xBB};
+ json const j = { 3147483647u, 3147483648u };
+ std::vector<uint8_t> const expected = { '[', '$', 'm', '#', 'i', 2, 0xFF, 0xC9, 0x9A, 0xBB, 0x00, 0xCA, 0x9A, 0xBB };
+ std::vector<uint8_t> const expected_size = { '[', '#', 'i', 2, 'm', 0xFF, 0xC9, 0x9A, 0xBB, 'm', 0x00, 0xCA, 0x9A, 0xBB };
CHECK(json::to_bjdata(j, true, true) == expected);
CHECK(json::to_bjdata(j, true) == expected_size);
}
SECTION("array of L")
{
- json const j = {5000000000u, 5000000001u};
- std::vector<uint8_t> const expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0xF2, 0x05, 0x2A, 0x01,
- 0x00, 0x00, 0x00, 0x01, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00};
- std::vector<uint8_t> const expected_size = {'[', '#', 'i', 2, 'L', 0x00, 0xF2, 0x05, 0x2A, 0x01, 0x00,
- 0x00, 0x00, 'L', 0x01, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00};
+ json const j = { 5000000000u, 5000000001u };
+ std::vector<uint8_t> const expected = { '[', '$', 'L', '#', 'i', 2, 0x00, 0xF2, 0x05, 0x2A, 0x01,
+ 0x00, 0x00, 0x00, 0x01, 0xF2, 0x05, 0x2A, 0x01, 0x00, 0x00, 0x00 };
+ std::vector<uint8_t> 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);
}
SECTION("array of M")
{
- json const j = {10223372036854775807ull, 10223372036854775808ull};
- std::vector<uint8_t> const expected = {'[', '$', 'M', '#', 'i', 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3,
- 0xB6, 0xE0, 0x8D, 0x00, 0x00, 0x64, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D};
- std::vector<uint8_t> const expected_size = {'[', '#', 'i', 2, 'M', 0xFF, 0xFF, 0x63, 0xA7, 0xB3, 0xB6,
- 0xE0, 0x8D, 'M', 0x00, 0x00, 0x64, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D};
+ json const j = { 10223372036854775807ull, 10223372036854775808ull };
+ std::vector<uint8_t> const expected = { '[', '$', 'M', '#', 'i', 2, 0xFF, 0xFF, 0x63, 0xA7, 0xB3,
+ 0xB6, 0xE0, 0x8D, 0x00, 0x00, 0x64, 0xA7, 0xB3, 0xB6, 0xE0, 0x8D };
+ std::vector<uint8_t> 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);
}
@@ -3294,18 +3292,18 @@
{
SECTION("Null Value")
{
- json const j = {{"passcode", nullptr}};
- std::vector<uint8_t> v = {'{', 'i', 8, 'p', 'a', 's', 's', 'c', 'o', 'd', 'e', 'Z', '}'};
+ json const j = { { "passcode", nullptr } };
+ std::vector<uint8_t> v = { '{', 'i', 8, 'p', 'a', 's', 's', 'c', 'o', 'd', 'e', 'Z', '}' };
CHECK(json::to_bjdata(j) == v);
CHECK(json::from_bjdata(v) == j);
}
SECTION("No-Op Value")
{
- json const j = {"foo", "bar", "baz"};
- std::vector<uint8_t> v = {'[', 'S', 'i', 3, 'f', 'o', 'o', 'S', 'i', 3, 'b', 'a', 'r', 'S', 'i', 3, 'b', 'a', 'z', ']'};
- std::vector<uint8_t> 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', ']'};
+ json const j = { "foo", "bar", "baz" };
+ std::vector<uint8_t> v = { '[', 'S', 'i', 3, 'f', 'o', 'o', 'S', 'i', 3, 'b', 'a', 'r', 'S', 'i', 3, 'b', 'a', 'z', ']' };
+ std::vector<uint8_t> 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);
@@ -3313,38 +3311,39 @@
SECTION("Boolean Types")
{
- json const j = {{"authorized", true}, {"verified", false}};
- std::vector<uint8_t> 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', '}'};
+ json const j = { { "authorized", true }, { "verified", false } };
+ std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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);
}
SECTION("Char Type")
{
- json const j = {{"rolecode", "a"}, {"delim", ";"}};
- std::vector<uint8_t> const v = {'{', 'i', 5, 'd', 'e', 'l', 'i', 'm', 'C', ';', 'i', 8, 'r', 'o', 'l', 'e', 'c', 'o', 'd', 'e', 'C', 'a', '}'};
+ json const j = { { "rolecode", "a" }, { "delim", ";" } };
+ std::vector<uint8_t> const v = { '{', 'i', 5, 'd', 'e', 'l', 'i', 'm', 'C', ';', 'i', 8, 'r', 'o', 'l', 'e', 'c', 'o', 'd', 'e', 'C', 'a', '}' };
//CHECK(json::to_bjdata(j) == v);
CHECK(json::from_bjdata(v) == j);
}
@@ -3354,7 +3353,7 @@
SECTION("English")
{
json const j = "hello";
- std::vector<uint8_t> v = {'S', 'i', 5, 'h', 'e', 'l', 'l', 'o'};
+ std::vector<uint8_t> v = { 'S', 'i', 5, 'h', 'e', 'l', 'l', 'o' };
CHECK(json::to_bjdata(j) == v);
CHECK(json::from_bjdata(v) == j);
}
@@ -3362,7 +3361,7 @@
SECTION("Russian")
{
json const j = "привет";
- std::vector<uint8_t> v = {'S', 'i', 12, 0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82};
+ std::vector<uint8_t> v = { 'S', 'i', 12, 0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82 };
CHECK(json::to_bjdata(j) == v);
CHECK(json::from_bjdata(v) == j);
}
@@ -3370,7 +3369,7 @@
SECTION("Russian")
{
json const j = "مرحبا";
- std::vector<uint8_t> v = {'S', 'i', 10, 0xD9, 0x85, 0xD8, 0xB1, 0xD8, 0xAD, 0xD8, 0xA8, 0xD8, 0xA7};
+ std::vector<uint8_t> v = { 'S', 'i', 10, 0xD9, 0x85, 0xD8, 0xB1, 0xD8, 0xAD, 0xD8, 0xA8, 0xD8, 0xA7 };
CHECK(json::to_bjdata(j) == v);
CHECK(json::from_bjdata(v) == j);
}
@@ -3381,9 +3380,9 @@
SECTION("size=false type=false")
{
// note the float has been replaced by a double
- json const j = {nullptr, true, false, 4782345193, 153.132, "ham"};
- std::vector<uint8_t> 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', ']'};
+ json const j = { nullptr, true, false, 4782345193, 153.132, "ham" };
+ std::vector<uint8_t> 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);
}
@@ -3391,9 +3390,9 @@
SECTION("size=true type=false")
{
// note the float has been replaced by a double
- json const j = {nullptr, true, false, 4782345193, 153.132, "ham"};
- std::vector<uint8_t> 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'};
+ json const j = { nullptr, true, false, 4782345193, 153.132, "ham" };
+ std::vector<uint8_t> 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);
}
@@ -3401,9 +3400,9 @@
SECTION("size=true type=true")
{
// note the float has been replaced by a double
- json const j = {nullptr, true, false, 4782345193, 153.132, "ham"};
- std::vector<uint8_t> 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'};
+ json const j = { nullptr, true, false, 4782345193, 153.132, "ham" };
+ std::vector<uint8_t> 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);
}
@@ -3413,18 +3412,18 @@
{
SECTION("size=false type=false")
{
- json j = {{"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}};
- std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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', ' ',
@@ -3437,7 +3436,7 @@
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<uint8_t> 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', ' ',
@@ -3456,10 +3455,10 @@
SECTION("No Optimization")
{
// note the floats have been replaced by doubles
- json const j = {29.97, 31.13, 67.0, 2.113, 23.888};
- std::vector<uint8_t> 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, ']'};
+ json const j = { 29.97, 31.13, 67.0, 2.113, 23.888 };
+ std::vector<uint8_t> 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);
}
@@ -3467,7 +3466,7 @@
SECTION("Optimized with count")
{
// note the floats have been replaced by doubles
- json const j = {29.97, 31.13, 67.0, 2.113, 23.888};
+ json const j = { 29.97, 31.13, 67.0, 2.113, 23.888 };
std::vector<uint8_t> 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,
@@ -3480,7 +3479,7 @@
SECTION("Optimized with type & count")
{
// note the floats have been replaced by doubles
- json const j = {29.97, 31.13, 67.0, 2.113, 23.888};
+ json const j = { 29.97, 31.13, 67.0, 2.113, 23.888 };
std::vector<uint8_t> 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,
@@ -3495,10 +3494,10 @@
SECTION("No Optimization")
{
// note the floats have been replaced by doubles
- json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}};
- std::vector<uint8_t> 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, '}'};
+ json const j = { { "lat", 29.976 }, { "long", 31.131 }, { "alt", 67.0 } };
+ std::vector<uint8_t> 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);
}
@@ -3506,7 +3505,7 @@
SECTION("Optimized with count")
{
// note the floats have been replaced by doubles
- json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}};
+ json const j = { { "lat", 29.976 }, { "long", 31.131 }, { "alt", 67.0 } };
std::vector<uint8_t> 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,
@@ -3518,7 +3517,7 @@
SECTION("Optimized with type & count")
{
// note the floats have been replaced by doubles
- json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}};
+ json const j = { { "lat", 29.976 }, { "long", 31.131 }, { "alt", 67.0 } };
std::vector<uint8_t> 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,
@@ -3533,7 +3532,7 @@
SECTION("Array")
{
json _;
- std::vector<uint8_t> const v = {'[', '$', 'N', '#', 'I', 0x00, 0x02};
+ std::vector<uint8_t> 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",
@@ -3544,8 +3543,8 @@
SECTION("Object")
{
json _;
- std::vector<uint8_t> 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<uint8_t> 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",
@@ -3560,7 +3559,7 @@
TEST_CASE("all BJData first bytes")
{
// these bytes will fail immediately with exception parse_error.112
- std::set<uint8_t> supported = {'T', 'F', 'Z', 'U', 'i', 'I', 'l', 'L', 'd', 'D', 'C', 'S', '[', '{', 'N', 'H', 'u', 'm', 'M', 'h'};
+ std::set<uint8_t> 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)
{
@@ -3593,48 +3592,48 @@
{
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 5759b6e..5cc2b79 100644
--- a/tests/src/unit-bson.cpp
+++ b/tests/src/unit-bson.cpp
@@ -74,7 +74,7 @@
SECTION("array")
{
- json const j = std::vector<int>{1, 2, 3, 4, 5, 6, 7};
+ json const j = std::vector<int>{ 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&);
@@ -83,7 +83,7 @@
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)",
@@ -96,7 +96,7 @@
SECTION("string length must be at least 1")
{
// from https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11175
- std::vector<std::uint8_t> const v = {0x20, 0x20, 0x20, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x80};
+ std::vector<std::uint8_t> const v = { 0x20, 0x20, 0x20, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x80 };
json _;
CHECK_THROWS_WITH_AS(
_ = json::from_bson(v),
@@ -128,20 +128,13 @@
SECTION("non-empty object with bool")
{
- json const j = {{"entry", true}};
+ json const j = { { "entry", true } };
std::vector<std::uint8_t> const expected = {
- 0x0D,
- 0x00,
- 0x00,
+ 0x0D, 0x00, 0x00,
0x00, // size (little endian)
0x08, // entry: boolean
- 'e',
- 'n',
- 't',
- 'r',
- 'y',
- '\x00',
+ 'e', 'n', 't', 'r', 'y', '\x00',
0x01, // value = true
0x00 // end marker
};
@@ -156,20 +149,13 @@
SECTION("non-empty object with bool")
{
- json const j = {{"entry", false}};
+ json const j = { { "entry", false } };
std::vector<std::uint8_t> const expected = {
- 0x0D,
- 0x00,
- 0x00,
+ 0x0D, 0x00, 0x00,
0x00, // size (little endian)
0x08, // entry: boolean
- 'e',
- 'n',
- 't',
- 'r',
- 'y',
- '\x00',
+ 'e', 'n', 't', 'r', 'y', '\x00',
0x00, // value = false
0x00 // end marker
};
@@ -184,7 +170,7 @@
SECTION("non-empty object with double")
{
- json const j = {{"entry", 4.2}};
+ json const j = { { "entry", 4.2 } };
std::vector<std::uint8_t> const expected = {
0x14, 0x00, 0x00,
@@ -204,7 +190,7 @@
SECTION("non-empty object with string")
{
- json const j = {{"entry", "bsonstr"}};
+ json const j = { { "entry", "bsonstr" } };
std::vector<std::uint8_t> const expected = {
0x18, 0x00, 0x00,
@@ -224,20 +210,13 @@
SECTION("non-empty object with null member")
{
- json const j = {{"entry", nullptr}};
+ json const j = { { "entry", nullptr } };
std::vector<std::uint8_t> const expected = {
- 0x0C,
- 0x00,
- 0x00,
+ 0x0C, 0x00, 0x00,
0x00, // size (little endian)
0x0A, /// entry: null
- 'e',
- 'n',
- 't',
- 'r',
- 'y',
- '\x00',
+ 'e', 'n', 't', 'r', 'y', '\x00',
0x00 // end marker
};
@@ -251,24 +230,13 @@
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<std::uint8_t> const expected = {
- 0x10,
- 0x00,
- 0x00,
+ 0x10, 0x00, 0x00,
0x00, // size (little endian)
0x10, /// entry: int32
- 'e',
- 'n',
- 't',
- 'r',
- 'y',
- '\x00',
- 0x78,
- 0x56,
- 0x34,
- 0x12,
+ 'e', 'n', 't', 'r', 'y', '\x00', 0x78, 0x56, 0x34, 0x12,
0x00 // end marker
};
@@ -282,7 +250,7 @@
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<std::uint8_t> const expected = {
0x14, 0x00, 0x00,
@@ -302,24 +270,13 @@
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<std::uint8_t> const expected = {
- 0x10,
- 0x00,
- 0x00,
+ 0x10, 0x00, 0x00,
0x00, // size (little endian)
0x10, /// entry: int32
- 'e',
- 'n',
- 't',
- 'r',
- 'y',
- '\x00',
- 0xFF,
- 0xFF,
- 0xFF,
- 0xFF,
+ 'e', 'n', 't', 'r', 'y', '\x00', 0xFF, 0xFF, 0xFF, 0xFF,
0x00 // end marker
};
@@ -333,24 +290,13 @@
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<std::uint8_t> const expected = {
- 0x10,
- 0x00,
- 0x00,
+ 0x10, 0x00, 0x00,
0x00, // size (little endian)
0x10, /// entry: int32
- 'e',
- 'n',
- 't',
- 'r',
- 'y',
- '\x00',
- 0xFF,
- 0xFF,
- 0xFF,
- 0xFF,
+ 'e', 'n', 't', 'r', 'y', '\x00', 0xFF, 0xFF, 0xFF, 0xFF,
0x00 // end marker
};
@@ -365,7 +311,7 @@
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<std::uint8_t> const expected = {
0x14, 0x00, 0x00,
@@ -385,24 +331,13 @@
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<std::uint8_t> const expected = {
- 0x10,
- 0x00,
- 0x00,
+ 0x10, 0x00, 0x00,
0x00, // size (little endian)
0x10, /// entry: int32
- 'e',
- 'n',
- 't',
- 'r',
- 'y',
- '\x00',
- 0x42,
- 0x00,
- 0x00,
- 0x00,
+ 'e', 'n', 't', 'r', 'y', '\x00', 0x42, 0x00, 0x00, 0x00,
0x00 // end marker
};
@@ -416,7 +351,7 @@
SECTION("non-empty object with object member")
{
- json const j = {{"entry", json::object()}};
+ json const j = { { "entry", json::object() } };
std::vector<std::uint8_t> const expected = {
0x11,
@@ -451,7 +386,7 @@
SECTION("non-empty object with array member")
{
- json const j = {{"entry", json::array()}};
+ json const j = { { "entry", json::array() } };
std::vector<std::uint8_t> const expected = {
0x11,
@@ -486,7 +421,7 @@
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<std::uint8_t> const expected = {
0x49, 0x00, 0x00,
@@ -516,7 +451,7 @@
{
const size_t N = 10;
const auto s = std::vector<std::uint8_t>(N, 'x');
- json const j = {{"entry", json::binary(s, 0)}};
+ json const j = { { "entry", json::binary(s, 0) } };
std::vector<std::uint8_t> const expected = {
0x1B, 0x00, 0x00,
@@ -543,8 +478,8 @@
SECTION("non-empty object with binary member with subtype")
{
// an MD5 hash
- const std::vector<std::uint8_t> 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)}};
+ const std::vector<std::uint8_t> 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) } };
std::vector<std::uint8_t> const expected = {
0x21, 0x00, 0x00,
@@ -571,87 +506,87 @@
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"}}}};
+ json const j = { { "double", 42.5 }, { "entry", 4.2 }, { "number", 12345 }, { "object", { { "string", "value" } } } };
- std::vector<std::uint8_t> 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};
+ std::vector<std::uint8_t> 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);
@@ -666,10 +601,10 @@
{
SECTION("Example 1")
{
- std::vector<std::uint8_t> 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<std::uint8_t> 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"}};
+ json expected = { { "hello", "world" } };
CHECK(parsed == expected);
auto dumped = json::to_bson(parsed);
CHECK(dumped == input);
@@ -678,11 +613,11 @@
SECTION("Example 2")
{
- std::vector<std::uint8_t> 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<std::uint8_t> 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}}};
+ json expected = { { "BSON", { "awesome", 5.05, 1986 } } };
CHECK(parsed == expected);
auto dumped = json::to_bson(parsed);
CHECK(dumped == input);
@@ -693,87 +628,87 @@
TEST_CASE("BSON input/output_adapters")
{
- json json_representation = {{"double", 42.5}, {"entry", 4.2}, {"number", 12345}, {"object", {{"string", "value"}}}};
+ json json_representation = { { "double", 42.5 }, { "entry", 4.2 }, { "number", 12345 }, { "object", { { "string", "value" } } } };
- std::vector<std::uint8_t> 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};
+ std::vector<std::uint8_t> 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));
@@ -895,13 +830,10 @@
SECTION("Incomplete BSON Input 1")
{
std::vector<std::uint8_t> const incomplete_bson = {
- 0x0D,
- 0x00,
- 0x00,
+ 0x0D, 0x00, 0x00,
0x00, // size (little endian)
0x08, // entry: boolean
- 'e',
- 'n',
+ 'e', 'n',
't' // unexpected EOF
};
@@ -919,9 +851,7 @@
SECTION("Incomplete BSON Input 2")
{
std::vector<std::uint8_t> const incomplete_bson = {
- 0x0D,
- 0x00,
- 0x00,
+ 0x0D, 0x00, 0x00,
0x00, // size (little endian)
0x08, // entry: boolean, unexpected EOF
};
@@ -982,7 +912,7 @@
{
SECTION("key")
{
- json const j = {{"key", "value"}};
+ json const j = { { "key", "value" } };
auto bson_vec = json::to_bson(j);
SaxCountdown scp(2);
CHECK(!json::sax_parse(bson_vec, &scp, json::input_format_t::bson));
@@ -990,7 +920,7 @@
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));
@@ -1024,17 +954,10 @@
TEST_CASE("Unsupported BSON input")
{
std::vector<std::uint8_t> const bson = {
- 0x0C,
- 0x00,
- 0x00,
+ 0x0C, 0x00, 0x00,
0x00, // size (little endian)
0xFF, // entry type: Min key (not supported yet)
- 'e',
- 'n',
- 't',
- 'r',
- 'y',
- '\x00',
+ 'e', 'n', 't', 'r', 'y', '\x00',
0x00 // end marker
};
@@ -1074,7 +997,7 @@
{
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<const std::uint64_t*>(&i);
@@ -1114,37 +1037,37 @@
SECTION("signed std::int32_t: INT32_MIN .. INT32_MAX")
{
- std::vector<int32_t> const numbers{(std::numeric_limits<int32_t>::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<int32_t>::max)()};
+ std::vector<int32_t> const numbers{ (std::numeric_limits<int32_t>::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<int32_t>::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<const std::uint32_t*>(&i);
@@ -1198,7 +1121,7 @@
{
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<const std::uint64_t*>(&i);
@@ -1241,25 +1164,25 @@
{
SECTION("unsigned std::uint64_t: 0 .. INT32_MAX")
{
- std::vector<std::uint64_t> const numbers{0ULL,
- 1ULL,
- 10ULL,
- 100ULL,
- 1000ULL,
- 10000ULL,
- 100000ULL,
- 1000000ULL,
- 10000000ULL,
- 100000000ULL,
- 1000000000ULL,
- 2147483646ULL,
- static_cast<std::uint64_t>((std::numeric_limits<int32_t>::max)())};
+ std::vector<std::uint64_t> const numbers{ 0ULL,
+ 1ULL,
+ 10ULL,
+ 100ULL,
+ 1000ULL,
+ 10000ULL,
+ 100000ULL,
+ 1000000ULL,
+ 10000000ULL,
+ 100000000ULL,
+ 1000000000ULL,
+ 2147483646ULL,
+ static_cast<std::uint64_t>((std::numeric_limits<int32_t>::max)()) };
for (const auto i : numbers)
{
CAPTURE(i)
- json const j = {{"entry", i}};
+ json const j = { { "entry", i } };
auto iu = i;
std::vector<std::uint8_t> const expected_bson = {
@@ -1315,7 +1238,7 @@
{
CAPTURE(i)
- json const j = {{"entry", i}};
+ json const j = { { "entry", i } };
auto iu = i;
std::vector<std::uint8_t> const expected_bson = {
@@ -1367,7 +1290,7 @@
{
CAPTURE(i)
- json const j = {{"entry", i}};
+ json const j = { { "entry", i } };
auto iu = i;
std::vector<std::uint8_t> const expected_bson = {
@@ -1413,11 +1336,11 @@
{
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)
@@ -1460,7 +1383,7 @@
// parse BSON file
auto packed = utils::read_binary_file(filename + ".bson");
json j2;
- CHECK_NOTHROW(j2 = json::from_bson({packed.data(), packed.size()}));
+ CHECK_NOTHROW(j2 = json::from_bson({ packed.data(), packed.size() }));
// compare parsed JSON values
CHECK(j1 == j2);
diff --git a/tests/src/unit-byte_container_with_subtype.cpp b/tests/src/unit-byte_container_with_subtype.cpp
index 4116076..afe66e4 100644
--- a/tests/src/unit-byte_container_with_subtype.cpp
+++ b/tests/src/unit-byte_container_with_subtype.cpp
@@ -45,7 +45,7 @@
SECTION("comparisons")
{
- std::vector<std::uint8_t> const bytes = {{0xCA, 0xFE, 0xBA, 0xBE}};
+ std::vector<std::uint8_t> const bytes = { { 0xCA, 0xFE, 0xBA, 0xBE } };
nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>> container1;
nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>> container2({}, 42);
nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>> container3(bytes);
diff --git a/tests/src/unit-capacity.cpp b/tests/src/unit-capacity.cpp
index 2a0b5ab..8f5a7b9 100644
--- a/tests/src/unit-capacity.cpp
+++ b/tests/src/unit-capacity.cpp
@@ -74,8 +74,8 @@
SECTION("filled array")
{
- json j = {1, 2, 3}; // NOLINT(misc-const-correctness)
- const json j_const = {1, 2, 3};
+ json j = { 1, 2, 3 }; // NOLINT(misc-const-correctness)
+ const json j_const = { 1, 2, 3 };
SECTION("result of empty")
{
@@ -113,8 +113,8 @@
SECTION("filled object")
{
- json j = {{"one", 1}, {"two", 2}, {"three", 3}}; // NOLINT(misc-const-correctness)
- const json j_const = {{"one", 1}, {"two", 2}, {"three", 3}};
+ json j = { { "one", 1 }, { "two", 2 }, { "three", 3 } }; // NOLINT(misc-const-correctness)
+ const json j_const = { { "one", 1 }, { "two", 2 }, { "three", 3 } };
SECTION("result of empty")
{
@@ -269,8 +269,8 @@
SECTION("filled array")
{
- json j = {1, 2, 3}; // NOLINT(misc-const-correctness)
- const json j_const = {1, 2, 3};
+ json j = { 1, 2, 3 }; // NOLINT(misc-const-correctness)
+ const json j_const = { 1, 2, 3 };
SECTION("result of size")
{
@@ -312,8 +312,8 @@
SECTION("filled object")
{
- json j = {{"one", 1}, {"two", 2}, {"three", 3}}; // NOLINT(misc-const-correctness)
- const json j_const = {{"one", 1}, {"two", 2}, {"three", 3}};
+ json j = { { "one", 1 }, { "two", 2 }, { "three", 3 } }; // NOLINT(misc-const-correctness)
+ const json j_const = { { "one", 1 }, { "two", 2 }, { "three", 3 } };
SECTION("result of size")
{
@@ -454,8 +454,8 @@
SECTION("filled array")
{
- json j = {1, 2, 3}; // NOLINT(misc-const-correctness)
- const json j_const = {1, 2, 3};
+ json j = { 1, 2, 3 }; // NOLINT(misc-const-correctness)
+ const json j_const = { 1, 2, 3 };
SECTION("result of max_size")
{
@@ -481,8 +481,8 @@
SECTION("filled object")
{
- json j = {{"one", 1}, {"two", 2}, {"three", 3}}; // NOLINT(misc-const-correctness)
- const json j_const = {{"one", 1}, {"two", 2}, {"three", 3}};
+ json j = { { "one", 1 }, { "two", 2 }, { "three", 3 } }; // NOLINT(misc-const-correctness)
+ const json j_const = { { "one", 1 }, { "two", 2 }, { "three", 3 } };
SECTION("result of max_size")
{
diff --git a/tests/src/unit-cbor.cpp b/tests/src/unit-cbor.cpp
index b6b01d3..8de1aa5 100644
--- a/tests/src/unit-cbor.cpp
+++ b/tests/src/unit-cbor.cpp
@@ -117,7 +117,7 @@
{
// NaN value
json const j = std::numeric_limits<json::number_float_t>::quiet_NaN();
- const std::vector<uint8_t> expected = {0xf9, 0x7e, 0x00};
+ const std::vector<uint8_t> expected = { 0xf9, 0x7e, 0x00 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
}
@@ -126,7 +126,7 @@
{
// Infinity value
json const j = std::numeric_limits<json::number_float_t>::infinity();
- const std::vector<uint8_t> expected = {0xf9, 0x7c, 0x00};
+ const std::vector<uint8_t> expected = { 0xf9, 0x7c, 0x00 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
}
@@ -134,7 +134,7 @@
SECTION("null")
{
const json j = nullptr;
- const std::vector<uint8_t> expected = {0xf6};
+ const std::vector<uint8_t> expected = { 0xf6 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -148,7 +148,7 @@
SECTION("true")
{
const json j = true;
- const std::vector<uint8_t> expected = {0xf5};
+ const std::vector<uint8_t> expected = { 0xf5 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -160,7 +160,7 @@
SECTION("false")
{
const json j = false;
- const std::vector<uint8_t> expected = {0xf4};
+ const std::vector<uint8_t> expected = { 0xf4 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -236,13 +236,7 @@
SECTION("-4294967296..-65537")
{
const std::vector<int64_t> numbers{
- -65537,
- -100000,
- -1000000,
- -10000000,
- -100000000,
- -1000000000,
- -4294967296,
+ -65537, -100000, -1000000, -10000000, -100000000, -1000000000, -4294967296,
};
for (const auto i : numbers)
{
@@ -322,7 +316,7 @@
SECTION("-9263 (int 16)")
{
const json j = -9263;
- std::vector<uint8_t> expected = {0x39, 0x24, 0x2e};
+ std::vector<uint8_t> expected = { 0x39, 0x24, 0x2e };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -503,7 +497,7 @@
SECTION("65536..4294967295")
{
- for (const uint32_t i : {65536u, 77777u, 1048576u})
+ for (const uint32_t i : { 65536u, 77777u, 1048576u })
{
CAPTURE(i)
@@ -542,7 +536,7 @@
SECTION("4294967296..4611686018427387903")
{
- for (const uint64_t i : {4294967296ul, 4611686018427387903ul})
+ for (const uint64_t i : { 4294967296ul, 4611686018427387903ul })
{
CAPTURE(i)
@@ -724,7 +718,7 @@
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)
@@ -762,7 +756,7 @@
SECTION("4294967296..4611686018427387903 (eight-byte uint64_t)")
{
- for (const uint64_t i : {4294967296ul, 4611686018427387903ul})
+ for (const uint64_t i : { 4294967296ul, 4611686018427387903ul })
{
CAPTURE(i)
@@ -811,7 +805,7 @@
{
double v = 3.1415925;
const json j = v;
- std::vector<uint8_t> expected = {0xfb, 0x40, 0x09, 0x21, 0xfb, 0x3f, 0xa6, 0xde, 0xfc};
+ std::vector<uint8_t> expected = { 0xfb, 0x40, 0x09, 0x21, 0xfb, 0x3f, 0xa6, 0xde, 0xfc };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -832,7 +826,7 @@
// its double-precision float binary value is
// {0xfb, 0x3f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
// but to save memory, we can store it as single-precision float.
- const std::vector<uint8_t> expected = {0xfa, 0x3f, 0x00, 0x00, 0x00};
+ const std::vector<uint8_t> expected = { 0xfa, 0x3f, 0x00, 0x00, 0x00 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
// roundtrip
@@ -845,7 +839,7 @@
const json j = v;
// its double-precision binary value is:
// {0xfb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
- const std::vector<uint8_t> expected = {0xfa, 0x00, 0x00, 0x00, 0x00};
+ const std::vector<uint8_t> expected = { 0xfa, 0x00, 0x00, 0x00, 0x00 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
// roundtrip
@@ -858,7 +852,7 @@
const json j = v;
// its double-precision binary value is:
// {0xfb, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
- const std::vector<uint8_t> expected = {0xfa, 0x80, 0x00, 0x00, 0x00};
+ const std::vector<uint8_t> expected = { 0xfa, 0x80, 0x00, 0x00, 0x00 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
// roundtrip
@@ -871,7 +865,7 @@
const json j = v;
// its double-precision binary value is:
// {0xfb, 0x40, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
- const std::vector<uint8_t> expected = {0xfa, 0x42, 0xc8, 0x00, 0x00};
+ const std::vector<uint8_t> expected = { 0xfa, 0x42, 0xc8, 0x00, 0x00 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
// roundtrip
@@ -884,7 +878,7 @@
const json j = v;
// its double-precision binary value is:
// {0xfb, 0x40, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
- const std::vector<uint8_t> expected = {0xfa, 0x43, 0x48, 0x00, 0x00};
+ const std::vector<uint8_t> expected = { 0xfa, 0x43, 0x48, 0x00, 0x00 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
// roundtrip
@@ -895,7 +889,7 @@
{
float v = (std::numeric_limits<float>::max)();
const json j = v;
- const std::vector<uint8_t> expected = {0xfa, 0x7f, 0x7f, 0xff, 0xff};
+ const std::vector<uint8_t> expected = { 0xfa, 0x7f, 0x7f, 0xff, 0xff };
const auto result = json::to_cbor(j);
CHECK(result == expected);
// roundtrip
@@ -906,7 +900,7 @@
{
auto v = static_cast<double>(std::numeric_limits<float>::lowest());
const json j = v;
- const std::vector<uint8_t> expected = {0xfa, 0xff, 0x7f, 0xff, 0xff};
+ const std::vector<uint8_t> expected = { 0xfa, 0xff, 0x7f, 0xff, 0xff };
const auto result = json::to_cbor(j);
CHECK(result == expected);
// roundtrip
@@ -917,7 +911,7 @@
{
double v = static_cast<double>((std::numeric_limits<float>::max)()) + 0.1e+34;
const json j = v;
- const std::vector<uint8_t> expected = {0xfb, 0x47, 0xf0, 0x00, 0x03, 0x04, 0xdc, 0x64, 0x49};
+ const std::vector<uint8_t> expected = { 0xfb, 0x47, 0xf0, 0x00, 0x03, 0x04, 0xdc, 0x64, 0x49 };
// double
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -929,7 +923,7 @@
{
double v = static_cast<double>(std::numeric_limits<float>::lowest()) - 1.0;
const json j = v;
- const std::vector<uint8_t> expected = {0xfa, 0xff, 0x7f, 0xff, 0xff};
+ const std::vector<uint8_t> expected = { 0xfa, 0xff, 0x7f, 0xff, 0xff };
// the same with lowest float
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -947,19 +941,19 @@
{
json _;
CHECK_THROWS_WITH_AS(
- _ = json::from_cbor(std::vector<uint8_t>({0xf9})),
+ _ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0xf9}), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0xf9 }), true, false).is_discarded());
}
SECTION("only one byte follows")
{
json _;
CHECK_THROWS_WITH_AS(
- _ = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c})),
+ _ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0xf9, 0x7c}), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x7c }), true, false).is_discarded());
}
}
@@ -967,22 +961,22 @@
{
SECTION("0 (0 00000 0000000000)")
{
- json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x00}));
- json::number_float_t d{j};
+ json const j = json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x00, 0x00 }));
+ json::number_float_t d{ j };
CHECK(d == 0.0);
}
SECTION("-0 (1 00000 0000000000)")
{
- json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x80, 0x00}));
- json::number_float_t d{j};
+ json const j = json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x80, 0x00 }));
+ json::number_float_t d{ j };
CHECK(d == -0.0);
}
SECTION("2**-24 (0 00000 0000000001)")
{
- json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x01}));
- json::number_float_t d{j};
+ json const j = json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x00, 0x01 }));
+ json::number_float_t d{ j };
CHECK(d == std::pow(2.0, -24.0));
}
}
@@ -991,16 +985,16 @@
{
SECTION("infinity (0 11111 0000000000)")
{
- json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c, 0x00}));
- json::number_float_t d{j};
+ json const j = json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x7c, 0x00 }));
+ json::number_float_t d{ j };
CHECK(d == std::numeric_limits<json::number_float_t>::infinity());
CHECK(j.dump() == "null");
}
SECTION("-infinity (1 11111 0000000000)")
{
- json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0xfc, 0x00}));
- json::number_float_t d{j};
+ json const j = json::from_cbor(std::vector<uint8_t>({ 0xf9, 0xfc, 0x00 }));
+ json::number_float_t d{ j };
CHECK(d == -std::numeric_limits<json::number_float_t>::infinity());
CHECK(j.dump() == "null");
}
@@ -1010,38 +1004,38 @@
{
SECTION("1 (0 01111 0000000000)")
{
- json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x3c, 0x00}));
- json::number_float_t d{j};
+ json const j = json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x3c, 0x00 }));
+ json::number_float_t d{ j };
CHECK(d == 1);
}
SECTION("-2 (1 10000 0000000000)")
{
- json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0xc0, 0x00}));
- json::number_float_t d{j};
+ json const j = json::from_cbor(std::vector<uint8_t>({ 0xf9, 0xc0, 0x00 }));
+ json::number_float_t d{ j };
CHECK(d == -2);
}
SECTION("65504 (0 11110 1111111111)")
{
- json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7b, 0xff}));
- json::number_float_t d{j};
+ json const j = json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x7b, 0xff }));
+ json::number_float_t d{ j };
CHECK(d == 65504);
}
}
SECTION("infinity")
{
- json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c, 0x00}));
- json::number_float_t const d{j};
+ json const j = json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x7c, 0x00 }));
+ json::number_float_t const d{ j };
CHECK(!std::isfinite(d));
CHECK(j.dump() == "null");
}
SECTION("NaN")
{
- json const j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7e, 0x00}));
- json::number_float_t const d{j};
+ json const j = json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x7e, 0x00 }));
+ json::number_float_t const d{ j };
CHECK(std::isnan(d));
CHECK(j.dump() == "null");
}
@@ -1119,7 +1113,7 @@
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)
@@ -1149,7 +1143,7 @@
SECTION("N = 65536..4294967295")
{
- for (const size_t N : {65536u, 77777u, 1048576u})
+ for (const size_t N : { 65536u, 77777u, 1048576u })
{
CAPTURE(N)
@@ -1185,7 +1179,7 @@
SECTION("empty")
{
const json j = json::array();
- std::vector<uint8_t> expected = {0x80};
+ std::vector<uint8_t> expected = { 0x80 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -1196,8 +1190,8 @@
SECTION("[null]")
{
- const json j = {nullptr};
- const std::vector<uint8_t> expected = {0x81, 0xf6};
+ const json j = { nullptr };
+ const std::vector<uint8_t> expected = { 0x81, 0xf6 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -1209,7 +1203,7 @@
SECTION("[1,2,3,4,5]")
{
const json j = json::parse("[1,2,3,4,5]");
- const std::vector<uint8_t> expected = {0x85, 0x01, 0x02, 0x03, 0x04, 0x05};
+ const std::vector<uint8_t> expected = { 0x85, 0x01, 0x02, 0x03, 0x04, 0x05 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -1221,7 +1215,7 @@
SECTION("[[[[]]]]")
{
const json j = json::parse("[[[[]]]]");
- const std::vector<uint8_t> expected = {0x81, 0x81, 0x81, 0x80};
+ const std::vector<uint8_t> expected = { 0x81, 0x81, 0x81, 0x80 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -1268,7 +1262,7 @@
SECTION("empty")
{
const json j = json::object();
- const std::vector<uint8_t> expected = {0xa0};
+ const std::vector<uint8_t> expected = { 0xa0 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -1279,8 +1273,8 @@
SECTION("{\"\":null}")
{
- const json j = {{"", nullptr}};
- const std::vector<uint8_t> expected = {0xa1, 0x60, 0xf6};
+ const json j = { { "", nullptr } };
+ const std::vector<uint8_t> expected = { 0xa1, 0x60, 0xf6 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -1292,7 +1286,7 @@
SECTION("{\"a\": {\"b\": {\"c\": {}}}}")
{
const json j = json::parse(R"({"a": {"b": {"c": {}}}})");
- const std::vector<uint8_t> expected = {0xa1, 0x61, 0x61, 0xa1, 0x61, 0x62, 0xa1, 0x61, 0x63, 0xa0};
+ const std::vector<uint8_t> expected = { 0xa1, 0x61, 0x61, 0xa1, 0x61, 0x62, 0xa1, 0x61, 0x63, 0xa0 };
const auto result = json::to_cbor(j);
CHECK(result == expected);
@@ -1459,7 +1453,7 @@
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)
@@ -1489,7 +1483,7 @@
SECTION("N = 65536..4294967295")
{
- for (const size_t N : {65536u, 77777u, 1048576u})
+ for (const size_t N : { 65536u, 77777u, 1048576u })
{
CAPTURE(N)
@@ -1521,10 +1515,10 @@
SECTION("indefinite size")
{
- std::vector<std::uint8_t> const input = {0x5F, 0x44, 0xaa, 0xbb, 0xcc, 0xdd, 0x43, 0xee, 0xff, 0x99, 0xFF};
+ std::vector<std::uint8_t> const input = { 0x5F, 0x44, 0xaa, 0xbb, 0xcc, 0xdd, 0x43, 0xee, 0xff, 0x99, 0xFF };
auto j = json::from_cbor(input);
CHECK(j.is_binary());
- auto k = json::binary({0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x99});
+ auto k = json::binary({ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x99 });
CAPTURE(j.dump(0, ' ', false, json::error_handler_t::strict))
CHECK(j == k);
}
@@ -1532,7 +1526,7 @@
SECTION("binary in array")
{
// array with three empty byte strings
- std::vector<std::uint8_t> const input = {0x83, 0x40, 0x40, 0x40};
+ std::vector<std::uint8_t> const input = { 0x83, 0x40, 0x40, 0x40 };
json _;
CHECK_NOTHROW(_ = json::from_cbor(input));
}
@@ -1540,7 +1534,7 @@
SECTION("binary in object")
{
// object mapping "foo" to empty byte string
- std::vector<std::uint8_t> const input = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0x40};
+ std::vector<std::uint8_t> const input = { 0xA1, 0x63, 0x66, 0x6F, 0x6F, 0x40 };
json _;
CHECK_NOTHROW(_ = json::from_cbor(input));
}
@@ -1548,7 +1542,7 @@
SECTION("SAX callback with binary")
{
// object mapping "foo" to byte string
- std::vector<std::uint8_t> const input = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0x41, 0x00};
+ std::vector<std::uint8_t> const input = { 0xA1, 0x63, 0x66, 0x6F, 0x6F, 0x41, 0x00 };
// callback to set binary_seen to true if a binary value was seen
bool binary_seen = false;
@@ -1573,28 +1567,28 @@
{
SECTION("0x5b (byte array)")
{
- std::vector<uint8_t> const given = {0x5b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x61};
+ std::vector<uint8_t> const given = { 0x5b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x61 };
const json j = json::from_cbor(given);
- CHECK(j == json::binary(std::vector<uint8_t>{'a'}));
+ CHECK(j == json::binary(std::vector<uint8_t>{ 'a' }));
}
SECTION("0x7b (string)")
{
- std::vector<uint8_t> const given = {0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x61};
+ std::vector<uint8_t> const given = { 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x61 };
const json j = json::from_cbor(given);
CHECK(j == "a");
}
SECTION("0x9b (array)")
{
- std::vector<uint8_t> const given = {0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf4};
+ std::vector<uint8_t> const given = { 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf4 };
const json j = json::from_cbor(given);
CHECK(j == json::parse("[false]"));
}
SECTION("0xbb (map)")
{
- std::vector<uint8_t> const given = {0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x60, 0xf4};
+ std::vector<uint8_t> const given = { 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x60, 0xf4 };
const json j = json::from_cbor(given);
CHECK(j == json::parse("{\"\": false}"));
}
@@ -1614,116 +1608,116 @@
SECTION("too short byte vector")
{
json _;
- CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({0x18})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x19})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x19, 0x00})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1a})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1a, 0x00})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1a, 0x00, 0x00})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1a, 0x00, 0x00, 0x00})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1b})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1b, 0x00})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1b, 0x00, 0x00})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1b, 0x00, 0x00, 0x00})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x62})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x62, 0x60})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x7F})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x7F, 0x60})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x82, 0x01})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x9F, 0x01})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0xBF, 0x61, 0x61, 0xF5})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0xA1, 0x61, 0X61})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0xBF, 0x61, 0X61})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x5F})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x5F, 0x00})),
+ _ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x41})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x18}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x19}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x19, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1a}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1b}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x62}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x62, 0x60}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x7F}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x7F, 0x60}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x82, 0x01}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x9F, 0x01}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0xBF, 0x61, 0x61, 0xF5}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0xA1, 0x61, 0x61}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0xBF, 0x61, 0x61}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x5F}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x5F, 0x00}), true, false).is_discarded());
- CHECK(json::from_cbor(std::vector<uint8_t>({0x41}), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x18 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x19 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x19, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1a }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1a, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1a, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1a, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1b }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1b, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1b, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1b, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1b, 0x00, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x62 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x62, 0x60 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x7F }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x7F, 0x60 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x82, 0x01 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x9F, 0x01 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0xBF, 0x61, 0x61, 0xF5 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0xA1, 0x61, 0x61 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0xBF, 0x61, 0x61 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x5F }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x5F, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x41 }), true, false).is_discarded());
}
SECTION("unsupported bytes")
@@ -1731,114 +1725,114 @@
SECTION("concrete examples")
{
json _;
- CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1c})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x1c}), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0x1c }), true, false).is_discarded());
- CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({0xf8})),
+ CHECK_THROWS_WITH_AS(_ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0xf8}), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({static_cast<uint8_t>(byte)})), json::parse_error&);
- CHECK(json::from_cbor(std::vector<uint8_t>({static_cast<uint8_t>(byte)}), true, false).is_discarded());
+ CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({ static_cast<uint8_t>(byte) })), json::parse_error&);
+ CHECK(json::from_cbor(std::vector<uint8_t>({ static_cast<uint8_t>(byte) }), true, false).is_discarded());
}
}
}
@@ -1847,15 +1841,15 @@
{
json _;
CHECK_THROWS_WITH_AS(
- _ = json::from_cbor(std::vector<uint8_t>({0xa1, 0xff, 0x01})),
+ _ = json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0xa1, 0xff, 0x01}), true, false).is_discarded());
+ CHECK(json::from_cbor(std::vector<uint8_t>({ 0xa1, 0xff, 0x01 }), true, false).is_discarded());
}
SECTION("strict mode")
{
- std::vector<uint8_t> const vec = {0xf6, 0xf6};
+ std::vector<uint8_t> const vec = { 0xf6, 0xf6 };
SECTION("non-strict mode")
{
const auto result = json::from_cbor(vec, false);
@@ -1879,21 +1873,21 @@
{
SECTION("start_array(len)")
{
- std::vector<uint8_t> const v = {0x83, 0x01, 0x02, 0x03};
+ std::vector<uint8_t> const v = { 0x83, 0x01, 0x02, 0x03 };
SaxCountdown scp(0);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor));
}
SECTION("start_object(len)")
{
- std::vector<uint8_t> const v = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4};
+ std::vector<uint8_t> const v = { 0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4 };
SaxCountdown scp(0);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor));
}
SECTION("key()")
{
- std::vector<uint8_t> const v = {0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4};
+ std::vector<uint8_t> const v = { 0xA1, 0x63, 0x66, 0x6F, 0x6F, 0xF4 };
SaxCountdown scp(1);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor));
}
@@ -1955,13 +1949,13 @@
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)
@@ -2015,151 +2009,152 @@
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)
@@ -2202,7 +2197,7 @@
// parse CBOR file
const auto packed = utils::read_binary_file(filename + ".cbor");
json j2;
- CHECK_NOTHROW(j2 = json::from_cbor({packed.data(), packed.size()}));
+ CHECK_NOTHROW(j2 = json::from_cbor({ packed.data(), packed.size() }));
// compare parsed JSON values
CHECK(j1 == j2);
@@ -2235,100 +2230,101 @@
TEST_CASE("all CBOR first bytes")
{
// these bytes will fail immediately with exception parse_error.112
- std::set<uint8_t> unsupported = {//// types not supported by this library
+ std::set<uint8_t> 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,
+ // 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
+ //// 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,
+ 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
+ /// break cannot be the first byte
- 0xff};
+ 0xff
+ };
for (auto i = 0; i < 256; ++i)
{
@@ -2360,38 +2356,38 @@
{
SECTION("numbers")
{
- CHECK(json::to_cbor(json::parse("0")) == std::vector<uint8_t>({0x00}));
- CHECK(json::parse("0") == json::from_cbor(std::vector<uint8_t>({0x00})));
+ CHECK(json::to_cbor(json::parse("0")) == std::vector<uint8_t>({ 0x00 }));
+ CHECK(json::parse("0") == json::from_cbor(std::vector<uint8_t>({ 0x00 })));
- CHECK(json::to_cbor(json::parse("1")) == std::vector<uint8_t>({0x01}));
- CHECK(json::parse("1") == json::from_cbor(std::vector<uint8_t>({0x01})));
+ CHECK(json::to_cbor(json::parse("1")) == std::vector<uint8_t>({ 0x01 }));
+ CHECK(json::parse("1") == json::from_cbor(std::vector<uint8_t>({ 0x01 })));
- CHECK(json::to_cbor(json::parse("10")) == std::vector<uint8_t>({0x0a}));
- CHECK(json::parse("10") == json::from_cbor(std::vector<uint8_t>({0x0a})));
+ CHECK(json::to_cbor(json::parse("10")) == std::vector<uint8_t>({ 0x0a }));
+ CHECK(json::parse("10") == json::from_cbor(std::vector<uint8_t>({ 0x0a })));
- CHECK(json::to_cbor(json::parse("23")) == std::vector<uint8_t>({0x17}));
- CHECK(json::parse("23") == json::from_cbor(std::vector<uint8_t>({0x17})));
+ CHECK(json::to_cbor(json::parse("23")) == std::vector<uint8_t>({ 0x17 }));
+ CHECK(json::parse("23") == json::from_cbor(std::vector<uint8_t>({ 0x17 })));
- CHECK(json::to_cbor(json::parse("24")) == std::vector<uint8_t>({0x18, 0x18}));
- CHECK(json::parse("24") == json::from_cbor(std::vector<uint8_t>({0x18, 0x18})));
+ CHECK(json::to_cbor(json::parse("24")) == std::vector<uint8_t>({ 0x18, 0x18 }));
+ CHECK(json::parse("24") == json::from_cbor(std::vector<uint8_t>({ 0x18, 0x18 })));
- CHECK(json::to_cbor(json::parse("25")) == std::vector<uint8_t>({0x18, 0x19}));
- CHECK(json::parse("25") == json::from_cbor(std::vector<uint8_t>({0x18, 0x19})));
+ CHECK(json::to_cbor(json::parse("25")) == std::vector<uint8_t>({ 0x18, 0x19 }));
+ CHECK(json::parse("25") == json::from_cbor(std::vector<uint8_t>({ 0x18, 0x19 })));
- CHECK(json::to_cbor(json::parse("100")) == std::vector<uint8_t>({0x18, 0x64}));
- CHECK(json::parse("100") == json::from_cbor(std::vector<uint8_t>({0x18, 0x64})));
+ CHECK(json::to_cbor(json::parse("100")) == std::vector<uint8_t>({ 0x18, 0x64 }));
+ CHECK(json::parse("100") == json::from_cbor(std::vector<uint8_t>({ 0x18, 0x64 })));
- CHECK(json::to_cbor(json::parse("1000")) == std::vector<uint8_t>({0x19, 0x03, 0xe8}));
- CHECK(json::parse("1000") == json::from_cbor(std::vector<uint8_t>({0x19, 0x03, 0xe8})));
+ CHECK(json::to_cbor(json::parse("1000")) == std::vector<uint8_t>({ 0x19, 0x03, 0xe8 }));
+ CHECK(json::parse("1000") == json::from_cbor(std::vector<uint8_t>({ 0x19, 0x03, 0xe8 })));
- CHECK(json::to_cbor(json::parse("1000000")) == std::vector<uint8_t>({0x1a, 0x00, 0x0f, 0x42, 0x40}));
- CHECK(json::parse("1000000") == json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x0f, 0x42, 0x40})));
+ CHECK(json::to_cbor(json::parse("1000000")) == std::vector<uint8_t>({ 0x1a, 0x00, 0x0f, 0x42, 0x40 }));
+ CHECK(json::parse("1000000") == json::from_cbor(std::vector<uint8_t>({ 0x1a, 0x00, 0x0f, 0x42, 0x40 })));
- CHECK(json::to_cbor(json::parse("1000000000000")) == std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0xe8, 0xd4, 0xa5, 0x10, 0x00}));
- CHECK(json::parse("1000000000000") == json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0xe8, 0xd4, 0xa5, 0x10, 0x00})));
+ CHECK(json::to_cbor(json::parse("1000000000000")) == std::vector<uint8_t>({ 0x1b, 0x00, 0x00, 0x00, 0xe8, 0xd4, 0xa5, 0x10, 0x00 }));
+ CHECK(json::parse("1000000000000") == json::from_cbor(std::vector<uint8_t>({ 0x1b, 0x00, 0x00, 0x00, 0xe8, 0xd4, 0xa5, 0x10, 0x00 })));
- CHECK(json::to_cbor(json::parse("18446744073709551615")) == std::vector<uint8_t>({0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}));
- CHECK(json::parse("18446744073709551615") == json::from_cbor(std::vector<uint8_t>({0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff})));
+ CHECK(json::to_cbor(json::parse("18446744073709551615")) == std::vector<uint8_t>({ 0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }));
+ CHECK(json::parse("18446744073709551615") == json::from_cbor(std::vector<uint8_t>({ 0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff })));
// positive bignum is not supported
//CHECK(json::to_cbor(json::parse("18446744073709551616")) == std::vector<uint8_t>({0xc2, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}));
@@ -2404,101 +2400,101 @@
//CHECK(json::to_cbor(json::parse("-18446744073709551617")) == std::vector<uint8_t>({0xc3, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}));
//CHECK(json::parse("-18446744073709551617") == json::from_cbor(std::vector<uint8_t>({0xc3, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})));
- CHECK(json::to_cbor(json::parse("-1")) == std::vector<uint8_t>({0x20}));
- CHECK(json::parse("-1") == json::from_cbor(std::vector<uint8_t>({0x20})));
+ CHECK(json::to_cbor(json::parse("-1")) == std::vector<uint8_t>({ 0x20 }));
+ CHECK(json::parse("-1") == json::from_cbor(std::vector<uint8_t>({ 0x20 })));
- CHECK(json::to_cbor(json::parse("-10")) == std::vector<uint8_t>({0x29}));
- CHECK(json::parse("-10") == json::from_cbor(std::vector<uint8_t>({0x29})));
+ CHECK(json::to_cbor(json::parse("-10")) == std::vector<uint8_t>({ 0x29 }));
+ CHECK(json::parse("-10") == json::from_cbor(std::vector<uint8_t>({ 0x29 })));
- CHECK(json::to_cbor(json::parse("-100")) == std::vector<uint8_t>({0x38, 0x63}));
- CHECK(json::parse("-100") == json::from_cbor(std::vector<uint8_t>({0x38, 0x63})));
+ CHECK(json::to_cbor(json::parse("-100")) == std::vector<uint8_t>({ 0x38, 0x63 }));
+ CHECK(json::parse("-100") == json::from_cbor(std::vector<uint8_t>({ 0x38, 0x63 })));
- CHECK(json::to_cbor(json::parse("-1000")) == std::vector<uint8_t>({0x39, 0x03, 0xe7}));
- CHECK(json::parse("-1000") == json::from_cbor(std::vector<uint8_t>({0x39, 0x03, 0xe7})));
+ CHECK(json::to_cbor(json::parse("-1000")) == std::vector<uint8_t>({ 0x39, 0x03, 0xe7 }));
+ CHECK(json::parse("-1000") == json::from_cbor(std::vector<uint8_t>({ 0x39, 0x03, 0xe7 })));
// half-precision float
//CHECK(json::to_cbor(json::parse("0.0")) == std::vector<uint8_t>({0xf9, 0x00, 0x00}));
- CHECK(json::parse("0.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x00})));
+ CHECK(json::parse("0.0") == json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x00, 0x00 })));
// half-precision float
//CHECK(json::to_cbor(json::parse("-0.0")) == std::vector<uint8_t>({0xf9, 0x80, 0x00}));
- CHECK(json::parse("-0.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0x80, 0x00})));
+ CHECK(json::parse("-0.0") == json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x80, 0x00 })));
// half-precision float
//CHECK(json::to_cbor(json::parse("1.0")) == std::vector<uint8_t>({0xf9, 0x3c, 0x00}));
- CHECK(json::parse("1.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0x3c, 0x00})));
+ CHECK(json::parse("1.0") == json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x3c, 0x00 })));
- CHECK(json::to_cbor(json::parse("1.1")) == std::vector<uint8_t>({0xfb, 0x3f, 0xf1, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a}));
- CHECK(json::parse("1.1") == json::from_cbor(std::vector<uint8_t>({0xfb, 0x3f, 0xf1, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a})));
+ CHECK(json::to_cbor(json::parse("1.1")) == std::vector<uint8_t>({ 0xfb, 0x3f, 0xf1, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a }));
+ CHECK(json::parse("1.1") == json::from_cbor(std::vector<uint8_t>({ 0xfb, 0x3f, 0xf1, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a })));
// half-precision float
//CHECK(json::to_cbor(json::parse("1.5")) == std::vector<uint8_t>({0xf9, 0x3e, 0x00}));
- CHECK(json::parse("1.5") == json::from_cbor(std::vector<uint8_t>({0xf9, 0x3e, 0x00})));
+ CHECK(json::parse("1.5") == json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x3e, 0x00 })));
// half-precision float
//CHECK(json::to_cbor(json::parse("65504.0")) == std::vector<uint8_t>({0xf9, 0x7b, 0xff}));
- CHECK(json::parse("65504.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0x7b, 0xff})));
+ CHECK(json::parse("65504.0") == json::from_cbor(std::vector<uint8_t>({ 0xf9, 0x7b, 0xff })));
//CHECK(json::to_cbor(json::parse("100000.0")) == std::vector<uint8_t>({0xfa, 0x47, 0xc3, 0x50, 0x00}));
- CHECK(json::parse("100000.0") == json::from_cbor(std::vector<uint8_t>({0xfa, 0x47, 0xc3, 0x50, 0x00})));
+ CHECK(json::parse("100000.0") == json::from_cbor(std::vector<uint8_t>({ 0xfa, 0x47, 0xc3, 0x50, 0x00 })));
//CHECK(json::to_cbor(json::parse("3.4028234663852886e+38")) == std::vector<uint8_t>({0xfa, 0x7f, 0x7f, 0xff, 0xff}));
- CHECK(json::parse("3.4028234663852886e+38") == json::from_cbor(std::vector<uint8_t>({0xfa, 0x7f, 0x7f, 0xff, 0xff})));
+ CHECK(json::parse("3.4028234663852886e+38") == json::from_cbor(std::vector<uint8_t>({ 0xfa, 0x7f, 0x7f, 0xff, 0xff })));
- CHECK(json::to_cbor(json::parse("1.0e+300")) == std::vector<uint8_t>({0xfb, 0x7e, 0x37, 0xe4, 0x3c, 0x88, 0x00, 0x75, 0x9c}));
- CHECK(json::parse("1.0e+300") == json::from_cbor(std::vector<uint8_t>({0xfb, 0x7e, 0x37, 0xe4, 0x3c, 0x88, 0x00, 0x75, 0x9c})));
+ CHECK(json::to_cbor(json::parse("1.0e+300")) == std::vector<uint8_t>({ 0xfb, 0x7e, 0x37, 0xe4, 0x3c, 0x88, 0x00, 0x75, 0x9c }));
+ CHECK(json::parse("1.0e+300") == json::from_cbor(std::vector<uint8_t>({ 0xfb, 0x7e, 0x37, 0xe4, 0x3c, 0x88, 0x00, 0x75, 0x9c })));
// half-precision float
//CHECK(json::to_cbor(json::parse("5.960464477539063e-8")) == std::vector<uint8_t>({0xf9, 0x00, 0x01}));
- CHECK(json::parse("-4.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0xc4, 0x00})));
+ CHECK(json::parse("-4.0") == json::from_cbor(std::vector<uint8_t>({ 0xf9, 0xc4, 0x00 })));
// half-precision float
//CHECK(json::to_cbor(json::parse("0.00006103515625")) == std::vector<uint8_t>({0xf9, 0x04, 0x00}));
- CHECK(json::parse("-4.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0xc4, 0x00})));
+ CHECK(json::parse("-4.0") == json::from_cbor(std::vector<uint8_t>({ 0xf9, 0xc4, 0x00 })));
// half-precision float
//CHECK(json::to_cbor(json::parse("-4.0")) == std::vector<uint8_t>({0xf9, 0xc4, 0x00}));
- CHECK(json::parse("-4.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0xc4, 0x00})));
+ CHECK(json::parse("-4.0") == json::from_cbor(std::vector<uint8_t>({ 0xf9, 0xc4, 0x00 })));
- CHECK(json::to_cbor(json::parse("-4.1")) == std::vector<uint8_t>({0xfb, 0xc0, 0x10, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66}));
- CHECK(json::parse("-4.1") == json::from_cbor(std::vector<uint8_t>({0xfb, 0xc0, 0x10, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66})));
+ CHECK(json::to_cbor(json::parse("-4.1")) == std::vector<uint8_t>({ 0xfb, 0xc0, 0x10, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66 }));
+ CHECK(json::parse("-4.1") == json::from_cbor(std::vector<uint8_t>({ 0xfb, 0xc0, 0x10, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66 })));
}
SECTION("simple values")
{
- CHECK(json::to_cbor(json::parse("false")) == std::vector<uint8_t>({0xf4}));
- CHECK(json::parse("false") == json::from_cbor(std::vector<uint8_t>({0xf4})));
+ CHECK(json::to_cbor(json::parse("false")) == std::vector<uint8_t>({ 0xf4 }));
+ CHECK(json::parse("false") == json::from_cbor(std::vector<uint8_t>({ 0xf4 })));
- CHECK(json::to_cbor(json::parse("true")) == std::vector<uint8_t>({0xf5}));
- CHECK(json::parse("true") == json::from_cbor(std::vector<uint8_t>({0xf5})));
+ CHECK(json::to_cbor(json::parse("true")) == std::vector<uint8_t>({ 0xf5 }));
+ CHECK(json::parse("true") == json::from_cbor(std::vector<uint8_t>({ 0xf5 })));
- CHECK(json::to_cbor(json::parse("true")) == std::vector<uint8_t>({0xf5}));
- CHECK(json::parse("true") == json::from_cbor(std::vector<uint8_t>({0xf5})));
+ CHECK(json::to_cbor(json::parse("true")) == std::vector<uint8_t>({ 0xf5 }));
+ CHECK(json::parse("true") == json::from_cbor(std::vector<uint8_t>({ 0xf5 })));
}
SECTION("strings")
{
- CHECK(json::to_cbor(json::parse("\"\"")) == std::vector<uint8_t>({0x60}));
- CHECK(json::parse("\"\"") == json::from_cbor(std::vector<uint8_t>({0x60})));
+ CHECK(json::to_cbor(json::parse("\"\"")) == std::vector<uint8_t>({ 0x60 }));
+ CHECK(json::parse("\"\"") == json::from_cbor(std::vector<uint8_t>({ 0x60 })));
- CHECK(json::to_cbor(json::parse("\"a\"")) == std::vector<uint8_t>({0x61, 0x61}));
- CHECK(json::parse("\"a\"") == json::from_cbor(std::vector<uint8_t>({0x61, 0x61})));
+ CHECK(json::to_cbor(json::parse("\"a\"")) == std::vector<uint8_t>({ 0x61, 0x61 }));
+ CHECK(json::parse("\"a\"") == json::from_cbor(std::vector<uint8_t>({ 0x61, 0x61 })));
- CHECK(json::to_cbor(json::parse("\"IETF\"")) == std::vector<uint8_t>({0x64, 0x49, 0x45, 0x54, 0x46}));
- CHECK(json::parse("\"IETF\"") == json::from_cbor(std::vector<uint8_t>({0x64, 0x49, 0x45, 0x54, 0x46})));
+ CHECK(json::to_cbor(json::parse("\"IETF\"")) == std::vector<uint8_t>({ 0x64, 0x49, 0x45, 0x54, 0x46 }));
+ CHECK(json::parse("\"IETF\"") == json::from_cbor(std::vector<uint8_t>({ 0x64, 0x49, 0x45, 0x54, 0x46 })));
- CHECK(json::to_cbor(json::parse("\"\\u00fc\"")) == std::vector<uint8_t>({0x62, 0xc3, 0xbc}));
- CHECK(json::parse("\"\\u00fc\"") == json::from_cbor(std::vector<uint8_t>({0x62, 0xc3, 0xbc})));
+ CHECK(json::to_cbor(json::parse("\"\\u00fc\"")) == std::vector<uint8_t>({ 0x62, 0xc3, 0xbc }));
+ CHECK(json::parse("\"\\u00fc\"") == json::from_cbor(std::vector<uint8_t>({ 0x62, 0xc3, 0xbc })));
- CHECK(json::to_cbor(json::parse("\"\\u6c34\"")) == std::vector<uint8_t>({0x63, 0xe6, 0xb0, 0xb4}));
- CHECK(json::parse("\"\\u6c34\"") == json::from_cbor(std::vector<uint8_t>({0x63, 0xe6, 0xb0, 0xb4})));
+ CHECK(json::to_cbor(json::parse("\"\\u6c34\"")) == std::vector<uint8_t>({ 0x63, 0xe6, 0xb0, 0xb4 }));
+ CHECK(json::parse("\"\\u6c34\"") == json::from_cbor(std::vector<uint8_t>({ 0x63, 0xe6, 0xb0, 0xb4 })));
- CHECK(json::to_cbor(json::parse("\"\\ud800\\udd51\"")) == std::vector<uint8_t>({0x64, 0xf0, 0x90, 0x85, 0x91}));
- CHECK(json::parse("\"\\ud800\\udd51\"") == json::from_cbor(std::vector<uint8_t>({0x64, 0xf0, 0x90, 0x85, 0x91})));
+ CHECK(json::to_cbor(json::parse("\"\\ud800\\udd51\"")) == std::vector<uint8_t>({ 0x64, 0xf0, 0x90, 0x85, 0x91 }));
+ CHECK(json::parse("\"\\ud800\\udd51\"") == json::from_cbor(std::vector<uint8_t>({ 0x64, 0xf0, 0x90, 0x85, 0x91 })));
// indefinite length strings
CHECK(json::parse("\"streaming\"") ==
- json::from_cbor(std::vector<uint8_t>({0x7f, 0x65, 0x73, 0x74, 0x72, 0x65, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x67, 0xff})));
+ json::from_cbor(std::vector<uint8_t>({ 0x7f, 0x65, 0x73, 0x74, 0x72, 0x65, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x67, 0xff })));
}
SECTION("byte arrays")
@@ -2511,21 +2507,21 @@
CHECK(j == json::binary(expected));
// 0xd8
- CHECK(json::to_cbor(json::binary(std::vector<uint8_t>{}, 0x42)) == std::vector<uint8_t>{0xd8, 0x42, 0x40});
+ CHECK(json::to_cbor(json::binary(std::vector<uint8_t>{}, 0x42)) == std::vector<uint8_t>{ 0xd8, 0x42, 0x40 });
CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t>{}, 0x42)), true, true, json::cbor_tag_handler_t::ignore)
.get_binary()
.has_subtype());
CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t>{}, 0x42)), true, true, json::cbor_tag_handler_t::store).get_binary().subtype() ==
0x42);
// 0xd9
- CHECK(json::to_cbor(json::binary(std::vector<uint8_t>{}, 1000)) == std::vector<uint8_t>{0xd9, 0x03, 0xe8, 0x40});
+ CHECK(json::to_cbor(json::binary(std::vector<uint8_t>{}, 1000)) == std::vector<uint8_t>{ 0xd9, 0x03, 0xe8, 0x40 });
CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t>{}, 1000)), true, true, json::cbor_tag_handler_t::ignore)
.get_binary()
.has_subtype());
CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t>{}, 1000)), true, true, json::cbor_tag_handler_t::store).get_binary().subtype() ==
1000);
// 0xda
- CHECK(json::to_cbor(json::binary(std::vector<uint8_t>{}, 394216)) == std::vector<uint8_t>{0xda, 0x00, 0x06, 0x03, 0xe8, 0x40});
+ CHECK(json::to_cbor(json::binary(std::vector<uint8_t>{}, 394216)) == std::vector<uint8_t>{ 0xda, 0x00, 0x06, 0x03, 0xe8, 0x40 });
CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t>{}, 394216)), true, true, json::cbor_tag_handler_t::ignore)
.get_binary()
.has_subtype());
@@ -2534,7 +2530,7 @@
394216);
// 0xdb
CHECK(json::to_cbor(json::binary(std::vector<uint8_t>{}, 8589934590)) ==
- std::vector<uint8_t>{0xdb, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x40});
+ std::vector<uint8_t>{ 0xdb, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x40 });
CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t>{}, 8589934590)), true, true, json::cbor_tag_handler_t::ignore)
.get_binary()
.has_subtype());
@@ -2545,57 +2541,57 @@
SECTION("arrays")
{
- CHECK(json::to_cbor(json::parse("[]")) == std::vector<uint8_t>({0x80}));
- CHECK(json::parse("[]") == json::from_cbor(std::vector<uint8_t>({0x80})));
+ CHECK(json::to_cbor(json::parse("[]")) == std::vector<uint8_t>({ 0x80 }));
+ CHECK(json::parse("[]") == json::from_cbor(std::vector<uint8_t>({ 0x80 })));
- CHECK(json::to_cbor(json::parse("[1, 2, 3]")) == std::vector<uint8_t>({0x83, 0x01, 0x02, 0x03}));
- CHECK(json::parse("[1, 2, 3]") == json::from_cbor(std::vector<uint8_t>({0x83, 0x01, 0x02, 0x03})));
+ CHECK(json::to_cbor(json::parse("[1, 2, 3]")) == std::vector<uint8_t>({ 0x83, 0x01, 0x02, 0x03 }));
+ CHECK(json::parse("[1, 2, 3]") == json::from_cbor(std::vector<uint8_t>({ 0x83, 0x01, 0x02, 0x03 })));
- CHECK(json::to_cbor(json::parse("[1, [2, 3], [4, 5]]")) == std::vector<uint8_t>({0x83, 0x01, 0x82, 0x02, 0x03, 0x82, 0x04, 0x05}));
- CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({0x83, 0x01, 0x82, 0x02, 0x03, 0x82, 0x04, 0x05})));
+ CHECK(json::to_cbor(json::parse("[1, [2, 3], [4, 5]]")) == std::vector<uint8_t>({ 0x83, 0x01, 0x82, 0x02, 0x03, 0x82, 0x04, 0x05 }));
+ CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({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}));
+ std::vector<uint8_t>({ 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<uint8_t>({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})));
+ json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({0x9f, 0xff})));
- CHECK(json::parse("[1, [2, 3], [4, 5]] ") == json::from_cbor(std::vector<uint8_t>({0x9f, 0x01, 0x82, 0x02, 0x03, 0x9f, 0x04, 0x05, 0xff, 0xff})));
- CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({0x9f, 0x01, 0x82, 0x02, 0x03, 0x82, 0x04, 0x05, 0xff})));
- CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({0x83, 0x01, 0x82, 0x02, 0x03, 0x9f, 0x04, 0x05, 0xff})));
- CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({0x83, 0x01, 0x9f, 0x02, 0x03, 0xff, 0x82, 0x04, 0x05})));
+ CHECK(json::parse("[]") == json::from_cbor(std::vector<uint8_t>({ 0x9f, 0xff })));
+ CHECK(json::parse("[1, [2, 3], [4, 5]] ") == json::from_cbor(std::vector<uint8_t>({ 0x9f, 0x01, 0x82, 0x02, 0x03, 0x9f, 0x04, 0x05, 0xff, 0xff })));
+ CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({ 0x9f, 0x01, 0x82, 0x02, 0x03, 0x82, 0x04, 0x05, 0xff })));
+ CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({ 0x83, 0x01, 0x82, 0x02, 0x03, 0x9f, 0x04, 0x05, 0xff })));
+ CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>({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})));
+ json::from_cbor(std::vector<uint8_t>({ 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")
{
- CHECK(json::to_cbor(json::parse("{}")) == std::vector<uint8_t>({0xa0}));
- CHECK(json::parse("{}") == json::from_cbor(std::vector<uint8_t>({0xa0})));
+ CHECK(json::to_cbor(json::parse("{}")) == std::vector<uint8_t>({ 0xa0 }));
+ CHECK(json::parse("{}") == json::from_cbor(std::vector<uint8_t>({ 0xa0 })));
- CHECK(json::to_cbor(json::parse("{\"a\": 1, \"b\": [2, 3]}")) == std::vector<uint8_t>({0xa2, 0x61, 0x61, 0x01, 0x61, 0x62, 0x82, 0x02, 0x03}));
- CHECK(json::parse("{\"a\": 1, \"b\": [2, 3]}") == json::from_cbor(std::vector<uint8_t>({0xa2, 0x61, 0x61, 0x01, 0x61, 0x62, 0x82, 0x02, 0x03})));
+ CHECK(json::to_cbor(json::parse("{\"a\": 1, \"b\": [2, 3]}")) == std::vector<uint8_t>({ 0xa2, 0x61, 0x61, 0x01, 0x61, 0x62, 0x82, 0x02, 0x03 }));
+ CHECK(json::parse("{\"a\": 1, \"b\": [2, 3]}") == json::from_cbor(std::vector<uint8_t>({ 0xa2, 0x61, 0x61, 0x01, 0x61, 0x62, 0x82, 0x02, 0x03 })));
- CHECK(json::to_cbor(json::parse("[\"a\", {\"b\": \"c\"}]")) == std::vector<uint8_t>({0x82, 0x61, 0x61, 0xa1, 0x61, 0x62, 0x61, 0x63}));
- CHECK(json::parse("[\"a\", {\"b\": \"c\"}]") == json::from_cbor(std::vector<uint8_t>({0x82, 0x61, 0x61, 0xa1, 0x61, 0x62, 0x61, 0x63})));
+ CHECK(json::to_cbor(json::parse("[\"a\", {\"b\": \"c\"}]")) == std::vector<uint8_t>({ 0x82, 0x61, 0x61, 0xa1, 0x61, 0x62, 0x61, 0x63 }));
+ CHECK(json::parse("[\"a\", {\"b\": \"c\"}]") == json::from_cbor(std::vector<uint8_t>({ 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<uint8_t>(
- {0xa5, 0x61, 0x61, 0x61, 0x41, 0x61, 0x62, 0x61, 0x42, 0x61, 0x63, 0x61, 0x43, 0x61, 0x64, 0x61, 0x44, 0x61, 0x65, 0x61, 0x45}));
+ { 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<uint8_t>(
- {0xa5, 0x61, 0x61, 0x61, 0x41, 0x61, 0x62, 0x61, 0x42, 0x61, 0x63, 0x61, 0x43, 0x61, 0x64, 0x61, 0x44, 0x61, 0x65, 0x61, 0x45})));
+ { 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<uint8_t>({0xbf, 0x61, 0x61, 0x01, 0x61, 0x62, 0x9f, 0x02, 0x03, 0xff, 0xff})));
- CHECK(json::parse("[\"a\", {\"b\": \"c\"}]") == json::from_cbor(std::vector<uint8_t>({0x82, 0x61, 0x61, 0xbf, 0x61, 0x62, 0x61, 0x63, 0xff})));
+ json::from_cbor(std::vector<uint8_t>({ 0xbf, 0x61, 0x61, 0x01, 0x61, 0x62, 0x9f, 0x02, 0x03, 0xff, 0xff })));
+ CHECK(json::parse("[\"a\", {\"b\": \"c\"}]") == json::from_cbor(std::vector<uint8_t>({ 0x82, 0x61, 0x61, 0xbf, 0x61, 0x62, 0x61, 0x63, 0xff })));
CHECK(json::parse("{\"Fun\": true, \"Amt\": -2}") ==
- json::from_cbor(std::vector<uint8_t>({0xbf, 0x63, 0x46, 0x75, 0x6e, 0xf5, 0x63, 0x41, 0x6d, 0x74, 0x21, 0xff})));
+ json::from_cbor(std::vector<uint8_t>({ 0xbf, 0x63, 0x46, 0x75, 0x6e, 0xf5, 0x63, 0x41, 0x6d, 0x74, 0x21, 0xff })));
}
}
@@ -2606,7 +2602,7 @@
SECTION("0xC6..0xD4")
{
- for (const auto b : std::vector<std::uint8_t>{0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4})
+ for (const auto b : std::vector<std::uint8_t>{ 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4 })
{
CAPTURE(b);
@@ -2786,11 +2782,11 @@
{
// create a binary value of subtype 42
json j_binary;
- j_binary["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42);
+ j_binary["binary"] = json::binary({ 0xCA, 0xFE, 0xBA, 0xBE }, 42);
// convert to CBOR
const auto vec = json::to_cbor(j_binary);
- CHECK(vec == std::vector<std::uint8_t>{0xA1, 0x66, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79, 0xD8, 0x2A, 0x44, 0xCA, 0xFE, 0xBA, 0xBE});
+ CHECK(vec == std::vector<std::uint8_t>{ 0xA1, 0x66, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79, 0xD8, 0x2A, 0x44, 0xCA, 0xFE, 0xBA, 0xBE });
// parse error when parsing tagged value
json _;
diff --git a/tests/src/unit-class_const_iterator.cpp b/tests/src/unit-class_const_iterator.cpp
index d94e520..2c7934f 100644
--- a/tests/src/unit-class_const_iterator.cpp
+++ b/tests/src/unit-class_const_iterator.cpp
@@ -141,14 +141,14 @@
SECTION("object")
{
- json const j({{"foo", "bar"}});
+ json const j({ { "foo", "bar" } });
json::const_iterator const it = j.cbegin();
CHECK(*it == json("bar"));
}
SECTION("array")
{
- json const j({1, 2, 3, 4});
+ json const j({ 1, 2, 3, 4 });
json::const_iterator const it = j.cbegin();
CHECK(*it == json(1));
}
@@ -174,14 +174,14 @@
SECTION("object")
{
- json const j({{"foo", "bar"}});
+ json const j({ { "foo", "bar" } });
json::const_iterator const it = j.cbegin();
CHECK(std::string(it->type_name()) == "string");
}
SECTION("array")
{
- json const j({1, 2, 3, 4});
+ json const j({ 1, 2, 3, 4 });
json::const_iterator const it = j.cbegin();
CHECK(std::string(it->type_name()) == "number");
}
@@ -214,7 +214,7 @@
SECTION("object")
{
- json const j({{"foo", "bar"}});
+ json const j({ { "foo", "bar" } });
json::const_iterator it = j.cbegin();
CHECK((it.m_it.object_iterator == it.m_object->m_data.m_value.object->begin()));
it++;
@@ -223,7 +223,7 @@
SECTION("array")
{
- json const j({1, 2, 3, 4});
+ json const j({ 1, 2, 3, 4 });
json::const_iterator it = j.cbegin();
CHECK((it.m_it.array_iterator == it.m_object->m_data.m_value.array->begin()));
it++;
@@ -265,7 +265,7 @@
SECTION("object")
{
- json const j({{"foo", "bar"}});
+ json const j({ { "foo", "bar" } });
json::const_iterator it = j.cbegin();
CHECK((it.m_it.object_iterator == it.m_object->m_data.m_value.object->begin()));
++it;
@@ -274,7 +274,7 @@
SECTION("array")
{
- json const j({1, 2, 3, 4});
+ json const j({ 1, 2, 3, 4 });
json::const_iterator it = j.cbegin();
CHECK((it.m_it.array_iterator == it.m_object->m_data.m_value.array->begin()));
++it;
@@ -314,7 +314,7 @@
SECTION("object")
{
- json const j({{"foo", "bar"}});
+ json const j({ { "foo", "bar" } });
json::const_iterator it = j.cend();
CHECK((it.m_it.object_iterator == it.m_object->m_data.m_value.object->end()));
it--;
@@ -323,7 +323,7 @@
SECTION("array")
{
- json const j({1, 2, 3, 4});
+ json const j({ 1, 2, 3, 4 });
json::const_iterator it = j.cend();
CHECK((it.m_it.array_iterator == it.m_object->m_data.m_value.array->end()));
it--;
@@ -363,7 +363,7 @@
SECTION("object")
{
- json const j({{"foo", "bar"}});
+ json const j({ { "foo", "bar" } });
json::const_iterator it = j.cend();
CHECK((it.m_it.object_iterator == it.m_object->m_data.m_value.object->end()));
--it;
@@ -372,7 +372,7 @@
SECTION("array")
{
- json const j({1, 2, 3, 4});
+ json const j({ 1, 2, 3, 4 });
json::const_iterator it = j.cend();
CHECK((it.m_it.array_iterator == it.m_object->m_data.m_value.array->end()));
--it;
diff --git a/tests/src/unit-class_iterator.cpp b/tests/src/unit-class_iterator.cpp
index 1e8342e..1736c87 100644
--- a/tests/src/unit-class_iterator.cpp
+++ b/tests/src/unit-class_iterator.cpp
@@ -131,14 +131,14 @@
SECTION("object")
{
- json j({{"foo", "bar"}});
+ json j({ { "foo", "bar" } });
json::iterator const it = j.begin();
CHECK(*it == json("bar"));
}
SECTION("array")
{
- json j({1, 2, 3, 4});
+ json j({ 1, 2, 3, 4 });
json::iterator const it = j.begin();
CHECK(*it == json(1));
}
@@ -164,14 +164,14 @@
SECTION("object")
{
- json j({{"foo", "bar"}});
+ json j({ { "foo", "bar" } });
json::iterator const it = j.begin();
CHECK(std::string(it->type_name()) == "string");
}
SECTION("array")
{
- json j({1, 2, 3, 4});
+ json j({ 1, 2, 3, 4 });
json::iterator const it = j.begin();
CHECK(std::string(it->type_name()) == "number");
}
@@ -204,7 +204,7 @@
SECTION("object")
{
- json j({{"foo", "bar"}});
+ json j({ { "foo", "bar" } });
json::iterator it = j.begin();
CHECK((it.m_it.object_iterator == it.m_object->m_data.m_value.object->begin()));
it++;
@@ -213,7 +213,7 @@
SECTION("array")
{
- json j({1, 2, 3, 4});
+ json j({ 1, 2, 3, 4 });
json::iterator it = j.begin();
CHECK((it.m_it.array_iterator == it.m_object->m_data.m_value.array->begin()));
it++;
@@ -255,7 +255,7 @@
SECTION("object")
{
- json j({{"foo", "bar"}});
+ json j({ { "foo", "bar" } });
json::iterator it = j.begin();
CHECK((it.m_it.object_iterator == it.m_object->m_data.m_value.object->begin()));
++it;
@@ -264,7 +264,7 @@
SECTION("array")
{
- json j({1, 2, 3, 4});
+ json j({ 1, 2, 3, 4 });
json::iterator it = j.begin();
CHECK((it.m_it.array_iterator == it.m_object->m_data.m_value.array->begin()));
++it;
@@ -304,7 +304,7 @@
SECTION("object")
{
- json j({{"foo", "bar"}});
+ json j({ { "foo", "bar" } });
json::iterator it = j.end();
CHECK((it.m_it.object_iterator == it.m_object->m_data.m_value.object->end()));
it--;
@@ -313,7 +313,7 @@
SECTION("array")
{
- json j({1, 2, 3, 4});
+ json j({ 1, 2, 3, 4 });
json::iterator it = j.end();
CHECK((it.m_it.array_iterator == it.m_object->m_data.m_value.array->end()));
it--;
@@ -353,7 +353,7 @@
SECTION("object")
{
- json j({{"foo", "bar"}});
+ json j({ { "foo", "bar" } });
json::iterator it = j.end();
CHECK((it.m_it.object_iterator == it.m_object->m_data.m_value.object->end()));
--it;
@@ -362,7 +362,7 @@
SECTION("array")
{
- json j({1, 2, 3, 4});
+ json j({ 1, 2, 3, 4 });
json::iterator it = j.end();
CHECK((it.m_it.array_iterator == it.m_object->m_data.m_value.array->end()));
--it;
diff --git a/tests/src/unit-class_parser.cpp b/tests/src/unit-class_parser.cpp
index 1a4888d..14a8e01 100644
--- a/tests/src/unit-class_parser.cpp
+++ b/tests/src/unit-class_parser.cpp
@@ -333,7 +333,7 @@
SECTION("nonempty array")
{
- CHECK(parser_helper("[true, false, null]") == json({true, false, nullptr}));
+ CHECK(parser_helper("[true, false, null]") == json({ true, false, nullptr }));
}
}
@@ -347,7 +347,7 @@
SECTION("nonempty object")
{
- CHECK(parser_helper("{\"\": true, \"one\": 1, \"two\": null}") == json({{"", true}, {"one", 1}, {"two", nullptr}}));
+ CHECK(parser_helper("{\"\": true, \"one\": 1, \"two\": null}") == json({ { "", true }, { "one", 1 }, { "two", nullptr } }));
}
}
@@ -1675,13 +1675,13 @@
return true;
});
- CHECK(j_object == json({{"foo", 2}, {"bar", {{"baz", 1}}}}));
+ CHECK(j_object == json({ { "foo", 2 }, { "bar", { { "baz", 1 } } } }));
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/) noexcept {
return true;
});
- CHECK(j_array == json({1, 2, {3, 4, 5}, 4, 5}));
+ CHECK(j_array == json({ 1, 2, { 3, 4, 5 }, 4, 5 }));
}
SECTION("filter everything")
@@ -1708,13 +1708,13 @@
return event != json::parse_event_t::value || j != json(2);
});
- CHECK(j_object == json({{"bar", {{"baz", 1}}}}));
+ CHECK(j_object == json({ { "bar", { { "baz", 1 } } } }));
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t event, const json& j) noexcept {
return event != json::parse_event_t::value || j != json(2);
});
- CHECK(j_array == json({1, {3, 4, 5}, 4, 5}));
+ CHECK(j_array == json({ 1, { 3, 4, 5 }, 4, 5 }));
}
SECTION("filter object in array")
@@ -1725,7 +1725,7 @@
// the specified object will be discarded, and removed.
CHECK(j_filtered1.size() == 2);
- CHECK(j_filtered1 == json({1, {{"qux", "baz"}}}));
+ CHECK(j_filtered1 == json({ 1, { { "qux", "baz" } } }));
json j_filtered2 = json::parse(structured_array, [](int /*unused*/, json::parse_event_t e, const json& /*parsed*/) noexcept {
return e != json::parse_event_t::object_end;
@@ -1733,7 +1733,7 @@
// removed all objects in array.
CHECK(j_filtered2.size() == 1);
- CHECK(j_filtered2 == json({1}));
+ CHECK(j_filtered2 == json({ 1 }));
}
SECTION("filter specific events")
@@ -1753,7 +1753,7 @@
});
// the first completed object will be discarded
- CHECK(j_object == json({{"foo", 2}}));
+ CHECK(j_object == json({ { "foo", 2 } }));
}
{
@@ -1769,7 +1769,7 @@
});
// the first completed array will be discarded
- CHECK(j_array == json({1, 2, 4, 5}));
+ CHECK(j_array == json({ 1, 2, 4, 5 }));
}
}
}
@@ -1796,7 +1796,7 @@
{
SECTION("from std::vector")
{
- std::vector<uint8_t> v = {'t', 'r', 'u', 'e'};
+ std::vector<uint8_t> v = { 't', 'r', 'u', 'e' };
json j;
json::parser(nlohmann::detail::input_adapter(std::begin(v), std::end(v))).parse(true, j);
CHECK(j == json(true));
@@ -1804,7 +1804,7 @@
SECTION("from std::array")
{
- std::array<uint8_t, 5> v{{'t', 'r', 'u', 'e'}};
+ std::array<uint8_t, 5> v{ { 't', 'r', 'u', 'e' } };
json j;
json::parser(nlohmann::detail::input_adapter(std::begin(v), std::end(v))).parse(true, j);
CHECK(j == json(true));
@@ -1812,7 +1812,7 @@
SECTION("from array")
{
- uint8_t v[] = {'t', 'r', 'u', 'e'}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+ uint8_t v[] = { 't', 'r', 'u', 'e' }; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
json j;
json::parser(nlohmann::detail::input_adapter(std::begin(v), std::end(v))).parse(true, j);
CHECK(j == json(true));
@@ -1825,7 +1825,7 @@
SECTION("from std::string")
{
- std::string v = {'t', 'r', 'u', 'e'};
+ std::string v = { 't', 'r', 'u', 'e' };
json j;
json::parser(nlohmann::detail::input_adapter(std::begin(v), std::end(v))).parse(true, j);
CHECK(j == json(true));
@@ -1833,7 +1833,7 @@
SECTION("from std::initializer_list")
{
- std::initializer_list<uint8_t> const v = {'t', 'r', 'u', 'e'};
+ std::initializer_list<uint8_t> const v = { 't', 'r', 'u', 'e' };
json j;
json::parser(nlohmann::detail::input_adapter(std::begin(v), std::end(v))).parse(true, j);
CHECK(j == json(true));
@@ -1841,7 +1841,7 @@
SECTION("from std::valarray")
{
- std::valarray<uint8_t> v = {'t', 'r', 'u', 'e'};
+ std::valarray<uint8_t> v = { 't', 'r', 'u', 'e' };
json j;
json::parser(nlohmann::detail::input_adapter(std::begin(v), std::end(v))).parse(true, j);
CHECK(j == json(true));
diff --git a/tests/src/unit-comparison.cpp b/tests/src/unit-comparison.cpp
index ca8e10a..abd9020 100644
--- a/tests/src/unit-comparison.cpp
+++ b/tests/src/unit-comparison.cpp
@@ -87,29 +87,23 @@
SECTION("types")
{
- std::vector<json::value_t> 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<json::value_t> 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<std::vector<bool>> 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
+ { 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")
@@ -139,16 +133,16 @@
{
std::vector<std::vector<std::partial_ordering>> 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
+ { 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
@@ -197,94 +191,94 @@
"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
+ { 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<std::vector<bool>> 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
+ { _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<std::vector<bool>> 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
+ { 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<std::vector<bool>> 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
+ { 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
@@ -306,28 +300,28 @@
{
std::vector<std::vector<bool>> 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
+ { 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)
@@ -500,28 +494,28 @@
{
std::vector<std::vector<std::partial_ordering>> 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
+ { 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
@@ -582,13 +576,13 @@
return j != json(2);
});
- CHECK(j_object == json({{"bar", {{"baz", 1}}}}));
+ CHECK(j_object == json({ { "bar", { { "baz", 1 } } } }));
json j_array = json::parse(s_array, [](int /*unused*/, json::parse_event_t /*unused*/, const json& j) noexcept {
return j != json(2);
});
- CHECK(j_array == json({1, {3, 4, 5}, 4, 5}));
+ CHECK(j_array == json({ 1, { 3, 4, 5 }, 4, 5 }));
}
}
#endif
diff --git a/tests/src/unit-concepts.cpp b/tests/src/unit-concepts.cpp
index d6bf2c9..b8a5633 100644
--- a/tests/src/unit-concepts.cpp
+++ b/tests/src/unit-concepts.cpp
@@ -129,7 +129,7 @@
SECTION("Swappable")
{
{
- json j{1, 2, 3};
+ json j{ 1, 2, 3 };
json::iterator it1 = j.begin();
json::iterator it2 = j.end();
swap(it1, it2);
@@ -137,7 +137,7 @@
CHECK(it2 == j.begin());
}
{
- json j{1, 2, 3};
+ json j{ 1, 2, 3 };
json::const_iterator it1 = j.cbegin();
json::const_iterator it2 = j.cend();
swap(it1, it2);
diff --git a/tests/src/unit-constructor1.cpp b/tests/src/unit-constructor1.cpp
index 3d3f1c5..c69be14 100644
--- a/tests/src/unit-constructor1.cpp
+++ b/tests/src/unit-constructor1.cpp
@@ -131,7 +131,7 @@
SECTION("filled object")
{
- json::object_t const o{{"a", json(1)}, {"b", json(1u)}, {"c", json(2.2)}, {"d", json(false)}, {"e", json("string")}, {"f", json()}};
+ json::object_t 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);
}
@@ -140,12 +140,14 @@
SECTION("create an object (implicit)")
{
// reference object
- json::object_t const o_reference{{"a", json(1)}, {"b", json(1u)}, {"c", json(2.2)}, {"d", json(false)}, {"e", json("string")}, {"f", json()}};
+ json::object_t const o_reference{ { "a", json(1) }, { "b", json(1u) }, { "c", json(2.2) },
+ { "d", json(false) }, { "e", json("string") }, { "f", json() } };
json const j_reference(o_reference);
SECTION("std::map<json::string_t, json>")
{
- std::map<json::string_t, json> const o{{"a", json(1)}, {"b", json(1u)}, {"c", json(2.2)}, {"d", json(false)}, {"e", json("string")}, {"f", json()}};
+ std::map<json::string_t, json> 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);
@@ -154,9 +156,9 @@
SECTION("std::map<std::string, std::string> #600")
{
const std::map<std::string, std::string> m{
- {"a", "b"},
- {"c", "d"},
- {"e", "f"},
+ { "a", "b" },
+ { "c", "d" },
+ { "e", "f" },
};
json const j(m);
@@ -165,7 +167,8 @@
SECTION("std::map<const char*, json>")
{
- std::map<const char*, json> const o{{"a", json(1)}, {"b", json(1u)}, {"c", json(2.2)}, {"d", json(false)}, {"e", json("string")}, {"f", json()}};
+ std::map<const char*, json> 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);
@@ -173,12 +176,8 @@
SECTION("std::multimap<json::string_t, json>")
{
- std::multimap<json::string_t, json> const o{{"a", json(1)},
- {"b", json(1u)},
- {"c", json(2.2)},
- {"d", json(false)},
- {"e", json("string")},
- {"f", json()}};
+ std::multimap<json::string_t, json> 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);
@@ -186,12 +185,8 @@
SECTION("std::unordered_map<json::string_t, json>")
{
- std::unordered_map<json::string_t, json> const o{{"a", json(1)},
- {"b", json(1u)},
- {"c", json(2.2)},
- {"d", json(false)},
- {"e", json("string")},
- {"f", json()}};
+ std::unordered_map<json::string_t, json> 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);
@@ -199,12 +194,8 @@
SECTION("std::unordered_multimap<json::string_t, json>")
{
- std::unordered_multimap<json::string_t, json> const o{{"a", json(1)},
- {"b", json(1u)},
- {"c", json(2.2)},
- {"d", json(false)},
- {"e", json("string")},
- {"f", json()}};
+ std::unordered_multimap<json::string_t, json> 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);
@@ -212,7 +203,7 @@
SECTION("associative container literal")
{
- json const j({{"a", json(1)}, {"b", json(1u)}, {"c", json(2.2)}, {"d", json(false)}, {"e", json("string")}, {"f", json()}});
+ json const j({ { "a", json(1) }, { "b", json(1u) }, { "c", json(2.2) }, { "d", json(false) }, { "e", json("string") }, { "f", json() } });
CHECK(j.type() == json::value_t::object);
CHECK(j == j_reference);
}
@@ -229,7 +220,7 @@
SECTION("filled array")
{
- json::array_t const a{json(1), json(1u), json(2.2), json(false), json("string"), json()};
+ json::array_t const a{ json(1), json(1u), json(2.2), json(false), json("string"), json() };
json const j(a);
CHECK(j.type() == json::value_t::array);
}
@@ -238,12 +229,12 @@
SECTION("create an array (implicit)")
{
// reference array
- json::array_t const a_reference{json(1), json(1u), json(2.2), json(false), json("string"), json()};
+ json::array_t const a_reference{ json(1), json(1u), json(2.2), json(false), json("string"), json() };
json const j_reference(a_reference);
SECTION("std::list<json>")
{
- std::list<json> const a{json(1), json(1u), json(2.2), json(false), json("string"), json()};
+ std::list<json> const a{ json(1), json(1u), json(2.2), json(false), json("string"), json() };
json const j(a);
CHECK(j.type() == json::value_t::array);
CHECK(j == j_reference);
@@ -251,7 +242,7 @@
SECTION("std::pair")
{
- std::pair<float, std::string> const p{1.0f, "string"};
+ std::pair<float, std::string> const p{ 1.0f, "string" };
json const j(p);
CHECK(j.type() == json::value_t::array);
@@ -263,7 +254,7 @@
SECTION("std::pair with discarded values")
{
- json const j{1, 2.0, "string"};
+ json const j{ 1, 2.0, "string" };
const auto p = j.get<std::pair<int, float>>();
CHECK(p.first == j[0]);
@@ -272,7 +263,7 @@
SECTION("std::tuple")
{
- const auto t = std::make_tuple(1.0, std::string{"string"}, 42, std::vector<int>{0, 1});
+ const auto t = std::make_tuple(1.0, std::string{ "string" }, 42, std::vector<int>{ 0, 1 });
json const j(t);
CHECK(j.type() == json::value_t::array);
@@ -287,7 +278,7 @@
SECTION("std::tuple with discarded values")
{
- json const j{1, 2.0, "string", 42};
+ json const j{ 1, 2.0, "string", 42 };
const auto t = j.get<std::tuple<int, float, std::string>>();
CHECK(std::get<0>(t) == j[0]);
@@ -297,7 +288,7 @@
SECTION("std::pair/tuple/array failures")
{
- json const j{1};
+ json const j{ 1 };
CHECK_THROWS_WITH_AS((j.get<std::pair<int, int>>()), "[json.exception.out_of_range.401] array index 1 is out of range", json::out_of_range&);
CHECK_THROWS_WITH_AS((j.get<std::tuple<int, int>>()), "[json.exception.out_of_range.401] array index 1 is out of range", json::out_of_range&);
@@ -306,7 +297,7 @@
SECTION("std::forward_list<json>")
{
- std::forward_list<json> const a{json(1), json(1u), json(2.2), json(false), json("string"), json()};
+ std::forward_list<json> const a{ json(1), json(1u), json(2.2), json(false), json("string"), json() };
json const j(a);
CHECK(j.type() == json::value_t::array);
CHECK(j == j_reference);
@@ -314,7 +305,7 @@
SECTION("std::array<json, 6>")
{
- std::array<json, 6> const a{{json(1), json(1u), json(2.2), json(false), json("string"), json()}};
+ std::array<json, 6> const a{ { json(1), json(1u), json(2.2), json(false), json("string"), json() } };
json const j(a);
CHECK(j.type() == json::value_t::array);
CHECK(j == j_reference);
@@ -325,10 +316,10 @@
SECTION("std::valarray<int>")
{
- std::valarray<int> const va = {1, 2, 3, 4, 5};
+ std::valarray<int> const va = { 1, 2, 3, 4, 5 };
json const j(va);
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1, 2, 3, 4, 5}));
+ CHECK(j == json({ 1, 2, 3, 4, 5 }));
auto jva = j.get<std::valarray<int>>();
CHECK(jva.size() == va.size());
@@ -340,10 +331,10 @@
SECTION("std::valarray<double>")
{
- std::valarray<double> const va = {1.2, 2.3, 3.4, 4.5, 5.6};
+ std::valarray<double> const va = { 1.2, 2.3, 3.4, 4.5, 5.6 };
json const j(va);
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1.2, 2.3, 3.4, 4.5, 5.6}));
+ CHECK(j == json({ 1.2, 2.3, 3.4, 4.5, 5.6 }));
auto jva = j.get<std::valarray<double>>();
CHECK(jva.size() == va.size());
@@ -355,7 +346,7 @@
SECTION("std::vector<json>")
{
- std::vector<json> const a{json(1), json(1u), json(2.2), json(false), json("string"), json()};
+ std::vector<json> const a{ json(1), json(1u), json(2.2), json(false), json("string"), json() };
json const j(a);
CHECK(j.type() == json::value_t::array);
CHECK(j == j_reference);
@@ -363,7 +354,7 @@
SECTION("std::deque<json>")
{
- std::deque<json> const a{json(1), json(1u), json(2.2), json(false), json("string"), json()};
+ std::deque<json> const a{ json(1), json(1u), json(2.2), json(false), json("string"), json() };
json const j(a);
CHECK(j.type() == json::value_t::array);
CHECK(j == j_reference);
@@ -371,7 +362,7 @@
SECTION("std::set<json>")
{
- std::set<json> const a{json(1), json(1u), json(2.2), json(false), json("string"), json()};
+ std::set<json> const a{ json(1), json(1u), json(2.2), json(false), json("string"), json() };
json const j(a);
CHECK(j.type() == json::value_t::array);
// we cannot really check for equality here
@@ -379,7 +370,7 @@
SECTION("std::unordered_set<json>")
{
- std::unordered_set<json> const a{json(1), json(1u), json(2.2), json(false), json("string"), json()};
+ std::unordered_set<json> const a{ json(1), json(1u), json(2.2), json(false), json("string"), json() };
json const j(a);
CHECK(j.type() == json::value_t::array);
// we cannot really check for equality here
@@ -387,7 +378,7 @@
SECTION("sequence container literal")
{
- json const j({json(1), json(1u), json(2.2), json(false), json("string"), json()});
+ json const j({ json(1), json(1u), json(2.2), json(false), json("string"), json() });
CHECK(j.type() == json::value_t::array);
CHECK(j == j_reference);
}
@@ -404,7 +395,7 @@
SECTION("filled string")
{
- json::string_t const s{"Hello world"};
+ json::string_t const s{ "Hello world" };
json const j(s);
CHECK(j.type() == json::value_t::string);
}
@@ -413,12 +404,12 @@
SECTION("create a string (implicit)")
{
// reference string
- json::string_t const s_reference{"Hello world"};
+ json::string_t const s_reference{ "Hello world" };
json const j_reference(s_reference);
SECTION("std::string")
{
- std::string const s{"Hello world"};
+ std::string const s{ "Hello world" };
json const j(s);
CHECK(j.type() == json::value_t::string);
CHECK(j == j_reference);
@@ -426,7 +417,7 @@
SECTION("char[]")
{
- char const s[]{"Hello world"}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+ char const s[]{ "Hello world" }; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
json const j(s);
CHECK(j.type() == json::value_t::string);
CHECK(j == j_reference);
@@ -434,7 +425,7 @@
SECTION("const char*")
{
- const char* s{"Hello world"};
+ const char* s{ "Hello world" };
json const j(s);
CHECK(j.type() == json::value_t::string);
CHECK(j == j_reference);
@@ -471,7 +462,7 @@
SECTION("from std::vector<bool>::reference")
{
- std::vector<bool> v{true};
+ std::vector<bool> v{ true };
json const j(v[0]);
CHECK(std::is_same<decltype(v[0]), std::vector<bool>::reference>::value);
CHECK(j.type() == json::value_t::boolean);
@@ -479,7 +470,7 @@
SECTION("from std::vector<bool>::const_reference")
{
- const std::vector<bool> v{true};
+ const std::vector<bool> v{ true };
json const j(v[0]);
CHECK(std::is_same<decltype(v[0]), std::vector<bool>::const_reference>::value);
CHECK(j.type() == json::value_t::boolean);
@@ -497,7 +488,7 @@
SECTION("filled binary")
{
- json::binary_t const b({1, 2, 3});
+ json::binary_t const b({ 1, 2, 3 });
json const j(b);
CHECK(j.type() == json::value_t::binary);
}
@@ -851,7 +842,7 @@
CHECK(j.type() == json::value_t::number_float);
// check round trip of NaN
- json::number_float_t const d{j};
+ json::number_float_t const d{ j };
CHECK((std::isnan(d) && std::isnan(n)) == true);
// check that NaN is serialized to null
@@ -866,7 +857,7 @@
CHECK(j.type() == json::value_t::number_float);
// check round trip of infinity
- json::number_float_t const d{j};
+ json::number_float_t const d{ j };
CHECK(d == n);
// check that inf is serialized to null
@@ -949,13 +940,13 @@
{
SECTION("explicit")
{
- json const j(json::initializer_list_t{json(json::array_t())});
+ json const j(json::initializer_list_t{ json(json::array_t()) });
CHECK(j.type() == json::value_t::array);
}
SECTION("implicit")
{
- json const j{json::array_t()};
+ json const j{ json::array_t() };
CHECK(j.type() == json::value_t::array);
}
}
@@ -964,13 +955,13 @@
{
SECTION("explicit")
{
- json const j(json::initializer_list_t{json(json::object_t())});
+ json const j(json::initializer_list_t{ json(json::object_t()) });
CHECK(j.type() == json::value_t::array);
}
SECTION("implicit")
{
- json const j{json::object_t()};
+ json const j{ json::object_t() };
CHECK(j.type() == json::value_t::array);
}
}
@@ -979,13 +970,13 @@
{
SECTION("explicit")
{
- json const j(json::initializer_list_t{json("Hello world")});
+ json const j(json::initializer_list_t{ json("Hello world") });
CHECK(j.type() == json::value_t::array);
}
SECTION("implicit")
{
- json const j{"Hello world"};
+ json const j{ "Hello world" };
CHECK(j.type() == json::value_t::array);
}
}
@@ -994,13 +985,13 @@
{
SECTION("explicit")
{
- json const j(json::initializer_list_t{json(true)});
+ json const j(json::initializer_list_t{ json(true) });
CHECK(j.type() == json::value_t::array);
}
SECTION("implicit")
{
- json const j{true};
+ json const j{ true };
CHECK(j.type() == json::value_t::array);
}
}
@@ -1009,13 +1000,13 @@
{
SECTION("explicit")
{
- json const j(json::initializer_list_t{json(1)});
+ json const j(json::initializer_list_t{ json(1) });
CHECK(j.type() == json::value_t::array);
}
SECTION("implicit")
{
- json const j{1};
+ json const j{ 1 };
CHECK(j.type() == json::value_t::array);
}
}
@@ -1024,13 +1015,13 @@
{
SECTION("explicit")
{
- json const j(json::initializer_list_t{json(1u)});
+ json const j(json::initializer_list_t{ json(1u) });
CHECK(j.type() == json::value_t::array);
}
SECTION("implicit")
{
- json const j{1u};
+ json const j{ 1u };
CHECK(j.type() == json::value_t::array);
}
}
@@ -1039,13 +1030,13 @@
{
SECTION("explicit")
{
- json const j(json::initializer_list_t{json(42.23)});
+ json const j(json::initializer_list_t{ json(42.23) });
CHECK(j.type() == json::value_t::array);
}
SECTION("implicit")
{
- json const j{42.23};
+ json const j{ 42.23 };
CHECK(j.type() == json::value_t::array);
}
}
@@ -1055,13 +1046,13 @@
{
SECTION("explicit")
{
- json const j(json::initializer_list_t{1, 1u, 42.23, true, nullptr, json::object_t(), json::array_t()});
+ json const j(json::initializer_list_t{ 1, 1u, 42.23, true, nullptr, json::object_t(), json::array_t() });
CHECK(j.type() == json::value_t::array);
}
SECTION("implicit")
{
- json const j{1, 1u, 42.23, true, nullptr, json::object_t(), json::array_t()};
+ json const j{ 1, 1u, 42.23, true, nullptr, json::object_t(), json::array_t() };
CHECK(j.type() == json::value_t::array);
}
}
@@ -1070,13 +1061,13 @@
{
SECTION("object")
{
- json const j{{"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}};
+ json const j{ { "one", 1 }, { "two", 1u }, { "three", 2.2 }, { "four", false } };
CHECK(j.type() == json::value_t::object);
}
SECTION("array")
{
- json const j{{"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}, 13};
+ json const j{ { "one", 1 }, { "two", 1u }, { "three", 2.2 }, { "four", false }, 13 };
CHECK(j.type() == json::value_t::array);
}
}
@@ -1091,14 +1082,14 @@
SECTION("object")
{
- json const j = json::object({{"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}});
+ json const j = json::object({ { "one", 1 }, { "two", 1u }, { "three", 2.2 }, { "four", false } });
CHECK(j.type() == json::value_t::object);
}
SECTION("object with error")
{
json _;
- CHECK_THROWS_WITH_AS(_ = json::object({{"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}, 13}),
+ 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&);
}
@@ -1111,7 +1102,7 @@
SECTION("array")
{
- json const j = json::array({{"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}});
+ json const j = json::array({ { "one", 1 }, { "two", 1u }, { "three", 2.2 }, { "four", false } });
CHECK(j.type() == json::value_t::array);
}
}
@@ -1125,7 +1116,7 @@
// This should break through any short string optimization in std::string
std::string source(1024, '!');
const auto* source_addr = source.data();
- json j = {std::move(source)};
+ json j = { std::move(source) };
const auto* target_addr = j[0].get_ref<std::string const&>().data();
const bool success = (target_addr == source_addr);
CHECK(success);
@@ -1136,7 +1127,7 @@
// This should break through any short string optimization in std::string
std::string source(1024, '!');
const auto* source_addr = source.data();
- json j = {{"key", std::move(source)}};
+ json j = { { "key", std::move(source) } };
const auto* target_addr = j["key"].get_ref<std::string const&>().data();
const bool success = (target_addr == source_addr);
CHECK(success);
@@ -1147,7 +1138,7 @@
// This should break through any short string optimization in std::string
std::string source(1024, '!');
const auto* source_addr = source.data();
- json j = {{std::move(source), 42}};
+ json j = { { std::move(source), 42 } };
const auto* target_addr = j.get_ref<json::object_t&>().begin()->first.data();
const bool success = (target_addr == source_addr);
CHECK(success);
@@ -1158,9 +1149,9 @@
{
SECTION("constructor with implicit types (array)")
{
- json::array_t source = {1, 2, 3};
+ json::array_t source = { 1, 2, 3 };
const auto* source_addr = source.data();
- json j{std::move(source)};
+ json j{ std::move(source) };
const auto* target_addr = j[0].get_ref<json::array_t const&>().data();
const bool success = (target_addr == source_addr);
CHECK(success);
@@ -1168,9 +1159,9 @@
SECTION("constructor with implicit types (object)")
{
- json::array_t source = {1, 2, 3};
+ json::array_t source = { 1, 2, 3 };
const auto* source_addr = source.data();
- json const j{{"key", std::move(source)}};
+ json const j{ { "key", std::move(source) } };
const auto* target_addr = j["key"].get_ref<json::array_t const&>().data();
const bool success = (target_addr == source_addr);
CHECK(success);
@@ -1178,9 +1169,9 @@
SECTION("assignment with implicit types (array)")
{
- json::array_t source = {1, 2, 3};
+ json::array_t source = { 1, 2, 3 };
const auto* source_addr = source.data();
- json j = {std::move(source)};
+ json j = { std::move(source) };
const auto* target_addr = j[0].get_ref<json::array_t const&>().data();
const bool success = (target_addr == source_addr);
CHECK(success);
@@ -1188,9 +1179,9 @@
SECTION("assignment with implicit types (object)")
{
- json::array_t source = {1, 2, 3};
+ json::array_t source = { 1, 2, 3 };
const auto* source_addr = source.data();
- json j = {{"key", std::move(source)}};
+ json j = { { "key", std::move(source) } };
const auto* target_addr = j["key"].get_ref<json::array_t const&>().data();
const bool success = (target_addr == source_addr);
CHECK(success);
@@ -1201,33 +1192,33 @@
{
SECTION("constructor with implicit types (array)")
{
- json::object_t source = {{"hello", "world"}};
+ json::object_t source = { { "hello", "world" } };
const json* source_addr = &source.at("hello");
- json j{std::move(source)};
+ json j{ std::move(source) };
CHECK(&(j[0].get_ref<json::object_t const&>().at("hello")) == source_addr);
}
SECTION("constructor with implicit types (object)")
{
- json::object_t source = {{"hello", "world"}};
+ json::object_t source = { { "hello", "world" } };
const json* source_addr = &source.at("hello");
- json j{{"key", std::move(source)}};
+ json j{ { "key", std::move(source) } };
CHECK(&(j["key"].get_ref<json::object_t const&>().at("hello")) == source_addr);
}
SECTION("assignment with implicit types (array)")
{
- json::object_t source = {{"hello", "world"}};
+ json::object_t source = { { "hello", "world" } };
const json* source_addr = &source.at("hello");
- json j = {std::move(source)};
+ json j = { std::move(source) };
CHECK(&(j[0].get_ref<json::object_t const&>().at("hello")) == source_addr);
}
SECTION("assignment with implicit types (object)")
{
- json::object_t source = {{"hello", "world"}};
+ json::object_t source = { { "hello", "world" } };
const json* source_addr = &source.at("hello");
- json j = {{"key", std::move(source)}};
+ json j = { { "key", std::move(source) } };
CHECK(&(j["key"].get_ref<json::object_t const&>().at("hello")) == source_addr);
}
}
@@ -1236,33 +1227,33 @@
{
SECTION("constructor with implicit types (array)")
{
- json source{1, 2, 3};
+ json source{ 1, 2, 3 };
const json* source_addr = &source[0];
- json j{std::move(source), {}};
+ json j{ std::move(source), {} };
CHECK(&j[0][0] == source_addr);
}
SECTION("constructor with implicit types (object)")
{
- json source{1, 2, 3};
+ json source{ 1, 2, 3 };
const json* source_addr = &source[0];
- json j{{"key", std::move(source)}};
+ json j{ { "key", std::move(source) } };
CHECK(&j["key"][0] == source_addr);
}
SECTION("assignment with implicit types (array)")
{
- json source{1, 2, 3};
+ json source{ 1, 2, 3 };
const json* source_addr = &source[0];
- json j = {std::move(source), {}};
+ json j = { std::move(source), {} };
CHECK(&j[0][0] == source_addr);
}
SECTION("assignment with implicit types (object)")
{
- json source{1, 2, 3};
+ json source{ 1, 2, 3 };
const json* source_addr = &source[0];
- json j = {{"key", std::move(source)}};
+ json j = { { "key", std::move(source) } };
CHECK(&j["key"][0] == source_addr);
}
}
@@ -1273,14 +1264,14 @@
{
SECTION("cnt = 0")
{
- json const v = {1, "foo", 34.23, {1, 2, 3}, {{"A", 1}, {"B", 2u}}};
+ json const v = { 1, "foo", 34.23, { 1, 2, 3 }, { { "A", 1 }, { "B", 2u } } };
json const arr(0, v);
CHECK(arr.size() == 0);
}
SECTION("cnt = 1")
{
- json const v = {1, "foo", 34.23, {1, 2, 3}, {{"A", 1}, {"B", 2u}}};
+ json const v = { 1, "foo", 34.23, { 1, 2, 3 }, { { "A", 1 }, { "B", 2u } } };
json const arr(1, v);
CHECK(arr.size() == 1);
for (const auto& x : arr)
@@ -1291,7 +1282,7 @@
SECTION("cnt = 3")
{
- json const v = {1, "foo", 34.23, {1, 2, 3}, {{"A", 1}, {"B", 2u}}};
+ json const v = { 1, "foo", 34.23, { 1, 2, 3 }, { { "A", 1 }, { "B", 2u } } };
json const arr(3, v);
CHECK(arr.size() == 3);
for (const auto& x : arr)
@@ -1308,12 +1299,12 @@
SECTION("json(begin(), end())")
{
{
- json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
json const j_new(jobject.begin(), jobject.end());
CHECK(j_new == jobject);
}
{
- json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
json const j_new(jobject.cbegin(), jobject.cend());
CHECK(j_new == jobject);
}
@@ -1322,12 +1313,12 @@
SECTION("json(begin(), begin())")
{
{
- json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
json const j_new(jobject.begin(), jobject.begin());
CHECK(j_new == json::object());
}
{
- json const jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ json const jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
json const j_new(jobject.cbegin(), jobject.cbegin());
CHECK(j_new == json::object());
}
@@ -1335,16 +1326,16 @@
SECTION("construct from subrange")
{
- json const jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}};
+ json const jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u }, { "d", false }, { "e", true } };
json const j_new(jobject.find("b"), jobject.find("e"));
- CHECK(j_new == json({{"b", 1}, {"c", 17u}, {"d", false}}));
+ CHECK(j_new == json({ { "b", 1 }, { "c", 17u }, { "d", false } }));
}
SECTION("incompatible iterators")
{
{
- json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}};
- json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ 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&);
@@ -1353,8 +1344,8 @@
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}};
+ 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&);
@@ -1370,12 +1361,12 @@
SECTION("json(begin(), end())")
{
{
- json jarray = {1, 2, 3, 4, 5};
+ json jarray = { 1, 2, 3, 4, 5 };
json const j_new(jarray.begin(), jarray.end());
CHECK(j_new == jarray);
}
{
- json const jarray = {1, 2, 3, 4, 5};
+ json const jarray = { 1, 2, 3, 4, 5 };
json const j_new(jarray.cbegin(), jarray.cend());
CHECK(j_new == jarray);
}
@@ -1384,12 +1375,12 @@
SECTION("json(begin(), begin())")
{
{
- json jarray = {1, 2, 3, 4, 5};
+ json jarray = { 1, 2, 3, 4, 5 };
json j_new(jarray.begin(), jarray.begin());
CHECK(j_new == json::array());
}
{
- json const jarray = {1, 2, 3, 4, 5};
+ json const jarray = { 1, 2, 3, 4, 5 };
json const j_new(jarray.cbegin(), jarray.cbegin());
CHECK(j_new == json::array());
}
@@ -1398,22 +1389,22 @@
SECTION("construct from subrange")
{
{
- json jarray = {1, 2, 3, 4, 5};
+ json jarray = { 1, 2, 3, 4, 5 };
json const j_new(jarray.begin() + 1, jarray.begin() + 3);
- CHECK(j_new == json({2, 3}));
+ CHECK(j_new == json({ 2, 3 }));
}
{
- json const jarray = {1, 2, 3, 4, 5};
+ json const jarray = { 1, 2, 3, 4, 5 };
json const j_new(jarray.cbegin() + 1, jarray.cbegin() + 3);
- CHECK(j_new == json({2, 3}));
+ CHECK(j_new == json({ 2, 3 }));
}
}
SECTION("incompatible iterators")
{
{
- json jarray = {1, 2, 3, 4};
- json jarray2 = {2, 3, 4, 5};
+ 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&);
@@ -1422,8 +1413,8 @@
json::invalid_iterator&);
}
{
- json const jarray = {1, 2, 3, 4};
- json const jarray2 = {2, 3, 4, 5};
+ 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&);
@@ -1527,12 +1518,12 @@
SECTION("binary")
{
{
- json j = json::binary({1, 2, 3});
+ json j = json::binary({ 1, 2, 3 });
json const j_new(j.begin(), j.end());
CHECK((j == j_new));
}
{
- json const j = json::binary({1, 2, 3});
+ json const j = json::binary({ 1, 2, 3 });
json const j_new(j.cbegin(), j.cend());
CHECK((j == j_new));
}
diff --git a/tests/src/unit-constructor2.cpp b/tests/src/unit-constructor2.cpp
index 64d308e..d116e8f 100644
--- a/tests/src/unit-constructor2.cpp
+++ b/tests/src/unit-constructor2.cpp
@@ -17,14 +17,14 @@
{
SECTION("object")
{
- json j{{"foo", 1}, {"bar", false}};
+ json j{ { "foo", 1 }, { "bar", false } };
json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k);
}
SECTION("array")
{
- json j{"foo", 1, 42.23, false};
+ json j{ "foo", 1, 42.23, false };
json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k);
}
@@ -73,7 +73,7 @@
SECTION("binary")
{
- json j = json::binary({1, 2, 3});
+ json j = json::binary({ 1, 2, 3 });
json k(j); // NOLINT(performance-unnecessary-copy-initialization)
CHECK(j == k);
}
@@ -81,7 +81,7 @@
SECTION("move constructor")
{
- json j{{"foo", "bar"}, {"baz", {1, 2, 3, 4}}, {"a", 42u}, {"b", 42.23}, {"c", nullptr}};
+ json j{ { "foo", "bar" }, { "baz", { 1, 2, 3, 4 } }, { "a", 42u }, { "b", 42.23 }, { "c", nullptr } };
CHECK(j.type() == json::value_t::object);
const json k(std::move(j));
CHECK(k.type() == json::value_t::object);
@@ -92,7 +92,7 @@
{
SECTION("object")
{
- json j{{"foo", 1}, {"bar", false}};
+ json j{ { "foo", 1 }, { "bar", false } };
json k;
k = j;
CHECK(j == k);
@@ -100,7 +100,7 @@
SECTION("array")
{
- json j{"foo", 1, 42.23, false};
+ json j{ "foo", 1, 42.23, false };
json k;
k = j;
CHECK(j == k);
@@ -156,7 +156,7 @@
SECTION("binary")
{
- json j = json::binary({1, 2, 3});
+ json j = json::binary({ 1, 2, 3 });
json k;
k = j;
CHECK(j == k);
@@ -167,14 +167,14 @@
{
SECTION("object")
{
- auto* j = new json{{"foo", 1}, {"bar", false}}; // NOLINT(cppcoreguidelines-owning-memory)
- delete j; // NOLINT(cppcoreguidelines-owning-memory)
+ auto* j = new json{ { "foo", 1 }, { "bar", false } }; // NOLINT(cppcoreguidelines-owning-memory)
+ delete j; // NOLINT(cppcoreguidelines-owning-memory)
}
SECTION("array")
{
- auto* j = new json{"foo", 1, 1u, false, 23.42}; // NOLINT(cppcoreguidelines-owning-memory)
- delete j; // NOLINT(cppcoreguidelines-owning-memory)
+ auto* j = new json{ "foo", 1, 1u, false, 23.42 }; // NOLINT(cppcoreguidelines-owning-memory)
+ delete j; // NOLINT(cppcoreguidelines-owning-memory)
}
SECTION("string")
diff --git a/tests/src/unit-convenience.cpp b/tests/src/unit-convenience.cpp
index 4621e01..e4a7be5 100644
--- a/tests/src/unit-convenience.cpp
+++ b/tests/src/unit-convenience.cpp
@@ -173,8 +173,8 @@
using nlohmann::detail::concat;
const char* expected = "Hello, world!";
- alt_string_iter const hello_iter{"Hello, "};
- alt_string_data const hello_data{"Hello, "};
+ alt_string_iter const hello_iter{ "Hello, " };
+ alt_string_data const hello_data{ "Hello, " };
std::string const world = "world";
SECTION("std::string")
diff --git a/tests/src/unit-conversions.cpp b/tests/src/unit-conversions.cpp
index 8c0fd73..f895c38 100644
--- a/tests/src/unit-conversions.cpp
+++ b/tests/src/unit-conversions.cpp
@@ -36,8 +36,8 @@
{
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")
@@ -99,41 +99,41 @@
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")
{
- json::object_t o = {{"previous", "value"}};
+ json::object_t o = { { "previous", "value" } };
j.get_to(o);
CHECK(json(o) == j);
}
SECTION("std::map<json::string_t, json>")
{
- std::map<json::string_t, json> o{{"previous", "value"}};
+ std::map<json::string_t, json> o{ { "previous", "value" } };
j.get_to(o);
CHECK(json(o) == j);
}
SECTION("std::multimap<json::string_t, json>")
{
- std::multimap<json::string_t, json> o{{"previous", "value"}};
+ std::multimap<json::string_t, json> o{ { "previous", "value" } };
j.get_to(o);
CHECK(json(o) == j);
}
SECTION("std::unordered_map<json::string_t, json>")
{
- std::unordered_map<json::string_t, json> o{{"previous", "value"}};
+ std::unordered_map<json::string_t, json> o{ { "previous", "value" } };
j.get_to(o);
CHECK(json(o) == j);
}
SECTION("std::unordered_multimap<json::string_t, json>")
{
- std::unordered_multimap<json::string_t, json> o{{"previous", "value"}};
+ std::unordered_multimap<json::string_t, json> o{ { "previous", "value" } };
j.get_to(o);
CHECK(json(o) == j);
}
@@ -142,8 +142,8 @@
#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")
@@ -180,7 +180,7 @@
SECTION("get an array (explicit)")
{
- const json::array_t a_reference{json(1), json(1u), json(2.2), json(false), json("string"), json()};
+ const json::array_t a_reference{ json(1), json(1u), json(2.2), json(false), json("string"), json() };
json j(a_reference);
SECTION("json::array_t")
@@ -218,7 +218,7 @@
SECTION("reserve is called on containers that supports it")
{
// make sure all values are properly copied
- const json j2({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
+ const json j2({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
auto v2 = j2.get<std::vector<int>>();
CHECK(v2.size() == 10);
}
@@ -228,7 +228,7 @@
SECTION("built-in arrays")
{
const char str[] = "a string"; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
- const int nbs[] = {0, 1, 2}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+ const int nbs[] = { 0, 1, 2 }; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
const json j2 = nbs;
const json j3 = str;
@@ -276,48 +276,48 @@
SECTION("get an array (explicit, get_to)")
{
- const json::array_t a_reference{json(1), json(1u), json(2.2), json(false), json("string"), json()};
+ const json::array_t a_reference{ json(1), json(1u), json(2.2), json(false), json("string"), json() };
json j(a_reference);
SECTION("json::array_t")
{
- json::array_t a{"previous", "value"};
+ json::array_t a{ "previous", "value" };
j.get_to(a);
CHECK(json(a) == j);
}
SECTION("std::valarray<json>")
{
- std::valarray<json> a{"previous", "value"};
+ std::valarray<json> a{ "previous", "value" };
j.get_to(a);
CHECK(json(a) == j);
}
SECTION("std::list<json>")
{
- std::list<json> a{"previous", "value"};
+ std::list<json> a{ "previous", "value" };
j.get_to(a);
CHECK(json(a) == j);
}
SECTION("std::forward_list<json>")
{
- std::forward_list<json> a{"previous", "value"};
+ std::forward_list<json> a{ "previous", "value" };
j.get_to(a);
CHECK(json(a) == j);
}
SECTION("std::vector<json>")
{
- std::vector<json> a{"previous", "value"};
+ std::vector<json> a{ "previous", "value" };
j.get_to(a);
CHECK(json(a) == j);
}
SECTION("built-in arrays")
{
- const int nbs[] = {0, 1, 2}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
- int nbs2[] = {0, 0, 0}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+ const int nbs[] = { 0, 1, 2 }; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+ int nbs2[] = { 0, 0, 0 }; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
const json j2 = nbs;
j2.get_to(nbs2);
@@ -326,7 +326,7 @@
SECTION("std::deque<json>")
{
- std::deque<json> a{"previous", "value"};
+ std::deque<json> a{ "previous", "value" };
j.get_to(a);
CHECK(json(a) == j);
}
@@ -335,7 +335,7 @@
#if JSON_USE_IMPLICIT_CONVERSIONS
SECTION("get an array (implicit)")
{
- const json::array_t a_reference{json(1), json(1u), json(2.2), json(false), json("string"), json()};
+ const json::array_t a_reference{ json(1), json(1u), json(2.2), json(false), json("string"), json() };
json j(a_reference);
SECTION("json::array_t")
@@ -372,7 +372,7 @@
SECTION("get a string (explicit)")
{
- const json::string_t s_reference{"Hello world"};
+ const json::string_t s_reference{ "Hello world" };
json j(s_reference);
SECTION("string_t")
@@ -450,7 +450,7 @@
SECTION("get a string (explicit, get_to)")
{
- const json::string_t s_reference{"Hello world"};
+ const json::string_t s_reference{ "Hello world" };
json j(s_reference);
SECTION("string_t")
@@ -511,7 +511,7 @@
#if JSON_USE_IMPLICIT_CONVERSIONS
SECTION("get a string (implicit)")
{
- const json::string_t s_reference{"Hello world"};
+ const json::string_t s_reference{ "Hello world" };
json j(s_reference);
SECTION("string_t")
@@ -538,7 +538,7 @@
SECTION("get a boolean (explicit)")
{
- const json::boolean_t b_reference{true};
+ const json::boolean_t b_reference{ true };
json j(b_reference);
SECTION("boolean_t")
@@ -595,7 +595,7 @@
#if JSON_USE_IMPLICIT_CONVERSIONS
SECTION("get a boolean (implicit)")
{
- const json::boolean_t b_reference{true};
+ const json::boolean_t b_reference{ true };
json j(b_reference);
SECTION("boolean_t")
@@ -614,9 +614,9 @@
SECTION("get an integer number (explicit)")
{
- const json::number_integer_t n_reference{42};
+ const json::number_integer_t n_reference{ 42 };
json j(n_reference);
- const json::number_unsigned_t n_unsigned_reference{42u};
+ const json::number_unsigned_t n_unsigned_reference{ 42u };
json j_unsigned(n_unsigned_reference);
SECTION("number_integer_t")
@@ -850,9 +850,9 @@
#if JSON_USE_IMPLICIT_CONVERSIONS
SECTION("get an integer number (implicit)")
{
- json::number_integer_t const n_reference{42};
+ json::number_integer_t const n_reference{ 42 };
json j(n_reference);
- json::number_unsigned_t const n_unsigned_reference{42u};
+ json::number_unsigned_t const n_unsigned_reference{ 42u };
json j_unsigned(n_unsigned_reference);
SECTION("number_integer_t")
@@ -1063,7 +1063,7 @@
SECTION("get a floating-point number (explicit)")
{
- json::number_float_t const n_reference{42.23};
+ json::number_float_t const n_reference{ 42.23 };
json const j(n_reference);
SECTION("number_float_t")
@@ -1111,7 +1111,7 @@
#if JSON_USE_IMPLICIT_CONVERSIONS
SECTION("get a floating-point number (implicit)")
{
- json::number_float_t const n_reference{42.23};
+ json::number_float_t const n_reference{ 42.23 };
json const j(n_reference);
SECTION("number_float_t")
@@ -1136,7 +1136,7 @@
SECTION("get a binary value (explicit)")
{
- json::binary_t const n_reference{{1, 2, 3}};
+ json::binary_t const n_reference{ { 1, 2, 3 } };
json j(n_reference);
SECTION("binary_t")
@@ -1205,7 +1205,7 @@
#if JSON_USE_IMPLICIT_CONVERSIONS
SECTION("get a binary value (implicit)")
{
- json::binary_t const n_reference{{1, 2, 3}};
+ json::binary_t const n_reference{ { 1, 2, 3 } };
json const j(n_reference);
SECTION("binary_t")
@@ -1237,11 +1237,11 @@
{
SECTION("object-like STL containers")
{
- json const j1 = {{"one", 1}, {"two", 2}, {"three", 3}};
- json const j2 = {{"one", 1u}, {"two", 2u}, {"three", 3u}};
- json const j3 = {{"one", 1.1}, {"two", 2.2}, {"three", 3.3}};
- json const j4 = {{"one", true}, {"two", false}, {"three", true}};
- json const j5 = {{"one", "eins"}, {"two", "zwei"}, {"three", "drei"}};
+ json const j1 = { { "one", 1 }, { "two", 2 }, { "three", 3 } };
+ json const j2 = { { "one", 1u }, { "two", 2u }, { "three", 3u } };
+ json const j3 = { { "one", 1.1 }, { "two", 2.2 }, { "three", 3.3 } };
+ json const j4 = { { "one", true }, { "two", false }, { "three", true } };
+ json const j5 = { { "one", "eins" }, { "two", "zwei" }, { "three", "drei" } };
SECTION("std::map")
{
@@ -1292,11 +1292,11 @@
SECTION("array-like STL containers")
{
- json const j1 = {1, 2, 3, 4};
- json const j2 = {1u, 2u, 3u, 4u};
- json const j3 = {1.2, 2.3, 3.4, 4.5};
- json const j4 = {true, false, true};
- json const j5 = {"one", "two", "three"};
+ json const j1 = { 1, 2, 3, 4 };
+ json const j2 = { 1u, 2u, 3u, 4u };
+ json const j3 = { 1.2, 2.3, 3.4, 4.5 };
+ json const j4 = { true, false, true };
+ json const j5 = { "one", "two", "three" };
SECTION("std::list")
{
@@ -1326,7 +1326,7 @@
SECTION("std::array is larger than JSON")
{
- std::array<int, 6> arr6 = {{1, 2, 3, 4, 5, 6}};
+ std::array<int, 6> 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",
@@ -1335,7 +1335,7 @@
SECTION("std::array is smaller than JSON")
{
- std::array<int, 2> arr2 = {{8, 9}};
+ std::array<int, 2> arr2 = { { 8, 9 } };
j1.get_to(arr2);
CHECK(arr2[0] == 1);
CHECK(arr2[1] == 2);
@@ -1389,13 +1389,13 @@
SECTION("std::map (array of pairs)")
{
- std::map<int, int> m{{0, 1}, {1, 2}, {2, 3}};
+ std::map<int, int> m{ { 0, 1 }, { 1, 2 }, { 2, 3 } };
json const j6 = m;
auto m2 = j6.get<std::map<int, int>>();
CHECK(m == m2);
- json const j7 = {0, 1, 2, 3};
+ json const j7 = { 0, 1, 2, 3 };
json const j8 = 2;
CHECK_THROWS_WITH_AS((j7.get<std::map<int, int>>()),
"[json.exception.type_error.302] type must be array, "
@@ -1408,7 +1408,7 @@
SECTION("superfluous entries")
{
- json const j9 = {{0, 1, 2}, {1, 2, 3}, {2, 3, 4}};
+ json const j9 = { { 0, 1, 2 }, { 1, 2, 3 }, { 2, 3, 4 } };
m2 = j9.get<std::map<int, int>>();
CHECK(m == m2);
}
@@ -1416,13 +1416,13 @@
SECTION("std::unordered_map (array of pairs)")
{
- std::unordered_map<int, int> m{{0, 1}, {1, 2}, {2, 3}};
+ std::unordered_map<int, int> m{ { 0, 1 }, { 1, 2 }, { 2, 3 } };
json const j6 = m;
auto m2 = j6.get<std::unordered_map<int, int>>();
CHECK(m == m2);
- json const j7 = {0, 1, 2, 3};
+ json const j7 = { 0, 1, 2, 3 };
json const j8 = 2;
CHECK_THROWS_WITH_AS((j7.get<std::unordered_map<int, int>>()),
"[json.exception.type_error.302] type must be array, "
@@ -1435,7 +1435,7 @@
SECTION("superfluous entries")
{
- json const j9{{0, 1, 2}, {1, 2, 3}, {2, 3, 4}};
+ json const j9{ { 0, 1, 2 }, { 1, 2, 3 }, { 2, 3, 4 } };
m2 = j9.get<std::unordered_map<int, int>>();
CHECK(m == m2);
}
@@ -1466,11 +1466,11 @@
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - false positive
NLOHMANN_JSON_SERIALIZE_ENUM(cards,
- {{cards::kreuz, "kreuz"},
- {cards::pik, "pik"},
- {cards::pik, "puk"}, // second entry for cards::puk; will not be used
- {cards::herz, "herz"},
- {cards::karo, "karo"}})
+ { { cards::kreuz, "kreuz" },
+ { cards::pik, "pik" },
+ { cards::pik, "puk" }, // second entry for cards::puk; will not be used
+ { cards::herz, "herz" },
+ { cards::karo, "karo" } })
enum TaskState
{
@@ -1483,10 +1483,10 @@
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - false positive
NLOHMANN_JSON_SERIALIZE_ENUM(TaskState,
{
- {TS_INVALID, nullptr},
- {TS_STOPPED, "stopped"},
- {TS_RUNNING, "running"},
- {TS_COMPLETED, "completed"},
+ { TS_INVALID, nullptr },
+ { TS_STOPPED, "stopped" },
+ { TS_RUNNING, "running" },
+ { TS_COMPLETED, "completed" },
})
TEST_CASE("JSON to enum mapping")
diff --git a/tests/src/unit-custom-base-class.cpp b/tests/src/unit-custom-base-class.cpp
index f9a4f7a..c0b8d94 100644
--- a/tests/src/unit-custom-base-class.cpp
+++ b/tests/src/unit-custom-base-class.cpp
@@ -258,23 +258,23 @@
json["array"].push_back(1);
json["array"].push_back(json);
- std::set<std::string> 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",
+ std::set<std::string> 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"};
+ "/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;
diff --git a/tests/src/unit-deserialization.cpp b/tests/src/unit-deserialization.cpp
index 46280f5..aa8524e 100644
--- a/tests/src/unit-deserialization.cpp
+++ b/tests/src/unit-deserialization.cpp
@@ -231,22 +231,22 @@
ss3 << R"(["foo",1,2,3,false,{"one":1}])";
json j = json::parse(ss1);
CHECK(json::accept(ss2));
- CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}}));
+ CHECK(j == json({ "foo", 1, 2, 3, false, { { "one", 1 } } }));
SaxEventLogger l;
CHECK(json::sax_parse(ss3, &l));
CHECK(l.events.size() == 11);
- CHECK(l.events == std::vector<std::string>({"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<std::string>({ "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")
@@ -254,22 +254,22 @@
const auto* s = R"(["foo",1,2,3,false,{"one":1}])";
json j = json::parse(s);
CHECK(json::accept(s));
- CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}}));
+ CHECK(j == json({ "foo", 1, 2, 3, false, { { "one", 1 } } }));
SaxEventLogger l;
CHECK(json::sax_parse(s, &l));
CHECK(l.events.size() == 11);
- CHECK(l.events == std::vector<std::string>({"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<std::string>({ "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")
@@ -277,22 +277,22 @@
json::string_t const s = R"(["foo",1,2,3,false,{"one":1}])";
json j = json::parse(s);
CHECK(json::accept(s));
- CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}}));
+ CHECK(j == json({ "foo", 1, 2, 3, false, { { "one", 1 } } }));
SaxEventLogger l;
CHECK(json::sax_parse(s, &l));
CHECK(l.events.size() == 11);
- CHECK(l.events == std::vector<std::string>({"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<std::string>({ "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<<")
@@ -301,7 +301,7 @@
ss << R"(["foo",1,2,3,false,{"one":1}])";
json j;
j << ss;
- CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}}));
+ CHECK(j == json({ "foo", 1, 2, 3, false, { { "one", 1 } } }));
}
SECTION("operator>>")
@@ -310,12 +310,12 @@
ss << R"(["foo",1,2,3,false,{"one":1}])";
json j;
ss >> j;
- CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}}));
+ CHECK(j == json({ "foo", 1, 2, 3, false, { { "one", 1 } } }));
}
SECTION("user-defined string literal")
{
- CHECK("[\"foo\",1,2,3,false,{\"one\":1}]"_json == json({"foo", 1, 2, 3, false, {{"one", 1}}}));
+ CHECK("[\"foo\",1,2,3,false,{\"one\":1}]"_json == json({ "foo", 1, 2, 3, false, { { "one", 1 } } }));
}
}
@@ -346,17 +346,17 @@
SaxEventLogger l;
CHECK(!json::sax_parse(ss5, &l));
CHECK(l.events.size() == 11);
- CHECK(l.events == std::vector<std::string>({"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<std::string>({ "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")
@@ -376,17 +376,17 @@
SaxEventLogger l;
CHECK(!json::sax_parse(s, &l));
CHECK(l.events.size() == 11);
- CHECK(l.events == std::vector<std::string>({"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<std::string>({ "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<<")
@@ -426,38 +426,38 @@
{
SECTION("from std::vector")
{
- std::vector<uint8_t> const v = {'t', 'r', 'u', 'e'};
+ std::vector<uint8_t> const v = { 't', 'r', 'u', 'e' };
CHECK(json::parse(v) == json(true));
CHECK(json::accept(v));
SaxEventLogger l;
CHECK(json::sax_parse(v, &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
SECTION("from std::array")
{
- std::array<uint8_t, 5> const v{{'t', 'r', 'u', 'e'}};
+ std::array<uint8_t, 5> const v{ { 't', 'r', 'u', 'e' } };
CHECK(json::parse(v) == json(true));
CHECK(json::accept(v));
SaxEventLogger l;
CHECK(json::sax_parse(v, &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
SECTION("from array")
{
- uint8_t v[] = {'t', 'r', 'u', 'e'}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+ uint8_t v[] = { 't', 'r', 'u', 'e' }; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
CHECK(json::parse(v) == json(true));
CHECK(json::accept(v));
SaxEventLogger l;
CHECK(json::sax_parse(v, &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
SECTION("from chars")
@@ -474,33 +474,33 @@
SaxEventLogger l;
CHECK(json::sax_parse(v, &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
delete[] v; // NOLINT(cppcoreguidelines-owning-memory)
}
SECTION("from std::string")
{
- std::string const v = {'t', 'r', 'u', 'e'};
+ std::string const v = { 't', 'r', 'u', 'e' };
CHECK(json::parse(v) == json(true));
CHECK(json::accept(v));
SaxEventLogger l;
CHECK(json::sax_parse(v, &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
SECTION("from std::initializer_list")
{
- std::initializer_list<uint8_t> const v = {'t', 'r', 'u', 'e'};
+ std::initializer_list<uint8_t> const v = { 't', 'r', 'u', 'e' };
CHECK(json::parse(v) == json(true));
CHECK(json::accept(v));
SaxEventLogger l;
CHECK(json::sax_parse(v, &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
SECTION("empty container")
@@ -513,7 +513,7 @@
SaxEventLogger l;
CHECK(!json::sax_parse(v, &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(1)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(1)" }));
}
}
@@ -521,74 +521,74 @@
{
SECTION("from std::vector")
{
- std::vector<uint8_t> v = {'t', 'r', 'u', 'e'};
+ std::vector<uint8_t> v = { 't', 'r', 'u', 'e' };
CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
CHECK(json::accept(std::begin(v), std::end(v)));
SaxEventLogger l;
CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
SECTION("from std::array")
{
- std::array<uint8_t, 5> v{{'t', 'r', 'u', 'e'}};
+ std::array<uint8_t, 5> v{ { 't', 'r', 'u', 'e' } };
CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
CHECK(json::accept(std::begin(v), std::end(v)));
SaxEventLogger l;
CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
SECTION("from array")
{
- uint8_t v[] = {'t', 'r', 'u', 'e'}; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+ uint8_t v[] = { 't', 'r', 'u', 'e' }; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
CHECK(json::accept(std::begin(v), std::end(v)));
SaxEventLogger l;
CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
SECTION("from std::string")
{
- std::string v = {'t', 'r', 'u', 'e'};
+ std::string v = { 't', 'r', 'u', 'e' };
CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
CHECK(json::accept(std::begin(v), std::end(v)));
SaxEventLogger l;
CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
SECTION("from std::initializer_list")
{
- std::initializer_list<uint8_t> const v = {'t', 'r', 'u', 'e'};
+ std::initializer_list<uint8_t> const v = { 't', 'r', 'u', 'e' };
CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
CHECK(json::accept(std::begin(v), std::end(v)));
SaxEventLogger l;
CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
SECTION("from std::valarray")
{
- std::valarray<uint8_t> v = {'t', 'r', 'u', 'e'};
+ std::valarray<uint8_t> v = { 't', 'r', 'u', 'e' };
CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
CHECK(json::accept(std::begin(v), std::end(v)));
SaxEventLogger l;
CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
SECTION("with empty range")
@@ -601,7 +601,7 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(1)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(1)" }));
}
SECTION("iterator_input_adapter advances iterators correctly")
@@ -631,7 +631,7 @@
{
SECTION("case 1")
{
- std::array<std::uint8_t, 9> v = {{'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u'}};
+ std::array<std::uint8_t, 9> v = { { '\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u' } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -643,12 +643,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(10)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(10)" }));
}
SECTION("case 2")
{
- std::array<std::uint8_t, 10> v = {{'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u', '1'}};
+ std::array<std::uint8_t, 10> v = { { '\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u', '1' } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -660,12 +660,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(11)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(11)" }));
}
SECTION("case 3")
{
- std::array<std::uint8_t, 17> v = {{'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u', '1', '1', '1', '1', '1', '1', '1', '1'}};
+ std::array<std::uint8_t, 17> v = { { '\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u', '1', '1', '1', '1', '1', '1', '1', '1' } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -677,12 +677,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(18)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(18)" }));
}
SECTION("case 4")
{
- std::array<std::uint8_t, 17> v = {{'\"', 'a', 'a', 'a', 'a', 'a', 'a', 'u', '1', '1', '1', '1', '1', '1', '1', '1', '\\'}};
+ std::array<std::uint8_t, 17> v = { { '\"', 'a', 'a', 'a', 'a', 'a', 'a', 'u', '1', '1', '1', '1', '1', '1', '1', '1', '\\' } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -694,12 +694,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(18)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(18)" }));
}
SECTION("case 5")
{
- std::array<std::uint8_t, 3> v = {{'\"', 0x7F, 0xC1}};
+ std::array<std::uint8_t, 3> v = { { '\"', 0x7F, 0xC1 } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -711,12 +711,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(3)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(3)" }));
}
SECTION("case 6")
{
- std::array<std::uint8_t, 4> v = {{'\"', 0x7F, 0xDF, 0x7F}};
+ std::array<std::uint8_t, 4> v = { { '\"', 0x7F, 0xDF, 0x7F } };
json _;
CHECK_THROWS_WITH_AS(
_ = json::parse(std::begin(v), std::end(v)),
@@ -731,12 +731,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(4)" }));
}
SECTION("case 7")
{
- std::array<std::uint8_t, 4> v = {{'\"', 0x7F, 0xDF, 0xC0}};
+ std::array<std::uint8_t, 4> v = { { '\"', 0x7F, 0xDF, 0xC0 } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -748,12 +748,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(4)" }));
}
SECTION("case 8")
{
- std::array<std::uint8_t, 4> v = {{'\"', 0x7F, 0xE0, 0x9F}};
+ std::array<std::uint8_t, 4> v = { { '\"', 0x7F, 0xE0, 0x9F } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -765,12 +765,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(4)" }));
}
SECTION("case 9")
{
- std::array<std::uint8_t, 4> v = {{'\"', 0x7F, 0xEF, 0xC0}};
+ std::array<std::uint8_t, 4> v = { { '\"', 0x7F, 0xEF, 0xC0 } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -782,12 +782,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(4)" }));
}
SECTION("case 10")
{
- std::array<std::uint8_t, 4> v = {{'\"', 0x7F, 0xED, 0x7F}};
+ std::array<std::uint8_t, 4> v = { { '\"', 0x7F, 0xED, 0x7F } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -799,12 +799,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(4)" }));
}
SECTION("case 11")
{
- std::array<std::uint8_t, 4> v = {{'\"', 0x7F, 0xF0, 0x8F}};
+ std::array<std::uint8_t, 4> v = { { '\"', 0x7F, 0xF0, 0x8F } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -816,12 +816,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(4)" }));
}
SECTION("case 12")
{
- std::array<std::uint8_t, 4> v = {{'\"', 0x7F, 0xF0, 0xC0}};
+ std::array<std::uint8_t, 4> v = { { '\"', 0x7F, 0xF0, 0xC0 } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -833,12 +833,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(4)" }));
}
SECTION("case 13")
{
- std::array<std::uint8_t, 4> v = {{'\"', 0x7F, 0xF3, 0x7F}};
+ std::array<std::uint8_t, 4> v = { { '\"', 0x7F, 0xF3, 0x7F } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -850,12 +850,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(4)" }));
}
SECTION("case 14")
{
- std::array<std::uint8_t, 4> v = {{'\"', 0x7F, 0xF3, 0xC0}};
+ std::array<std::uint8_t, 4> v = { { '\"', 0x7F, 0xF3, 0xC0 } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -867,12 +867,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(4)" }));
}
SECTION("case 15")
{
- std::array<std::uint8_t, 4> v = {{'\"', 0x7F, 0xF4, 0x7F}};
+ std::array<std::uint8_t, 4> v = { { '\"', 0x7F, 0xF4, 0x7F } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -884,12 +884,12 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(4)" }));
}
SECTION("case 16")
{
- std::array<std::uint8_t, 6> v = {{'{', '\"', '\"', ':', '1', '1'}};
+ std::array<std::uint8_t, 6> v = { { '{', '\"', '\"', ':', '1', '1' } };
json _;
CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&);
CHECK(!json::accept(std::begin(v), std::end(v)));
@@ -901,7 +901,7 @@
SaxEventLogger l;
CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 4);
- CHECK(l.events == std::vector<std::string>({"start_object()", "key()", "number_unsigned(11)", "parse_error(7)"}));
+ CHECK(l.events == std::vector<std::string>({ "start_object()", "key()", "number_unsigned(11)", "parse_error(7)" }));
}
}
}
@@ -926,7 +926,7 @@
SaxEventLogger l;
CHECK(!json::sax_parse(bom, &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"parse_error(4)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(4)" }));
}
SECTION("BOM and content")
@@ -939,9 +939,9 @@
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<std::string>({"number_unsigned(1)"}));
+ CHECK(l1.events == std::vector<std::string>({ "number_unsigned(1)" }));
CHECK(l2.events.size() == 1);
- CHECK(l2.events == std::vector<std::string>({"number_unsigned(1)"}));
+ CHECK(l2.events == std::vector<std::string>({ "number_unsigned(1)" }));
}
SECTION("2 byte of BOM")
@@ -962,9 +962,9 @@
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<std::string>({"parse_error(3)"}));
+ CHECK(l1.events == std::vector<std::string>({ "parse_error(3)" }));
CHECK(l2.events.size() == 1);
- CHECK(l2.events == std::vector<std::string>({"parse_error(3)"}));
+ CHECK(l2.events == std::vector<std::string>({ "parse_error(3)" }));
}
SECTION("1 byte of BOM")
@@ -985,9 +985,9 @@
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<std::string>({"parse_error(2)"}));
+ CHECK(l1.events == std::vector<std::string>({ "parse_error(2)" }));
CHECK(l2.events.size() == 1);
- CHECK(l2.events == std::vector<std::string>({"parse_error(2)"}));
+ CHECK(l2.events == std::vector<std::string>({ "parse_error(2)" }));
}
SECTION("variations")
@@ -1019,7 +1019,7 @@
SaxEventLogger l;
CHECK(json::sax_parse(s + "null", &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"null()"}));
+ CHECK(l.events == std::vector<std::string>({ "null()" }));
}
else
{
@@ -1034,15 +1034,15 @@
if (i0 != 0)
{
- CHECK(l.events == std::vector<std::string>({"parse_error(1)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(1)" }));
}
else if (i1 != 0)
{
- CHECK(l.events == std::vector<std::string>({"parse_error(2)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(2)" }));
}
else
{
- CHECK(l.events == std::vector<std::string>({"parse_error(3)"}));
+ CHECK(l.events == std::vector<std::string>({ "parse_error(3)" }));
}
}
}
@@ -1072,43 +1072,47 @@
json::sax_parse(s, &default_logger);
CHECK(default_logger.events.size() == 14);
- CHECK(default_logger.events == std::vector<std::string>({"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<std::string>({ "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<std::string>(
- {"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<std::string>({ "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<std::string>({"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<std::string>({ "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<std::string>({"start_array()"}));
+ CHECK(exit_after_start_array.events == std::vector<std::string>({ "start_array()" }));
}
SECTION("JSON Lines")
@@ -1169,21 +1173,22 @@
std::int32_t,
std::uint32_t)
{
- std::vector<T> const v = {'t', 'r', 'u', 'e'};
+ std::vector<T> const v = { 't', 'r', 'u', 'e' };
CHECK(json::parse(v) == json(true));
CHECK(json::accept(v));
SaxEventLogger l;
CHECK(json::sax_parse(v, &l));
CHECK(l.events.size() == 1);
- CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
+ CHECK(l.events == std::vector<std::string>({ "boolean(true)" }));
}
TEST_CASE_TEMPLATE("deserialization of different character types (UTF-8)", T, char, unsigned char, std::uint8_t)
{
// a star emoji
- std::vector<T> const v =
- {'"', static_cast<T>(0xe2u), static_cast<T>(0xadu), static_cast<T>(0x90u), static_cast<T>(0xefu), static_cast<T>(0xb8u), static_cast<T>(0x8fu), '"'};
+ std::vector<T> const v = {
+ '"', static_cast<T>(0xe2u), static_cast<T>(0xadu), static_cast<T>(0x90u), static_cast<T>(0xefu), static_cast<T>(0xb8u), static_cast<T>(0x8fu), '"'
+ };
CHECK(json::parse(v).dump(-1, ' ', true) == "\"\\u2b50\\ufe0f\"");
CHECK(json::accept(v));
@@ -1195,7 +1200,7 @@
TEST_CASE_TEMPLATE("deserialization of different character types (UTF-16)", T, char16_t, std::uint16_t)
{
// a star emoji
- std::vector<T> const v = {static_cast<T>('"'), static_cast<T>(0x2b50), static_cast<T>(0xfe0f), static_cast<T>('"')};
+ std::vector<T> const v = { static_cast<T>('"'), static_cast<T>(0x2b50), static_cast<T>(0xfe0f), static_cast<T>('"') };
CHECK(json::parse(v).dump(-1, ' ', true) == "\"\\u2b50\\ufe0f\"");
CHECK(json::accept(v));
@@ -1207,7 +1212,7 @@
TEST_CASE_TEMPLATE("deserialization of different character types (UTF-32)", T, char32_t, std::uint32_t)
{
// a star emoji
- std::vector<T> const v = {static_cast<T>('"'), static_cast<T>(0x2b50), static_cast<T>(0xfe0f), static_cast<T>('"')};
+ std::vector<T> const v = { static_cast<T>('"'), static_cast<T>(0x2b50), static_cast<T>(0xfe0f), static_cast<T>('"') };
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 8c79a54..97445bc 100644
--- a/tests/src/unit-diagnostics.cpp
+++ b/tests/src/unit-diagnostics.cpp
@@ -90,8 +90,8 @@
SECTION("Wrong type in update()")
{
- json j = {{"foo", "bar"}};
- json k = {{"bla", 1}};
+ 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",
@@ -104,14 +104,14 @@
{
SECTION("Regression test for https://github.com/nlohmann/json/pull/2562#pullrequestreview-574858448")
{
- CHECK_THROWS_WITH_AS(json({"0", "0"})[1].get<int>(), "[json.exception.type_error.302] (/1) type must be number, but is string", json::type_error);
- CHECK_THROWS_WITH_AS(json({"0", "1"})[1].get<int>(), "[json.exception.type_error.302] (/1) type must be number, but is string", json::type_error);
+ CHECK_THROWS_WITH_AS(json({ "0", "0" })[1].get<int>(), "[json.exception.type_error.302] (/1) type must be number, but is string", json::type_error);
+ CHECK_THROWS_WITH_AS(json({ "0", "1" })[1].get<int>(), "[json.exception.type_error.302] (/1) type must be number, but is string", json::type_error);
}
SECTION("Regression test for https://github.com/nlohmann/json/pull/2562/files/380a613f2b5d32425021129cd1f371ddcfd54ddf#r563259793")
{
json j;
- j["/foo"] = {1, 2, 3};
+ j["/foo"] = { 1, 2, 3 };
CHECK_THROWS_WITH_AS(j.unflatten(), "[json.exception.type_error.315] (/~1foo) values in object must be primitive", json::type_error);
}
@@ -173,7 +173,7 @@
// iterator insert(const_iterator pos, const_iterator first, const_iterator last)
{
json j_arr = json::array();
- json j_objects = {json::object(), json::object()};
+ json j_objects = { json::object(), json::object() };
j_arr.insert(j_arr.begin(), j_objects.begin(), j_objects.end());
json j_obj = json::object();
j_obj["key"] = j_arr;
diff --git a/tests/src/unit-element_access1.cpp b/tests/src/unit-element_access1.cpp
index 0534c2f..c9fd52f 100644
--- a/tests/src/unit-element_access1.cpp
+++ b/tests/src/unit-element_access1.cpp
@@ -16,7 +16,7 @@
{
SECTION("array")
{
- json j = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json j = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
const json j_const = j;
SECTION("access specified element with bounds checking")
@@ -30,7 +30,7 @@
CHECK(j.at(4) == json("string"));
CHECK(j.at(5) == json(42.23));
CHECK(j.at(6) == json::object());
- CHECK(j.at(7) == json({1, 2, 3}));
+ CHECK(j.at(7) == json({ 1, 2, 3 }));
CHECK(j_const.at(0) == json(1));
CHECK(j_const.at(1) == json(1u));
@@ -39,7 +39,7 @@
CHECK(j_const.at(4) == json("string"));
CHECK(j_const.at(5) == json(42.23));
CHECK(j_const.at(6) == json::object());
- CHECK(j_const.at(7) == json({1, 2, 3}));
+ CHECK(j_const.at(7) == json({ 1, 2, 3 }));
}
SECTION("access outside bounds")
@@ -119,8 +119,8 @@
{
CHECK(j.front() == json(1));
CHECK(j_const.front() == json(1));
- CHECK(j.back() == json({1, 2, 3}));
- CHECK(j_const.back() == json({1, 2, 3}));
+ CHECK(j.back() == json({ 1, 2, 3 }));
+ CHECK(j_const.back() == json({ 1, 2, 3 }));
}
SECTION("access specified element")
@@ -134,7 +134,7 @@
CHECK(j[4] == json("string"));
CHECK(j[5] == json(42.23));
CHECK(j[6] == json::object());
- CHECK(j[7] == json({1, 2, 3}));
+ CHECK(j[7] == json({ 1, 2, 3 }));
CHECK(j_const[0] == json(1));
CHECK(j_const[1] == json(1u));
@@ -143,7 +143,7 @@
CHECK(j_const[4] == json("string"));
CHECK(j_const[5] == json(42.23));
CHECK(j_const[6] == json::object());
- CHECK(j_const[7] == json({1, 2, 3}));
+ CHECK(j_const[7] == json({ 1, 2, 3 }));
}
SECTION("access on non-array type")
@@ -164,7 +164,7 @@
{
json j_nonarray;
j_nonarray[3] = 42;
- CHECK(j_nonarray == json({nullptr, nullptr, nullptr, 42}));
+ CHECK(j_nonarray == json({ nullptr, nullptr, nullptr, 42 }));
}
}
@@ -247,47 +247,47 @@
SECTION("remove element by index")
{
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
jarray.erase(0);
- CHECK(jarray == json({1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } }));
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
jarray.erase(1);
- CHECK(jarray == json({1, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } }));
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
jarray.erase(2);
- CHECK(jarray == json({1, 1u, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1, 1u, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } }));
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
jarray.erase(3);
- CHECK(jarray == json({1, 1u, true, "string", 42.23, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1, 1u, true, "string", 42.23, json::object(), { 1, 2, 3 } }));
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
jarray.erase(4);
- CHECK(jarray == json({1, 1u, true, nullptr, 42.23, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1, 1u, true, nullptr, 42.23, json::object(), { 1, 2, 3 } }));
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
jarray.erase(5);
- CHECK(jarray == json({1, 1u, true, nullptr, "string", json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1, 1u, true, nullptr, "string", json::object(), { 1, 2, 3 } }));
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
jarray.erase(6);
- CHECK(jarray == json({1, 1u, true, nullptr, "string", 42.23, {1, 2, 3}}));
+ CHECK(jarray == json({ 1, 1u, true, nullptr, "string", 42.23, { 1, 2, 3 } }));
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
jarray.erase(7);
- CHECK(jarray == json({1, 1u, true, nullptr, "string", 42.23, json::object()}));
+ CHECK(jarray == json({ 1, 1u, true, nullptr, "string", 42.23, json::object() }));
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
CHECK_THROWS_WITH_AS(jarray.erase(8), "[json.exception.out_of_range.401] array index 8 is out of range", json::out_of_range&);
}
}
@@ -297,15 +297,15 @@
SECTION("erase(begin())")
{
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
json::iterator const it2 = jarray.erase(jarray.begin());
- CHECK(jarray == json({1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } }));
CHECK(*it2 == json(1u));
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
json::const_iterator const it2 = jarray.erase(jarray.cbegin());
- CHECK(jarray == json({1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } }));
CHECK(*it2 == json(1u));
}
}
@@ -313,13 +313,13 @@
SECTION("erase(begin(), end())")
{
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
json::iterator it2 = jarray.erase(jarray.begin(), jarray.end());
CHECK(jarray == json::array());
CHECK(it2 == jarray.end());
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
json::const_iterator it2 = jarray.erase(jarray.cbegin(), jarray.cend());
CHECK(jarray == json::array());
CHECK(it2 == jarray.cend());
@@ -329,15 +329,15 @@
SECTION("erase(begin(), begin())")
{
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
json::iterator const it2 = jarray.erase(jarray.begin(), jarray.begin());
- CHECK(jarray == json({1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } }));
CHECK(*it2 == json(1));
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
json::const_iterator const it2 = jarray.erase(jarray.cbegin(), jarray.cbegin());
- CHECK(jarray == json({1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } }));
CHECK(*it2 == json(1));
}
}
@@ -345,17 +345,17 @@
SECTION("erase at offset")
{
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
json::iterator const it = jarray.begin() + 4;
json::iterator const it2 = jarray.erase(it);
- CHECK(jarray == json({1, 1u, true, nullptr, 42.23, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1, 1u, true, nullptr, 42.23, json::object(), { 1, 2, 3 } }));
CHECK(*it2 == json(42.23));
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
json::const_iterator const it = jarray.cbegin() + 4;
json::const_iterator const it2 = jarray.erase(it);
- CHECK(jarray == json({1, 1u, true, nullptr, 42.23, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1, 1u, true, nullptr, 42.23, json::object(), { 1, 2, 3 } }));
CHECK(*it2 == json(42.23));
}
}
@@ -363,15 +363,15 @@
SECTION("erase subrange")
{
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
json::iterator const it2 = jarray.erase(jarray.begin() + 3, jarray.begin() + 6);
- CHECK(jarray == json({1, 1u, true, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1, 1u, true, json::object(), { 1, 2, 3 } }));
CHECK(*it2 == json::object());
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
json::const_iterator const it2 = jarray.erase(jarray.cbegin() + 3, jarray.cbegin() + 6);
- CHECK(jarray == json({1, 1u, true, json::object(), {1, 2, 3}}));
+ CHECK(jarray == json({ 1, 1u, true, json::object(), { 1, 2, 3 } }));
CHECK(*it2 == json::object());
}
}
@@ -379,8 +379,8 @@
SECTION("different arrays")
{
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
- json jarray2 = {"foo", "bar"};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
+ json jarray2 = { "foo", "bar" };
CHECK_THROWS_WITH_AS(jarray.erase(jarray2.begin()),
"[json.exception.invalid_iterator.202] iterator does not fit current value",
@@ -396,8 +396,8 @@
json::invalid_iterator&);
}
{
- json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
- json const jarray2 = {"foo", "bar"};
+ json jarray = { 1, 1u, true, nullptr, "string", 42.23, json::object(), { 1, 2, 3 } };
+ json const jarray2 = { "foo", "bar" };
CHECK_THROWS_WITH_AS(jarray.erase(jarray2.cbegin()),
"[json.exception.invalid_iterator.202] iterator does not fit current value",
@@ -648,13 +648,13 @@
SECTION("binary")
{
{
- json j = json::binary({1, 2, 3});
+ json j = json::binary({ 1, 2, 3 });
json::iterator it = j.erase(j.begin());
CHECK(j.type() == json::value_t::null);
CHECK(it == j.end());
}
{
- json j = json::binary({1, 2, 3});
+ json j = json::binary({ 1, 2, 3 });
json::const_iterator it = j.erase(j.cbegin());
CHECK(j.type() == json::value_t::null);
CHECK(it == j.end());
@@ -822,13 +822,13 @@
SECTION("binary")
{
{
- json j = json::binary({1, 2, 3});
+ json j = json::binary({ 1, 2, 3 });
json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null);
CHECK(it == j.end());
}
{
- json j = json::binary({1, 2, 3});
+ json j = json::binary({ 1, 2, 3 });
json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null);
CHECK(it == j.end());
diff --git a/tests/src/unit-element_access2.cpp b/tests/src/unit-element_access2.cpp
index 9bdbd7f..77ca44a 100644
--- a/tests/src/unit-element_access2.cpp
+++ b/tests/src/unit-element_access2.cpp
@@ -21,14 +21,8 @@
{
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")
@@ -42,7 +36,7 @@
CHECK(j.at("string") == Json("hello world"));
CHECK(j.at("floating") == Json(42.23));
CHECK(j.at("object") == Json::object());
- CHECK(j.at("array") == Json({1, 2, 3}));
+ CHECK(j.at("array") == Json({ 1, 2, 3 }));
CHECK(j_const.at("integer") == Json(1));
CHECK(j_const.at("unsigned") == Json(1u));
@@ -51,7 +45,7 @@
CHECK(j_const.at("string") == Json("hello world"));
CHECK(j_const.at("floating") == Json(42.23));
CHECK(j_const.at("object") == Json::object());
- CHECK(j_const.at("array") == Json({1, 2, 3}));
+ CHECK(j_const.at("array") == Json({ 1, 2, 3 }));
#ifdef JSON_HAS_CPP_17
CHECK(j.at(std::string_view("integer")) == Json(1));
@@ -61,7 +55,7 @@
CHECK(j.at(std::string_view("string")) == Json("hello world"));
CHECK(j.at(std::string_view("floating")) == Json(42.23));
CHECK(j.at(std::string_view("object")) == Json::object());
- CHECK(j.at(std::string_view("array")) == Json({1, 2, 3}));
+ CHECK(j.at(std::string_view("array")) == Json({ 1, 2, 3 }));
CHECK(j_const.at(std::string_view("integer")) == Json(1));
CHECK(j_const.at(std::string_view("unsigned")) == Json(1u));
@@ -70,7 +64,7 @@
CHECK(j_const.at(std::string_view("string")) == Json("hello world"));
CHECK(j_const.at(std::string_view("floating")) == Json(42.23));
CHECK(j_const.at(std::string_view("object")) == Json::object());
- CHECK(j_const.at(std::string_view("array")) == Json({1, 2, 3}));
+ CHECK(j_const.at(std::string_view("array")) == Json({ 1, 2, 3 }));
#endif
}
@@ -236,8 +230,8 @@
CHECK(j.value("string", std::string("bar")) == "hello world");
CHECK(j.value("floating", 12.34) == Approx(42.23));
CHECK(j.value("floating", 12) == 42);
- CHECK(j.value("object", Json({{"foo", "bar"}})) == Json::object());
- CHECK(j.value("array", Json({10, 100})) == Json({1, 2, 3}));
+ CHECK(j.value("object", Json({ { "foo", "bar" } })) == Json::object());
+ CHECK(j.value("array", Json({ 10, 100 })) == Json({ 1, 2, 3 }));
CHECK(j_const.value("integer", 2) == 1);
CHECK(j_const.value("integer", 1.0) == Approx(1));
@@ -248,8 +242,8 @@
CHECK(j_const.value("string", std::string("bar")) == "hello world");
CHECK(j_const.value("floating", 12.34) == Approx(42.23));
CHECK(j_const.value("floating", 12) == 42);
- CHECK(j_const.value("object", Json({{"foo", "bar"}})) == Json::object());
- CHECK(j_const.value("array", Json({10, 100})) == Json({1, 2, 3}));
+ CHECK(j_const.value("object", Json({ { "foo", "bar" } })) == Json::object());
+ CHECK(j_const.value("array", Json({ 10, 100 })) == Json({ 1, 2, 3 }));
#ifdef JSON_HAS_CPP_17
CHECK(j.value(std::string_view("integer"), 2) == 1);
@@ -262,8 +256,8 @@
CHECK(j.value(std::string_view("string"), std::string("bar")) == "hello world");
CHECK(j.value(std::string_view("floating"), 12.34) == Approx(42.23));
CHECK(j.value(std::string_view("floating"), 12) == 42);
- CHECK(j.value(std::string_view("object"), Json({{"foo", "bar"}})) == Json::object());
- CHECK(j.value(std::string_view("array"), Json({10, 100})) == Json({1, 2, 3}));
+ CHECK(j.value(std::string_view("object"), Json({ { "foo", "bar" } })) == Json::object());
+ CHECK(j.value(std::string_view("array"), Json({ 10, 100 })) == Json({ 1, 2, 3 }));
CHECK(j_const.value(std::string_view("integer"), 2) == 1);
CHECK(j_const.value(std::string_view("integer"), 1.0) == Approx(1));
@@ -274,8 +268,8 @@
CHECK(j_const.value(std::string_view("string"), std::string("bar")) == "hello world");
CHECK(j_const.value(std::string_view("floating"), 12.34) == Approx(42.23));
CHECK(j_const.value(std::string_view("floating"), 12) == 42);
- CHECK(j_const.value(std::string_view("object"), Json({{"foo", "bar"}})) == Json::object());
- CHECK(j_const.value(std::string_view("array"), Json({10, 100})) == Json({1, 2, 3}));
+ CHECK(j_const.value(std::string_view("object"), Json({ { "foo", "bar" } })) == Json::object());
+ CHECK(j_const.value(std::string_view("array"), Json({ 10, 100 })) == Json({ 1, 2, 3 }));
#endif
}
@@ -286,16 +280,16 @@
CHECK(j.value("_", false) == false);
CHECK(j.value("_", "bar") == "bar");
CHECK(j.value("_", 12.34) == Approx(12.34));
- CHECK(j.value("_", Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
- CHECK(j.value("_", Json({10, 100})) == Json({10, 100}));
+ CHECK(j.value("_", Json({ { "foo", "bar" } })) == Json({ { "foo", "bar" } }));
+ CHECK(j.value("_", Json({ 10, 100 })) == Json({ 10, 100 }));
CHECK(j_const.value("_", 2) == 2);
CHECK(j_const.value("_", 2u) == 2u);
CHECK(j_const.value("_", false) == false);
CHECK(j_const.value("_", "bar") == "bar");
CHECK(j_const.value("_", 12.34) == Approx(12.34));
- CHECK(j_const.value("_", Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
- CHECK(j_const.value("_", Json({10, 100})) == Json({10, 100}));
+ CHECK(j_const.value("_", Json({ { "foo", "bar" } })) == Json({ { "foo", "bar" } }));
+ CHECK(j_const.value("_", Json({ 10, 100 })) == Json({ 10, 100 }));
#ifdef JSON_HAS_CPP_17
CHECK(j.value(std::string_view("_"), 2) == 2);
@@ -303,16 +297,16 @@
CHECK(j.value(std::string_view("_"), false) == false);
CHECK(j.value(std::string_view("_"), "bar") == "bar");
CHECK(j.value(std::string_view("_"), 12.34) == Approx(12.34));
- CHECK(j.value(std::string_view("_"), Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
- CHECK(j.value(std::string_view("_"), Json({10, 100})) == Json({10, 100}));
+ CHECK(j.value(std::string_view("_"), Json({ { "foo", "bar" } })) == Json({ { "foo", "bar" } }));
+ CHECK(j.value(std::string_view("_"), Json({ 10, 100 })) == Json({ 10, 100 }));
CHECK(j_const.value(std::string_view("_"), 2) == 2);
CHECK(j_const.value(std::string_view("_"), 2u) == 2u);
CHECK(j_const.value(std::string_view("_"), false) == false);
CHECK(j_const.value(std::string_view("_"), "bar") == "bar");
CHECK(j_const.value(std::string_view("_"), 12.34) == Approx(12.34));
- CHECK(j_const.value(std::string_view("_"), Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
- CHECK(j_const.value(std::string_view("_"), Json({10, 100})) == Json({10, 100}));
+ CHECK(j_const.value(std::string_view("_"), Json({ { "foo", "bar" } })) == Json({ { "foo", "bar" } }));
+ CHECK(j_const.value(std::string_view("_"), Json({ 10, 100 })) == Json({ 10, 100 }));
#endif
}
@@ -481,8 +475,8 @@
CHECK(j.value("/string"_json_pointer, std::string("bar")) == "hello world");
CHECK(j.value("/floating"_json_pointer, 12.34) == Approx(42.23));
CHECK(j.value("/floating"_json_pointer, 12) == 42);
- CHECK(j.value("/object"_json_pointer, Json({{"foo", "bar"}})) == Json::object());
- CHECK(j.value("/array"_json_pointer, Json({10, 100})) == Json({1, 2, 3}));
+ CHECK(j.value("/object"_json_pointer, Json({ { "foo", "bar" } })) == Json::object());
+ CHECK(j.value("/array"_json_pointer, Json({ 10, 100 })) == Json({ 1, 2, 3 }));
CHECK(j_const.value("/integer"_json_pointer, 2) == 1);
CHECK(j_const.value("/integer"_json_pointer, 1.0) == Approx(1));
@@ -493,8 +487,8 @@
CHECK(j_const.value("/string"_json_pointer, std::string("bar")) == "hello world");
CHECK(j_const.value("/floating"_json_pointer, 12.34) == Approx(42.23));
CHECK(j_const.value("/floating"_json_pointer, 12) == 42);
- CHECK(j_const.value("/object"_json_pointer, Json({{"foo", "bar"}})) == Json::object());
- CHECK(j_const.value("/array"_json_pointer, Json({10, 100})) == Json({1, 2, 3}));
+ CHECK(j_const.value("/object"_json_pointer, Json({ { "foo", "bar" } })) == Json::object());
+ CHECK(j_const.value("/array"_json_pointer, Json({ 10, 100 })) == Json({ 1, 2, 3 }));
}
SECTION("access on non-object type")
@@ -586,7 +580,7 @@
}
}
- 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());
@@ -616,14 +610,14 @@
CHECK(j.front() == Json(1));
CHECK(j_const.front() == Json(1));
// "array" is last key
- CHECK(j.back() == Json({1, 2, 3}));
- CHECK(j_const.back() == Json({1, 2, 3}));
+ CHECK(j.back() == Json({ 1, 2, 3 }));
+ CHECK(j_const.back() == Json({ 1, 2, 3 }));
}
else
{
// "array" is the smallest key
- CHECK(j.front() == Json({1, 2, 3}));
- CHECK(j_const.front() == Json({1, 2, 3}));
+ CHECK(j.front() == Json({ 1, 2, 3 }));
+ CHECK(j_const.front() == Json({ 1, 2, 3 }));
// "unsigned" is the largest key
CHECK(j.back() == Json(1u));
CHECK(j_const.back() == Json(1u));
@@ -655,7 +649,7 @@
CHECK(j["object"] == Json::object());
CHECK(j[typename Json::object_t::key_type("object")] == j["object"]);
- CHECK(j["array"] == Json({1, 2, 3}));
+ CHECK(j["array"] == Json({ 1, 2, 3 }));
CHECK(j[typename Json::object_t::key_type("array")] == j["array"]);
CHECK(j_const["integer"] == Json(1));
@@ -676,7 +670,7 @@
CHECK(j_const["object"] == Json::object());
CHECK(j_const[typename Json::object_t::key_type("object")] == j["object"]);
- CHECK(j_const["array"] == Json({1, 2, 3}));
+ CHECK(j_const["array"] == Json({ 1, 2, 3 }));
CHECK(j_const[typename Json::object_t::key_type("array")] == j["array"]);
}
@@ -704,7 +698,7 @@
CHECK(j["object"] == Json::object());
CHECK(j[std::string_view("object")] == j["object"]);
- CHECK(j["array"] == Json({1, 2, 3}));
+ CHECK(j["array"] == Json({ 1, 2, 3 }));
CHECK(j[std::string_view("array")] == j["array"]);
CHECK(j_const["integer"] == Json(1));
@@ -725,7 +719,7 @@
CHECK(j_const["object"] == Json::object());
CHECK(j_const[std::string_view("object")] == j["object"]);
- CHECK(j_const["array"] == Json({1, 2, 3}));
+ CHECK(j_const["array"] == Json({ 1, 2, 3 }));
CHECK(j_const[std::string_view("array")] == j["array"]);
}
#endif
@@ -1014,15 +1008,15 @@
SECTION("erase(begin())")
{
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
typename Json::iterator const it2 = jobject.erase(jobject.begin());
- CHECK(jobject == Json({{"b", 1}, {"c", 17u}}));
+ CHECK(jobject == Json({ { "b", 1 }, { "c", 17u } }));
CHECK(*it2 == Json(1));
}
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
typename Json::const_iterator const it2 = jobject.erase(jobject.cbegin());
- CHECK(jobject == Json({{"b", 1}, {"c", 17u}}));
+ CHECK(jobject == Json({ { "b", 1 }, { "c", 17u } }));
CHECK(*it2 == Json(1));
}
}
@@ -1030,13 +1024,13 @@
SECTION("erase(begin(), end())")
{
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
typename Json::iterator it2 = jobject.erase(jobject.begin(), jobject.end());
CHECK(jobject == Json::object());
CHECK(it2 == jobject.end());
}
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
typename Json::const_iterator it2 = jobject.erase(jobject.cbegin(), jobject.cend());
CHECK(jobject == Json::object());
CHECK(it2 == jobject.cend());
@@ -1046,15 +1040,15 @@
SECTION("erase(begin(), begin())")
{
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
typename Json::iterator const it2 = jobject.erase(jobject.begin(), jobject.begin());
- CHECK(jobject == Json({{"a", "a"}, {"b", 1}, {"c", 17u}}));
+ CHECK(jobject == Json({ { "a", "a" }, { "b", 1 }, { "c", 17u } }));
CHECK(*it2 == Json("a"));
}
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
typename Json::const_iterator const it2 = jobject.erase(jobject.cbegin(), jobject.cbegin());
- CHECK(jobject == Json({{"a", "a"}, {"b", 1}, {"c", 17u}}));
+ CHECK(jobject == Json({ { "a", "a" }, { "b", 1 }, { "c", 17u } }));
CHECK(*it2 == Json("a"));
}
}
@@ -1062,17 +1056,17 @@
SECTION("erase at offset")
{
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
typename Json::iterator const it = jobject.find("b");
typename Json::iterator const it2 = jobject.erase(it);
- CHECK(jobject == Json({{"a", "a"}, {"c", 17u}}));
+ CHECK(jobject == Json({ { "a", "a" }, { "c", 17u } }));
CHECK(*it2 == Json(17));
}
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
typename Json::const_iterator const it = jobject.find("b");
typename Json::const_iterator const it2 = jobject.erase(it);
- CHECK(jobject == Json({{"a", "a"}, {"c", 17u}}));
+ CHECK(jobject == Json({ { "a", "a" }, { "c", 17u } }));
CHECK(*it2 == Json(17));
}
}
@@ -1080,15 +1074,15 @@
SECTION("erase subrange")
{
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u }, { "d", false }, { "e", true } };
typename Json::iterator const it2 = jobject.erase(jobject.find("b"), jobject.find("e"));
- CHECK(jobject == Json({{"a", "a"}, {"e", true}}));
+ CHECK(jobject == Json({ { "a", "a" }, { "e", true } }));
CHECK(*it2 == Json(true));
}
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u }, { "d", false }, { "e", true } };
typename Json::const_iterator const it2 = jobject.erase(jobject.find("b"), jobject.find("e"));
- CHECK(jobject == Json({{"a", "a"}, {"e", true}}));
+ CHECK(jobject == Json({ { "a", "a" }, { "e", true } }));
CHECK(*it2 == Json(true));
}
}
@@ -1096,8 +1090,8 @@
SECTION("different objects")
{
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}};
- Json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u }, { "d", false }, { "e", true } };
+ Json jobject2 = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
CHECK_THROWS_WITH_AS(jobject.erase(jobject2.begin()),
"[json.exception.invalid_iterator.202] iterator does not fit current value",
typename Json::invalid_iterator&);
@@ -1112,8 +1106,8 @@
typename Json::invalid_iterator&);
}
{
- Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}};
- Json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}};
+ Json jobject = { { "a", "a" }, { "b", 1 }, { "c", 17u }, { "d", false }, { "e", true } };
+ Json jobject2 = { { "a", "a" }, { "b", 1 }, { "c", 17u } };
CHECK_THROWS_WITH_AS(jobject.erase(jobject2.cbegin()),
"[json.exception.invalid_iterator.202] iterator does not fit current value",
typename Json::invalid_iterator&);
@@ -1210,7 +1204,7 @@
{
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));
@@ -1218,7 +1212,7 @@
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));
@@ -1359,13 +1353,13 @@
{
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);
@@ -1504,14 +1498,14 @@
{
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);
@@ -1651,22 +1645,10 @@
{
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")
{
@@ -1679,16 +1661,16 @@
CHECK(j.value("/not/existing"_json_pointer, false) == false);
CHECK(j.value("/not/existing"_json_pointer, "bar") == "bar");
CHECK(j.value("/not/existing"_json_pointer, 12.34) == Approx(12.34));
- CHECK(j.value("/not/existing"_json_pointer, Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
- CHECK(j.value("/not/existing"_json_pointer, Json({10, 100})) == Json({10, 100}));
+ CHECK(j.value("/not/existing"_json_pointer, Json({ { "foo", "bar" } })) == Json({ { "foo", "bar" } }));
+ CHECK(j.value("/not/existing"_json_pointer, Json({ 10, 100 })) == Json({ 10, 100 }));
CHECK(j_const.value("/not/existing"_json_pointer, 2) == 2);
CHECK(j_const.value("/not/existing"_json_pointer, 2u) == 2u);
CHECK(j_const.value("/not/existing"_json_pointer, false) == false);
CHECK(j_const.value("/not/existing"_json_pointer, "bar") == "bar");
CHECK(j_const.value("/not/existing"_json_pointer, 12.34) == Approx(12.34));
- CHECK(j_const.value("/not/existing"_json_pointer, Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
- CHECK(j_const.value("/not/existing"_json_pointer, Json({10, 100})) == Json({10, 100}));
+ CHECK(j_const.value("/not/existing"_json_pointer, Json({ { "foo", "bar" } })) == Json({ { "foo", "bar" } }));
+ CHECK(j_const.value("/not/existing"_json_pointer, Json({ 10, 100 })) == Json({ 10, 100 }));
}
}
}
@@ -1705,7 +1687,7 @@
// test assumes string_t and object_t::key_type are the same
REQUIRE(std::is_same<string_t, typename Json::object_t::key_type>::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)
@@ -1714,7 +1696,7 @@
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");
diff --git a/tests/src/unit-hash.cpp b/tests/src/unit-hash.cpp
index 65d86bf..411b25f 100644
--- a/tests/src/unit-hash.cpp
+++ b/tests/src/unit-hash.cpp
@@ -43,19 +43,19 @@
// array
hashes.insert(std::hash<json>{}(json::array()));
- hashes.insert(std::hash<json>{}(json::array({1, 2, 3})));
+ hashes.insert(std::hash<json>{}(json::array({ 1, 2, 3 })));
// object
hashes.insert(std::hash<json>{}(json::object()));
- hashes.insert(std::hash<json>{}(json::object({{"foo", "bar"}})));
+ hashes.insert(std::hash<json>{}(json::object({ { "foo", "bar" } })));
// binary
hashes.insert(std::hash<json>{}(json::binary({})));
hashes.insert(std::hash<json>{}(json::binary({}, 0)));
hashes.insert(std::hash<json>{}(json::binary({}, 42)));
- hashes.insert(std::hash<json>{}(json::binary({1, 2, 3})));
- hashes.insert(std::hash<json>{}(json::binary({1, 2, 3}, 0)));
- hashes.insert(std::hash<json>{}(json::binary({1, 2, 3}, 42)));
+ hashes.insert(std::hash<json>{}(json::binary({ 1, 2, 3 })));
+ hashes.insert(std::hash<json>{}(json::binary({ 1, 2, 3 }, 0)));
+ hashes.insert(std::hash<json>{}(json::binary({ 1, 2, 3 }, 42)));
// discarded
hashes.insert(std::hash<json>{}(json(json::value_t::discarded)));
@@ -92,19 +92,19 @@
// array
hashes.insert(std::hash<ordered_json>{}(ordered_json::array()));
- hashes.insert(std::hash<ordered_json>{}(ordered_json::array({1, 2, 3})));
+ hashes.insert(std::hash<ordered_json>{}(ordered_json::array({ 1, 2, 3 })));
// object
hashes.insert(std::hash<ordered_json>{}(ordered_json::object()));
- hashes.insert(std::hash<ordered_json>{}(ordered_json::object({{"foo", "bar"}})));
+ hashes.insert(std::hash<ordered_json>{}(ordered_json::object({ { "foo", "bar" } })));
// binary
hashes.insert(std::hash<ordered_json>{}(ordered_json::binary({})));
hashes.insert(std::hash<ordered_json>{}(ordered_json::binary({}, 0)));
hashes.insert(std::hash<ordered_json>{}(ordered_json::binary({}, 42)));
- hashes.insert(std::hash<ordered_json>{}(ordered_json::binary({1, 2, 3})));
- hashes.insert(std::hash<ordered_json>{}(ordered_json::binary({1, 2, 3}, 0)));
- hashes.insert(std::hash<ordered_json>{}(ordered_json::binary({1, 2, 3}, 42)));
+ hashes.insert(std::hash<ordered_json>{}(ordered_json::binary({ 1, 2, 3 })));
+ hashes.insert(std::hash<ordered_json>{}(ordered_json::binary({ 1, 2, 3 }, 0)));
+ hashes.insert(std::hash<ordered_json>{}(ordered_json::binary({ 1, 2, 3 }, 42)));
// discarded
hashes.insert(std::hash<ordered_json>{}(ordered_json(ordered_json::value_t::discarded)));
diff --git a/tests/src/unit-inspection.cpp b/tests/src/unit-inspection.cpp
index f3403f2..5701f9b 100644
--- a/tests/src/unit-inspection.cpp
+++ b/tests/src/unit-inspection.cpp
@@ -21,7 +21,7 @@
{
SECTION("object")
{
- json const j{{"foo", 1}, {"bar", false}};
+ json const j{ { "foo", 1 }, { "bar", false } };
CHECK(!j.is_null());
CHECK(!j.is_boolean());
CHECK(!j.is_number());
@@ -39,7 +39,7 @@
SECTION("array")
{
- json const j{"foo", 1, 1u, 42.23, false};
+ json const j{ "foo", 1, 1u, 42.23, false };
CHECK(!j.is_null());
CHECK(!j.is_boolean());
CHECK(!j.is_number());
@@ -202,7 +202,8 @@
SECTION("serialization")
{
- json const j{{"object", json::object()}, {"array", {1, 2, 3, 4}}, {"number", 42}, {"boolean", false}, {"null", nullptr}, {"string", "Hello world"}};
+ json const j{ { "object", json::object() }, { "array", { 1, 2, 3, 4 } }, { "number", 42 },
+ { "boolean", false }, { "null", nullptr }, { "string", "Hello world" } };
SECTION("no indent / indent=-1")
{
@@ -242,7 +243,7 @@
// inside the dump() function
CHECK(j.dump(1024).size() == 15472);
- const auto binary = json::binary({1, 2, 3}, 128);
+ const auto binary = json::binary({ 1, 2, 3 }, 128);
CHECK(binary.dump(1024).size() == 2086);
}
@@ -328,7 +329,7 @@
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();
@@ -348,13 +349,13 @@
SECTION("object")
{
- json const j = {{"foo", "bar"}};
+ json const j = { { "foo", "bar" } };
CHECK(j.type() == json::value_t::object);
}
SECTION("array")
{
- json const j = {1, 2, 3, 4};
+ json const j = { 1, 2, 3, 4 };
CHECK(j.type() == json::value_t::array);
}
@@ -400,14 +401,14 @@
SECTION("object")
{
- json const j = {{"foo", "bar"}};
+ json const j = { { "foo", "bar" } };
json::value_t t = j;
CHECK(t == j.type());
}
SECTION("array")
{
- json const j = {1, 2, 3, 4};
+ json const j = { 1, 2, 3, 4 };
json::value_t t = j;
CHECK(t == j.type());
}
diff --git a/tests/src/unit-items.cpp b/tests/src/unit-items.cpp
index f913e93..86a3a7e 100644
--- a/tests/src/unit-items.cpp
+++ b/tests/src/unit-items.cpp
@@ -25,7 +25,7 @@
{
SECTION("value")
{
- json j = {{"A", 1}, {"B", 2}};
+ json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-copy)
@@ -58,7 +58,7 @@
SECTION("reference")
{
- json j = {{"A", 1}, {"B", 2}};
+ json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (auto& i : json::iterator_wrapper(j)) // NOLINT(readability-qualified-auto)
@@ -97,12 +97,12 @@
CHECK(counter == 3);
// check if values where changed
- CHECK(j == json({{"A", 11}, {"B", 22}}));
+ CHECK(j == json({ { "A", 11 }, { "B", 22 } }));
}
SECTION("const value")
{
- json j = {{"A", 1}, {"B", 2}};
+ json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (const auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-copy)
@@ -135,7 +135,7 @@
SECTION("const reference")
{
- json j = {{"A", 1}, {"B", 2}};
+ json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (const auto& i : json::iterator_wrapper(j))
@@ -171,7 +171,7 @@
{
SECTION("value")
{
- const json j = {{"A", 1}, {"B", 2}};
+ const json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-copy)
@@ -204,7 +204,7 @@
SECTION("reference")
{
- const json j = {{"A", 1}, {"B", 2}};
+ const json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (auto& i : json::iterator_wrapper(j)) // NOLINT(readability-qualified-auto)
@@ -237,7 +237,7 @@
SECTION("const value")
{
- const json j = {{"A", 1}, {"B", 2}};
+ const json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (const auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-copy)
@@ -270,7 +270,7 @@
SECTION("const reference")
{
- const json j = {{"A", 1}, {"B", 2}};
+ const json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (const auto& i : json::iterator_wrapper(j))
@@ -306,7 +306,7 @@
{
SECTION("value")
{
- json j = {"A", "B"};
+ json j = { "A", "B" };
int counter = 1;
for (auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-copy)
@@ -339,7 +339,7 @@
SECTION("reference")
{
- json j = {"A", "B"};
+ json j = { "A", "B" };
int counter = 1;
for (auto& i : json::iterator_wrapper(j)) // NOLINT(readability-qualified-auto)
@@ -378,12 +378,12 @@
CHECK(counter == 3);
// check if values where changed
- CHECK(j == json({"AA", "BB"}));
+ CHECK(j == json({ "AA", "BB" }));
}
SECTION("const value")
{
- json j = {"A", "B"};
+ json j = { "A", "B" };
int counter = 1;
for (const auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-copy)
@@ -416,7 +416,7 @@
SECTION("const reference")
{
- json j = {"A", "B"};
+ json j = { "A", "B" };
int counter = 1;
for (const auto& i : json::iterator_wrapper(j))
@@ -452,7 +452,7 @@
{
SECTION("value")
{
- const json j = {"A", "B"};
+ const json j = { "A", "B" };
int counter = 1;
for (auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-copy)
@@ -485,7 +485,7 @@
SECTION("reference")
{
- const json j = {"A", "B"};
+ const json j = { "A", "B" };
int counter = 1;
for (auto& i : json::iterator_wrapper(j)) // NOLINT(readability-qualified-auto)
@@ -518,7 +518,7 @@
SECTION("const value")
{
- const json j = {"A", "B"};
+ const json j = { "A", "B" };
int counter = 1;
for (const auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-copy)
@@ -551,7 +551,7 @@
SECTION("const reference")
{
- const json j = {"A", "B"};
+ const json j = { "A", "B" };
int counter = 1;
for (const auto& i : json::iterator_wrapper(j))
@@ -718,7 +718,7 @@
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)
@@ -751,7 +751,7 @@
SECTION("reference")
{
- json j = {{"A", 1}, {"B", 2}};
+ json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (auto& i : j.items()) // NOLINT(readability-qualified-auto)
@@ -790,12 +790,12 @@
CHECK(counter == 3);
// check if values where changed
- CHECK(j == json({{"A", 11}, {"B", 22}}));
+ CHECK(j == json({ { "A", 11 }, { "B", 22 } }));
}
SECTION("const value")
{
- json j = {{"A", 1}, {"B", 2}};
+ json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (const auto i : j.items()) // NOLINT(performance-for-range-copy)
@@ -828,7 +828,7 @@
SECTION("const reference")
{
- json j = {{"A", 1}, {"B", 2}};
+ json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (const auto& i : j.items())
@@ -862,7 +862,7 @@
#ifdef JSON_HAS_CPP_17
SECTION("structured bindings")
{
- json j = {{"A", 1}, {"B", 2}};
+ json j = { { "A", 1 }, { "B", 2 } };
std::map<std::string, int> m;
@@ -880,7 +880,7 @@
{
SECTION("value")
{
- const json j = {{"A", 1}, {"B", 2}};
+ const json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (auto i : j.items()) // NOLINT(performance-for-range-copy)
@@ -913,7 +913,7 @@
SECTION("reference")
{
- const json j = {{"A", 1}, {"B", 2}};
+ const json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (auto& i : j.items()) // NOLINT(readability-qualified-auto)
@@ -946,7 +946,7 @@
SECTION("const value")
{
- const json j = {{"A", 1}, {"B", 2}};
+ const json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (const auto i : j.items()) // NOLINT(performance-for-range-copy)
@@ -979,7 +979,7 @@
SECTION("const reference")
{
- const json j = {{"A", 1}, {"B", 2}};
+ const json j = { { "A", 1 }, { "B", 2 } };
int counter = 1;
for (const auto& i : j.items())
@@ -1015,7 +1015,7 @@
{
SECTION("value")
{
- json j = {"A", "B"};
+ json j = { "A", "B" };
int counter = 1;
for (auto i : j.items()) // NOLINT(performance-for-range-copy)
@@ -1048,7 +1048,7 @@
SECTION("reference")
{
- json j = {"A", "B"};
+ json j = { "A", "B" };
int counter = 1;
for (auto& i : j.items()) // NOLINT(readability-qualified-auto)
@@ -1087,12 +1087,12 @@
CHECK(counter == 3);
// check if values where changed
- CHECK(j == json({"AA", "BB"}));
+ CHECK(j == json({ "AA", "BB" }));
}
SECTION("const value")
{
- json j = {"A", "B"};
+ json j = { "A", "B" };
int counter = 1;
for (const auto i : j.items()) // NOLINT(performance-for-range-copy)
@@ -1125,7 +1125,7 @@
SECTION("const reference")
{
- json j = {"A", "B"};
+ json j = { "A", "B" };
int counter = 1;
for (const auto& i : j.items())
@@ -1161,7 +1161,7 @@
{
SECTION("value")
{
- const json j = {"A", "B"};
+ const json j = { "A", "B" };
int counter = 1;
for (auto i : j.items()) // NOLINT(performance-for-range-copy)
@@ -1194,7 +1194,7 @@
SECTION("reference")
{
- const json j = {"A", "B"};
+ const json j = { "A", "B" };
int counter = 1;
for (auto& i : j.items()) // NOLINT(readability-qualified-auto)
@@ -1227,7 +1227,7 @@
SECTION("const value")
{
- const json j = {"A", "B"};
+ const json j = { "A", "B" };
int counter = 1;
for (const auto i : j.items()) // NOLINT(performance-for-range-copy)
@@ -1260,7 +1260,7 @@
SECTION("const reference")
{
- const json j = {"A", "B"};
+ const json j = { "A", "B" };
int counter = 1;
for (const auto& i : j.items())
diff --git a/tests/src/unit-iterators1.cpp b/tests/src/unit-iterators1.cpp
index 24669a6..41cd6e8 100644
--- a/tests/src/unit-iterators1.cpp
+++ b/tests/src/unit-iterators1.cpp
@@ -531,7 +531,7 @@
SECTION("array")
{
- json j = {1, 2, 3};
+ json j = { 1, 2, 3 };
json j_const(j);
SECTION("json + begin/end")
@@ -715,7 +715,7 @@
SECTION("object")
{
- json j = {{"A", 1}, {"B", 2}, {"C", 3}};
+ json j = { { "A", 1 }, { "B", 2 }, { "C", 3 } };
json j_const(j);
SECTION("json + begin/end")
@@ -1580,7 +1580,7 @@
}
SECTION("array")
{
- json j = {1, 2, 3};
+ json j = { 1, 2, 3 };
json::const_iterator it = j.begin();
CHECK(it == j.cbegin());
it = j.begin();
@@ -1588,7 +1588,7 @@
}
SECTION("object")
{
- json j = {{"A", 1}, {"B", 2}, {"C", 3}};
+ json j = { { "A", 1 }, { "B", 2 }, { "C", 3 } };
json::const_iterator it = j.begin();
CHECK(it == j.cbegin());
it = j.begin();
diff --git a/tests/src/unit-iterators2.cpp b/tests/src/unit-iterators2.cpp
index 0c8c0e0..8e62627 100644
--- a/tests/src/unit-iterators2.cpp
+++ b/tests/src/unit-iterators2.cpp
@@ -27,7 +27,7 @@
{
SECTION("iterator comparisons")
{
- json j_values = {nullptr, true, 42, 42u, 23.23, {{"one", 1}, {"two", 2}}, {1, 2, 3, 4, 5}, "Hello, world"};
+ json j_values = { nullptr, true, 42, 42u, 23.23, { { "one", 1 }, { "two", 2 } }, { 1, 2, 3, 4, 5 }, "Hello, world" };
for (json& j : j_values)
{
@@ -347,8 +347,8 @@
SECTION("iterator arithmetic")
{
- json j_object = {{"one", 1}, {"two", 2}, {"three", 3}};
- json j_array = {1, 2, 3, 4, 5, 6};
+ json j_object = { { "one", 1 }, { "two", 2 }, { "three", 3 } };
+ json j_array = { 1, 2, 3, 4, 5, 6 };
json j_null = nullptr;
json j_value = 42;
@@ -555,7 +555,7 @@
SECTION("reverse iterator comparisons")
{
- json j_values = {nullptr, true, 42, 42u, 23.23, {{"one", 1}, {"two", 2}}, {1, 2, 3, 4, 5}, "Hello, world"};
+ json j_values = { nullptr, true, 42, 42u, 23.23, { { "one", 1 }, { "two", 2 } }, { 1, 2, 3, 4, 5 }, "Hello, world" };
for (json& j : j_values)
{
@@ -875,8 +875,8 @@
SECTION("reverse iterator arithmetic")
{
- json j_object = {{"one", 1}, {"two", 2}, {"three", 3}};
- json j_array = {1, 2, 3, 4, 5, 6};
+ json j_object = { { "one", 1 }, { "two", 2 }, { "three", 3 } };
+ json j_array = { 1, 2, 3, 4, 5, 6 };
json j_null = nullptr;
json j_value = 42;
@@ -1107,7 +1107,7 @@
{
SECTION("copy")
{
- json j{"foo", "bar"};
+ json j{ "foo", "bar" };
auto j_copied = json::array();
std::ranges::copy(j, std::back_inserter(j_copied));
@@ -1117,7 +1117,7 @@
SECTION("find_if")
{
- json j{1, 3, 2, 4};
+ json j{ 1, 3, 2, 4 };
auto j_even = json::array();
#if JSON_USE_IMPLICIT_CONVERSIONS
@@ -1144,8 +1144,8 @@
{
SECTION("reverse")
{
- json j{1, 2, 3, 4, 5};
- json j_expected{5, 4, 3, 2, 1};
+ json j{ 1, 2, 3, 4, 5 };
+ json j_expected{ 5, 4, 3, 2, 1 };
auto reversed = j | std::views::reverse;
CHECK(std::ranges::equal(reversed, j_expected));
@@ -1154,11 +1154,11 @@
SECTION("transform")
{
json j{
- {"a_key", "a_value"},
- {"b_key", "b_value"},
- {"c_key", "c_value"},
+ { "a_key", "a_value" },
+ { "b_key", "b_value" },
+ { "c_key", "c_value" },
};
- json j_expected{"a_key", "b_key", "c_key"};
+ json j_expected{ "a_key", "b_key", "c_key" };
auto transformed = j.items() | std::views::transform([](const auto& item) {
return item.key();
diff --git a/tests/src/unit-json_patch.cpp b/tests/src/unit-json_patch.cpp
index 68655e4..3004756 100644
--- a/tests/src/unit-json_patch.cpp
+++ b/tests/src/unit-json_patch.cpp
@@ -77,9 +77,9 @@
{
// If removing an element from an array, any elements above the
// specified index are shifted one position to the left.
- json const doc = {1, 2, 3, 4};
- json const patch = {{{"op", "remove"}, {"path", "/1"}}};
- CHECK(doc.patch(patch) == json({1, 3, 4}));
+ json const doc = { 1, 2, 3, 4 };
+ json const patch = { { { "op", "remove" }, { "path", "/1" } } };
+ CHECK(doc.patch(patch) == json({ 1, 3, 4 }));
}
SECTION("A.1. Adding an Object Member")
@@ -529,7 +529,7 @@
)"_json;
// The resulting JSON document:
- json expected = {1, 2, 3};
+ json expected = { 1, 2, 3 };
// check if patched value is as expected
CHECK(doc.patch(patch) == expected);
@@ -545,7 +545,7 @@
// exactly the number of elements in the array which is legal.
// An example target JSON document:
- json const doc = {0, 1, 2};
+ json const doc = { 0, 1, 2 };
// A JSON Patch document:
json const patch = R"(
@@ -555,7 +555,7 @@
)"_json;
// The resulting JSON document:
- json expected = {0, 1, 2, 3};
+ json expected = { 0, 1, 2, 3 };
// check if patched value is as expected
CHECK(doc.patch(patch) == expected);
@@ -611,7 +611,7 @@
SECTION("replace")
{
json const j = "string";
- json const patch = {{{"op", "replace"}, {"path", ""}, {"value", 1}}};
+ json const patch = { { { "op", "replace" }, { "path", "" }, { "value", 1 } } };
CHECK(j.patch(patch) == json(1));
}
@@ -640,13 +640,13 @@
}
{
// a JSON value
- json j = {"good", "bad", "ugly"};
+ json j = { "good", "bad", "ugly" };
// a JSON pointer
auto ptr = json::json_pointer("/2");
// use to access elements
- j[ptr] = {{"it", "cattivo"}};
+ j[ptr] = { { "it", "cattivo" } };
CHECK(j == R"(["good","bad",{"it":"cattivo"}])"_json);
// use user-defined string literal
@@ -666,7 +666,7 @@
SECTION("not an array")
{
json const j;
- json const patch = {{"op", "add"}, {"path", ""}, {"value", 1}};
+ 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&);
@@ -675,7 +675,7 @@
SECTION("not an array of objects")
{
json const j;
- json const patch = {"op", "add", "path", "", "value", 1};
+ 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",
@@ -690,7 +690,7 @@
SECTION("missing 'op'")
{
json const j;
- json const patch = {{{"foo", "bar"}}};
+ json const patch = { { { "foo", "bar" } } };
#if JSON_DIAGNOSTICS
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation must have member 'op'", json::parse_error&);
#else
@@ -701,7 +701,7 @@
SECTION("non-string 'op'")
{
json const j;
- json const patch = {{{"op", 1}}};
+ 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'",
@@ -716,7 +716,7 @@
SECTION("invalid operation")
{
json const j;
- json const patch = {{{"op", "foo"}, {"path", ""}}};
+ json const patch = { { { "op", "foo" }, { "path", "" } } };
#if JSON_DIAGNOSTICS
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation value 'foo' is invalid", json::parse_error&);
#else
@@ -730,7 +730,7 @@
SECTION("missing 'path'")
{
json const j;
- json const patch = {{{"op", "add"}}};
+ 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'",
@@ -745,7 +745,7 @@
SECTION("non-string 'path'")
{
json const j;
- json const patch = {{{"op", "add"}, {"path", 1}}};
+ 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'",
@@ -760,7 +760,7 @@
SECTION("missing 'value'")
{
json const j;
- json const patch = {{{"op", "add"}, {"path", ""}}};
+ 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'",
@@ -774,8 +774,8 @@
SECTION("invalid array index")
{
- json const j = {1, 2};
- json const patch = {{{"op", "add"}, {"path", "/4"}, {"value", 4}}};
+ json const j = { 1, 2 };
+ json const patch = { { { "op", "add" }, { "path", "/4" }, { "value", 4 } } };
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.out_of_range.401] array index 4 is out of range", json::out_of_range&);
}
}
@@ -785,7 +785,7 @@
SECTION("missing 'path'")
{
json const j;
- json const patch = {{{"op", "remove"}}};
+ 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'",
@@ -800,7 +800,7 @@
SECTION("non-string 'path'")
{
json const j;
- json const patch = {{{"op", "remove"}, {"path", 1}}};
+ 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'",
@@ -814,22 +814,22 @@
SECTION("nonexisting target location (array)")
{
- json const j = {1, 2, 3};
- json const patch = {{{"op", "remove"}, {"path", "/17"}}};
+ json const j = { 1, 2, 3 };
+ json const patch = { { { "op", "remove" }, { "path", "/17" } } };
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.out_of_range.401] array index 17 is out of range", json::out_of_range&);
}
SECTION("nonexisting target location (object)")
{
- json const j = {{"foo", 1}, {"bar", 2}};
- json const patch = {{{"op", "remove"}, {"path", "/baz"}}};
+ json const j = { { "foo", 1 }, { "bar", 2 } };
+ json const patch = { { { "op", "remove" }, { "path", "/baz" } } };
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.out_of_range.403] key 'baz' not found", json::out_of_range&);
}
SECTION("root element as target location")
{
json const j = "string";
- json const patch = {{{"op", "remove"}, {"path", ""}}};
+ json const patch = { { { "op", "remove" }, { "path", "" } } };
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.out_of_range.405] JSON pointer has no parent", json::out_of_range&);
}
}
@@ -839,7 +839,7 @@
SECTION("missing 'path'")
{
json const j;
- json const patch = {{{"op", "replace"}}};
+ 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'",
@@ -854,7 +854,7 @@
SECTION("non-string 'path'")
{
json const j;
- json const patch = {{{"op", "replace"}, {"path", 1}}};
+ 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'",
@@ -869,7 +869,7 @@
SECTION("missing 'value'")
{
json const j;
- json const patch = {{{"op", "replace"}, {"path", ""}}};
+ 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'",
@@ -883,15 +883,15 @@
SECTION("nonexisting target location (array)")
{
- json const j = {1, 2, 3};
- json const patch = {{{"op", "replace"}, {"path", "/17"}, {"value", 19}}};
+ json const j = { 1, 2, 3 };
+ json const patch = { { { "op", "replace" }, { "path", "/17" }, { "value", 19 } } };
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.out_of_range.401] array index 17 is out of range", json::out_of_range&);
}
SECTION("nonexisting target location (object)")
{
- json const j = {{"foo", 1}, {"bar", 2}};
- json const patch = {{{"op", "replace"}, {"path", "/baz"}, {"value", 3}}};
+ json const j = { { "foo", 1 }, { "bar", 2 } };
+ json const patch = { { { "op", "replace" }, { "path", "/baz" }, { "value", 3 } } };
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.out_of_range.403] key 'baz' not found", json::out_of_range&);
}
}
@@ -901,7 +901,7 @@
SECTION("missing 'path'")
{
json const j;
- json const patch = {{{"op", "move"}}};
+ 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'",
@@ -916,7 +916,7 @@
SECTION("non-string 'path'")
{
json const j;
- json const patch = {{{"op", "move"}, {"path", 1}}};
+ 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'",
@@ -931,7 +931,7 @@
SECTION("missing 'from'")
{
json const j;
- json const patch = {{{"op", "move"}, {"path", ""}}};
+ 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),
@@ -947,7 +947,7 @@
SECTION("non-string 'from'")
{
json const j;
- json const patch = {{{"op", "move"}, {"path", ""}, {"from", 1}}};
+ 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),
@@ -962,15 +962,15 @@
SECTION("nonexisting from location (array)")
{
- json const j = {1, 2, 3};
- json const patch = {{{"op", "move"}, {"path", "/0"}, {"from", "/5"}}};
+ json const j = { 1, 2, 3 };
+ json const patch = { { { "op", "move" }, { "path", "/0" }, { "from", "/5" } } };
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.out_of_range.401] array index 5 is out of range", json::out_of_range&);
}
SECTION("nonexisting from location (object)")
{
- json const j = {{"foo", 1}, {"bar", 2}};
- json const patch = {{{"op", "move"}, {"path", "/baz"}, {"from", "/baz"}}};
+ json const j = { { "foo", 1 }, { "bar", 2 } };
+ json const patch = { { { "op", "move" }, { "path", "/baz" }, { "from", "/baz" } } };
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.out_of_range.403] key 'baz' not found", json::out_of_range&);
}
}
@@ -980,7 +980,7 @@
SECTION("missing 'path'")
{
json const j;
- json const patch = {{{"op", "copy"}}};
+ 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'",
@@ -995,7 +995,7 @@
SECTION("non-string 'path'")
{
json const j;
- json const patch = {{{"op", "copy"}, {"path", 1}}};
+ 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'",
@@ -1010,7 +1010,7 @@
SECTION("missing 'from'")
{
json const j;
- json const patch = {{{"op", "copy"}, {"path", ""}}};
+ 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'",
@@ -1025,7 +1025,7 @@
SECTION("non-string 'from'")
{
json const j;
- json const patch = {{{"op", "copy"}, {"path", ""}, {"from", 1}}};
+ 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'",
@@ -1039,15 +1039,15 @@
SECTION("nonexisting from location (array)")
{
- json const j = {1, 2, 3};
- json const patch = {{{"op", "copy"}, {"path", "/0"}, {"from", "/5"}}};
+ json const j = { 1, 2, 3 };
+ json const patch = { { { "op", "copy" }, { "path", "/0" }, { "from", "/5" } } };
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.out_of_range.401] array index 5 is out of range", json::out_of_range&);
}
SECTION("nonexisting from location (object)")
{
- json const j = {{"foo", 1}, {"bar", 2}};
- json const patch = {{{"op", "copy"}, {"path", "/fob"}, {"from", "/baz"}}};
+ json const j = { { "foo", 1 }, { "bar", 2 } };
+ json const patch = { { { "op", "copy" }, { "path", "/fob" }, { "from", "/baz" } } };
CHECK_THROWS_WITH_AS(j.patch(patch), "[json.exception.out_of_range.403] key 'baz' not found", json::out_of_range&);
}
}
@@ -1057,7 +1057,7 @@
SECTION("missing 'path'")
{
json const j;
- json const patch = {{{"op", "test"}}};
+ 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'",
@@ -1072,7 +1072,7 @@
SECTION("non-string 'path'")
{
json const j;
- json const patch = {{{"op", "test"}, {"path", 1}}};
+ 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'",
@@ -1087,7 +1087,7 @@
SECTION("missing 'value'")
{
json const j;
- json const patch = {{{"op", "test"}, {"path", ""}}};
+ 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'",
@@ -1347,7 +1347,7 @@
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 653846b..4d4be14 100644
--- a/tests/src/unit-json_pointer.cpp
+++ b/tests/src/unit-json_pointer.cpp
@@ -40,7 +40,7 @@
SECTION("array index error")
{
- json v = {1, 2, 3, 4};
+ 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&);
}
@@ -131,15 +131,15 @@
CHECK(!j.contains(json::json_pointer("/a/c/1")));
CHECK_NOTHROW(j[json::json_pointer("/a/c/1")] = 42);
- CHECK(j["a"]["c"] == json({nullptr, 42}));
+ CHECK(j["a"]["c"] == json({ nullptr, 42 }));
CHECK(j.contains(json::json_pointer("/a/c/1")));
CHECK(!j.contains(json::json_pointer("/a/d/-")));
CHECK_NOTHROW(j[json::json_pointer("/a/d/-")] = 42);
CHECK(!j.contains(json::json_pointer("/a/d/-")));
- CHECK(j["a"]["d"] == json::array({42}));
+ CHECK(j["a"]["d"] == json::array({ 42 }));
// "/a/b" works for JSON {"a": {"b": 42}}
- CHECK(json({{"a", {{"b", 42}}}})[json::json_pointer("/a/b")] == json(42));
+ CHECK(json({ { "a", { { "b", 42 } } } })[json::json_pointer("/a/b")] == json(42));
// unresolved access
json j_primitive = 1;
@@ -251,7 +251,7 @@
{
SECTION("nonconst access")
{
- json j = {1, 2, 3};
+ json j = { 1, 2, 3 };
const json j_const = j;
// check reading access
@@ -269,7 +269,7 @@
// assign to nonexisting index (with gap)
j["/5"_json_pointer] = 55;
- CHECK(j == json({1, 13, 3, 33, nullptr, 55}));
+ CHECK(j == json({ 1, 13, 3, 33, nullptr, 55 }));
// error with leading 0
CHECK_THROWS_WITH_AS(j["/01"_json_pointer],
@@ -353,13 +353,13 @@
CHECK(!j_const.contains("/one"_json_pointer));
CHECK(!j_const.contains("/one"_json_pointer));
- CHECK_THROWS_WITH_AS(json({{"/list/0", 1}, {"/list/1", 2}, {"/list/three", 3}}).unflatten(),
+ CHECK_THROWS_WITH_AS(json({ { "/list/0", 1 }, { "/list/1", 2 }, { "/list/three", 3 } }).unflatten(),
"[json.exception.parse_error.109] parse error: array index 'three' is not a number",
json::parse_error&);
// assign to "-"
j["/-"_json_pointer] = 99;
- CHECK(j == json({1, 13, 3, 33, nullptr, 55, 99}));
+ 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&);
@@ -373,7 +373,7 @@
SECTION("const access")
{
- const json j = {1, 2, 3};
+ const json j = { 1, 2, 3 };
// check reading access
CHECK(j["/0"_json_pointer] == j[0]);
@@ -397,28 +397,29 @@
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 = { { "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_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);
@@ -431,15 +432,17 @@
// error for nonprimitve values
#if JSON_DIAGNOSTICS
- CHECK_THROWS_WITH_AS(json({{"/1", {1, 2, 3}}}).unflatten(),
+ 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&);
+ 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}};
+ 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&);
// explicit roundtrip check
@@ -464,7 +467,7 @@
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;
@@ -496,14 +499,15 @@
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;
@@ -555,14 +559,15 @@
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;
@@ -602,7 +607,7 @@
{
const char* ptr_cpstring = "/foo/bar";
const char ptr_castring[] = "/foo/bar"; // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays)
- std::string ptr_string{"/foo/bar"};
+ std::string ptr_string{ "/foo/bar" };
auto ptr1 = json::json_pointer(ptr_string);
auto ptr2 = json::json_pointer(ptr_string);
@@ -694,10 +699,10 @@
CHECK(std::is_same<json_ptr_str::string_t, json_ptr_j::string_t>::value);
CHECK(std::is_same<json_ptr_str::string_t, json_ptr_oj::string_t>::value);
- std::string const ptr_string{"/foo/0"};
- json_ptr_str ptr{ptr_string};
- json_ptr_j ptr_j{ptr_string};
- json_ptr_oj ptr_oj{ptr_string};
+ std::string const ptr_string{ "/foo/0" };
+ json_ptr_str ptr{ ptr_string };
+ json_ptr_j ptr_j{ ptr_string };
+ json_ptr_oj ptr_oj{ ptr_string };
CHECK(j.contains(ptr));
CHECK(j.contains(ptr_j));
diff --git a/tests/src/unit-meta.cpp b/tests/src/unit-meta.cpp
index 0be2347..1e03344 100644
--- a/tests/src/unit-meta.cpp
+++ b/tests/src/unit-meta.cpp
@@ -20,7 +20,7 @@
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 84ffe88..2059bd2 100644
--- a/tests/src/unit-modifiers.cpp
+++ b/tests/src/unit-modifiers.cpp
@@ -51,7 +51,7 @@
SECTION("filled array")
{
- json j = {1, 2, 3};
+ json j = { 1, 2, 3 };
json const k = j;
j.clear();
@@ -76,7 +76,7 @@
SECTION("filled object")
{
- json j = {{"one", 1}, {"two", 2}, {"three", 3}};
+ json j = { { "one", 1 }, { "two", 2 }, { "three", 3 } };
json const k = j;
j.clear();
@@ -101,7 +101,7 @@
SECTION("filled binary")
{
- json j = json::binary({1, 2, 3, 4, 5});
+ json j = json::binary({ 1, 2, 3, 4, 5 });
json const k = j;
j.clear();
@@ -164,15 +164,15 @@
j.push_back(1);
j.push_back(2);
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1, 2}));
+ CHECK(j == json({ 1, 2 }));
}
SECTION("array")
{
- json j = {1, 2, 3};
+ json j = { 1, 2, 3 };
j.push_back("Hello");
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1, 2, 3, "Hello"}));
+ CHECK(j == json({ 1, 2, 3, "Hello" }));
}
SECTION("other type")
@@ -191,16 +191,16 @@
j.push_back(k);
j.push_back(k);
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1, 1}));
+ CHECK(j == json({ 1, 1 }));
}
SECTION("array")
{
- json j = {1, 2, 3};
+ json j = { 1, 2, 3 };
json const k("Hello");
j.push_back(k);
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1, 2, 3, "Hello"}));
+ CHECK(j == json({ 1, 2, 3, "Hello" }));
}
SECTION("other type")
@@ -217,8 +217,8 @@
SECTION("null")
{
json j;
- j.push_back(json::object_t::value_type({"one", 1}));
- j.push_back(json::object_t::value_type({"two", 2}));
+ j.push_back(json::object_t::value_type({ "one", 1 }));
+ j.push_back(json::object_t::value_type({ "two", 2 }));
CHECK(j.type() == json::value_t::object);
CHECK(j.size() == 2);
CHECK(j["one"] == json(1));
@@ -228,8 +228,8 @@
SECTION("object")
{
json j(json::value_t::object);
- j.push_back(json::object_t::value_type({"one", 1}));
- j.push_back(json::object_t::value_type({"two", 2}));
+ j.push_back(json::object_t::value_type({ "one", 1 }));
+ j.push_back(json::object_t::value_type({ "two", 2 }));
CHECK(j.size() == 2);
CHECK(j["one"] == json(1));
CHECK(j["two"] == json(2));
@@ -239,7 +239,7 @@
{
json j = 1;
json const k("Hello");
- CHECK_THROWS_WITH_AS(j.push_back(json::object_t::value_type({"one", 1})),
+ 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&);
}
@@ -250,35 +250,35 @@
SECTION("null")
{
json j;
- j.push_back({"foo", "bar"});
- CHECK(j == json::array({{"foo", "bar"}}));
+ j.push_back({ "foo", "bar" });
+ CHECK(j == json::array({ { "foo", "bar" } }));
json k;
- k.push_back({1, 2, 3});
- CHECK(k == json::array({{1, 2, 3}}));
+ k.push_back({ 1, 2, 3 });
+ CHECK(k == json::array({ { 1, 2, 3 } }));
}
SECTION("array")
{
- json j = {1, 2, 3};
- j.push_back({"foo", "bar"});
- CHECK(j == json({1, 2, 3, {"foo", "bar"}}));
+ json j = { 1, 2, 3 };
+ j.push_back({ "foo", "bar" });
+ CHECK(j == json({ 1, 2, 3, { "foo", "bar" } }));
- json k = {1, 2, 3};
- k.push_back({1, 2, 3});
- CHECK(k == json({1, 2, 3, {1, 2, 3}}));
+ json k = { 1, 2, 3 };
+ k.push_back({ 1, 2, 3 });
+ CHECK(k == json({ 1, 2, 3, { 1, 2, 3 } }));
}
SECTION("object")
{
- json j = {{"key1", 1}};
- j.push_back({"key2", "bar"});
- CHECK(j == json({{"key1", 1}, {"key2", "bar"}}));
+ json j = { { "key1", 1 } };
+ j.push_back({ "key2", "bar" });
+ CHECK(j == json({ { "key1", 1 }, { "key2", "bar" } }));
// invalid values (no string/val pair)
- CHECK_THROWS_WITH_AS(j.push_back({1}), "[json.exception.type_error.308] cannot use push_back() with object", json::type_error&);
- CHECK_THROWS_WITH_AS(j.push_back({1, 2}), "[json.exception.type_error.308] cannot use push_back() with object", json::type_error&);
- CHECK_THROWS_WITH_AS(j.push_back({1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object", json::type_error&);
+ CHECK_THROWS_WITH_AS(j.push_back({ 1 }), "[json.exception.type_error.308] cannot use push_back() with object", json::type_error&);
+ CHECK_THROWS_WITH_AS(j.push_back({ 1, 2 }), "[json.exception.type_error.308] cannot use push_back() with object", json::type_error&);
+ CHECK_THROWS_WITH_AS(j.push_back({ 1, 2, 3, 4 }), "[json.exception.type_error.308] cannot use push_back() with object", json::type_error&);
}
}
}
@@ -295,25 +295,25 @@
auto& x2 = j.emplace_back(2);
CHECK(x2 == 2);
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1, 2}));
+ CHECK(j == json({ 1, 2 }));
}
SECTION("array")
{
- json j = {1, 2, 3};
+ json j = { 1, 2, 3 };
auto& x = j.emplace_back("Hello");
CHECK(x == "Hello");
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1, 2, 3, "Hello"}));
+ CHECK(j == json({ 1, 2, 3, "Hello" }));
}
SECTION("multiple values")
{
json j;
auto& x = j.emplace_back(3, "foo");
- CHECK(x == json({"foo", "foo", "foo"}));
+ CHECK(x == json({ "foo", "foo", "foo" }));
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({{"foo", "foo", "foo"}}));
+ CHECK(j == json({ { "foo", "foo", "foo" } }));
}
}
@@ -352,13 +352,13 @@
CHECK(*res3.first == "bam");
// the final object
- CHECK(j == json({{"baz", "bam"}, {"foo", "bar"}}));
+ CHECK(j == json({ { "baz", "bam" }, { "foo", "bar" } }));
}
SECTION("object")
{
// start with an object
- json j = {{"foo", "bar"}};
+ json j = { { "foo", "bar" } };
// add a new key
auto res1 = j.emplace("baz", "bam");
@@ -371,7 +371,7 @@
CHECK(*res2.first == "bar");
// check final object
- CHECK(j == json({{"baz", "bam"}, {"foo", "bar"}}));
+ CHECK(j == json({ { "baz", "bam" }, { "foo", "bar" } }));
}
}
@@ -394,15 +394,15 @@
j += 1;
j += 2;
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1, 2}));
+ CHECK(j == json({ 1, 2 }));
}
SECTION("array")
{
- json j = {1, 2, 3};
+ json j = { 1, 2, 3 };
j += "Hello";
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1, 2, 3, "Hello"}));
+ CHECK(j == json({ 1, 2, 3, "Hello" }));
}
SECTION("other type")
@@ -421,16 +421,16 @@
j += k;
j += k;
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1, 1}));
+ CHECK(j == json({ 1, 1 }));
}
SECTION("array")
{
- json j = {1, 2, 3};
+ json j = { 1, 2, 3 };
json const k("Hello");
j += k;
CHECK(j.type() == json::value_t::array);
- CHECK(j == json({1, 2, 3, "Hello"}));
+ CHECK(j == json({ 1, 2, 3, "Hello" }));
}
SECTION("other type")
@@ -447,8 +447,8 @@
SECTION("null")
{
json j;
- j += json::object_t::value_type({"one", 1});
- j += json::object_t::value_type({"two", 2});
+ j += json::object_t::value_type({ "one", 1 });
+ j += json::object_t::value_type({ "two", 2 });
CHECK(j.type() == json::value_t::object);
CHECK(j.size() == 2);
CHECK(j["one"] == json(1));
@@ -458,8 +458,8 @@
SECTION("object")
{
json j(json::value_t::object);
- j += json::object_t::value_type({"one", 1});
- j += json::object_t::value_type({"two", 2});
+ j += json::object_t::value_type({ "one", 1 });
+ j += json::object_t::value_type({ "two", 2 });
CHECK(j.size() == 2);
CHECK(j["one"] == json(1));
CHECK(j["two"] == json(2));
@@ -469,7 +469,7 @@
{
json j = 1;
json const k("Hello");
- CHECK_THROWS_WITH_AS(j += json::object_t::value_type({"one", 1}),
+ 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&);
}
@@ -480,40 +480,40 @@
SECTION("null")
{
json j;
- j += {"foo", "bar"};
- CHECK(j == json::array({{"foo", "bar"}}));
+ j += { "foo", "bar" };
+ CHECK(j == json::array({ { "foo", "bar" } }));
json k;
- k += {1, 2, 3};
- CHECK(k == json::array({{1, 2, 3}}));
+ k += { 1, 2, 3 };
+ CHECK(k == json::array({ { 1, 2, 3 } }));
}
SECTION("array")
{
- json j = {1, 2, 3};
- j += {"foo", "bar"};
- CHECK(j == json({1, 2, 3, {"foo", "bar"}}));
+ json j = { 1, 2, 3 };
+ j += { "foo", "bar" };
+ CHECK(j == json({ 1, 2, 3, { "foo", "bar" } }));
- json k = {1, 2, 3};
- k += {1, 2, 3};
- CHECK(k == json({1, 2, 3, {1, 2, 3}}));
+ json k = { 1, 2, 3 };
+ k += { 1, 2, 3 };
+ CHECK(k == json({ 1, 2, 3, { 1, 2, 3 } }));
}
SECTION("object")
{
- json j = {{"key1", 1}};
- j += {"key2", "bar"};
- CHECK(j == json({{"key1", 1}, {"key2", "bar"}}));
+ json j = { { "key1", 1 } };
+ j += { "key2", "bar" };
+ CHECK(j == json({ { "key1", 1 }, { "key2", "bar" } }));
- json k = {{"key1", 1}};
- CHECK_THROWS_WITH_AS((k += {1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object", json::type_error&);
+ json k = { { "key1", 1 } };
+ CHECK_THROWS_WITH_AS((k += { 1, 2, 3, 4 }), "[json.exception.type_error.308] cannot use push_back() with object", json::type_error&);
}
}
}
SECTION("insert()")
{
- json j_array = {1, 2, 3, 4};
+ json j_array = { 1, 2, 3, 4 };
json j_value = 5;
SECTION("value at position")
@@ -524,7 +524,7 @@
CHECK(j_array.size() == 5);
CHECK(*it == j_value);
CHECK(j_array.begin() == it);
- CHECK(j_array == json({5, 1, 2, 3, 4}));
+ CHECK(j_array == json({ 5, 1, 2, 3, 4 }));
}
SECTION("insert in the middle")
@@ -533,7 +533,7 @@
CHECK(j_array.size() == 5);
CHECK(*it == j_value);
CHECK((it - j_array.begin()) == 2);
- CHECK(j_array == json({1, 2, 5, 3, 4}));
+ CHECK(j_array == json({ 1, 2, 5, 3, 4 }));
}
SECTION("insert before end()")
@@ -542,7 +542,7 @@
CHECK(j_array.size() == 5);
CHECK(*it == j_value);
CHECK((j_array.end() - it) == 1);
- CHECK(j_array == json({1, 2, 3, 4, 5}));
+ CHECK(j_array == json({ 1, 2, 3, 4, 5 }));
}
}
@@ -554,7 +554,7 @@
CHECK(j_array.size() == 5);
CHECK(*it == j_value);
CHECK(j_array.begin() == it);
- CHECK(j_array == json({5, 1, 2, 3, 4}));
+ CHECK(j_array == json({ 5, 1, 2, 3, 4 }));
}
SECTION("insert in the middle")
@@ -563,7 +563,7 @@
CHECK(j_array.size() == 5);
CHECK(*it == j_value);
CHECK((it - j_array.begin()) == 2);
- CHECK(j_array == json({1, 2, 5, 3, 4}));
+ CHECK(j_array == json({ 1, 2, 5, 3, 4 }));
}
SECTION("insert before end()")
@@ -572,7 +572,7 @@
CHECK(j_array.size() == 5);
CHECK(*it == j_value);
CHECK((j_array.end() - it) == 1);
- CHECK(j_array == json({1, 2, 3, 4, 5}));
+ CHECK(j_array == json({ 1, 2, 3, 4, 5 }));
}
}
@@ -584,7 +584,7 @@
CHECK(j_array.size() == 7);
CHECK(*it == j_value);
CHECK(j_array.begin() == it);
- CHECK(j_array == json({5, 5, 5, 1, 2, 3, 4}));
+ CHECK(j_array == json({ 5, 5, 5, 1, 2, 3, 4 }));
}
SECTION("insert in the middle")
@@ -593,7 +593,7 @@
CHECK(j_array.size() == 7);
CHECK(*it == j_value);
CHECK((it - j_array.begin()) == 2);
- CHECK(j_array == json({1, 2, 5, 5, 5, 3, 4}));
+ CHECK(j_array == json({ 1, 2, 5, 5, 5, 3, 4 }));
}
SECTION("insert before end()")
@@ -602,7 +602,7 @@
CHECK(j_array.size() == 7);
CHECK(*it == j_value);
CHECK((j_array.end() - it) == 3);
- CHECK(j_array == json({1, 2, 3, 4, 5, 5, 5}));
+ CHECK(j_array == json({ 1, 2, 3, 4, 5, 5, 5 }));
}
SECTION("insert nothing (count = 0)")
@@ -612,13 +612,13 @@
// the returned iterator points to the first inserted element;
// there were 4 elements, so it should point to the 5th
CHECK(it == j_array.begin() + 4);
- CHECK(j_array == json({1, 2, 3, 4}));
+ CHECK(j_array == json({ 1, 2, 3, 4 }));
}
}
SECTION("range for array")
{
- json j_other_array = {"first", "second"};
+ json j_other_array = { "first", "second" };
SECTION("proper usage")
{
@@ -626,7 +626,7 @@
CHECK(j_array.size() == 6);
CHECK(*it == *j_other_array.begin());
CHECK((j_array.end() - it) == 2);
- CHECK(j_array == json({1, 2, 3, 4, "first", "second"}));
+ CHECK(j_array == json({ 1, 2, 3, 4, "first", "second" }));
}
SECTION("empty range")
@@ -634,12 +634,12 @@
auto it = j_array.insert(j_array.end(), j_other_array.begin(), j_other_array.begin());
CHECK(j_array.size() == 4);
CHECK(it == j_array.end());
- CHECK(j_array == json({1, 2, 3, 4}));
+ CHECK(j_array == json({ 1, 2, 3, 4 }));
}
SECTION("invalid iterators")
{
- json j_other_array2 = {"first", "second"};
+ 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",
@@ -652,8 +652,8 @@
SECTION("range for object")
{
- json j_object1 = {{"one", "eins"}, {"two", "zwei"}};
- json j_object2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}};
+ json j_object1 = { { "one", "eins" }, { "two", "zwei" } };
+ json j_object2 = { { "eleven", "elf" }, { "seventeen", "siebzehn" } };
SECTION("proper usage")
{
@@ -669,7 +669,7 @@
SECTION("invalid iterators")
{
- json const j_other_array2 = {"first", "second"};
+ 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",
@@ -687,37 +687,37 @@
{
SECTION("insert before begin()")
{
- auto it = j_array.insert(j_array.begin(), {7, 8, 9});
+ auto it = j_array.insert(j_array.begin(), { 7, 8, 9 });
CHECK(j_array.size() == 7);
CHECK(*it == json(7));
CHECK(j_array.begin() == it);
- CHECK(j_array == json({7, 8, 9, 1, 2, 3, 4}));
+ CHECK(j_array == json({ 7, 8, 9, 1, 2, 3, 4 }));
}
SECTION("insert in the middle")
{
- auto it = j_array.insert(j_array.begin() + 2, {7, 8, 9});
+ auto it = j_array.insert(j_array.begin() + 2, { 7, 8, 9 });
CHECK(j_array.size() == 7);
CHECK(*it == json(7));
CHECK((it - j_array.begin()) == 2);
- CHECK(j_array == json({1, 2, 7, 8, 9, 3, 4}));
+ CHECK(j_array == json({ 1, 2, 7, 8, 9, 3, 4 }));
}
SECTION("insert before end()")
{
- auto it = j_array.insert(j_array.end(), {7, 8, 9});
+ auto it = j_array.insert(j_array.end(), { 7, 8, 9 });
CHECK(j_array.size() == 7);
CHECK(*it == json(7));
CHECK((j_array.end() - it) == 3);
- CHECK(j_array == json({1, 2, 3, 4, 7, 8, 9}));
+ CHECK(j_array == json({ 1, 2, 3, 4, 7, 8, 9 }));
}
}
SECTION("invalid iterator")
{
// pass iterator to a different array
- json j_another_array = {1, 2};
- json j_yet_another_array = {"first", "second"};
+ 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&);
@@ -730,7 +730,7 @@
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}),
+ 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&);
}
@@ -739,7 +739,7 @@
{
// call insert on a non-array type
json j_nonarray = 3;
- json j_yet_another_array = {"first", "second"};
+ 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",
@@ -750,7 +750,7 @@
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}),
+ 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&);
}
@@ -760,16 +760,16 @@
{
SECTION("non-recursive (default)")
{
- json j_object1 = {{"one", "eins"}, {"two", "zwei"}};
- json j_object2 = {{"three", "drei"}, {"two", "zwo"}};
- json j_array = {1, 2, 3, 4};
+ json j_object1 = { { "one", "eins" }, { "two", "zwei" } };
+ json j_object2 = { { "three", "drei" }, { "two", "zwo" } };
+ json j_array = { 1, 2, 3, 4 };
SECTION("const reference")
{
SECTION("proper usage")
{
j_object1.update(j_object2);
- CHECK(j_object1 == json({{"one", "eins"}, {"two", "zwo"}, {"three", "drei"}}));
+ CHECK(j_object1 == json({ { "one", "eins" }, { "two", "zwo" }, { "three", "drei" } }));
json j_null;
j_null.update(j_object2);
@@ -789,7 +789,7 @@
SECTION("proper usage")
{
j_object1.update(j_object2.begin(), j_object2.end());
- CHECK(j_object1 == json({{"one", "eins"}, {"two", "zwo"}, {"three", "drei"}}));
+ CHECK(j_object1 == json({ { "one", "eins" }, { "two", "zwo" }, { "three", "drei" } }));
json j_null;
j_null.update(j_object2.begin(), j_object2.end());
@@ -799,12 +799,12 @@
SECTION("empty range")
{
j_object1.update(j_object2.begin(), j_object2.begin());
- CHECK(j_object1 == json({{"one", "eins"}, {"two", "zwei"}}));
+ CHECK(j_object1 == json({ { "one", "eins" }, { "two", "zwei" } }));
}
SECTION("invalid iterators")
{
- json const j_other_array2 = {"first", "second"};
+ 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",
@@ -825,18 +825,18 @@
{
SECTION("extend object")
{
- json j1 = {{"string", "s"}, {"numbers", {{"one", 1}}}};
- json const j2 = {{"string", "t"}, {"numbers", {{"two", 2}}}};
+ json j1 = { { "string", "s" }, { "numbers", { { "one", 1 } } } };
+ json const j2 = { { "string", "t" }, { "numbers", { { "two", 2 } } } };
j1.update(j2, true);
- CHECK(j1 == json({{"string", "t"}, {"numbers", {{"one", 1}, {"two", 2}}}}));
+ CHECK(j1 == json({ { "string", "t" }, { "numbers", { { "one", 1 }, { "two", 2 } } } }));
}
SECTION("replace object")
{
- json j1 = {{"string", "s"}, {"numbers", {{"one", 1}}}};
- json const j2 = {{"string", "t"}, {"numbers", 1}};
+ json j1 = { { "string", "s" }, { "numbers", { { "one", 1 } } } };
+ json const j2 = { { "string", "t" }, { "numbers", 1 } };
j1.update(j2, true);
- CHECK(j1 == json({{"string", "t"}, {"numbers", 1}}));
+ CHECK(j1 == json({ { "string", "t" }, { "numbers", 1 } }));
}
}
}
@@ -874,22 +874,22 @@
{
SECTION("array_t type")
{
- json j = {1, 2, 3, 4};
- json::array_t a = {"foo", "bar", "baz"};
+ json j = { 1, 2, 3, 4 };
+ json::array_t a = { "foo", "bar", "baz" };
j.swap(a);
- CHECK(j == json({"foo", "bar", "baz"}));
+ CHECK(j == json({ "foo", "bar", "baz" }));
j.swap(a);
- CHECK(j == json({1, 2, 3, 4}));
+ CHECK(j == json({ 1, 2, 3, 4 }));
}
SECTION("non-array_t type")
{
json j = 17;
- json::array_t a = {"foo", "bar", "baz"};
+ json::array_t a = { "foo", "bar", "baz" };
CHECK_THROWS_WITH_AS(j.swap(a), "[json.exception.type_error.310] cannot use swap(array_t&) with number", json::type_error&);
}
@@ -899,22 +899,22 @@
{
SECTION("object_t type")
{
- json j = {{"one", 1}, {"two", 2}};
- json::object_t o = {{"cow", "Kuh"}, {"chicken", "Huhn"}};
+ json j = { { "one", 1 }, { "two", 2 } };
+ json::object_t o = { { "cow", "Kuh" }, { "chicken", "Huhn" } };
j.swap(o);
- CHECK(j == json({{"cow", "Kuh"}, {"chicken", "Huhn"}}));
+ CHECK(j == json({ { "cow", "Kuh" }, { "chicken", "Huhn" } }));
j.swap(o);
- CHECK(j == json({{"one", 1}, {"two", 2}}));
+ CHECK(j == json({ { "one", 1 }, { "two", 2 } }));
}
SECTION("non-object_t type")
{
json j = 17;
- json::object_t o = {{"cow", "Kuh"}, {"chicken", "Huhn"}};
+ json::object_t o = { { "cow", "Kuh" }, { "chicken", "Huhn" } };
CHECK_THROWS_WITH_AS(j.swap(o), "[json.exception.type_error.310] cannot use swap(object_t&) with number", json::type_error&);
}
@@ -949,37 +949,37 @@
{
SECTION("binary_t type")
{
- json j = json::binary({1, 2, 3, 4});
- json::binary_t s = {{5, 6, 7, 8}};
+ json j = json::binary({ 1, 2, 3, 4 });
+ json::binary_t s = { { 5, 6, 7, 8 } };
j.swap(s);
- CHECK(j == json::binary({5, 6, 7, 8}));
+ CHECK(j == json::binary({ 5, 6, 7, 8 }));
j.swap(s);
- CHECK(j == json::binary({1, 2, 3, 4}));
+ CHECK(j == json::binary({ 1, 2, 3, 4 }));
}
SECTION("binary_t::container_type type")
{
- json j = json::binary({1, 2, 3, 4});
- std::vector<std::uint8_t> s = {{5, 6, 7, 8}};
+ json j = json::binary({ 1, 2, 3, 4 });
+ std::vector<std::uint8_t> s = { { 5, 6, 7, 8 } };
j.swap(s);
- CHECK(j == json::binary({5, 6, 7, 8}));
+ CHECK(j == json::binary({ 5, 6, 7, 8 }));
j.swap(s);
- CHECK(j == json::binary({1, 2, 3, 4}));
+ CHECK(j == json::binary({ 1, 2, 3, 4 }));
}
SECTION("non-binary_t type")
{
json j = 17;
- json::binary_t s1 = {{1, 2, 3, 4}};
- std::vector<std::uint8_t> s2 = {{5, 6, 7, 8}};
+ json::binary_t s1 = { { 1, 2, 3, 4 } };
+ std::vector<std::uint8_t> s2 = { { 5, 6, 7, 8 } };
CHECK_THROWS_WITH_AS(j.swap(s1), "[json.exception.type_error.310] cannot use swap(binary_t&) with number", json::type_error);
CHECK_THROWS_WITH_AS(j.swap(s2), "[json.exception.type_error.310] cannot use swap(binary_t::container_type&) with number", json::type_error);
diff --git a/tests/src/unit-msgpack.cpp b/tests/src/unit-msgpack.cpp
index 7ed17c4..bbeb822 100644
--- a/tests/src/unit-msgpack.cpp
+++ b/tests/src/unit-msgpack.cpp
@@ -118,7 +118,7 @@
SECTION("null")
{
json const j = nullptr;
- std::vector<uint8_t> const expected = {0xc0};
+ std::vector<uint8_t> const expected = { 0xc0 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -132,7 +132,7 @@
SECTION("true")
{
json const j = true;
- std::vector<uint8_t> const expected = {0xc3};
+ std::vector<uint8_t> const expected = { 0xc3 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -144,7 +144,7 @@
SECTION("false")
{
json const j = false;
- std::vector<uint8_t> const expected = {0xc2};
+ std::vector<uint8_t> const expected = { 0xc2 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -171,7 +171,7 @@
CHECK(j.is_number_integer());
// create expected byte vector
- std::vector<uint8_t> const expected{static_cast<uint8_t>(i)};
+ std::vector<uint8_t> const expected{ static_cast<uint8_t>(i) };
// compare result + size
const auto result = json::to_msgpack(j);
@@ -201,7 +201,7 @@
CHECK(j.is_number_integer());
// create expected byte vector
- std::vector<uint8_t> const expected{static_cast<uint8_t>(i)};
+ std::vector<uint8_t> const expected{ static_cast<uint8_t>(i) };
// compare result + size
const auto result = json::to_msgpack(j);
@@ -290,7 +290,7 @@
SECTION("65536..4294967295 (int 32)")
{
- for (uint32_t i : {65536u, 77777u, 1048576u, 4294967295u})
+ for (uint32_t i : { 65536u, 77777u, 1048576u, 4294967295u })
{
CAPTURE(i)
@@ -329,7 +329,7 @@
SECTION("4294967296..9223372036854775807 (int 64)")
{
- for (uint64_t i : {4294967296LU, 9223372036854775807LU})
+ for (uint64_t i : { 4294967296LU, 9223372036854775807LU })
{
CAPTURE(i)
@@ -408,7 +408,7 @@
SECTION("-9263 (int 16)")
{
json const j = -9263;
- std::vector<uint8_t> const expected = {0xd1, 0xdb, 0xd1};
+ std::vector<uint8_t> const expected = { 0xd1, 0xdb, 0xd1 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -459,11 +459,7 @@
SECTION("-32769..-2147483648")
{
std::vector<int32_t> const numbers{
- -32769,
- -65536,
- -77777,
- -1048576,
- -2147483648LL,
+ -32769, -65536, -77777, -1048576, -2147483648LL,
};
for (auto i : numbers)
{
@@ -565,7 +561,7 @@
CHECK(j.is_number_unsigned());
// create expected byte vector
- std::vector<uint8_t> const expected{static_cast<uint8_t>(i)};
+ std::vector<uint8_t> const expected{ static_cast<uint8_t>(i) };
// compare result + size
const auto result = json::to_msgpack(j);
@@ -652,7 +648,7 @@
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)
@@ -690,7 +686,7 @@
SECTION("4294967296..18446744073709551615 (uint 64)")
{
- for (const uint64_t i : {4294967296LU, 18446744073709551615LU})
+ for (const uint64_t i : { 4294967296LU, 18446744073709551615LU })
{
CAPTURE(i)
@@ -739,7 +735,7 @@
{
double const v = 3.1415925;
json const j = v;
- std::vector<uint8_t> const expected = {0xcb, 0x40, 0x09, 0x21, 0xfb, 0x3f, 0xa6, 0xde, 0xfc};
+ std::vector<uint8_t> const expected = { 0xcb, 0x40, 0x09, 0x21, 0xfb, 0x3f, 0xa6, 0xde, 0xfc };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -753,7 +749,7 @@
{
double const v = 1.0;
json const j = v;
- std::vector<uint8_t> const expected = {0xca, 0x3f, 0x80, 0x00, 0x00};
+ std::vector<uint8_t> const expected = { 0xca, 0x3f, 0x80, 0x00, 0x00 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -767,7 +763,7 @@
{
double const v = 128.1280059814453125;
json const j = v;
- std::vector<uint8_t> const expected = {0xca, 0x43, 0x00, 0x20, 0xc5};
+ std::vector<uint8_t> const expected = { 0xca, 0x43, 0x00, 0x20, 0xc5 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -784,8 +780,8 @@
SECTION("N = 0..31")
{
// explicitly enumerate the first byte for all 32 strings
- const std::vector<uint8_t> 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<uint8_t> 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)
{
@@ -856,7 +852,7 @@
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)
@@ -886,7 +882,7 @@
SECTION("N = 65536..4294967295")
{
- for (size_t N : {65536u, 77777u, 1048576u})
+ for (size_t N : { 65536u, 77777u, 1048576u })
{
CAPTURE(N)
@@ -922,7 +918,7 @@
SECTION("empty")
{
json const j = json::array();
- std::vector<uint8_t> const expected = {0x90};
+ std::vector<uint8_t> const expected = { 0x90 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -933,8 +929,8 @@
SECTION("[null]")
{
- json const j = {nullptr};
- std::vector<uint8_t> const expected = {0x91, 0xc0};
+ json const j = { nullptr };
+ std::vector<uint8_t> const expected = { 0x91, 0xc0 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -946,7 +942,7 @@
SECTION("[1,2,3,4,5]")
{
json const j = json::parse("[1,2,3,4,5]");
- std::vector<uint8_t> const expected = {0x95, 0x01, 0x02, 0x03, 0x04, 0x05};
+ std::vector<uint8_t> const expected = { 0x95, 0x01, 0x02, 0x03, 0x04, 0x05 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -958,7 +954,7 @@
SECTION("[[[[]]]]")
{
json const j = json::parse("[[[[]]]]");
- std::vector<uint8_t> const expected = {0x91, 0x91, 0x91, 0x90};
+ std::vector<uint8_t> const expected = { 0x91, 0x91, 0x91, 0x90 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -1012,7 +1008,7 @@
SECTION("empty")
{
json const j = json::object();
- std::vector<uint8_t> const expected = {0x80};
+ std::vector<uint8_t> const expected = { 0x80 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -1023,8 +1019,8 @@
SECTION("{\"\":null}")
{
- json const j = {{"", nullptr}};
- std::vector<uint8_t> const expected = {0x81, 0xa0, 0xc0};
+ json const j = { { "", nullptr } };
+ std::vector<uint8_t> const expected = { 0x81, 0xa0, 0xc0 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -1036,7 +1032,7 @@
SECTION("{\"a\": {\"b\": {\"c\": {}}}}")
{
json const j = json::parse(R"({"a": {"b": {"c": {}}}})");
- std::vector<uint8_t> const expected = {0x81, 0xa1, 0x61, 0x81, 0xa1, 0x62, 0x81, 0xa1, 0x63, 0x80};
+ std::vector<uint8_t> const expected = { 0x81, 0xa1, 0x61, 0x81, 0xa1, 0x62, 0x81, 0xa1, 0x63, 0x80 };
const auto result = json::to_msgpack(j);
CHECK(result == expected);
@@ -1177,7 +1173,7 @@
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)
@@ -1210,7 +1206,7 @@
SECTION("N = 65536..4294967295")
{
- for (std::size_t N : {65536u, 77777u, 1048576u})
+ for (std::size_t N : { 65536u, 77777u, 1048576u })
{
CAPTURE(N)
@@ -1283,7 +1279,7 @@
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)
@@ -1313,7 +1309,7 @@
SECTION("N = 65536..4294967295")
{
- for (std::size_t N : {65536u, 77777u, 1048576u})
+ for (std::size_t N : { 65536u, 77777u, 1048576u })
{
CAPTURE(N)
@@ -1347,7 +1343,7 @@
SECTION("from float32")
{
- auto given = std::vector<uint8_t>({0xca, 0x41, 0xc8, 0x00, 0x01});
+ auto given = std::vector<uint8_t>({ 0xca, 0x41, 0xc8, 0x00, 0x01 });
json const j = json::from_msgpack(given);
CHECK(j.get<double>() == Approx(25.0000019073486));
}
@@ -1369,107 +1365,107 @@
json _;
CHECK_THROWS_WITH_AS(
- _ = json::from_msgpack(std::vector<uint8_t>({0x87})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xcc})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xcd})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xcd, 0x00})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xce})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xce, 0x00})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xce, 0x00, 0x00})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xce, 0x00, 0x00, 0x00})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xcf})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xcf, 0x00})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xcf, 0x00, 0x00})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xcf, 0x00, 0x00, 0x00})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xa5, 0x68, 0x65})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0x92, 0x01})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0x81, 0xa1, 0x61})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0xc4, 0x02})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0x87}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xcc}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xcd}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xcd, 0x00}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xce}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xcf}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xa5, 0x68, 0x65}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0x92, 0x01}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0x81, 0xA1, 0x61}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xc4, 0x02}), true, false).is_discarded());
- CHECK(json::from_msgpack(std::vector<uint8_t>({0xc4}), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0x87 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xcc }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xcd }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xcd, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xce }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xce, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xce, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xce, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xcf }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xcf, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xcf, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xcf, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xcf, 0x00, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xcf, 0x00, 0x00, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xa5, 0x68, 0x65 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0x92, 0x01 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0x81, 0xA1, 0x61 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xc4, 0x02 }), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0xc4 }), true, false).is_discarded());
}
SECTION("unsupported bytes")
@@ -1477,19 +1473,19 @@
SECTION("concrete examples")
{
json _;
- CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector<uint8_t>({0xc1})),
+ CHECK_THROWS_WITH_AS(_ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({static_cast<uint8_t>(byte)})), json::parse_error&);
- CHECK(json::from_msgpack(std::vector<uint8_t>({static_cast<uint8_t>(byte)}), true, false).is_discarded());
+ CHECK_THROWS_AS(_ = json::from_msgpack(std::vector<uint8_t>({ static_cast<uint8_t>(byte) })), json::parse_error&);
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ static_cast<uint8_t>(byte) }), true, false).is_discarded());
}
}
}
@@ -1498,15 +1494,15 @@
{
json _;
CHECK_THROWS_WITH_AS(
- _ = json::from_msgpack(std::vector<uint8_t>({0x81, 0xff, 0x01})),
+ _ = json::from_msgpack(std::vector<uint8_t>({ 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<uint8_t>({0x81, 0xff, 0x01}), true, false).is_discarded());
+ CHECK(json::from_msgpack(std::vector<uint8_t>({ 0x81, 0xff, 0x01 }), true, false).is_discarded());
}
SECTION("strict mode")
{
- std::vector<uint8_t> const vec = {0xc0, 0xc0};
+ std::vector<uint8_t> const vec = { 0xc0, 0xc0 };
SECTION("non-strict mode")
{
const auto result = json::from_msgpack(vec, false);
@@ -1529,21 +1525,21 @@
{
SECTION("start_array(len)")
{
- std::vector<uint8_t> const v = {0x93, 0x01, 0x02, 0x03};
+ std::vector<uint8_t> const v = { 0x93, 0x01, 0x02, 0x03 };
SaxCountdown scp(0);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::msgpack));
}
SECTION("start_object(len)")
{
- std::vector<uint8_t> const v = {0x81, 0xa3, 0x66, 0x6F, 0x6F, 0xc2};
+ std::vector<uint8_t> const v = { 0x81, 0xa3, 0x66, 0x6F, 0x6F, 0xc2 };
SaxCountdown scp(0);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::msgpack));
}
SECTION("key()")
{
- std::vector<uint8_t> const v = {0x81, 0xa3, 0x66, 0x6F, 0x6F, 0xc2};
+ std::vector<uint8_t> const v = { 0x81, 0xa3, 0x66, 0x6F, 0x6F, 0xc2 };
SaxCountdown scp(1);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::msgpack));
}
@@ -1615,151 +1611,151 @@
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)
@@ -1802,7 +1798,7 @@
// parse MessagePack file
auto packed = utils::read_binary_file(filename + ".msgpack");
json j2;
- CHECK_NOTHROW(j2 = json::from_msgpack({packed.data(), packed.size()}));
+ CHECK_NOTHROW(j2 = json::from_msgpack({ packed.data(), packed.size() }));
// compare parsed JSON values
CHECK(j1 == j2);
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 24d6018..15970ca 100644
--- a/tests/src/unit-no-mem-leak-on-adl-serialize.cpp
+++ b/tests/src/unit-no-mem-leak-on-adl-serialize.cpp
@@ -48,7 +48,7 @@
{
try
{
- const nlohmann::json j = Foo{1, 0};
+ const nlohmann::json j = Foo{ 1, 0 };
std::cout << j.dump() << "\n";
}
catch (...) // NOLINT(bugprone-empty-catch)
@@ -61,7 +61,7 @@
{
try
{
- const nlohmann::json j = Foo{1, 1};
+ const nlohmann::json j = Foo{ 1, 1 };
std::cout << j.dump() << "\n";
}
catch (...) // NOLINT(bugprone-empty-catch)
@@ -74,7 +74,7 @@
{
try
{
- const nlohmann::json j = Foo{1, 2};
+ const nlohmann::json j = Foo{ 1, 2 };
std::cout << j.dump() << "\n";
}
catch (...) // NOLINT(bugprone-empty-catch)
diff --git a/tests/src/unit-ordered_json.cpp b/tests/src/unit-ordered_json.cpp
index 930d8cf..64dadd3 100644
--- a/tests/src/unit-ordered_json.cpp
+++ b/tests/src/unit-ordered_json.cpp
@@ -45,11 +45,11 @@
CHECK(oj.dump() == "{\"element3\":3,\"element2\":2}");
// There are no dup keys cause constructor calls emplace...
- json const multi{{"z", 1}, {"m", 2}, {"m", 3}, {"y", 4}, {"m", 5}};
+ json const multi{ { "z", 1 }, { "m", 2 }, { "m", 3 }, { "y", 4 }, { "m", 5 } };
CHECK(multi.size() == 3);
CHECK(multi.dump() == "{\"m\":2,\"y\":4,\"z\":1}");
- ordered_json multi_ordered{{"z", 1}, {"m", 2}, {"m", 3}, {"y", 4}, {"m", 5}};
+ ordered_json multi_ordered{ { "z", 1 }, { "m", 2 }, { "m", 3 }, { "y", 4 }, { "m", 5 } };
CHECK(multi_ordered.size() == 3);
CHECK(multi_ordered.dump() == "{\"z\":1,\"m\":2,\"y\":4}");
CHECK(multi_ordered.erase("m") == 1);
@@ -57,14 +57,14 @@
// Ranged insert test.
// It seems that values shouldn't be overwritten. Only new values are added
- json j1{{"c", 1}, {"b", 2}, {"a", 3}};
- const json j2{{"c", 77}, {"d", 42}, {"a", 4}};
+ json j1{ { "c", 1 }, { "b", 2 }, { "a", 3 } };
+ const json j2{ { "c", 77 }, { "d", 42 }, { "a", 4 } };
j1.insert(j2.cbegin(), j2.cend());
CHECK(j1.size() == 4);
CHECK(j1.dump() == "{\"a\":3,\"b\":2,\"c\":1,\"d\":42}");
- ordered_json oj1{{"c", 1}, {"b", 2}, {"a", 3}};
- const ordered_json oj2{{"c", 77}, {"d", 42}, {"a", 4}};
+ ordered_json oj1{ { "c", 1 }, { "b", 2 }, { "a", 3 } };
+ const ordered_json oj2{ { "c", 77 }, { "d", 42 }, { "a", 4 } };
oj1.insert(oj2.cbegin(), oj2.cend());
CHECK(oj1.size() == 4);
CHECK(oj1.dump() == "{\"c\":1,\"b\":2,\"a\":3,\"d\":42}");
diff --git a/tests/src/unit-ordered_map.cpp b/tests/src/unit-ordered_map.cpp
index f682a49..7edd09b 100644
--- a/tests/src/unit-ordered_map.cpp
+++ b/tests/src/unit-ordered_map.cpp
@@ -17,14 +17,14 @@
{
SECTION("constructor from iterator range")
{
- std::map<std::string, std::string> m{{"eins", "one"}, {"zwei", "two"}, {"drei", "three"}};
+ std::map<std::string, std::string> m{ { "eins", "one" }, { "zwei", "two" }, { "drei", "three" } };
ordered_map<std::string, std::string> const om(m.begin(), m.end());
CHECK(om.size() == 3);
}
SECTION("copy assignment")
{
- std::map<std::string, std::string> m{{"eins", "one"}, {"zwei", "two"}, {"drei", "three"}};
+ std::map<std::string, std::string> m{ { "eins", "one" }, { "zwei", "two" }, { "drei", "three" } };
ordered_map<std::string, std::string> om(m.begin(), m.end());
const auto com = om;
om.clear(); // silence a warning by forbidding having "const auto& com = om;"
@@ -34,7 +34,7 @@
SECTION("at")
{
- std::map<std::string, std::string> m{{"eins", "one"}, {"zwei", "two"}, {"drei", "three"}};
+ std::map<std::string, std::string> m{ { "eins", "one" }, { "zwei", "two" }, { "drei", "three" } };
ordered_map<std::string, std::string> om(m.begin(), m.end());
const auto com = om;
@@ -67,7 +67,7 @@
SECTION("operator[]")
{
- std::map<std::string, std::string> m{{"eins", "one"}, {"zwei", "two"}, {"drei", "three"}};
+ std::map<std::string, std::string> m{ { "eins", "one" }, { "zwei", "two" }, { "drei", "three" } };
ordered_map<std::string, std::string> om(m.begin(), m.end());
const auto com = om;
@@ -280,8 +280,8 @@
SECTION("const value_type&")
{
- ordered_map<std::string, std::string>::value_type const vt1{"eins", "1"};
- ordered_map<std::string, std::string>::value_type const vt4{"vier", "four"};
+ ordered_map<std::string, std::string>::value_type const vt1{ "eins", "1" };
+ ordered_map<std::string, std::string>::value_type const vt4{ "vier", "four" };
auto res1 = om.insert(vt1);
CHECK(res1.first == om.begin());
@@ -296,12 +296,12 @@
SECTION("value_type&&")
{
- auto res1 = om.insert({"eins", "1"});
+ auto res1 = om.insert({ "eins", "1" });
CHECK(res1.first == om.begin());
CHECK(res1.second == false);
CHECK(om.size() == 3);
- auto res4 = om.insert({"vier", "four"});
+ auto res4 = om.insert({ "vier", "four" });
CHECK(res4.first == om.begin() + 3);
CHECK(res4.second == true);
CHECK(om.size() == 4);
diff --git a/tests/src/unit-pointer_access.cpp b/tests/src/unit-pointer_access.cpp
index 4503a3b..2d2ec65 100644
--- a/tests/src/unit-pointer_access.cpp
+++ b/tests/src/unit-pointer_access.cpp
@@ -16,7 +16,7 @@
SECTION("pointer access to object_t")
{
using test_type = json::object_t;
- json value = {{"one", 1}, {"two", 2}};
+ json value = { { "one", 1 }, { "two", 2 } };
// check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>();
@@ -45,7 +45,7 @@
SECTION("pointer access to const object_t")
{
using test_type = const json::object_t;
- const json value = {{"one", 1}, {"two", 2}};
+ const json value = { { "one", 1 }, { "two", 2 } };
// check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>();
@@ -74,7 +74,7 @@
SECTION("pointer access to array_t")
{
using test_type = json::array_t;
- json value = {1, 2, 3, 4};
+ json value = { 1, 2, 3, 4 };
// check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>();
@@ -103,7 +103,7 @@
SECTION("pointer access to const array_t")
{
using test_type = const json::array_t;
- const json value = {1, 2, 3, 4};
+ const json value = { 1, 2, 3, 4 };
// check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>();
@@ -422,7 +422,7 @@
SECTION("pointer access to const binary_t")
{
using test_type = const json::binary_t;
- const json value = json::binary({1, 2, 3});
+ const json value = json::binary({ 1, 2, 3 });
// check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>();
diff --git a/tests/src/unit-readme.cpp b/tests/src/unit-readme.cpp
index 810cdff..656f0d7 100644
--- a/tests/src/unit-readme.cpp
+++ b/tests/src/unit-readme.cpp
@@ -55,24 +55,24 @@
j["answer"]["everything"] = 42;
// add an array that is stored as std::vector (using an initializer list)
- j["list"] = {1, 0, 2};
+ j["list"] = { 1, 0, 2 };
// add another object (using an initializer list of pairs)
- j["object"] = {{"currency", "USD"}, {"value", 42.99}};
+ 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 } } } };
}
{
// ways to express the empty array []
- json const empty_array_implicit = {{}};
+ json const empty_array_implicit = { {} };
CHECK(empty_array_implicit.is_array());
json const empty_array_explicit = json::array();
CHECK(empty_array_explicit.is_array());
@@ -82,7 +82,7 @@
CHECK(empty_object_explicit.is_object());
// a way to express an _array_ of key/value pairs [["currency", "USD"], ["value", 42.99]]
- json array_not_object = json::array({{"currency", "USD"}, {"value", 42.99}});
+ json array_not_object = json::array({ { "currency", "USD" }, { "value", 42.99 } });
CHECK(array_not_object.is_array());
CHECK(array_not_object.size() == 2);
CHECK(array_not_object[0].is_array());
@@ -142,7 +142,7 @@
// getter/setter
const auto tmp = j[0].get<std::string>();
j[1] = 42;
- bool foo{j.at(2)};
+ bool foo{ j.at(2) };
CHECK(foo == true);
// other stuff
@@ -166,57 +166,57 @@
}
{
- std::vector<int> const c_vector{1, 2, 3, 4};
+ std::vector<int> const c_vector{ 1, 2, 3, 4 };
json const j_vec(c_vector);
// [1, 2, 3, 4]
- std::deque<float> const c_deque{1.2f, 2.3f, 3.4f, 5.6f};
+ std::deque<float> const c_deque{ 1.2f, 2.3f, 3.4f, 5.6f };
json const j_deque(c_deque);
// [1.2, 2.3, 3.4, 5.6]
- std::list<bool> const c_list{true, true, false, true};
+ std::list<bool> const c_list{ true, true, false, true };
json const j_list(c_list);
// [true, true, false, true]
- std::forward_list<int64_t> const c_flist{12345678909876, 23456789098765, 34567890987654, 45678909876543};
+ std::forward_list<int64_t> const c_flist{ 12345678909876, 23456789098765, 34567890987654, 45678909876543 };
json const j_flist(c_flist);
// [12345678909876, 23456789098765, 34567890987654, 45678909876543]
- std::array<unsigned long, 4> const c_array{{1, 2, 3, 4}};
+ std::array<unsigned long, 4> const c_array{ { 1, 2, 3, 4 } };
json const j_array(c_array);
// [1, 2, 3, 4]
- std::set<std::string> const c_set{"one", "two", "three", "four", "one"};
+ std::set<std::string> const c_set{ "one", "two", "three", "four", "one" };
json const j_set(c_set); // only one entry for "one" is used
// ["four", "one", "three", "two"]
- std::unordered_set<std::string> const c_uset{"one", "two", "three", "four", "one"};
+ std::unordered_set<std::string> const c_uset{ "one", "two", "three", "four", "one" };
json const j_uset(c_uset); // only one entry for "one" is used
// maybe ["two", "three", "four", "one"]
- std::multiset<std::string> const c_mset{"one", "two", "one", "four"};
+ std::multiset<std::string> const c_mset{ "one", "two", "one", "four" };
json const j_mset(c_mset); // both entries for "one" are used
// maybe ["one", "two", "one", "four"]
- std::unordered_multiset<std::string> const c_umset{"one", "two", "one", "four"};
+ std::unordered_multiset<std::string> const c_umset{ "one", "two", "one", "four" };
json const j_umset(c_umset); // both entries for "one" are used
// maybe ["one", "two", "one", "four"]
}
{
- std::map<std::string, int> const c_map{{"one", 1}, {"two", 2}, {"three", 3}};
+ std::map<std::string, int> const c_map{ { "one", 1 }, { "two", 2 }, { "three", 3 } };
json const j_map(c_map);
// {"one": 1, "two": 2, "three": 3}
- std::unordered_map<const char*, float> const c_umap{{"one", 1.2f}, {"two", 2.3f}, {"three", 3.4f}};
+ std::unordered_map<const char*, float> const c_umap{ { "one", 1.2f }, { "two", 2.3f }, { "three", 3.4f } };
json const j_umap(c_umap);
// {"one": 1.2, "two": 2.3, "three": 3.4}
- std::multimap<std::string, bool> const c_mmap{{"one", true}, {"two", true}, {"three", false}, {"three", true}};
+ std::multimap<std::string, bool> const c_mmap{ { "one", true }, { "two", true }, { "three", false }, { "three", true } };
json const j_mmap(c_mmap); // only one entry for key "three" is used
// maybe {"one": true, "two": true, "three": true}
- std::unordered_multimap<std::string, bool> const c_ummap{{"one", true}, {"two", true}, {"three", false}, {"three", true}};
+ std::unordered_multimap<std::string, bool> const c_ummap{ { "one", true }, { "two", true }, { "three", false }, { "three", true } };
json const j_ummap(c_ummap); // only one entry for key "three" is used
// maybe {"one": true, "two": true, "three": true}
}
@@ -230,13 +230,13 @@
// Booleans
bool const b1 = true;
json const jb = b1;
- bool b2{jb};
+ bool b2{ jb };
CHECK(b2 == true);
// numbers
int const i = 42;
json const jn = i;
- double f{jn};
+ double f{ jn };
CHECK(f == 42);
// etc.
diff --git a/tests/src/unit-reference_access.cpp b/tests/src/unit-reference_access.cpp
index e2738a1..831f480 100644
--- a/tests/src/unit-reference_access.cpp
+++ b/tests/src/unit-reference_access.cpp
@@ -14,16 +14,16 @@
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")
{
using test_type = json::object_t;
- json value = {{"one", 1}, {"two", 2}};
+ json value = { { "one", 1 }, { "two", 2 } };
// check if references are returned correctly
auto& p1 = value.get_ref<test_type&>();
@@ -59,7 +59,7 @@
SECTION("const reference access to const object_t")
{
using test_type = json::object_t;
- const json value = {{"one", 1}, {"two", 2}};
+ const json value = { { "one", 1 }, { "two", 2 } };
// this should not compile
// test_type& p1 = value.get_ref<test_type&>();
@@ -73,7 +73,7 @@
SECTION("reference access to array_t")
{
using test_type = json::array_t;
- json value = {1, 2, 3, 4};
+ json value = { 1, 2, 3, 4 };
// check if references are returned correctly
auto& p1 = value.get_ref<test_type&>();
diff --git a/tests/src/unit-regression1.cpp b/tests/src/unit-regression1.cpp
index 286a18e..c661b08 100644
--- a/tests/src/unit-regression1.cpp
+++ b/tests/src/unit-regression1.cpp
@@ -59,7 +59,7 @@
template<typename BasicJsonType>
static void to_json(BasicJsonType& j, const T& value)
{
- j = BasicJsonType{{"x", value.x}};
+ j = BasicJsonType{ { "x", value.x } };
}
template<typename BasicJsonType>
static void from_json(const BasicJsonType& j, T& value) // !!!
@@ -105,7 +105,7 @@
friend void to_json(json& j, const nocopy& n)
{
- j = {{"val", n.val}};
+ j = { { "val", n.val } };
}
};
} // namespace
@@ -146,12 +146,12 @@
{
json const j1 = NAN;
CHECK(j1.is_number_float());
- json::number_float_t const f1{j1};
+ json::number_float_t const f1{ j1 };
CHECK(std::isnan(f1));
json const j2 = static_cast<json::number_float_t>(NAN);
CHECK(j2.is_number_float());
- json::number_float_t const f2{j2};
+ json::number_float_t const f2{ j2 };
CHECK(std::isnan(f2));
}
@@ -159,12 +159,12 @@
{
json const j1 = INFINITY;
CHECK(j1.is_number_float());
- json::number_float_t const f1{j1};
+ json::number_float_t const f1{ j1 };
CHECK(!std::isfinite(f1));
json const j2 = static_cast<json::number_float_t>(INFINITY);
CHECK(j2.is_number_float());
- json::number_float_t const f2{j2};
+ json::number_float_t const f2{ j2 };
CHECK(!std::isfinite(f2));
}
}
@@ -190,7 +190,7 @@
static_assert(std::is_same<decltype(anon_enum_value), decltype(u)>::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")
@@ -241,9 +241,9 @@
auto test = j["Test"].get<std::string>();
CHECK(test == "Test1");
- int number{j["Number"]};
+ int number{ j["Number"] };
CHECK(number == 100);
- float foo{j["Foo"]};
+ float foo{ j["Foo"] };
CHECK(static_cast<double>(foo) == Approx(42.42));
}
@@ -281,41 +281,41 @@
SECTION("issue #93 reverse_iterator operator inheritance problem")
{
{
- json a = {1, 2, 3};
+ json a = { 1, 2, 3 };
json::reverse_iterator rit = a.rbegin();
++rit;
CHECK(*rit == json(2));
CHECK(rit.value() == json(2));
}
{
- json a = {1, 2, 3};
+ json a = { 1, 2, 3 };
json::reverse_iterator const rit = ++a.rbegin();
CHECK(*rit == json(2));
CHECK(rit.value() == json(2));
}
{
- json a = {1, 2, 3};
+ json a = { 1, 2, 3 };
json::reverse_iterator rit = a.rbegin();
++rit;
- json b = {0, 0, 0};
+ json b = { 0, 0, 0 };
std::transform(rit, a.rend(), b.rbegin(), [](json el) {
return el;
});
- CHECK(b == json({0, 1, 2}));
+ CHECK(b == json({ 0, 1, 2 }));
}
{
- json a = {1, 2, 3};
- json b = {0, 0, 0};
+ json a = { 1, 2, 3 };
+ json b = { 0, 0, 0 };
std::transform(++a.rbegin(), a.rend(), b.rbegin(), [](json el) {
return el;
});
- CHECK(b == json({0, 1, 2}));
+ CHECK(b == json({ 0, 1, 2 }));
}
}
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;
@@ -335,9 +335,9 @@
SECTION("issue #101 - binary string causes numbers to be dumped as hex")
{
int64_t const number = 10;
- std::string const bytes{"\x00"
- "asdf\n",
- 6};
+ std::string const bytes{ "\x00"
+ "asdf\n",
+ 6 };
json j;
j["int64"] = number;
j["binary string"] = bytes;
@@ -348,7 +348,7 @@
SECTION("issue #111 - subsequent unicode chars")
{
- std::string const bytes{0x7, 0x7};
+ std::string const bytes{ 0x7, 0x7 };
json j;
j["string"] = bytes;
CHECK(j["string"] == "\u0007\u0007");
@@ -357,7 +357,7 @@
#if JSON_USE_IMPLICIT_CONVERSIONS
SECTION("issue #144 - implicit assignment to std::string fails")
{
- json o = {{"name", "value"}};
+ json o = { { "name", "value" } };
std::string s1 = o["name"];
CHECK(s1 == "value");
@@ -558,8 +558,8 @@
SECTION("issue #233 - Can't use basic_json::iterator as a base iterator for std::move_iterator")
{
- json source = {"a", "b", "c"};
- json expected = {"a", "b"};
+ json source = { "a", "b", "c" };
+ json expected = { "a", "b" };
json dest;
std::copy_n(std::make_move_iterator(source.begin()), 2, std::back_inserter(dest));
@@ -569,11 +569,11 @@
SECTION("issue #235 - ambiguous overload for 'push_back' and 'operator+='")
{
- json data = {{"key", "value"}};
- data.push_back({"key2", "value2"});
- data += {"key3", "value3"};
+ json data = { { "key", "value" } };
+ data.push_back({ "key2", "value2" });
+ data += { "key3", "value3" };
- CHECK(data == json({{"key", "value"}, {"key2", "value2"}, {"key3", "value3"}}));
+ CHECK(data == json({ { "key", "value" }, { "key2", "value2" }, { "key3", "value3" } }));
}
SECTION("issue #269 - diff generates incorrect patch when removing multiple array elements")
@@ -588,10 +588,10 @@
SECTION("issue #283 - value() does not work with _json_pointer types")
{
json j = {
- {"object", {{"key1", 1}, {"key2", 2}}},
+ { "object", { { "key1", 1 }, { "key2", 2 } } },
};
- int at_integer{j.at("/object/key2"_json_pointer)};
+ int at_integer{ j.at("/object/key2"_json_pointer) };
int val_integer = j.value("/object/key2"_json_pointer, 0);
CHECK(at_integer == val_integer);
@@ -608,7 +608,7 @@
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;
@@ -619,10 +619,10 @@
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;
@@ -635,7 +635,7 @@
{
json j;
j["/this/that/2"_json_pointer] = 27;
- CHECK(j == json({{"this", {{"that", {nullptr, nullptr, 27}}}}}));
+ CHECK(j == json({ { "this", { { "that", { nullptr, nullptr, 27 } } } } }));
}
SECTION("issue #329 - serialized value not always can be parsed")
@@ -837,9 +837,9 @@
ss << "{\n \"one\" : 1,\n \"two\" : 2\n}\n{\n \"three\" : 3\n}";
json j;
CHECK_NOTHROW(ss >> j);
- CHECK(j == json({{"one", 1}, {"two", 2}}));
+ CHECK(j == json({ { "one", 1 }, { "two", 2 } }));
CHECK_NOTHROW(ss >> j);
- CHECK(j == json({{"three", 3}}));
+ CHECK(j == json({ { "three", 3 } }));
CHECK_THROWS_WITH_AS(
ss >> j,
@@ -869,12 +869,12 @@
if (i == 0)
{
- CHECK(val == json({{"one", 1}, {"two", 2}}));
+ CHECK(val == json({ { "one", 1 }, { "two", 2 } }));
}
if (i == 1)
{
- CHECK(val == json({{"three", 3}}));
+ CHECK(val == json({ { "three", 3 } }));
}
++i;
@@ -911,7 +911,7 @@
SECTION("issue #405 - Heap-buffer-overflow (OSS-Fuzz issue 342)")
{
// original test case
- std::vector<uint8_t> const vec{0x65, 0xf5, 0x0a, 0x48, 0x21};
+ std::vector<uint8_t> 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",
@@ -923,31 +923,31 @@
json _;
// original test case: incomplete float64
- std::vector<uint8_t> const vec1{0xcb, 0x8f, 0x0a};
+ std::vector<uint8_t> 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&);
// related test case: incomplete float32
- std::vector<uint8_t> const vec2{0xca, 0x8f, 0x0a};
+ std::vector<uint8_t> 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&);
// related test case: incomplete Half-Precision Float (CBOR)
- std::vector<uint8_t> const vec3{0xf9, 0x8f};
+ std::vector<uint8_t> 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&);
// related test case: incomplete Single-Precision Float (CBOR)
- std::vector<uint8_t> const vec4{0xfa, 0x8f, 0x0a};
+ std::vector<uint8_t> 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&);
// related test case: incomplete Double-Precision Float (CBOR)
- std::vector<uint8_t> const vec5{0xfb, 0x8f, 0x0a};
+ std::vector<uint8_t> 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&);
@@ -958,19 +958,19 @@
json _;
// original test case
- std::vector<uint8_t> const vec1{0x87};
+ std::vector<uint8_t> 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&);
// 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<uint8_t> const vec(1, static_cast<uint8_t>(b));
CHECK_THROWS_AS(_ = json::from_msgpack(vec), json::parse_error&);
@@ -1005,19 +1005,19 @@
json _;
// original test case: empty UTF-8 string (indefinite length)
- std::vector<uint8_t> const vec1{0x7f};
+ std::vector<uint8_t> 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&);
// related test case: empty array (indefinite length)
- std::vector<uint8_t> const vec2{0x9f};
+ std::vector<uint8_t> 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&);
// related test case: empty map (indefinite length)
- std::vector<uint8_t> const vec3{0xbf};
+ std::vector<uint8_t> 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&);
@@ -1026,13 +1026,13 @@
SECTION("issue #412 - Heap-buffer-overflow (OSS-Fuzz issue 367)")
{
// original test case
- std::vector<uint8_t> 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<uint8_t> 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(
@@ -1041,19 +1041,19 @@
json::parse_error&);
// related test case: nonempty UTF-8 string (indefinite length)
- std::vector<uint8_t> const vec1{0x7f, 0x61, 0x61};
+ std::vector<uint8_t> 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&);
// related test case: nonempty array (indefinite length)
- std::vector<uint8_t> const vec2{0x9f, 0x01};
+ std::vector<uint8_t> 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&);
// related test case: nonempty map (indefinite length)
- std::vector<uint8_t> const vec3{0xbf, 0x61, 0x61, 0x01};
+ std::vector<uint8_t> 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&);
@@ -1080,9 +1080,9 @@
SECTION("issue #416 - Use-of-uninitialized-value (OSS-Fuzz issue 377)")
{
// original test case
- std::vector<uint8_t> 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<uint8_t> 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(
@@ -1091,9 +1091,9 @@
json::parse_error&);
// related test case: double-precision
- std::vector<uint8_t> 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};
+ std::vector<uint8_t> 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",
@@ -1102,7 +1102,7 @@
SECTION("issue #452 - Heap-buffer-overflow (OSS-Fuzz issue 585)")
{
- std::vector<uint8_t> const vec = {'-', '0', '1', '2', '2', '7', '4'};
+ std::vector<uint8_t> const vec = { '-', '0', '1', '2', '2', '7', '4' };
json _;
CHECK_THROWS_AS(_ = json::parse(vec), json::parse_error&);
}
@@ -1135,7 +1135,7 @@
#if JSON_USE_IMPLICIT_CONVERSIONS
SECTION("issue #473 - inconsistent behavior in conversion to array type")
{
- json const j_array = {1, 2, 3, 4};
+ json const j_array = { 1, 2, 3, 4 };
json const j_number = 42;
json const j_null = nullptr;
@@ -1183,7 +1183,7 @@
SECTION("issue #494 - conversion from vector<bool> to json fails to build")
{
- std::vector<bool> const boolVector = {false, true, false, false};
+ std::vector<bool> const boolVector = { false, true, false, false };
json j;
j["bool_vector"] = boolVector;
@@ -1192,7 +1192,7 @@
SECTION("issue #504 - assertion error (OSS-Fuzz 856)")
{
- std::vector<uint8_t> const vec1 = {0xf9, 0xff, 0xff, 0x4a, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x37, 0x02, 0x38};
+ std::vector<uint8_t> const vec1 = { 0xf9, 0xff, 0xff, 0x4a, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x37, 0x02, 0x38 };
json const j1 = json::from_cbor(vec1, false);
// step 2: round trip
@@ -1247,7 +1247,7 @@
SECTION("issue #575 - heap-buffer-overflow (OSS-Fuzz 1400)")
{
json _;
- std::vector<uint8_t> const vec = {'"', '\\', '"', 'X', '"', '"'};
+ std::vector<uint8_t> const vec = { '"', '\\', '"', 'X', '"', '"' };
CHECK_THROWS_AS(_ = json::parse(vec), json::parse_error&);
}
@@ -1257,7 +1257,7 @@
SECTION("example 1")
{
// create a map
- std::map<std::string, int> m1{{"key", 1}};
+ std::map<std::string, int> m1{ { "key", 1 } };
// create and print a JSON from the map
json const j = m1;
@@ -1272,7 +1272,7 @@
SECTION("example 2")
{
// create a map
- std::map<std::string, std::string> m1{{"key", "val"}};
+ std::map<std::string, std::string> m1{ { "key", "val" } };
// create and print a JSON from the map
json const j = m1;
@@ -1305,7 +1305,7 @@
SECTION("full example")
{
- std::valarray<double> v = {1.2, 2.3, 3.4, 4.5};
+ std::valarray<double> v = { 1.2, 2.3, 3.4, 4.5 };
json j = v;
std::valarray<double> vj = j;
@@ -1336,10 +1336,10 @@
auto m1 = j1.get<std::map<std::string, std::string>>();
auto m2 = j2.get<std::map<std::string, std::string>>();
- int i3{j3};
+ int i3{ j3 };
- CHECK(m1 == (std::map<std::string, std::string>{{"first", "one"}}));
- CHECK(m2 == (std::map<std::string, std::string>{{"second", "two"}}));
+ CHECK(m1 == (std::map<std::string, std::string>{ { "first", "one" } }));
+ CHECK(m2 == (std::map<std::string, std::string>{ { "second", "two" } }));
CHECK(i3 == 3);
}
}
@@ -1371,14 +1371,14 @@
{
nocopy n;
json j;
- j = {{"nocopy", n}};
+ j = { { "nocopy", n } };
CHECK(j["nocopy"]["val"] == 0);
}
SECTION("issue #838 - incorrect parse error with binary data in keys")
{
- std::array<uint8_t, 28> 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<uint8_t, 28> 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<char*>(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&);
@@ -1388,7 +1388,7 @@
SECTION("issue #843 - converting to array not working")
{
json j;
- std::array<int, 4> ar = {{1, 1, 1, 1}};
+ std::array<int, 4> ar = { { 1, 1, 1, 1 } };
j = ar;
ar = j;
}
@@ -1418,7 +1418,7 @@
SECTION("issue #961 - incorrect parsing of indefinite length CBOR strings")
{
- std::vector<uint8_t> const v_cbor = {0x7F, 0x64, 'a', 'b', 'c', 'd', 0x63, '1', '2', '3', 0xFF};
+ std::vector<uint8_t> const v_cbor = { 0x7F, 0x64, 'a', 'b', 'c', 'd', 0x63, '1', '2', '3', 0xFF };
json j = json::from_cbor(v_cbor);
CHECK(j == "abcd123");
}
@@ -1426,7 +1426,7 @@
SECTION("issue #962 - Timeout (OSS-Fuzz 6034)")
{
json _;
- std::vector<uint8_t> v_ubjson = {'[', '$', 'Z', '#', 'L', 0x78, 0x28, 0x00, 0x68, 0x28, 0x69, 0x69, 0x17};
+ std::vector<uint8_t> v_ubjson = { '[', '$', 'Z', '#', 'L', 0x78, 0x28, 0x00, 0x68, 0x28, 0x69, 0x69, 0x17 };
CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&);
//CHECK_THROWS_WITH(json::from_ubjson(v_ubjson),
// "[json.exception.out_of_range.408] excessive array size: 8658170730974374167");
@@ -1476,7 +1476,7 @@
SECTION("issue #977 - Assigning between different json types")
{
- foo_json lj = ns::foo{3};
+ foo_json lj = ns::foo{ 3 };
ns::foo ff(lj);
CHECK(lj.is_object());
CHECK(lj.size() == 1);
diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp
index d2b43bd..99d8bb2 100644
--- a/tests/src/unit-regression2.cpp
+++ b/tests/src/unit-regression2.cpp
@@ -74,8 +74,8 @@
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays): this is a false positive
NLOHMANN_JSON_SERIALIZE_ENUM(for_1647,
{
- {for_1647::one, "one"},
- {for_1647::two, "two"},
+ { for_1647::one, "one" },
+ { for_1647::two, "two" },
})
} // namespace
@@ -418,15 +418,15 @@
CHECK(float_json::from_msgpack(float_json::to_msgpack(j)) == j);
CHECK(float_json::from_ubjson(float_json::to_ubjson(j)) == j);
- float_json j2 = {1000.0, 2000.0, 3000.0};
+ float_json j2 = { 1000.0, 2000.0, 3000.0 };
CHECK(float_json::from_ubjson(float_json::to_ubjson(j2, true, true)) == j2);
}
SECTION("issue #1045 - Using STL algorithms with JSON containers with expected results?")
{
json diffs = nlohmann::json::array();
- json m1{{"key1", 42}};
- json m2{{"key2", 42}};
+ json m1{ { "key1", 42 } };
+ json m2{ { "key2", 42 } };
auto p1 = m1.items();
auto p2 = m2.items();
@@ -451,15 +451,15 @@
"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"}}},
+ { "1", { { "a", "testa_1" }, { "b", "testb_1" } } },
+ { "2", { { "a", "testa_2" }, { "b", "testb_2" } } },
+ { "3", { { "a", "testa_3" }, { "b", "testb_3" } } },
};
std::map<std::string, Data> expected{
- {"1", {"testa_1", "testb_1"}},
- {"2", {"testa_2", "testb_2"}},
- {"3", {"testa_3", "testb_3"}},
+ { "1", { "testa_1", "testb_1" } },
+ { "2", { "testa_2", "testb_2" } },
+ { "3", { "testa_3", "testb_3" } },
};
const auto data = j.get<decltype(expected)>();
CHECK(expected == data);
@@ -504,11 +504,12 @@
SECTION("test case in issue #1445")
{
nlohmann::json dump_test;
- const std::array<int, 108> 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<int, 108> 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)
{
@@ -534,10 +535,10 @@
SECTION("issue #1727 - Contains with non-const lvalue json_pointer picks the wrong overload")
{
- const json j = {{"root", {{"settings", {{"logging", true}}}}}};
+ const json j = { { "root", { { "settings", { { "logging", true } } } } } };
auto jptr1 = "/root/settings/logging"_json_pointer;
- auto jptr2 = json::json_pointer{"/root/settings/logging"};
+ auto jptr2 = json::json_pointer{ "/root/settings/logging" };
CHECK(j.contains(jptr1));
CHECK(j.contains(jptr2));
@@ -570,7 +571,7 @@
SECTION("string array")
{
- const std::array<char, 2> input = {{'B', 0x00}};
+ const std::array<char, 2> input = { { 'B', 0x00 } };
const json cbor = json::from_cbor(input, true, false);
CHECK(cbor.is_discarded());
}
@@ -605,8 +606,8 @@
SECTION("issue #2067 - cannot serialize binary data to text JSON")
{
- const std::array<unsigned char, 23> 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<unsigned char, 23> 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
@@ -618,7 +619,7 @@
SECTION("PR #2181 - regression bug with lvalue")
{
// see https://github.com/nlohmann/json/pull/2181#issuecomment-653326060
- const json j{{"x", "test"}};
+ const json j{ { "x", "test" } };
const std::string defval = "default value";
auto val = j.value("x", defval);
auto val2 = j.value("y", defval);
@@ -626,22 +627,22 @@
SECTION("issue #2293 - eof doesn't cause parsing to stop")
{
- const std::vector<uint8_t> data = {0x7B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x20, 0x4F, 0x42};
+ const std::vector<uint8_t> data = { 0x7B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x20, 0x4F, 0x42 };
const json result = json::from_cbor(data, true, false);
CHECK(result.is_discarded());
}
SECTION("issue #2315 - json.update and vector<pair>does not work with ordered_json")
{
- nlohmann::ordered_json jsonAnimals = {{"animal", "dog"}};
- const nlohmann::ordered_json jsonCat = {{"animal", "cat"}};
+ nlohmann::ordered_json jsonAnimals = { { "animal", "dog" } };
+ const nlohmann::ordered_json jsonCat = { { "animal", "cat" } };
jsonAnimals.update(jsonCat);
CHECK(jsonAnimals["animal"] == "cat");
auto jsonAnimals_parsed = nlohmann::ordered_json::parse(jsonAnimals.dump());
CHECK(jsonAnimals == jsonAnimals_parsed);
- const std::vector<std::pair<std::string, int64_t>> intData = {std::make_pair("aaaa", 11), std::make_pair("bbb", 222)};
+ const std::vector<std::pair<std::string, int64_t>> intData = { std::make_pair("aaaa", 11), std::make_pair("bbb", 222) };
nlohmann::ordered_json jsonObj;
for (const auto& data : intData)
{
@@ -675,7 +676,7 @@
SECTION("std::array")
{
{
- const json j = {7, 4};
+ const json j = { 7, 4 };
auto arr = j.get<std::array<NonDefaultConstructible, 2>>();
CHECK(arr[0].x == 7);
CHECK(arr[1].x == 4);
@@ -690,21 +691,21 @@
SECTION("std::pair")
{
{
- const json j = {3, 8};
+ const json j = { 3, 8 };
auto p = j.get<std::pair<NonDefaultConstructible, NonDefaultConstructible>>();
CHECK(p.first.x == 3);
CHECK(p.second.x == 8);
}
{
- const json j = {4, 1};
+ const json j = { 4, 1 };
auto p = j.get<std::pair<int, NonDefaultConstructible>>();
CHECK(p.first == 4);
CHECK(p.second.x == 1);
}
{
- const json j = {6, 7};
+ const json j = { 6, 7 };
auto p = j.get<std::pair<NonDefaultConstructible, int>>();
CHECK(p.first.x == 6);
CHECK(p.second == 7);
@@ -719,13 +720,13 @@
SECTION("std::tuple")
{
{
- const json j = {9};
+ const json j = { 9 };
auto t = j.get<std::tuple<NonDefaultConstructible>>();
CHECK(std::get<0>(t).x == 9);
}
{
- const json j = {9, 8, 7};
+ const json j = { 9, 8, 7 };
auto t = j.get<std::tuple<NonDefaultConstructible, int, NonDefaultConstructible>>();
CHECK(std::get<0>(t).x == 9);
CHECK(std::get<1>(t) == 8);
@@ -803,7 +804,7 @@
SECTION("issue #2982 - to_{binary format} does not provide a mechanism for specifying a custom allocator for the returned type")
{
std::vector<std::uint8_t, my_allocator<std::uint8_t>> my_vector;
- json j = {1, 2, 3, 4};
+ json j = { 1, 2, 3, 4 };
json::to_cbor(j, my_vector);
json k = json::from_cbor(my_vector);
CHECK(j == k);
@@ -836,7 +837,7 @@
SECTION("issue #3108 - ordered_json doesn't support range based erase")
{
- ordered_json j = {1, 2, 2, 4};
+ ordered_json j = { 1, 2, 2, 4 };
auto last = std::unique(j.begin(), j.end());
j.erase(last, j.end());
@@ -855,8 +856,8 @@
SECTION("issue #3343 - json and ordered_json are not interchangable")
{
- json::object_t jobj({{"product", "one"}});
- ordered_json::object_t ojobj({{"product", "one"}});
+ json::object_t jobj({ { "product", "one" } });
+ ordered_json::object_t ojobj({ { "product", "one" } });
auto jit = jobj.begin();
auto ojit = ojobj.begin();
@@ -867,7 +868,7 @@
SECTION("issue #3171 - if class is_constructible from std::string wrong from_json overload is being selected, compilation failed")
{
- const json j{{"str", "value"}};
+ const json j{ { "str", "value" } };
// failed with: error: no match for ‘operator=’ (operand types are ‘for_3171_derived’ and ‘const nlohmann::basic_json<>::string_t’
// {aka ‘const std::__cxx11::basic_string<char>’})
@@ -881,7 +882,7 @@
SECTION("issue #3312 - Parse to custom class from unordered_json breaks on G++11.2.0 with C++20")
{
// see test for #3171
- const ordered_json j = {{"name", "class"}};
+ const ordered_json j = { { "name", "class" } };
for_3312 obj{};
j.get_to(obj);
@@ -913,7 +914,7 @@
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 0a2b67c..f109c1c 100644
--- a/tests/src/unit-serialization.cpp
+++ b/tests/src/unit-serialization.cpp
@@ -21,7 +21,7 @@
SECTION("no given width")
{
std::stringstream ss;
- const json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
+ const json j = { "foo", 1, 2, 3, false, { { "one", 1 } } };
ss << j;
CHECK(ss.str() == "[\"foo\",1,2,3,false,{\"one\":1}]");
}
@@ -29,7 +29,7 @@
SECTION("given width")
{
std::stringstream ss;
- const json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
+ 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]");
}
@@ -37,7 +37,7 @@
SECTION("given fill")
{
std::stringstream ss;
- const json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
+ 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]");
}
@@ -48,7 +48,7 @@
SECTION("no given width")
{
std::stringstream ss;
- const json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
+ const json j = { "foo", 1, 2, 3, false, { { "one", 1 } } };
j >> ss;
CHECK(ss.str() == "[\"foo\",1,2,3,false,{\"one\":1}]");
}
@@ -56,7 +56,7 @@
SECTION("given width")
{
std::stringstream ss;
- const json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
+ 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]");
@@ -65,7 +65,7 @@
SECTION("given fill")
{
std::stringstream ss;
- const json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
+ const json j = { "foo", 1, 2, 3, false, { { "one", 1 } } };
ss.width(1);
ss.fill('\t');
j >> ss;
@@ -249,20 +249,20 @@
TEST_CASE("dump with binary values")
{
- auto binary = json::binary({1, 2, 3, 4});
+ auto binary = json::binary({ 1, 2, 3, 4 });
auto binary_empty = json::binary({});
- auto binary_with_subtype = json::binary({1, 2, 3, 4}, 128);
+ auto binary_with_subtype = json::binary({ 1, 2, 3, 4 }, 128);
auto binary_empty_with_subtype = json::binary({}, 128);
- const json object = {{"key", binary}};
- const json object_empty = {{"key", binary_empty}};
- const json object_with_subtype = {{"key", binary_with_subtype}};
- const json object_empty_with_subtype = {{"key", binary_empty_with_subtype}};
+ const json object = { { "key", binary } };
+ const json object_empty = { { "key", binary_empty } };
+ const json object_with_subtype = { { "key", binary_with_subtype } };
+ const json object_empty_with_subtype = { { "key", binary_empty_with_subtype } };
- const json array = {"value", 1, binary};
- const json array_empty = {"value", 1, binary_empty};
- const json array_with_subtype = {"value", 1, binary_with_subtype};
- const json array_empty_with_subtype = {"value", 1, binary_empty_with_subtype};
+ const json array = { "value", 1, binary };
+ const json array_empty = { "value", 1, binary_empty };
+ const json array_with_subtype = { "value", 1, binary_with_subtype };
+ const json array_empty_with_subtype = { "value", 1, binary_empty_with_subtype };
SECTION("normal")
{
diff --git a/tests/src/unit-testsuites.cpp b/tests/src/unit-testsuites.cpp
index 33c8253..cf681e2 100644
--- a/tests/src/unit-testsuites.cpp
+++ b/tests/src/unit-testsuites.cpp
@@ -20,39 +20,39 @@
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);
@@ -82,7 +82,7 @@
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);
@@ -453,102 +453,102 @@
{
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);
@@ -559,201 +559,201 @@
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);
@@ -767,22 +767,22 @@
// 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);
@@ -793,15 +793,15 @@
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);
@@ -813,11 +813,11 @@
// 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);
@@ -828,19 +828,19 @@
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);
@@ -857,101 +857,101 @@
{
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);
@@ -964,192 +964,193 @@
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);
@@ -1162,8 +1163,8 @@
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);
@@ -1173,41 +1174,41 @@
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);
diff --git a/tests/src/unit-ubjson.cpp b/tests/src/unit-ubjson.cpp
index 1aa5b15..7edb34b 100644
--- a/tests/src/unit-ubjson.cpp
+++ b/tests/src/unit-ubjson.cpp
@@ -113,7 +113,7 @@
SECTION("null")
{
json const j = nullptr;
- std::vector<uint8_t> expected = {'Z'};
+ std::vector<uint8_t> expected = { 'Z' };
const auto result = json::to_ubjson(j);
CHECK(result == expected);
@@ -127,7 +127,7 @@
SECTION("true")
{
json const j = true;
- std::vector<uint8_t> const expected = {'T'};
+ std::vector<uint8_t> const expected = { 'T' };
const auto result = json::to_ubjson(j);
CHECK(result == expected);
@@ -139,7 +139,7 @@
SECTION("false")
{
json const j = false;
- std::vector<uint8_t> const expected = {'F'};
+ std::vector<uint8_t> const expected = { 'F' };
const auto result = json::to_ubjson(j);
CHECK(result == expected);
@@ -294,7 +294,7 @@
SECTION("-9263 (int16)")
{
json const j = -9263;
- std::vector<uint8_t> expected = {'I', 0xdb, 0xd1};
+ std::vector<uint8_t> expected = { 'I', 0xdb, 0xd1 };
// compare result + size
const auto result = json::to_ubjson(j);
@@ -450,7 +450,7 @@
SECTION("65536..2147483647 (int32)")
{
- for (uint32_t i : {65536u, 77777u, 1048576u})
+ for (uint32_t i : { 65536u, 77777u, 1048576u })
{
CAPTURE(i)
@@ -489,7 +489,7 @@
SECTION("2147483648..9223372036854775807 (int64)")
{
- std::vector<uint64_t> const v = {2147483648ul, 9223372036854775807ul};
+ std::vector<uint64_t> const v = { 2147483648ul, 9223372036854775807ul };
for (uint64_t i : v)
{
CAPTURE(i)
@@ -641,7 +641,7 @@
SECTION("65536..2147483647 (int32)")
{
- for (uint32_t i : {65536u, 77777u, 1048576u})
+ for (uint32_t i : { 65536u, 77777u, 1048576u })
{
CAPTURE(i)
@@ -679,7 +679,7 @@
SECTION("2147483648..9223372036854775807 (int64)")
{
- std::vector<uint64_t> const v = {2147483648ul, 9223372036854775807ul};
+ std::vector<uint64_t> const v = { 2147483648ul, 9223372036854775807ul };
for (uint64_t i : v)
{
CAPTURE(i)
@@ -729,7 +729,7 @@
{
double v = 3.1415925;
json const j = v;
- std::vector<uint8_t> expected = {'D', 0x40, 0x09, 0x21, 0xfb, 0x3f, 0xa6, 0xde, 0xfc};
+ std::vector<uint8_t> expected = { 'D', 0x40, 0x09, 0x21, 0xfb, 0x3f, 0xa6, 0xde, 0xfc };
const auto result = json::to_ubjson(j);
CHECK(result == expected);
@@ -744,8 +744,8 @@
{
SECTION("unsigned integer number")
{
- std::vector<uint8_t> 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<uint8_t> 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");
@@ -753,8 +753,8 @@
SECTION("signed integer number")
{
- std::vector<uint8_t> 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<uint8_t> 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");
@@ -762,8 +762,8 @@
SECTION("floating-point number")
{
- std::vector<uint8_t> 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<uint8_t> 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");
@@ -772,24 +772,24 @@
SECTION("errors")
{
// error while parsing length
- std::vector<uint8_t> const vec0 = {'H', 'i'};
+ std::vector<uint8_t> const vec0 = { 'H', 'i' };
CHECK(json::from_ubjson(vec0, true, false).is_discarded());
// error while parsing string
- std::vector<uint8_t> const vec1 = {'H', 'i', '1'};
+ std::vector<uint8_t> const vec1 = { 'H', 'i', '1' };
CHECK(json::from_ubjson(vec1, true, false).is_discarded());
json _;
- std::vector<uint8_t> const vec2 = {'H', 'i', 2, '1', 'A', '3'};
+ std::vector<uint8_t> 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);
- std::vector<uint8_t> const vec3 = {'H', 'i', 2, '1', '.'};
+ std::vector<uint8_t> 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);
- std::vector<uint8_t> const vec4 = {'H', 2, '1', '0'};
+ std::vector<uint8_t> 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",
@@ -804,8 +804,8 @@
// number will be serialized to high-precision number
const auto vec = json::to_ubjson(j);
- std::vector<uint8_t> 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<uint8_t> 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
@@ -887,7 +887,7 @@
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)
@@ -918,7 +918,7 @@
SECTION("N = 65536..2147483647")
{
- for (size_t N : {65536u, 77777u, 1048576u})
+ for (size_t N : { 65536u, 77777u, 1048576u })
{
CAPTURE(N)
@@ -1042,7 +1042,7 @@
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)
@@ -1076,7 +1076,7 @@
SECTION("N = 32768..2147483647")
{
- for (std::size_t N : {32768u, 77777u, 1048576u})
+ for (std::size_t N : { 32768u, 77777u, 1048576u })
{
CAPTURE(N)
@@ -1176,7 +1176,7 @@
SECTION("size=false type=false")
{
json const j = json::array();
- std::vector<uint8_t> expected = {'[', ']'};
+ std::vector<uint8_t> expected = { '[', ']' };
const auto result = json::to_ubjson(j);
CHECK(result == expected);
@@ -1188,7 +1188,7 @@
SECTION("size=true type=false")
{
json const j = json::array();
- std::vector<uint8_t> expected = {'[', '#', 'i', 0};
+ std::vector<uint8_t> expected = { '[', '#', 'i', 0 };
const auto result = json::to_ubjson(j, true);
CHECK(result == expected);
@@ -1200,7 +1200,7 @@
SECTION("size=true type=true")
{
json const j = json::array();
- std::vector<uint8_t> expected = {'[', '#', 'i', 0};
+ std::vector<uint8_t> expected = { '[', '#', 'i', 0 };
const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected);
@@ -1214,8 +1214,8 @@
{
SECTION("size=false type=false")
{
- json const j = {nullptr};
- std::vector<uint8_t> expected = {'[', 'Z', ']'};
+ json const j = { nullptr };
+ std::vector<uint8_t> expected = { '[', 'Z', ']' };
const auto result = json::to_ubjson(j);
CHECK(result == expected);
@@ -1226,8 +1226,8 @@
SECTION("size=true type=false")
{
- json const j = {nullptr};
- std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'};
+ json const j = { nullptr };
+ std::vector<uint8_t> expected = { '[', '#', 'i', 1, 'Z' };
const auto result = json::to_ubjson(j, true);
CHECK(result == expected);
@@ -1238,8 +1238,8 @@
SECTION("size=true type=true")
{
- json const j = {nullptr};
- std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'i', 1};
+ json const j = { nullptr };
+ std::vector<uint8_t> expected = { '[', '$', 'Z', '#', 'i', 1 };
const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected);
@@ -1254,7 +1254,7 @@
SECTION("size=false type=false")
{
json const j = json::parse("[1,2,3,4,5]");
- std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4, 'i', 5, ']'};
+ std::vector<uint8_t> expected = { '[', 'i', 1, 'i', 2, 'i', 3, 'i', 4, 'i', 5, ']' };
const auto result = json::to_ubjson(j);
CHECK(result == expected);
@@ -1266,7 +1266,7 @@
SECTION("size=true type=false")
{
json const j = json::parse("[1,2,3,4,5]");
- std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, 'i', 3, 'i', 4, 'i', 5};
+ std::vector<uint8_t> expected = { '[', '#', 'i', 5, 'i', 1, 'i', 2, 'i', 3, 'i', 4, 'i', 5 };
const auto result = json::to_ubjson(j, true);
CHECK(result == expected);
@@ -1278,7 +1278,7 @@
SECTION("size=true type=true")
{
json const j = json::parse("[1,2,3,4,5]");
- std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3, 4, 5};
+ std::vector<uint8_t> expected = { '[', '$', 'i', '#', 'i', 5, 1, 2, 3, 4, 5 };
const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected);
@@ -1293,7 +1293,7 @@
SECTION("size=false type=false")
{
json const j = json::parse("[[[[]]]]");
- std::vector<uint8_t> expected = {'[', '[', '[', '[', ']', ']', ']', ']'};
+ std::vector<uint8_t> expected = { '[', '[', '[', '[', ']', ']', ']', ']' };
const auto result = json::to_ubjson(j);
CHECK(result == expected);
@@ -1305,7 +1305,7 @@
SECTION("size=true type=false")
{
json const j = json::parse("[[[[]]]]");
- std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 0};
+ std::vector<uint8_t> expected = { '[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 1, '[', '#', 'i', 0 };
const auto result = json::to_ubjson(j, true);
CHECK(result == expected);
@@ -1317,7 +1317,7 @@
SECTION("size=true type=true")
{
json const j = json::parse("[[[[]]]]");
- std::vector<uint8_t> expected = {'[', '$', '[', '#', 'i', 1, '$', '[', '#', 'i', 1, '$', '[', '#', 'i', 1, '#', 'i', 0};
+ std::vector<uint8_t> expected = { '[', '$', '[', '#', 'i', 1, '$', '[', '#', 'i', 1, '$', '[', '#', 'i', 1, '#', 'i', 0 };
const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected);
@@ -1363,7 +1363,7 @@
SECTION("size=true type=true")
{
json j(257, nullptr);
- std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'I', 0x01, 0x01};
+ std::vector<uint8_t> expected = { '[', '$', 'Z', '#', 'I', 0x01, 0x01 };
const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected);
@@ -1411,7 +1411,7 @@
SECTION("size=true type=true")
{
json j(65793, nullptr);
- std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'l', 0x00, 0x01, 0x01, 0x01};
+ std::vector<uint8_t> expected = { '[', '$', 'Z', '#', 'l', 0x00, 0x01, 0x01, 0x01 };
const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected);
@@ -1429,7 +1429,7 @@
SECTION("size=false type=false")
{
json const j = json::object();
- std::vector<uint8_t> expected = {'{', '}'};
+ std::vector<uint8_t> expected = { '{', '}' };
const auto result = json::to_ubjson(j);
CHECK(result == expected);
@@ -1441,7 +1441,7 @@
SECTION("size=true type=false")
{
json const j = json::object();
- std::vector<uint8_t> expected = {'{', '#', 'i', 0};
+ std::vector<uint8_t> expected = { '{', '#', 'i', 0 };
const auto result = json::to_ubjson(j, true);
CHECK(result == expected);
@@ -1453,7 +1453,7 @@
SECTION("size=true type=true")
{
json const j = json::object();
- std::vector<uint8_t> expected = {'{', '#', 'i', 0};
+ std::vector<uint8_t> expected = { '{', '#', 'i', 0 };
const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected);
@@ -1467,8 +1467,8 @@
{
SECTION("size=false type=false")
{
- json const j = {{"", nullptr}};
- std::vector<uint8_t> expected = {'{', 'i', 0, 'Z', '}'};
+ json const j = { { "", nullptr } };
+ std::vector<uint8_t> expected = { '{', 'i', 0, 'Z', '}' };
const auto result = json::to_ubjson(j);
CHECK(result == expected);
@@ -1479,8 +1479,8 @@
SECTION("size=true type=false")
{
- json const j = {{"", nullptr}};
- std::vector<uint8_t> expected = {'{', '#', 'i', 1, 'i', 0, 'Z'};
+ json const j = { { "", nullptr } };
+ std::vector<uint8_t> expected = { '{', '#', 'i', 1, 'i', 0, 'Z' };
const auto result = json::to_ubjson(j, true);
CHECK(result == expected);
@@ -1491,8 +1491,8 @@
SECTION("size=true type=true")
{
- json const j = {{"", nullptr}};
- std::vector<uint8_t> expected = {'{', '$', 'Z', '#', 'i', 1, 'i', 0};
+ json const j = { { "", nullptr } };
+ std::vector<uint8_t> expected = { '{', '$', 'Z', '#', 'i', 1, 'i', 0 };
const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected);
@@ -1507,7 +1507,7 @@
SECTION("size=false type=false")
{
json const j = json::parse(R"({"a": {"b": {"c": {}}}})");
- std::vector<uint8_t> expected = {'{', 'i', 1, 'a', '{', 'i', 1, 'b', '{', 'i', 1, 'c', '{', '}', '}', '}', '}'};
+ std::vector<uint8_t> expected = { '{', 'i', 1, 'a', '{', 'i', 1, 'b', '{', 'i', 1, 'c', '{', '}', '}', '}', '}' };
const auto result = json::to_ubjson(j);
CHECK(result == expected);
@@ -1519,8 +1519,8 @@
SECTION("size=true type=false")
{
json const j = json::parse(R"({"a": {"b": {"c": {}}}})");
- std::vector<uint8_t> expected = {'{', '#', 'i', 1, 'i', 1, 'a', '{', '#', 'i', 1, 'i', 1,
- 'b', '{', '#', 'i', 1, 'i', 1, 'c', '{', '#', 'i', 0};
+ std::vector<uint8_t> 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);
@@ -1532,8 +1532,8 @@
SECTION("size=true type=true")
{
json const j = json::parse(R"({"a": {"b": {"c": {}}}})");
- std::vector<uint8_t> expected = {'{', '$', '{', '#', 'i', 1, 'i', 1, 'a', '$', '{', '#', 'i', 1,
- 'i', 1, 'b', '$', '{', '#', 'i', 1, 'i', 1, 'c', '#', 'i', 0};
+ std::vector<uint8_t> 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);
@@ -1549,7 +1549,7 @@
{
SECTION("strict mode")
{
- std::vector<uint8_t> const vec = {'Z', 'Z'};
+ std::vector<uint8_t> const vec = { 'Z', 'Z' };
SECTION("non-strict mode")
{
const auto result = json::from_ubjson(vec, false);
@@ -1570,7 +1570,7 @@
{
SECTION("array")
{
- std::vector<uint8_t> const v_ubjson = {'[', '$', 'Z', '#', 'L', 0x78, 0x28, 0x00, 0x68, 0x28, 0x69, 0x69, 0x17};
+ std::vector<uint8_t> const v_ubjson = { '[', '$', 'Z', '#', 'L', 0x78, 0x28, 0x00, 0x68, 0x28, 0x69, 0x69, 0x17 };
json _;
CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&);
@@ -1584,7 +1584,7 @@
SECTION("object")
{
- std::vector<uint8_t> const v_ubjson = {'{', '$', 'Z', '#', 'L', 0x78, 0x28, 0x00, 0x68, 0x28, 0x69, 0x69, 0x17};
+ std::vector<uint8_t> const v_ubjson = { '{', '$', 'Z', '#', 'L', 0x78, 0x28, 0x00, 0x68, 0x28, 0x69, 0x69, 0x17 };
json _;
CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&);
@@ -1602,42 +1602,42 @@
{
SECTION("start_array()")
{
- std::vector<uint8_t> const v = {'[', 'T', 'F', ']'};
+ std::vector<uint8_t> const v = { '[', 'T', 'F', ']' };
SaxCountdown scp(0);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
}
SECTION("start_object()")
{
- std::vector<uint8_t> const v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'};
+ std::vector<uint8_t> const v = { '{', 'i', 3, 'f', 'o', 'o', 'F', '}' };
SaxCountdown scp(0);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
}
SECTION("key() in object")
{
- std::vector<uint8_t> const v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'};
+ std::vector<uint8_t> const v = { '{', 'i', 3, 'f', 'o', 'o', 'F', '}' };
SaxCountdown scp(1);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
}
SECTION("start_array(len)")
{
- std::vector<uint8_t> const v = {'[', '#', 'i', '2', 'T', 'F'};
+ std::vector<uint8_t> const v = { '[', '#', 'i', '2', 'T', 'F' };
SaxCountdown scp(0);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
}
SECTION("start_object(len)")
{
- std::vector<uint8_t> const v = {'{', '#', 'i', '1', 3, 'f', 'o', 'o', 'F'};
+ std::vector<uint8_t> const v = { '{', '#', 'i', '1', 3, 'f', 'o', 'o', 'F' };
SaxCountdown scp(0);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
}
SECTION("key() in object with length")
{
- std::vector<uint8_t> const v = {'{', 'i', 3, 'f', 'o', 'o', 'F', '}'};
+ std::vector<uint8_t> const v = { '{', 'i', 3, 'f', 'o', 'o', 'F', '}' };
SaxCountdown scp(1);
CHECK(!json::sax_parse(v, &scp, json::input_format_t::ubjson));
}
@@ -1648,11 +1648,11 @@
SECTION("strings")
{
// create a single-character string for all number types
- std::vector<uint8_t> s_i = {'S', 'i', 1, 'a'};
- std::vector<uint8_t> const s_U = {'S', 'U', 1, 'a'};
- std::vector<uint8_t> const s_I = {'S', 'I', 0, 1, 'a'};
- std::vector<uint8_t> const s_l = {'S', 'l', 0, 0, 0, 1, 'a'};
- std::vector<uint8_t> const s_L = {'S', 'L', 0, 0, 0, 0, 0, 0, 0, 1, 'a'};
+ std::vector<uint8_t> s_i = { 'S', 'i', 1, 'a' };
+ std::vector<uint8_t> const s_U = { 'S', 'U', 1, 'a' };
+ std::vector<uint8_t> const s_I = { 'S', 'I', 0, 1, 'a' };
+ std::vector<uint8_t> const s_l = { 'S', 'l', 0, 0, 0, 1, 'a' };
+ std::vector<uint8_t> const s_L = { 'S', 'L', 0, 0, 0, 0, 0, 0, 0, 1, 'a' };
// check if string is parsed correctly to "a"
CHECK(json::from_ubjson(s_i) == "a");
@@ -1674,11 +1674,11 @@
SECTION("float")
{
// float32
- std::vector<uint8_t> const v_d = {'d', 0x40, 0x49, 0x0f, 0xd0};
+ std::vector<uint8_t> const v_d = { 'd', 0x40, 0x49, 0x0f, 0xd0 };
CHECK(json::from_ubjson(v_d) == 3.14159f);
// float64
- std::vector<uint8_t> const v_D = {'D', 0x40, 0x09, 0x21, 0xf9, 0xf0, 0x1b, 0x86, 0x6e};
+ std::vector<uint8_t> const v_D = { 'D', 0x40, 0x09, 0x21, 0xf9, 0xf0, 0x1b, 0x86, 0x6e };
CHECK(json::from_ubjson(v_D) == 3.14159);
// float32 is serialized as float64 as the library does not support float32
@@ -1691,34 +1691,34 @@
SECTION("optimized version (length only)")
{
// create vector with two elements of the same type
- std::vector<uint8_t> const v_TU = {'[', '#', 'U', 2, 'T', 'T'};
- std::vector<uint8_t> const v_T = {'[', '#', 'i', 2, 'T', 'T'};
- std::vector<uint8_t> const v_F = {'[', '#', 'i', 2, 'F', 'F'};
- std::vector<uint8_t> const v_Z = {'[', '#', 'i', 2, 'Z', 'Z'};
- std::vector<uint8_t> const v_i = {'[', '#', 'i', 2, 'i', 0x7F, 'i', 0x7F};
- std::vector<uint8_t> const v_U = {'[', '#', 'i', 2, 'U', 0xFF, 'U', 0xFF};
- std::vector<uint8_t> const v_I = {'[', '#', 'i', 2, 'I', 0x7F, 0xFF, 'I', 0x7F, 0xFF};
- std::vector<uint8_t> const v_l = {'[', '#', 'i', 2, 'l', 0x7F, 0xFF, 0xFF, 0xFF, 'l', 0x7F, 0xFF, 0xFF, 0xFF};
- std::vector<uint8_t> 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<uint8_t> 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<uint8_t> const v_S = {'[', '#', 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a'};
- std::vector<uint8_t> const v_C = {'[', '#', 'i', 2, 'C', 'a', 'C', 'a'};
+ std::vector<uint8_t> const v_TU = { '[', '#', 'U', 2, 'T', 'T' };
+ std::vector<uint8_t> const v_T = { '[', '#', 'i', 2, 'T', 'T' };
+ std::vector<uint8_t> const v_F = { '[', '#', 'i', 2, 'F', 'F' };
+ std::vector<uint8_t> const v_Z = { '[', '#', 'i', 2, 'Z', 'Z' };
+ std::vector<uint8_t> const v_i = { '[', '#', 'i', 2, 'i', 0x7F, 'i', 0x7F };
+ std::vector<uint8_t> const v_U = { '[', '#', 'i', 2, 'U', 0xFF, 'U', 0xFF };
+ std::vector<uint8_t> const v_I = { '[', '#', 'i', 2, 'I', 0x7F, 0xFF, 'I', 0x7F, 0xFF };
+ std::vector<uint8_t> const v_l = { '[', '#', 'i', 2, 'l', 0x7F, 0xFF, 0xFF, 0xFF, 'l', 0x7F, 0xFF, 0xFF, 0xFF };
+ std::vector<uint8_t> 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<uint8_t> 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<uint8_t> const v_S = { '[', '#', 'i', 2, 'S', 'i', 1, 'a', 'S', 'i', 1, 'a' };
+ std::vector<uint8_t> const v_C = { '[', '#', 'i', 2, 'C', 'a', 'C', 'a' };
// check if vector is parsed correctly
- CHECK(json::from_ubjson(v_TU) == json({true, true}));
- CHECK(json::from_ubjson(v_T) == json({true, true}));
- CHECK(json::from_ubjson(v_F) == json({false, false}));
- CHECK(json::from_ubjson(v_Z) == json({nullptr, nullptr}));
- CHECK(json::from_ubjson(v_i) == json({127, 127}));
- CHECK(json::from_ubjson(v_U) == json({255, 255}));
- CHECK(json::from_ubjson(v_I) == json({32767, 32767}));
- CHECK(json::from_ubjson(v_l) == json({2147483647, 2147483647}));
- CHECK(json::from_ubjson(v_L) == json({9223372036854775807, 9223372036854775807}));
- CHECK(json::from_ubjson(v_D) == json({3.1415926, 3.1415926}));
- CHECK(json::from_ubjson(v_S) == json({"a", "a"}));
- CHECK(json::from_ubjson(v_C) == json({"a", "a"}));
+ CHECK(json::from_ubjson(v_TU) == json({ true, true }));
+ CHECK(json::from_ubjson(v_T) == json({ true, true }));
+ CHECK(json::from_ubjson(v_F) == json({ false, false }));
+ CHECK(json::from_ubjson(v_Z) == json({ nullptr, nullptr }));
+ CHECK(json::from_ubjson(v_i) == json({ 127, 127 }));
+ CHECK(json::from_ubjson(v_U) == json({ 255, 255 }));
+ CHECK(json::from_ubjson(v_I) == json({ 32767, 32767 }));
+ CHECK(json::from_ubjson(v_l) == json({ 2147483647, 2147483647 }));
+ CHECK(json::from_ubjson(v_L) == json({ 9223372036854775807, 9223372036854775807 }));
+ CHECK(json::from_ubjson(v_D) == json({ 3.1415926, 3.1415926 }));
+ CHECK(json::from_ubjson(v_S) == json({ "a", "a" }));
+ CHECK(json::from_ubjson(v_C) == json({ "a", "a" }));
// roundtrip: output should be optimized
CHECK(json::to_ubjson(json::from_ubjson(v_T), true) == v_T);
@@ -1737,37 +1737,37 @@
SECTION("optimized version (type and length)")
{
// create vector with two elements of the same type
- std::vector<uint8_t> const v_N = {'[', '$', 'N', '#', 'i', 2};
- std::vector<uint8_t> const v_T = {'[', '$', 'T', '#', 'i', 2};
- std::vector<uint8_t> const v_F = {'[', '$', 'F', '#', 'i', 2};
- std::vector<uint8_t> const v_Z = {'[', '$', 'Z', '#', 'i', 2};
- std::vector<uint8_t> const v_i = {'[', '$', 'i', '#', 'i', 2, 0x7F, 0x7F};
- std::vector<uint8_t> const v_U = {'[', '$', 'U', '#', 'i', 2, 0xFF, 0xFF};
- std::vector<uint8_t> const v_I = {'[', '$', 'I', '#', 'i', 2, 0x7F, 0xFF, 0x7F, 0xFF};
- std::vector<uint8_t> const v_l = {'[', '$', 'l', '#', 'i', 2, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF};
- std::vector<uint8_t> const v_L = {'[', '$', 'L', '#', 'i', 2, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
- std::vector<uint8_t> const v_D = {'[', '$', 'D', '#', 'i', 2, 0x40, 0x09, 0x21, 0xfb, 0x4d,
- 0x12, 0xd8, 0x4a, 0x40, 0x09, 0x21, 0xfb, 0x4d, 0x12, 0xd8, 0x4a};
- std::vector<uint8_t> const v_S = {'[', '$', 'S', '#', 'i', 2, 'i', 1, 'a', 'i', 1, 'a'};
- std::vector<uint8_t> const v_C = {'[', '$', 'C', '#', 'i', 2, 'a', 'a'};
+ std::vector<uint8_t> const v_N = { '[', '$', 'N', '#', 'i', 2 };
+ std::vector<uint8_t> const v_T = { '[', '$', 'T', '#', 'i', 2 };
+ std::vector<uint8_t> const v_F = { '[', '$', 'F', '#', 'i', 2 };
+ std::vector<uint8_t> const v_Z = { '[', '$', 'Z', '#', 'i', 2 };
+ std::vector<uint8_t> const v_i = { '[', '$', 'i', '#', 'i', 2, 0x7F, 0x7F };
+ std::vector<uint8_t> const v_U = { '[', '$', 'U', '#', 'i', 2, 0xFF, 0xFF };
+ std::vector<uint8_t> const v_I = { '[', '$', 'I', '#', 'i', 2, 0x7F, 0xFF, 0x7F, 0xFF };
+ std::vector<uint8_t> const v_l = { '[', '$', 'l', '#', 'i', 2, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF };
+ std::vector<uint8_t> const v_L = { '[', '$', 'L', '#', 'i', 2, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+ std::vector<uint8_t> const v_D = { '[', '$', 'D', '#', 'i', 2, 0x40, 0x09, 0x21, 0xfb, 0x4d,
+ 0x12, 0xd8, 0x4a, 0x40, 0x09, 0x21, 0xfb, 0x4d, 0x12, 0xd8, 0x4a };
+ std::vector<uint8_t> const v_S = { '[', '$', 'S', '#', 'i', 2, 'i', 1, 'a', 'i', 1, 'a' };
+ std::vector<uint8_t> const v_C = { '[', '$', 'C', '#', 'i', 2, 'a', 'a' };
// check if vector is parsed correctly
CHECK(json::from_ubjson(v_N) == json::array());
- CHECK(json::from_ubjson(v_T) == json({true, true}));
- CHECK(json::from_ubjson(v_F) == json({false, false}));
- CHECK(json::from_ubjson(v_Z) == json({nullptr, nullptr}));
- CHECK(json::from_ubjson(v_i) == json({127, 127}));
- CHECK(json::from_ubjson(v_U) == json({255, 255}));
- CHECK(json::from_ubjson(v_I) == json({32767, 32767}));
- CHECK(json::from_ubjson(v_l) == json({2147483647, 2147483647}));
- CHECK(json::from_ubjson(v_L) == json({9223372036854775807, 9223372036854775807}));
- CHECK(json::from_ubjson(v_D) == json({3.1415926, 3.1415926}));
- CHECK(json::from_ubjson(v_S) == json({"a", "a"}));
- CHECK(json::from_ubjson(v_C) == json({"a", "a"}));
+ CHECK(json::from_ubjson(v_T) == json({ true, true }));
+ CHECK(json::from_ubjson(v_F) == json({ false, false }));
+ CHECK(json::from_ubjson(v_Z) == json({ nullptr, nullptr }));
+ CHECK(json::from_ubjson(v_i) == json({ 127, 127 }));
+ CHECK(json::from_ubjson(v_U) == json({ 255, 255 }));
+ CHECK(json::from_ubjson(v_I) == json({ 32767, 32767 }));
+ CHECK(json::from_ubjson(v_l) == json({ 2147483647, 2147483647 }));
+ CHECK(json::from_ubjson(v_L) == json({ 9223372036854775807, 9223372036854775807 }));
+ CHECK(json::from_ubjson(v_D) == json({ 3.1415926, 3.1415926 }));
+ CHECK(json::from_ubjson(v_S) == json({ "a", "a" }));
+ CHECK(json::from_ubjson(v_C) == json({ "a", "a" }));
// roundtrip: output should be optimized
- std::vector<uint8_t> const v_empty = {'[', '#', 'i', 0};
+ std::vector<uint8_t> const v_empty = { '[', '#', 'i', 0 };
CHECK(json::to_ubjson(json::from_ubjson(v_N), true, true) == v_empty);
CHECK(json::to_ubjson(json::from_ubjson(v_T), true, true) == v_T);
CHECK(json::to_ubjson(json::from_ubjson(v_F), true, true) == v_F);
@@ -1798,7 +1798,7 @@
{
SECTION("eof after C byte")
{
- std::vector<uint8_t> const v = {'C'};
+ std::vector<uint8_t> 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",
@@ -1807,7 +1807,7 @@
SECTION("byte out of range")
{
- std::vector<uint8_t> const v = {'C', 130};
+ std::vector<uint8_t> const v = { 'C', 130 };
json _;
CHECK_THROWS_WITH_AS(
_ = json::from_ubjson(v),
@@ -1820,7 +1820,7 @@
{
SECTION("eof after S byte")
{
- std::vector<uint8_t> const v = {'S'};
+ std::vector<uint8_t> 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",
@@ -1829,7 +1829,7 @@
SECTION("invalid byte")
{
- std::vector<uint8_t> const v = {'S', '1', 'a'};
+ std::vector<uint8_t> const v = { 'S', '1', 'a' };
json _;
CHECK_THROWS_WITH_AS(
_ = json::from_ubjson(v),
@@ -1842,7 +1842,7 @@
{
SECTION("optimized array: no size following type")
{
- std::vector<uint8_t> const v = {'[', '$', 'i', 2};
+ std::vector<uint8_t> const v = { '[', '$', 'i', 2 };
json _;
CHECK_THROWS_WITH_AS(
_ = json::from_ubjson(v),
@@ -1853,20 +1853,20 @@
SECTION("strings")
{
- std::vector<uint8_t> const vS = {'S'};
+ std::vector<uint8_t> 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(json::from_ubjson(vS, true, false).is_discarded());
- std::vector<uint8_t> const v = {'S', 'i', '2', 'a'};
+ std::vector<uint8_t> 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(json::from_ubjson(v, true, false).is_discarded());
- std::vector<uint8_t> const vC = {'C'};
+ std::vector<uint8_t> 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&);
@@ -1875,38 +1875,38 @@
SECTION("sizes")
{
- std::vector<uint8_t> const vU = {'[', '#', 'U'};
+ std::vector<uint8_t> 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(json::from_ubjson(vU, true, false).is_discarded());
- std::vector<uint8_t> const vi = {'[', '#', 'i'};
+ std::vector<uint8_t> 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(json::from_ubjson(vi, true, false).is_discarded());
- std::vector<uint8_t> const vI = {'[', '#', 'I'};
+ std::vector<uint8_t> 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(json::from_ubjson(vI, true, false).is_discarded());
- std::vector<uint8_t> const vl = {'[', '#', 'l'};
+ std::vector<uint8_t> 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(json::from_ubjson(vl, true, false).is_discarded());
- std::vector<uint8_t> const vL = {'[', '#', 'L'};
+ std::vector<uint8_t> 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(json::from_ubjson(vL, true, false).is_discarded());
- std::vector<uint8_t> const v0 = {'[', '#', 'T', ']'};
+ std::vector<uint8_t> 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",
@@ -1916,20 +1916,20 @@
SECTION("types")
{
- std::vector<uint8_t> const v0 = {'[', '$'};
+ std::vector<uint8_t> 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(json::from_ubjson(v0, true, false).is_discarded());
- std::vector<uint8_t> const vi = {'[', '$', '#'};
+ std::vector<uint8_t> 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(json::from_ubjson(vi, true, false).is_discarded());
- std::vector<uint8_t> const vT = {'[', '$', 'T'};
+ std::vector<uint8_t> 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&);
@@ -1938,20 +1938,20 @@
SECTION("arrays")
{
- std::vector<uint8_t> const vST = {'[', '$', 'i', '#', 'i', 2, 1};
+ std::vector<uint8_t> 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(json::from_ubjson(vST, true, false).is_discarded());
- std::vector<uint8_t> const vS = {'[', '#', 'i', 2, 'i', 1};
+ std::vector<uint8_t> 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(json::from_ubjson(vS, true, false).is_discarded());
- std::vector<uint8_t> const v = {'[', 'i', 2, 'i', 1};
+ std::vector<uint8_t> 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&);
@@ -1960,51 +1960,51 @@
SECTION("objects")
{
- std::vector<uint8_t> const vST = {'{', '$', 'i', '#', 'i', 2, 'i', 1, 'a', 1};
+ std::vector<uint8_t> 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(json::from_ubjson(vST, true, false).is_discarded());
- std::vector<uint8_t> const vT = {'{', '$', 'i', 'i', 1, 'a', 1};
+ std::vector<uint8_t> 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(json::from_ubjson(vT, true, false).is_discarded());
- std::vector<uint8_t> const vS = {'{', '#', 'i', 2, 'i', 1, 'a', 'i', 1};
+ std::vector<uint8_t> 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(json::from_ubjson(vS, true, false).is_discarded());
- std::vector<uint8_t> const v = {'{', 'i', 1, 'a', 'i', 1};
+ std::vector<uint8_t> 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(json::from_ubjson(v, true, false).is_discarded());
- std::vector<uint8_t> const v2 = {'{', 'i', 1, 'a', 'i', 1, 'i'};
+ std::vector<uint8_t> 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(json::from_ubjson(v2, true, false).is_discarded());
- std::vector<uint8_t> const v3 = {'{', 'i', 1, 'a'};
+ std::vector<uint8_t> 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(json::from_ubjson(v3, true, false).is_discarded());
- std::vector<uint8_t> const vST1 = {'{', '$', 'd', '#', 'i', 2, 'i', 1, 'a'};
+ std::vector<uint8_t> 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(json::from_ubjson(vST1, true, false).is_discarded());
- std::vector<uint8_t> const vST2 = {'{', '#', 'i', 2, 'i', 1, 'a'};
+ std::vector<uint8_t> 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&);
@@ -2018,37 +2018,37 @@
{
SECTION("array of i")
{
- json const j = {1, -1};
- std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 2, 1, 0xff};
+ json const j = { 1, -1 };
+ std::vector<uint8_t> expected = { '[', '$', 'i', '#', 'i', 2, 1, 0xff };
CHECK(json::to_ubjson(j, true, true) == expected);
}
SECTION("array of U")
{
- json const j = {200, 201};
- std::vector<uint8_t> expected = {'[', '$', 'U', '#', 'i', 2, 0xC8, 0xC9};
+ json const j = { 200, 201 };
+ std::vector<uint8_t> expected = { '[', '$', 'U', '#', 'i', 2, 0xC8, 0xC9 };
CHECK(json::to_ubjson(j, true, true) == expected);
}
SECTION("array of I")
{
- json const j = {30000, -30000};
- std::vector<uint8_t> expected = {'[', '$', 'I', '#', 'i', 2, 0x75, 0x30, 0x8a, 0xd0};
+ json const j = { 30000, -30000 };
+ std::vector<uint8_t> expected = { '[', '$', 'I', '#', 'i', 2, 0x75, 0x30, 0x8a, 0xd0 };
CHECK(json::to_ubjson(j, true, true) == expected);
}
SECTION("array of l")
{
- json const j = {70000, -70000};
- std::vector<uint8_t> expected = {'[', '$', 'l', '#', 'i', 2, 0x00, 0x01, 0x11, 0x70, 0xFF, 0xFE, 0xEE, 0x90};
+ json const j = { 70000, -70000 };
+ std::vector<uint8_t> expected = { '[', '$', 'l', '#', 'i', 2, 0x00, 0x01, 0x11, 0x70, 0xFF, 0xFE, 0xEE, 0x90 };
CHECK(json::to_ubjson(j, true, true) == expected);
}
SECTION("array of L")
{
- json const j = {5000000000, -5000000000};
- std::vector<uint8_t> expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0x00, 0x00, 0x01, 0x2A,
- 0x05, 0xF2, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0xD5, 0xFA, 0x0E, 0x00};
+ json const j = { 5000000000, -5000000000 };
+ std::vector<uint8_t> 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);
}
}
@@ -2057,47 +2057,47 @@
{
SECTION("array of i")
{
- json const j = {1u, 2u};
- std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 2, 1, 2};
- std::vector<uint8_t> expected_size = {'[', '#', 'i', 2, 'i', 1, 'i', 2};
+ json const j = { 1u, 2u };
+ std::vector<uint8_t> expected = { '[', '$', 'i', '#', 'i', 2, 1, 2 };
+ std::vector<uint8_t> expected_size = { '[', '#', 'i', 2, 'i', 1, 'i', 2 };
CHECK(json::to_ubjson(j, true, true) == expected);
CHECK(json::to_ubjson(j, true) == expected_size);
}
SECTION("array of U")
{
- json const j = {200u, 201u};
- std::vector<uint8_t> expected = {'[', '$', 'U', '#', 'i', 2, 0xC8, 0xC9};
- std::vector<uint8_t> expected_size = {'[', '#', 'i', 2, 'U', 0xC8, 'U', 0xC9};
+ json const j = { 200u, 201u };
+ std::vector<uint8_t> expected = { '[', '$', 'U', '#', 'i', 2, 0xC8, 0xC9 };
+ std::vector<uint8_t> expected_size = { '[', '#', 'i', 2, 'U', 0xC8, 'U', 0xC9 };
CHECK(json::to_ubjson(j, true, true) == expected);
CHECK(json::to_ubjson(j, true) == expected_size);
}
SECTION("array of I")
{
- json const j = {30000u, 30001u};
- std::vector<uint8_t> expected = {'[', '$', 'I', '#', 'i', 2, 0x75, 0x30, 0x75, 0x31};
- std::vector<uint8_t> expected_size = {'[', '#', 'i', 2, 'I', 0x75, 0x30, 'I', 0x75, 0x31};
+ json const j = { 30000u, 30001u };
+ std::vector<uint8_t> expected = { '[', '$', 'I', '#', 'i', 2, 0x75, 0x30, 0x75, 0x31 };
+ std::vector<uint8_t> expected_size = { '[', '#', 'i', 2, 'I', 0x75, 0x30, 'I', 0x75, 0x31 };
CHECK(json::to_ubjson(j, true, true) == expected);
CHECK(json::to_ubjson(j, true) == expected_size);
}
SECTION("array of l")
{
- json const j = {70000u, 70001u};
- std::vector<uint8_t> expected = {'[', '$', 'l', '#', 'i', 2, 0x00, 0x01, 0x11, 0x70, 0x00, 0x01, 0x11, 0x71};
- std::vector<uint8_t> expected_size = {'[', '#', 'i', 2, 'l', 0x00, 0x01, 0x11, 0x70, 'l', 0x00, 0x01, 0x11, 0x71};
+ json const j = { 70000u, 70001u };
+ std::vector<uint8_t> expected = { '[', '$', 'l', '#', 'i', 2, 0x00, 0x01, 0x11, 0x70, 0x00, 0x01, 0x11, 0x71 };
+ std::vector<uint8_t> expected_size = { '[', '#', 'i', 2, 'l', 0x00, 0x01, 0x11, 0x70, 'l', 0x00, 0x01, 0x11, 0x71 };
CHECK(json::to_ubjson(j, true, true) == expected);
CHECK(json::to_ubjson(j, true) == expected_size);
}
SECTION("array of L")
{
- json const j = {5000000000u, 5000000001u};
- std::vector<uint8_t> expected = {'[', '$', 'L', '#', 'i', 2, 0x00, 0x00, 0x00, 0x01, 0x2A,
- 0x05, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05, 0xF2, 0x01};
- std::vector<uint8_t> expected_size = {'[', '#', 'i', 2, 'L', 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05,
- 0xF2, 0x00, 'L', 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05, 0xF2, 0x01};
+ json const j = { 5000000000u, 5000000001u };
+ std::vector<uint8_t> expected = { '[', '$', 'L', '#', 'i', 2, 0x00, 0x00, 0x00, 0x01, 0x2A,
+ 0x05, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2A, 0x05, 0xF2, 0x01 };
+ std::vector<uint8_t> 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);
}
@@ -2105,8 +2105,8 @@
SECTION("discarded")
{
- json const j = {json::value_t::discarded, json::value_t::discarded};
- std::vector<uint8_t> expected = {'[', '$', 'N', '#', 'i', 2};
+ json const j = { json::value_t::discarded, json::value_t::discarded };
+ std::vector<uint8_t> expected = { '[', '$', 'N', '#', 'i', 2 };
CHECK(json::to_ubjson(j, true, true) == expected);
}
}
@@ -2116,18 +2116,18 @@
{
SECTION("Null Value")
{
- json const j = {{"passcode", nullptr}};
- std::vector<uint8_t> const v = {'{', 'i', 8, 'p', 'a', 's', 's', 'c', 'o', 'd', 'e', 'Z', '}'};
+ json const j = { { "passcode", nullptr } };
+ std::vector<uint8_t> const v = { '{', 'i', 8, 'p', 'a', 's', 's', 'c', 'o', 'd', 'e', 'Z', '}' };
CHECK(json::to_ubjson(j) == v);
CHECK(json::from_ubjson(v) == j);
}
SECTION("No-Op Value")
{
- json const j = {"foo", "bar", "baz"};
- std::vector<uint8_t> const v = {'[', 'S', 'i', 3, 'f', 'o', 'o', 'S', 'i', 3, 'b', 'a', 'r', 'S', 'i', 3, 'b', 'a', 'z', ']'};
- std::vector<uint8_t> 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', ']'};
+ json const j = { "foo", "bar", "baz" };
+ std::vector<uint8_t> const v = { '[', 'S', 'i', 3, 'f', 'o', 'o', 'S', 'i', 3, 'b', 'a', 'r', 'S', 'i', 3, 'b', 'a', 'z', ']' };
+ std::vector<uint8_t> 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);
@@ -2135,28 +2135,30 @@
SECTION("Boolean Types")
{
- json const j = {{"authorized", true}, {"verified", false}};
- std::vector<uint8_t> 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', '}'};
+ json const j = { { "authorized", true }, { "verified", false } };
+ std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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);
}
SECTION("Char Type")
{
- json const j = {{"rolecode", "a"}, {"delim", ";"}};
- std::vector<uint8_t> const v = {'{', 'i', 5, 'd', 'e', 'l', 'i', 'm', 'C', ';', 'i', 8, 'r', 'o', 'l', 'e', 'c', 'o', 'd', 'e', 'C', 'a', '}'};
+ json const j = { { "rolecode", "a" }, { "delim", ";" } };
+ std::vector<uint8_t> const v = { '{', 'i', 5, 'd', 'e', 'l', 'i', 'm', 'C', ';', 'i', 8, 'r', 'o', 'l', 'e', 'c', 'o', 'd', 'e', 'C', 'a', '}' };
//CHECK(json::to_ubjson(j) == v);
CHECK(json::from_ubjson(v) == j);
}
@@ -2166,7 +2168,7 @@
SECTION("English")
{
json const j = "hello";
- std::vector<uint8_t> const v = {'S', 'i', 5, 'h', 'e', 'l', 'l', 'o'};
+ std::vector<uint8_t> const v = { 'S', 'i', 5, 'h', 'e', 'l', 'l', 'o' };
CHECK(json::to_ubjson(j) == v);
CHECK(json::from_ubjson(v) == j);
}
@@ -2174,7 +2176,7 @@
SECTION("Russian")
{
json const j = "привет";
- std::vector<uint8_t> const v = {'S', 'i', 12, 0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82};
+ std::vector<uint8_t> const v = { 'S', 'i', 12, 0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x82 };
CHECK(json::to_ubjson(j) == v);
CHECK(json::from_ubjson(v) == j);
}
@@ -2182,7 +2184,7 @@
SECTION("Russian")
{
json const j = "مرحبا";
- std::vector<uint8_t> const v = {'S', 'i', 10, 0xD9, 0x85, 0xD8, 0xB1, 0xD8, 0xAD, 0xD8, 0xA8, 0xD8, 0xA7};
+ std::vector<uint8_t> const v = { 'S', 'i', 10, 0xD9, 0x85, 0xD8, 0xB1, 0xD8, 0xAD, 0xD8, 0xA8, 0xD8, 0xA7 };
CHECK(json::to_ubjson(j) == v);
CHECK(json::from_ubjson(v) == j);
}
@@ -2193,9 +2195,9 @@
SECTION("size=false type=false")
{
// note the float has been replaced by a double
- json const j = {nullptr, true, false, 4782345193, 153.132, "ham"};
- std::vector<uint8_t> 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', ']'};
+ json const j = { nullptr, true, false, 4782345193, 153.132, "ham" };
+ std::vector<uint8_t> 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);
}
@@ -2203,9 +2205,9 @@
SECTION("size=true type=false")
{
// note the float has been replaced by a double
- json const j = {nullptr, true, false, 4782345193, 153.132, "ham"};
- std::vector<uint8_t> 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'};
+ json const j = { nullptr, true, false, 4782345193, 153.132, "ham" };
+ std::vector<uint8_t> 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);
}
@@ -2213,9 +2215,9 @@
SECTION("size=true type=true")
{
// note the float has been replaced by a double
- json const j = {nullptr, true, false, 4782345193, 153.132, "ham"};
- std::vector<uint8_t> 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'};
+ json const j = { nullptr, true, false, 4782345193, 153.132, "ham" };
+ std::vector<uint8_t> 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);
}
@@ -2225,33 +2227,33 @@
{
SECTION("size=false type=false")
{
- json const j = {{"post", {{"id", 1137}, {"author", "rkalla"}, {"timestamp", 1364482090592}, {"body", "I totally agree!"}}}};
- std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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);
}
@@ -2264,10 +2266,10 @@
SECTION("No Optimization")
{
// note the floats have been replaced by doubles
- json const j = {29.97, 31.13, 67.0, 2.113, 23.888};
- std::vector<uint8_t> 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, ']'};
+ json const j = { 29.97, 31.13, 67.0, 2.113, 23.888 };
+ std::vector<uint8_t> 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);
}
@@ -2275,10 +2277,10 @@
SECTION("Optimized with count")
{
// note the floats have been replaced by doubles
- json const j = {29.97, 31.13, 67.0, 2.113, 23.888};
- std::vector<uint8_t> 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};
+ json const j = { 29.97, 31.13, 67.0, 2.113, 23.888 };
+ std::vector<uint8_t> 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);
}
@@ -2286,10 +2288,10 @@
SECTION("Optimized with type & count")
{
// note the floats have been replaced by doubles
- json const j = {29.97, 31.13, 67.0, 2.113, 23.888};
- std::vector<uint8_t> 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};
+ json const j = { 29.97, 31.13, 67.0, 2.113, 23.888 };
+ std::vector<uint8_t> 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);
}
@@ -2300,10 +2302,10 @@
SECTION("No Optimization")
{
// note the floats have been replaced by doubles
- json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}};
- std::vector<uint8_t> 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, '}'};
+ json const j = { { "lat", 29.976 }, { "long", 31.131 }, { "alt", 67.0 } };
+ std::vector<uint8_t> 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);
}
@@ -2311,10 +2313,10 @@
SECTION("Optimized with count")
{
// note the floats have been replaced by doubles
- json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}};
- std::vector<uint8_t> 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};
+ json const j = { { "lat", 29.976 }, { "long", 31.131 }, { "alt", 67.0 } };
+ std::vector<uint8_t> 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);
}
@@ -2322,10 +2324,10 @@
SECTION("Optimized with type & count")
{
// note the floats have been replaced by doubles
- json const j = {{"lat", 29.976}, {"long", 31.131}, {"alt", 67.0}};
- std::vector<uint8_t> 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};
+ json const j = { { "lat", 29.976 }, { "long", 31.131 }, { "alt", 67.0 } };
+ std::vector<uint8_t> 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);
}
@@ -2335,15 +2337,15 @@
{
SECTION("Array")
{
- std::vector<uint8_t> const v = {'[', '$', 'N', '#', 'I', 0x02, 0x00};
+ std::vector<uint8_t> const v = { '[', '$', 'N', '#', 'I', 0x02, 0x00 };
CHECK(json::from_ubjson(v) == json::array());
}
SECTION("Object")
{
- std::vector<uint8_t> 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}}));
+ std::vector<uint8_t> 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 } }));
}
}
}
@@ -2353,7 +2355,7 @@
TEST_CASE("all UBJSON first bytes")
{
// these bytes will fail immediately with exception parse_error.112
- std::set<uint8_t> supported = {'T', 'F', 'Z', 'U', 'i', 'I', 'l', 'L', 'd', 'D', 'C', 'S', '[', '{', 'N', 'H'};
+ std::set<uint8_t> supported = { 'T', 'F', 'Z', 'U', 'i', 'I', 'l', 'L', 'd', 'D', 'C', 'S', '[', '{', 'N', 'H' };
for (auto i = 0; i < 256; ++i)
{
@@ -2386,48 +2388,48 @@
{
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)
@@ -2470,7 +2472,7 @@
// parse UBJSON file
auto const packed = utils::read_binary_file(filename + ".ubjson");
json j2;
- CHECK_NOTHROW(j2 = json::from_ubjson({packed.data(), packed.size()}));
+ CHECK_NOTHROW(j2 = json::from_ubjson({ packed.data(), packed.size() }));
// compare parsed JSON values
CHECK(j1 == j2);
diff --git a/tests/src/unit-udt.cpp b/tests/src/unit-udt.cpp
index b3995ff..0f677d8 100644
--- a/tests/src/unit-udt.cpp
+++ b/tests/src/unit-udt.cpp
@@ -130,7 +130,7 @@
template<typename BasicJsonType>
static void to_json(BasicJsonType& j, const person& p)
{
- j = BasicJsonType{{"age", p.m_age}, {"name", p.m_name}, {"country", p.m_country}};
+ j = BasicJsonType{ { "age", p.m_age }, { "name", p.m_name }, { "country", p.m_country } };
}
static void to_json(nlohmann::json& j, const address& a)
@@ -140,12 +140,12 @@
static void to_json(nlohmann::json& j, const contact& c)
{
- j = json{{"person", c.m_person}, {"address", c.m_address}};
+ j = json{ { "person", c.m_person }, { "address", c.m_address } };
}
static void to_json(nlohmann::json& j, const contact_book& cb)
{
- j = json{{"name", cb.m_book_name}, {"contacts", cb.m_contacts}};
+ j = json{ { "name", cb.m_book_name }, { "contacts", cb.m_contacts } };
}
// operators
@@ -199,7 +199,9 @@
static void from_json(const BasicJsonType& j, country& c)
{
const auto str = j.template get<std::string>();
- const std::map<std::string, country> m = {{"中华人民共和国", country::china}, {"France", country::france}, {"Российская Федерация", country::russia}};
+ const std::map<std::string, country> m = { { "中华人民共和国", country::china },
+ { "France", country::france },
+ { "Российская Федерация", country::russia } };
const auto it = m.find(str);
// TODO(nlohmann) test exceptions
@@ -235,14 +237,14 @@
TEST_CASE("basic usage" * doctest::test_suite("udt"))
{
// a bit narcissistic maybe :) ?
- 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};
- const udt::person senior_programmer{{42}, {"王芳"}, udt::country::china};
- const udt::address addr{"Paris"};
- const udt::contact cpp_programmer{sfinae_addict, addr};
- const udt::contact_book book{{"C++"}, {cpp_programmer, {senior_programmer, addr}}};
+ 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 };
+ const udt::person senior_programmer{ { 42 }, { "王芳" }, udt::country::china };
+ const udt::address addr{ "Paris" };
+ const udt::contact cpp_programmer{ sfinae_addict, addr };
+ const udt::contact_book book{ { "C++" }, { cpp_programmer, { senior_programmer, addr } } };
SECTION("conversion to json via free-functions")
{
@@ -282,7 +284,7 @@
CHECK(person == sfinae_addict);
CHECK(contact == cpp_programmer);
CHECK(contacts == book.m_contacts);
- CHECK(book_name == udt::name{"C++"});
+ CHECK(book_name == udt::name{ "C++" });
CHECK(book == parsed_book);
}
@@ -320,7 +322,7 @@
CHECK(person == sfinae_addict);
CHECK(contact == cpp_programmer);
CHECK(contacts == book.m_contacts);
- CHECK(book_name == udt::name{"C++"});
+ CHECK(book_name == udt::name{ "C++" });
CHECK(book == parsed_book);
}
#endif
@@ -395,7 +397,7 @@
json j = optPerson;
CHECK(j.is_null());
- optPerson.reset(new udt::person{{42}, {"John Doe"}, udt::country::russia}); // NOLINT(cppcoreguidelines-owning-memory,modernize-make-shared)
+ optPerson.reset(new udt::person{ { 42 }, { "John Doe" }, udt::country::russia }); // NOLINT(cppcoreguidelines-owning-memory,modernize-make-shared)
j = optPerson;
CHECK_FALSE(j.is_null());
@@ -404,7 +406,7 @@
SECTION("from_json")
{
- auto person = udt::person{{42}, {"John Doe"}, udt::country::russia};
+ auto person = udt::person{ { 42 }, { "John Doe" }, udt::country::russia };
json j = person;
auto optPerson = j.get<std::shared_ptr<udt::person>>();
@@ -421,7 +423,7 @@
{
SECTION("to_json")
{
- udt::legacy_type const lt{"4242"};
+ udt::legacy_type const lt{ "4242" };
json const j = lt;
CHECK(j.get<int>() == 4242);
@@ -449,24 +451,24 @@
static void from_json(const json& /*unnamed*/, type& opt)
{
- opt = {42.0, 42.0, 42.0};
+ opt = { 42.0, 42.0, 42.0 };
}
// preferred version
static type from_json(const json& /*unnamed*/)
{
- return {4.0, 5.0, 6.0};
+ return { 4.0, 5.0, 6.0 };
}
};
} // namespace nlohmann
TEST_CASE("even supported types can be specialized" * doctest::test_suite("udt"))
{
- json const j = std::vector<float>{1.0, 2.0, 3.0};
+ json const j = std::vector<float>{ 1.0, 2.0, 3.0 };
CHECK(j.dump() == R"("hijacked!")");
auto f = j.get<std::vector<float>>();
// the single argument from_json method is preferred
- CHECK((f == std::vector<float>{4.0, 5.0, 6.0}));
+ CHECK((f == std::vector<float>{ 4.0, 5.0, 6.0 }));
}
namespace nlohmann
@@ -508,7 +510,7 @@
json j = optPerson;
CHECK(j.is_null());
- optPerson.reset(new udt::person{{42}, {"John Doe"}, udt::country::russia}); // NOLINT(cppcoreguidelines-owning-memory,modernize-make-unique)
+ optPerson.reset(new udt::person{ { 42 }, { "John Doe" }, udt::country::russia }); // NOLINT(cppcoreguidelines-owning-memory,modernize-make-unique)
j = optPerson;
CHECK_FALSE(j.is_null());
@@ -517,7 +519,7 @@
SECTION("from_json")
{
- auto person = udt::person{{42}, {"John Doe"}, udt::country::russia};
+ auto person = udt::person{ { 42 }, { "John Doe" }, udt::country::russia };
json j = person;
auto optPerson = j.get<std::unique_ptr<udt::person>>();
@@ -635,14 +637,14 @@
{
using custom_json = nlohmann::basic_json<std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator, pod_serializer>;
- auto p = udt::small_pod{42, '/', 42};
+ auto p = udt::small_pod{ 42, '/', 42 };
custom_json const j = p;
auto p2 = j.get<udt::small_pod>();
CHECK(p == p2);
- auto np = udt::non_pod{{"non-pod"}};
+ auto np = udt::non_pod{ { "non-pod" } };
custom_json const j2 = np;
auto np2 = j2.get<udt::non_pod>();
CHECK(np == np2);
@@ -671,7 +673,7 @@
TEST_CASE("custom serializer that does adl by default" * doctest::test_suite("udt"))
{
- auto me = udt::person{{23}, {"theo"}, udt::country::france};
+ auto me = udt::person{ { 23 }, { "theo" }, udt::country::france };
json const j = me;
custom_json const cj = me;
@@ -708,9 +710,9 @@
SECTION("array")
{
- json const j = {1, 2, 3};
+ json const j = { 1, 2, 3 };
custom_json const cj = j;
- CHECK((cj == std::vector<int>{1, 2, 3}));
+ CHECK((cj == std::vector<int>{ 1, 2, 3 }));
}
SECTION("integer")
@@ -743,7 +745,7 @@
SECTION("binary")
{
- json j = json::binary({1, 2, 3}, 42);
+ json j = json::binary({ 1, 2, 3 }, 42);
custom_json cj = j;
CHECK(cj.get_binary().subtype() == 42);
std::vector<std::uint8_t> cv = cj.get_binary();
@@ -753,7 +755,7 @@
SECTION("object")
{
- json const j = {{"forty", "two"}};
+ json const j = { { "forty", "two" } };
custom_json cj = j;
auto m = j.get<std::map<std::string, std::string>>();
CHECK(cj == m);
@@ -853,7 +855,7 @@
TEST_CASE("compatible array type, without iterator type alias")
{
- no_iterator_type const vec{1, 2, 3};
+ no_iterator_type const vec{ 1, 2, 3 };
json const j = vec;
}
diff --git a/tests/src/unit-udt_macro.cpp b/tests/src/unit-udt_macro.cpp
index 7db36cb..1716634 100644
--- a/tests/src/unit-udt_macro.cpp
+++ b/tests/src/unit-udt_macro.cpp
@@ -245,8 +245,8 @@
}
person_without_default_constructor_1(std::string name_, int age_)
- : name{std::move(name_)}
- , age{age_}
+ : name{ std::move(name_) }
+ , age{ age_ }
{}
NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(person_without_default_constructor_1, name, age)
@@ -264,8 +264,8 @@
}
person_without_default_constructor_2(std::string name_, int age_)
- : name{std::move(name_)}
- , age{age_}
+ : name{ std::move(name_) }
+ , age{ age_ }
{}
};
@@ -282,7 +282,7 @@
SECTION("person")
{
// serialization
- T p1("Erik", 1, {{"haircuts", 2}});
+ T p1("Erik", 1, { { "haircuts", 2 } });
CHECK(json(p1).dump() == "{\"age\":1,\"metadata\":{\"haircuts\":2},\"name\":\"Erik\"}");
// deserialization
@@ -312,7 +312,7 @@
CHECK(json(p0).dump() == "{\"age\":0,\"metadata\":null,\"name\":\"\"}");
// serialization
- T p1("Erik", 1, {{"haircuts", 2}});
+ T p1("Erik", 1, { { "haircuts", 2 } });
CHECK(json(p1).dump() == "{\"age\":1,\"metadata\":{\"haircuts\":2},\"name\":\"Erik\"}");
// deserialization
@@ -419,11 +419,11 @@
{
{
// serialization of a single object
- T person{"Erik", 1};
+ T person{ "Erik", 1 };
CHECK(json(person).dump() == "{\"age\":1,\"name\":\"Erik\"}");
// serialization of a container with objects
- std::vector<T> const two_persons{{"Erik", 1}, {"Kyle", 2}};
+ std::vector<T> 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-user_defined_input.cpp b/tests/src/unit-user_defined_input.cpp
index f3c5374..ac9e71c 100644
--- a/tests/src/unit-user_defined_input.cpp
+++ b/tests/src/unit-user_defined_input.cpp
@@ -44,7 +44,7 @@
TEST_CASE("Custom container non-member begin/end")
{
- const MyContainer data{"[1,2,3,4]"};
+ const MyContainer data{ "[1,2,3,4]" };
json as_json = json::parse(data);
CHECK(as_json.at(0) == 1);
CHECK(as_json.at(1) == 2);
@@ -69,7 +69,7 @@
}
};
- const MyContainer2 data{"[1,2,3,4]"};
+ const MyContainer2 data{ "[1,2,3,4]" };
json as_json = json::parse(data);
CHECK(as_json.at(0) == 1);
CHECK(as_json.at(1) == 2);
@@ -115,8 +115,8 @@
CHECK(std::is_same<MyIterator::reference, const char&>::value);
CHECK(std::is_same<MyIterator::iterator_category, std::input_iterator_tag>::value);
- const MyIterator begin{raw_data};
- const MyIterator end{raw_data + strlen(raw_data)}; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
+ const MyIterator begin{ raw_data };
+ const MyIterator end{ raw_data + strlen(raw_data) }; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
json as_json = json::parse(begin, end);
CHECK(as_json.at(0) == 1);