next json/tests/src/unit-items.cpp:739 │ json/tests/src/unit-items.cpp:42
│
SECTION("object") │ SECTION("object")
{ │ {
SECTION("value") │ SECTION("value")
{ │ {
json j = { {"A", 1}, {"B", 2} }; │ json j = { {"A", 1}, {"B", 2} };
int counter = 1; │ int counter = 1;
│
for (auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-cop
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "A"); │ CHECK(i.key() == "A");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "B"); │ CHECK(i.key() == "B");
CHECK(i.value() == json(2)); │ CHECK(i.value() == json(2));
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
│
SECTION("reference") │ SECTION("reference")
{ │ {
json j = { {"A", 1}, {"B", 2} }; │ json j = { {"A", 1}, {"B", 2} };
int counter = 1; │ int counter = 1;
│
for (auto& i : j.items()) │ for (auto& i : json::iterator_wrapper(j))
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "A"); │ CHECK(i.key() == "A");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
│
// change the value │ // change the value
i.value() = json(11); │ i.value() = json(11);
CHECK(i.value() == json(11)); │ CHECK(i.value() == json(11));
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "B"); │ CHECK(i.key() == "B");
CHECK(i.value() == json(2)); │ CHECK(i.value() == json(2));
│
// change the value │ // change the value
i.value() = json(22); │ i.value() = json(22);
CHECK(i.value() == json(22)); │ CHECK(i.value() == json(22));
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
│
// check if values where changed │ // check if values where changed
CHECK(j == json({ {"A", 11}, {"B", 22} })); │ CHECK(j == json({ {"A", 11}, {"B", 22} }));
} │ }
│
SECTION("const value") │ SECTION("const value")
{ │ {
json j = { {"A", 1}, {"B", 2} }; │ json j = { {"A", 1}, {"B", 2} };
int counter = 1; │ int counter = 1;
│
for (const auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (const auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-ran
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "A"); │ CHECK(i.key() == "A");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "B"); │ CHECK(i.key() == "B");
CHECK(i.value() == json(2)); │ CHECK(i.value() == json(2));
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
│
SECTION("const reference") │ SECTION("const reference")
{ │ {
json j = { {"A", 1}, {"B", 2} }; │ json j = { {"A", 1}, {"B", 2} };
int counter = 1; │ int counter = 1;
│
for (const auto& i : j.items()) │ for (const auto& i : json::iterator_wrapper(j))
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "A"); │ CHECK(i.key() == "A");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "B"); │ CHECK(i.key() == "B");
CHECK(i.value() == json(2)); │ CHECK(i.value() == json(2));
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
│
#ifdef JSON_HAS_CPP_17 │
SECTION("structured bindings") │
{ │
json j = { {"A", 1}, {"B", 2} }; │
│
std::map<std::string, int> m; │
│
for (auto const&[key, value] : j.items()) │
{ │
m.emplace(key, value); │
} │
│
CHECK(j.get<decltype(m)>() == m); │
} │
#endif │
} │ }
│
SECTION("const object") │ SECTION("const object")
{ │ {
SECTION("value") │ SECTION("value")
{ │ {
const json j = { {"A", 1}, {"B", 2} }; │ const json j = { {"A", 1}, {"B", 2} };
int counter = 1; │ int counter = 1;
│
for (auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-cop
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "A"); │ CHECK(i.key() == "A");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "B"); │ CHECK(i.key() == "B");
CHECK(i.value() == json(2)); │ CHECK(i.value() == json(2));
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
│
SECTION("reference") │ SECTION("reference")
{ │ {
const json j = { {"A", 1}, {"B", 2} }; │ const json j = { {"A", 1}, {"B", 2} };
int counter = 1; │ int counter = 1;
│
for (auto& i : j.items()) │ for (auto& i : json::iterator_wrapper(j))
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "A"); │ CHECK(i.key() == "A");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "B"); │ CHECK(i.key() == "B");
CHECK(i.value() == json(2)); │ CHECK(i.value() == json(2));
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
│
SECTION("const value") │ SECTION("const value")
{ │ {
const json j = { {"A", 1}, {"B", 2} }; │ const json j = { {"A", 1}, {"B", 2} };
int counter = 1; │ int counter = 1;
│
for (const auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (const auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-ran
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "A"); │ CHECK(i.key() == "A");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "B"); │ CHECK(i.key() == "B");
CHECK(i.value() == json(2)); │ CHECK(i.value() == json(2));
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
│
SECTION("const reference") │ SECTION("const reference")
{ │ {
const json j = { {"A", 1}, {"B", 2} }; │ const json j = { {"A", 1}, {"B", 2} };
int counter = 1; │ int counter = 1;
│
for (const auto& i : j.items()) │ for (const auto& i : json::iterator_wrapper(j))
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "A"); │ CHECK(i.key() == "A");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "B"); │ CHECK(i.key() == "B");
CHECK(i.value() == json(2)); │ CHECK(i.value() == json(2));
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
SECTION("value") │ SECTION("value")
{ │ {
json j = { "A", "B" }; │ json j = { "A", "B" };
int counter = 1; │ int counter = 1;
│
for (auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-cop
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "0"); │ CHECK(i.key() == "0");
CHECK(i.value() == "A"); │ CHECK(i.value() == "A");
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "1"); │ CHECK(i.key() == "1");
CHECK(i.value() == "B"); │ CHECK(i.value() == "B");
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
│
SECTION("reference") │ SECTION("reference")
{ │ {
json j = { "A", "B" }; │ json j = { "A", "B" };
int counter = 1; │ int counter = 1;
│
for (auto& i : j.items()) │ for (auto& i : json::iterator_wrapper(j))
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "0"); │ CHECK(i.key() == "0");
CHECK(i.value() == "A"); │ CHECK(i.value() == "A");
│
// change the value │ // change the value
i.value() = "AA"; │ i.value() = "AA";
CHECK(i.value() == "AA"); │ CHECK(i.value() == "AA");
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "1"); │ CHECK(i.key() == "1");
CHECK(i.value() == "B"); │ CHECK(i.value() == "B");
│
// change the value │ // change the value
i.value() = "BB"; │ i.value() = "BB";
CHECK(i.value() == "BB"); │ CHECK(i.value() == "BB");
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
│
// check if values where changed │ // check if values where changed
CHECK(j == json({ "AA", "BB" })); │ CHECK(j == json({ "AA", "BB" }));
} │ }
│
SECTION("const value") │ SECTION("const value")
{ │ {
json j = { "A", "B" }; │ json j = { "A", "B" };
int counter = 1; │ int counter = 1;
│
for (const auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (const auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-ran
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "0"); │ CHECK(i.key() == "0");
CHECK(i.value() == "A"); │ CHECK(i.value() == "A");
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "1"); │ CHECK(i.key() == "1");
CHECK(i.value() == "B"); │ CHECK(i.value() == "B");
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
│
SECTION("const reference") │ SECTION("const reference")
{ │ {
json j = { "A", "B" }; │ json j = { "A", "B" };
int counter = 1; │ int counter = 1;
│
for (const auto& i : j.items()) │ for (const auto& i : json::iterator_wrapper(j))
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "0"); │ CHECK(i.key() == "0");
CHECK(i.value() == "A"); │ CHECK(i.value() == "A");
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "1"); │ CHECK(i.key() == "1");
CHECK(i.value() == "B"); │ CHECK(i.value() == "B");
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
} │ }
│
SECTION("const array") │ SECTION("const array")
{ │ {
SECTION("value") │ SECTION("value")
{ │ {
const json j = { "A", "B" }; │ const json j = { "A", "B" };
int counter = 1; │ int counter = 1;
│
for (auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-cop
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "0"); │ CHECK(i.key() == "0");
CHECK(i.value() == "A"); │ CHECK(i.value() == "A");
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "1"); │ CHECK(i.key() == "1");
CHECK(i.value() == "B"); │ CHECK(i.value() == "B");
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
│
SECTION("reference") │ SECTION("reference")
{ │ {
const json j = { "A", "B" }; │ const json j = { "A", "B" };
int counter = 1; │ int counter = 1;
│
for (auto& i : j.items()) │ for (auto& i : json::iterator_wrapper(j))
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "0"); │ CHECK(i.key() == "0");
CHECK(i.value() == "A"); │ CHECK(i.value() == "A");
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "1"); │ CHECK(i.key() == "1");
CHECK(i.value() == "B"); │ CHECK(i.value() == "B");
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
│
SECTION("const value") │ SECTION("const value")
{ │ {
const json j = { "A", "B" }; │ const json j = { "A", "B" };
int counter = 1; │ int counter = 1;
│
for (const auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (const auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-ran
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "0"); │ CHECK(i.key() == "0");
CHECK(i.value() == "A"); │ CHECK(i.value() == "A");
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "1"); │ CHECK(i.key() == "1");
CHECK(i.value() == "B"); │ CHECK(i.value() == "B");
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
│
SECTION("const reference") │ SECTION("const reference")
{ │ {
const json j = { "A", "B" }; │ const json j = { "A", "B" };
int counter = 1; │ int counter = 1;
│
for (const auto& i : j.items()) │ for (const auto& i : json::iterator_wrapper(j))
{ │ {
switch (counter++) │ switch (counter++)
{ │ {
case 1: │ case 1:
{ │ {
CHECK(i.key() == "0"); │ CHECK(i.key() == "0");
CHECK(i.value() == "A"); │ CHECK(i.value() == "A");
break; │ break;
} │ }
│
case 2: │ case 2:
{ │ {
CHECK(i.key() == "1"); │ CHECK(i.key() == "1");
CHECK(i.value() == "B"); │ CHECK(i.value() == "B");
break; │ break;
} │ }
│
default: │ default:
{ │ {
break; │ break;
} │ }
} │ }
} │ }
│
CHECK(counter == 3); │ CHECK(counter == 3);
} │ }
} │ }
│
SECTION("primitive") │ SECTION("primitive")
{ │ {
SECTION("value") │ SECTION("value")
{ │ {
json j = 1; │ json j = 1;
int counter = 1; │ int counter = 1;
│
for (auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-cop
{ │ {
++counter; │ ++counter;
CHECK(i.key() == ""); │ CHECK(i.key() == "");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
} │ }
│
CHECK(counter == 2); │ CHECK(counter == 2);
} │ }
│
SECTION("reference") │ SECTION("reference")
{ │ {
json j = 1; │ json j = 1;
int counter = 1; │ int counter = 1;
│
for (auto& i : j.items()) │ for (auto& i : json::iterator_wrapper(j))
{ │ {
++counter; │ ++counter;
CHECK(i.key() == ""); │ CHECK(i.key() == "");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
│
// change value │ // change value
i.value() = json(2); │ i.value() = json(2);
} │ }
│
CHECK(counter == 2); │ CHECK(counter == 2);
│
// check if value has changed │ // check if value has changed
CHECK(j == json(2)); │ CHECK(j == json(2));
} │ }
│
SECTION("const value") │ SECTION("const value")
{ │ {
json j = 1; │ json j = 1;
int counter = 1; │ int counter = 1;
│
for (const auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (const auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-ran
{ │ {
++counter; │ ++counter;
CHECK(i.key() == ""); │ CHECK(i.key() == "");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
} │ }
│
CHECK(counter == 2); │ CHECK(counter == 2);
} │ }
│
SECTION("const reference") │ SECTION("const reference")
{ │ {
json j = 1; │ json j = 1;
int counter = 1; │ int counter = 1;
│
for (const auto& i : j.items()) │ for (const auto& i : json::iterator_wrapper(j))
{ │ {
++counter; │ ++counter;
CHECK(i.key() == ""); │ CHECK(i.key() == "");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
} │ }
│
CHECK(counter == 2); │ CHECK(counter == 2);
} │ }
} │ }
│
SECTION("const primitive") │ SECTION("const primitive")
{ │ {
SECTION("value") │ SECTION("value")
{ │ {
const json j = 1; │ const json j = 1;
int counter = 1; │ int counter = 1;
│
for (auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-range-cop
{ │ {
++counter; │ ++counter;
CHECK(i.key() == ""); │ CHECK(i.key() == "");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
} │ }
│
CHECK(counter == 2); │ CHECK(counter == 2);
} │ }
│
SECTION("reference") │ SECTION("reference")
{ │ {
const json j = 1; │ const json j = 1;
int counter = 1; │ int counter = 1;
│
for (auto& i : j.items()) │ for (auto& i : json::iterator_wrapper(j))
{ │ {
++counter; │ ++counter;
CHECK(i.key() == ""); │ CHECK(i.key() == "");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
} │ }
│
CHECK(counter == 2); │ CHECK(counter == 2);
} │ }
│
SECTION("const value") │ SECTION("const value")
{ │ {
const json j = 1; │ const json j = 1;
int counter = 1; │ int counter = 1;
│
for (const auto i : j.items()) // NOLINT(performance-for-range-copy) │ for (const auto i : json::iterator_wrapper(j)) // NOLINT(performance-for-ran
{ │ {
++counter; │ ++counter;
CHECK(i.key() == ""); │ CHECK(i.key() == "");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
} │ }
│
CHECK(counter == 2); │ CHECK(counter == 2);
} │ }
│
SECTION("const reference") │ SECTION("const reference")
{ │ {
const json j = 1; │ const json j = 1;
int counter = 1; │ int counter = 1;
│
for (const auto& i : j.items()) │ for (const auto& i : json::iterator_wrapper(j))
{ │ {
++counter; │ ++counter;
CHECK(i.key() == ""); │ CHECK(i.key() == "");
CHECK(i.value() == json(1)); │ CHECK(i.value() == json(1));
} │ }
│
CHECK(counter == 2); │ CHECK(counter == 2);
} │ }
} │ }
} │
next prev up json/tests/src/unit-iterators2.cpp:38 │ json/tests/src/unit-iterators2.cpp:462
│
json j_values = {nullptr, true, 42, 42u, 23.23, {{"one", 1}, {"two", 2}}, {1, 2, │ json j_values = {nullptr, true, 42, 42u, 23.23, {{"one", 1}, {"two", 2}}, {1, 2,
│
for (json& j : j_values) │ for (json& j : j_values)
{ │ {
auto it1 = j.begin(); │ auto it1 = j.rbegin();
auto it2 = j.begin(); │ auto it2 = j.rbegin();
auto it3 = j.begin(); │ auto it3 = j.rbegin();
++it2; │ ++it2;
++it3; │ ++it3;
++it3; │ ++it3;
auto it1_c = j.cbegin(); │ auto it1_c = j.crbegin();
auto it2_c = j.cbegin(); │ auto it2_c = j.crbegin();
auto it3_c = j.cbegin(); │ auto it3_c = j.crbegin();
++it2_c; │ ++it2_c;
++it3_c; │ ++it3_c;
++it3_c; │ ++it3_c;
│
// comparison: equal │ // comparison: equal
{ │ {
CHECK(it1 == it1); │ CHECK(it1 == it1);
CHECK(!(it1 == it2)); │ CHECK(!(it1 == it2));
CHECK(!(it1 == it3)); │ CHECK(!(it1 == it3));
CHECK(!(it2 == it3)); │ CHECK(!(it2 == it3));
CHECK(it1_c == it1_c); │ CHECK(it1_c == it1_c);
CHECK(!(it1_c == it2_c)); │ CHECK(!(it1_c == it2_c));
CHECK(!(it1_c == it3_c)); │ CHECK(!(it1_c == it3_c));
CHECK(!(it2_c == it3_c)); │ CHECK(!(it2_c == it3_c));
} │ }
│
// comparison: not equal │ // comparison: not equal
{ │ {
// check definition │ // check definition
CHECK( (it1 != it1) == !(it1 == it1) ); │ CHECK( (it1 != it1) == !(it1 == it1) );
CHECK( (it1 != it2) == !(it1 == it2) ); │ CHECK( (it1 != it2) == !(it1 == it2) );
CHECK( (it1 != it3) == !(it1 == it3) ); │ CHECK( (it1 != it3) == !(it1 == it3) );
CHECK( (it2 != it3) == !(it2 == it3) ); │ CHECK( (it2 != it3) == !(it2 == it3) );
CHECK( (it1_c != it1_c) == !(it1_c == it1_c) ); │ CHECK( (it1_c != it1_c) == !(it1_c == it1_c) );
CHECK( (it1_c != it2_c) == !(it1_c == it2_c) ); │ CHECK( (it1_c != it2_c) == !(it1_c == it2_c) );
CHECK( (it1_c != it3_c) == !(it1_c == it3_c) ); │ CHECK( (it1_c != it3_c) == !(it1_c == it3_c) );
CHECK( (it2_c != it3_c) == !(it2_c == it3_c) ); │ CHECK( (it2_c != it3_c) == !(it2_c == it3_c) );
} │ }
│
// comparison: smaller │ // comparison: smaller
{ │ {
if (j.type() == json::value_t::object) │ if (j.type() == json::value_t::object)
{ │ {
#if JSON_DIAGNOSTICS │ #if JSON_DIAGNOSTICS
CHECK_THROWS_WITH_AS(it1 < it1, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 < it1, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1 < it2, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 < it2, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it2 < it3, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it2 < it3, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1 < it3, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 < it3, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1_c < it1_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c < it1_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it1_c < it2_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c < it2_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it2_c < it3_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it2_c < it3_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it1_c < it3_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c < it3_c, "[json.exception.invalid_iterato
#else │ #else
CHECK_THROWS_WITH_AS(it1 < it1, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 < it1, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1 < it2, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 < it2, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it2 < it3, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it2 < it3, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1 < it3, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 < it3, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1_c < it1_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c < it1_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it1_c < it2_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c < it2_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it2_c < it3_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it2_c < it3_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it1_c < it3_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c < it3_c, "[json.exception.invalid_iterato
#endif │ #endif
} │ }
else │ else
{ │ {
CHECK(!(it1 < it1)); │ CHECK(!(it1 < it1));
CHECK(it1 < it2); │ CHECK(it1 < it2);
CHECK(it1 < it3); │ CHECK(it1 < it3);
CHECK(it2 < it3); │ CHECK(it2 < it3);
CHECK(!(it1_c < it1_c)); │ CHECK(!(it1_c < it1_c));
CHECK(it1_c < it2_c); │ CHECK(it1_c < it2_c);
CHECK(it1_c < it3_c); │ CHECK(it1_c < it3_c);
CHECK(it2_c < it3_c); │ CHECK(it2_c < it3_c);
} │ }
} │ }
│
// comparison: less than or equal │ // comparison: less than or equal
{ │ {
if (j.type() == json::value_t::object) │ if (j.type() == json::value_t::object)
{ │ {
#if JSON_DIAGNOSTICS │ #if JSON_DIAGNOSTICS
CHECK_THROWS_WITH_AS(it1 <= it1, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 <= it1, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1 <= it2, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 <= it2, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it2 <= it3, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it2 <= it3, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1 <= it3, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 <= it3, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1_c <= it1_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c <= it1_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it1_c <= it2_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c <= it2_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it2_c <= it3_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it2_c <= it3_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it1_c <= it3_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c <= it3_c, "[json.exception.invalid_iterat
#else │ #else
CHECK_THROWS_WITH_AS(it1 <= it1, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 <= it1, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1 <= it2, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 <= it2, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it2 <= it3, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it2 <= it3, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1 <= it3, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 <= it3, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1_c <= it1_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c <= it1_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it1_c <= it2_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c <= it2_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it2_c <= it3_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it2_c <= it3_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it1_c <= it3_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c <= it3_c, "[json.exception.invalid_iterat
#endif │ #endif
} │ }
else │ else
{ │ {
// check definition │ // check definition
CHECK( (it1 <= it1) == !(it1 < it1) ); │ CHECK( (it1 <= it1) == !(it1 < it1) );
CHECK( (it1 <= it2) == !(it2 < it1) ); │ CHECK( (it1 <= it2) == !(it2 < it1) );
CHECK( (it1 <= it3) == !(it3 < it1) ); │ CHECK( (it1 <= it3) == !(it3 < it1) );
CHECK( (it2 <= it3) == !(it3 < it2) ); │ CHECK( (it2 <= it3) == !(it3 < it2) );
CHECK( (it1_c <= it1_c) == !(it1_c < it1_c) ); │ CHECK( (it1_c <= it1_c) == !(it1_c < it1_c) );
CHECK( (it1_c <= it2_c) == !(it2_c < it1_c) ); │ CHECK( (it1_c <= it2_c) == !(it2_c < it1_c) );
CHECK( (it1_c <= it3_c) == !(it3_c < it1_c) ); │ CHECK( (it1_c <= it3_c) == !(it3_c < it1_c) );
CHECK( (it2_c <= it3_c) == !(it3_c < it2_c) ); │ CHECK( (it2_c <= it3_c) == !(it3_c < it2_c) );
} │ }
} │ }
│
// comparison: greater than │ // comparison: greater than
{ │ {
if (j.type() == json::value_t::object) │ if (j.type() == json::value_t::object)
{ │ {
#if JSON_DIAGNOSTICS │ #if JSON_DIAGNOSTICS
CHECK_THROWS_WITH_AS(it1 > it1, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 > it1, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1 > it2, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 > it2, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it2 > it3, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it2 > it3, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1 > it3, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 > it3, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1_c > it1_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c > it1_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it1_c > it2_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c > it2_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it2_c > it3_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it2_c > it3_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it1_c > it3_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c > it3_c, "[json.exception.invalid_iterato
#else │ #else
CHECK_THROWS_WITH_AS(it1 > it1, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 > it1, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1 > it2, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 > it2, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it2 > it3, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it2 > it3, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1 > it3, "[json.exception.invalid_iterator.21 │ CHECK_THROWS_WITH_AS(it1 > it3, "[json.exception.invalid_iterator.21
CHECK_THROWS_WITH_AS(it1_c > it1_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c > it1_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it1_c > it2_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c > it2_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it2_c > it3_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it2_c > it3_c, "[json.exception.invalid_iterato
CHECK_THROWS_WITH_AS(it1_c > it3_c, "[json.exception.invalid_iterato │ CHECK_THROWS_WITH_AS(it1_c > it3_c, "[json.exception.invalid_iterato
#endif │ #endif
} │ }
else │ else
{ │ {
// check definition │ // check definition
CHECK( (it1 > it1) == (it1 < it1) ); │ CHECK( (it1 > it1) == (it1 < it1) );
CHECK( (it1 > it2) == (it2 < it1) ); │ CHECK( (it1 > it2) == (it2 < it1) );
CHECK( (it1 > it3) == (it3 < it1) ); │ CHECK( (it1 > it3) == (it3 < it1) );
CHECK( (it2 > it3) == (it3 < it2) ); │ CHECK( (it2 > it3) == (it3 < it2) );
CHECK( (it1_c > it1_c) == (it1_c < it1_c) ); │ CHECK( (it1_c > it1_c) == (it1_c < it1_c) );
CHECK( (it1_c > it2_c) == (it2_c < it1_c) ); │ CHECK( (it1_c > it2_c) == (it2_c < it1_c) );
CHECK( (it1_c > it3_c) == (it3_c < it1_c) ); │ CHECK( (it1_c > it3_c) == (it3_c < it1_c) );
CHECK( (it2_c > it3_c) == (it3_c < it2_c) ); │ CHECK( (it2_c > it3_c) == (it3_c < it2_c) );
} │ }
} │ }
│
// comparison: greater than or equal │ // comparison: greater than or equal
{ │ {
if (j.type() == json::value_t::object) │ if (j.type() == json::value_t::object)
{ │ {
#if JSON_DIAGNOSTICS │ #if JSON_DIAGNOSTICS
CHECK_THROWS_WITH_AS(it1 >= it1, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 >= it1, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1 >= it2, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 >= it2, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it2 >= it3, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it2 >= it3, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1 >= it3, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 >= it3, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1_c >= it1_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c >= it1_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it1_c >= it2_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c >= it2_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it2_c >= it3_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it2_c >= it3_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it1_c >= it3_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c >= it3_c, "[json.exception.invalid_iterat
#else │ #else
CHECK_THROWS_WITH_AS(it1 >= it1, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 >= it1, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1 >= it2, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 >= it2, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it2 >= it3, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it2 >= it3, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1 >= it3, "[json.exception.invalid_iterator.2 │ CHECK_THROWS_WITH_AS(it1 >= it3, "[json.exception.invalid_iterator.2
CHECK_THROWS_WITH_AS(it1_c >= it1_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c >= it1_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it1_c >= it2_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c >= it2_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it2_c >= it3_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it2_c >= it3_c, "[json.exception.invalid_iterat
CHECK_THROWS_WITH_AS(it1_c >= it3_c, "[json.exception.invalid_iterat │ CHECK_THROWS_WITH_AS(it1_c >= it3_c, "[json.exception.invalid_iterat
#endif │ #endif
} │ }
else │ else
{ │ {
// check definition │ // check definition
CHECK( (it1 >= it1) == !(it1 < it1) ); │ CHECK( (it1 >= it1) == !(it1 < it1) );
CHECK( (it1 >= it2) == !(it1 < it2) ); │ CHECK( (it1 >= it2) == !(it1 < it2) );
CHECK( (it1 >= it3) == !(it1 < it3) ); │ CHECK( (it1 >= it3) == !(it1 < it3) );
CHECK( (it2 >= it3) == !(it2 < it3) ); │ CHECK( (it2 >= it3) == !(it2 < it3) );
CHECK( (it1_c >= it1_c) == !(it1_c < it1_c) ); │ CHECK( (it1_c >= it1_c) == !(it1_c < it1_c) );
CHECK( (it1_c >= it2_c) == !(it1_c < it2_c) ); │ CHECK( (it1_c >= it2_c) == !(it1_c < it2_c) );
CHECK( (it1_c >= it3_c) == !(it1_c < it3_c) ); │ CHECK( (it1_c >= it3_c) == !(it1_c < it3_c) );
CHECK( (it2_c >= it3_c) == !(it2_c < it3_c) ); │ CHECK( (it2_c >= it3_c) == !(it2_c < it3_c) );
} │ }
} │ }
} │ }
│
// check exceptions if different objects are compared │ // check exceptions if different objects are compared
for (auto j : j_values) │ for (auto j : j_values)
{ │ {
for (auto k : j_values) │ for (auto k : j_values)
{ │ {
if (j != k) │ if (j != k)
{ │ {
#if JSON_DIAGNOSTICS │ #if JSON_DIAGNOSTICS
// the output differs in each loop, so we cannot fix a string for th │ // the output differs in each loop, so we cannot fix a string for th
#else │ #else
CHECK_THROWS_WITH_AS(j.begin() == k.begin(), "[json.exception.invali │ CHECK_THROWS_WITH_AS(j.rbegin() == k.rbegin(), "[json.exception.inva
CHECK_THROWS_WITH_AS(j.cbegin() == k.cbegin(), "[json.exception.inva │ CHECK_THROWS_WITH_AS(j.crbegin() == k.crbegin(), "[json.exception.in
CHECK_THROWS_WITH_AS(j.begin() < k.begin(), "[json.exception.invalid │ CHECK_THROWS_WITH_AS(j.rbegin() < k.rbegin(), "[json.exception.inval
CHECK_THROWS_WITH_AS(j.cbegin() < k.cbegin(), "[json.exception.inval │ CHECK_THROWS_WITH_AS(j.crbegin() < k.crbegin(), "[json.exception.inv
#endif │ #endif
} │ }
} │ }
} │ }
} │
next prev up json/tests/src/unit-iterators2.cpp:254 │ json/tests/src/unit-iterators2.cpp:678
│
json j_object = {{"one", 1}, {"two", 2}, {"three", 3}}; │ json j_object = {{"one", 1}, {"two", 2}, {"three", 3}};
json j_array = {1, 2, 3, 4, 5, 6}; │ json j_array = {1, 2, 3, 4, 5, 6};
json j_null = nullptr; │ json j_null = nullptr;
json j_value = 42; │ json j_value = 42;
│
SECTION("addition and subtraction") │ SECTION("addition and subtraction")
{ │ {
SECTION("object") │ SECTION("object")
{ │ {
{ │ {
auto it = j_object.begin(); │ auto it = j_object.rbegin();
CHECK_THROWS_WITH_AS(it += 1, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(it += 1, "[json.exception.invalid_iterator.209]
} │ }
{ │ {
auto it = j_object.cbegin(); │ auto it = j_object.crbegin();
CHECK_THROWS_WITH_AS(it += 1, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(it += 1, "[json.exception.invalid_iterator.209]
} │ }
{ │ {
auto it = j_object.begin(); │ auto it = j_object.rbegin();
CHECK_THROWS_WITH_AS(it + 1, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(it + 1, "[json.exception.invalid_iterator.209]
} │ }
{ │ {
auto it = j_object.cbegin(); │ auto it = j_object.crbegin();
CHECK_THROWS_WITH_AS(it + 1, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(it + 1, "[json.exception.invalid_iterator.209]
} │ }
{ │ {
auto it = j_object.begin(); │ auto it = j_object.rbegin();
CHECK_THROWS_WITH_AS(1 + it, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(1 + it, "[json.exception.invalid_iterator.209]
} │ }
{ │ {
auto it = j_object.cbegin(); │ auto it = j_object.crbegin();
CHECK_THROWS_WITH_AS(1 + it, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(1 + it, "[json.exception.invalid_iterator.209]
} │ }
{ │ {
auto it = j_object.begin(); │ auto it = j_object.rbegin();
CHECK_THROWS_WITH_AS(it -= 1, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(it -= 1, "[json.exception.invalid_iterator.209]
} │ }
{ │ {
auto it = j_object.cbegin(); │ auto it = j_object.crbegin();
CHECK_THROWS_WITH_AS(it -= 1, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(it -= 1, "[json.exception.invalid_iterator.209]
} │ }
{ │ {
auto it = j_object.begin(); │ auto it = j_object.rbegin();
CHECK_THROWS_WITH_AS(it - 1, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(it - 1, "[json.exception.invalid_iterator.209]
} │ }
{ │ {
auto it = j_object.cbegin(); │ auto it = j_object.crbegin();
CHECK_THROWS_WITH_AS(it - 1, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(it - 1, "[json.exception.invalid_iterator.209]
} │ }
{ │ {
auto it = j_object.begin(); │ auto it = j_object.rbegin();
CHECK_THROWS_WITH_AS(it - it, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(it - it, "[json.exception.invalid_iterator.209]
} │ }
{ │ {
auto it = j_object.cbegin(); │ auto it = j_object.crbegin();
CHECK_THROWS_WITH_AS(it - it, "[json.exception.invalid_iterator.209] │ CHECK_THROWS_WITH_AS(it - it, "[json.exception.invalid_iterator.209]
} │ }
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
{ │ {
auto it = j_array.begin(); │ auto it = j_array.rbegin();
it += 3; │ it += 3;
CHECK((j_array.begin() + 3) == it); │ CHECK((j_array.rbegin() + 3) == it);
CHECK((3 + j_array.begin()) == it); │ CHECK(json::reverse_iterator(3 + j_array.rbegin()) == it);
CHECK((it - 3) == j_array.begin()); │ CHECK((it - 3) == j_array.rbegin());
CHECK((it - j_array.begin()) == 3); │ CHECK((it - j_array.rbegin()) == 3);
CHECK(*it == json(4)); │ CHECK(*it == json(3));
it -= 2; │ it -= 2;
CHECK(*it == json(2)); │ CHECK(*it == json(5));
} │ }
{ │ {
auto it = j_array.cbegin(); │ auto it = j_array.crbegin();
it += 3; │ it += 3;
CHECK((j_array.cbegin() + 3) == it); │ CHECK((j_array.crbegin() + 3) == it);
CHECK((3 + j_array.cbegin()) == it); │ CHECK(json::const_reverse_iterator(3 + j_array.crbegin()) == it);
CHECK((it - 3) == j_array.cbegin()); │ CHECK((it - 3) == j_array.crbegin());
CHECK((it - j_array.cbegin()) == 3); │ CHECK((it - j_array.crbegin()) == 3);
CHECK(*it == json(4)); │ CHECK(*it == json(3));
it -= 2; │ it -= 2;
CHECK(*it == json(2)); │ CHECK(*it == json(5));
} │ }
} │ }
│
SECTION("null") │ SECTION("null")
{ │ {
{ │ {
auto it = j_null.begin(); │ auto it = j_null.rbegin();
it += 3; │ it += 3;
CHECK((j_null.begin() + 3) == it); │ CHECK((j_null.rbegin() + 3) == it);
CHECK((3 + j_null.begin()) == it); │ CHECK(json::reverse_iterator(3 + j_null.rbegin()) == it);
CHECK((it - 3) == j_null.begin()); │ CHECK((it - 3) == j_null.rbegin());
CHECK((it - j_null.begin()) == 3); │ CHECK((it - j_null.rbegin()) == 3);
CHECK(it != j_null.end()); │ CHECK(it != j_null.rend());
it -= 3; │ it -= 3;
CHECK(it == j_null.end()); │ CHECK(it == j_null.rend());
} │ }
{ │ {
auto it = j_null.cbegin(); │ auto it = j_null.crbegin();
it += 3; │ it += 3;
CHECK((j_null.cbegin() + 3) == it); │ CHECK((j_null.crbegin() + 3) == it);
CHECK((3 + j_null.cbegin()) == it); │ CHECK(json::const_reverse_iterator(3 + j_null.crbegin()) == it);
CHECK((it - 3) == j_null.cbegin()); │ CHECK((it - 3) == j_null.crbegin());
CHECK((it - j_null.cbegin()) == 3); │ CHECK((it - j_null.crbegin()) == 3);
CHECK(it != j_null.cend()); │ CHECK(it != j_null.crend());
it -= 3; │ it -= 3;
CHECK(it == j_null.cend()); │ CHECK(it == j_null.crend());
} │ }
} │ }
│
SECTION("value") │ SECTION("value")
{ │ {
{ │ {
auto it = j_value.begin(); │ auto it = j_value.rbegin();
it += 3; │ it += 3;
CHECK((j_value.begin() + 3) == it); │ CHECK((j_value.rbegin() + 3) == it);
CHECK((3 + j_value.begin()) == it); │ CHECK(json::reverse_iterator(3 + j_value.rbegin()) == it);
CHECK((it - 3) == j_value.begin()); │ CHECK((it - 3) == j_value.rbegin());
CHECK((it - j_value.begin()) == 3); │ CHECK((it - j_value.rbegin()) == 3);
CHECK(it != j_value.end()); │ CHECK(it != j_value.rend());
it -= 3; │ it -= 3;
CHECK(*it == json(42)); │ CHECK(*it == json(42));
} │ }
{ │ {
auto it = j_value.cbegin(); │ auto it = j_value.crbegin();
it += 3; │ it += 3;
CHECK((j_value.cbegin() + 3) == it); │ CHECK((j_value.crbegin() + 3) == it);
CHECK((3 + j_value.cbegin()) == it); │ CHECK(json::const_reverse_iterator(3 + j_value.crbegin()) == it);
CHECK((it - 3) == j_value.cbegin()); │ CHECK((it - 3) == j_value.crbegin());
CHECK((it - j_value.cbegin()) == 3); │ CHECK((it - j_value.crbegin()) == 3);
CHECK(it != j_value.cend()); │ CHECK(it != j_value.crend());
it -= 3; │ it -= 3;
CHECK(*it == json(42)); │ CHECK(*it == json(42));
} │ }
} │ }
} │ }
│
SECTION("subscript operator") │ SECTION("subscript operator")
{ │ {
SECTION("object") │ SECTION("object")
{ │ {
{ │ {
auto it = j_object.begin(); │ auto it = j_object.rbegin();
CHECK_THROWS_WITH_AS(it[0], "[json.exception.invalid_iterator.208] c │ CHECK_THROWS_WITH_AS(it[0], "[json.exception.invalid_iterator.209] c
CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.208] c │ CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.209] c
} │ }
{ │ {
auto it = j_object.cbegin(); │ auto it = j_object.crbegin();
CHECK_THROWS_WITH_AS(it[0], "[json.exception.invalid_iterator.208] c │ CHECK_THROWS_WITH_AS(it[0], "[json.exception.invalid_iterator.209] c
CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.208] c │ CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.209] c
} │ }
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
{ │ {
auto it = j_array.begin(); │ auto it = j_array.rbegin();
CHECK(it[0] == json(1)); │ CHECK(it[0] == json(6));
CHECK(it[1] == json(2)); │ CHECK(it[1] == json(5));
CHECK(it[2] == json(3)); │ CHECK(it[2] == json(4));
CHECK(it[3] == json(4)); │ CHECK(it[3] == json(3));
CHECK(it[4] == json(5)); │ CHECK(it[4] == json(2));
CHECK(it[5] == json(6)); │ CHECK(it[5] == json(1));
} │ }
{ │ {
auto it = j_array.cbegin(); │ auto it = j_array.crbegin();
CHECK(it[0] == json(1)); │ CHECK(it[0] == json(6));
CHECK(it[1] == json(2)); │ CHECK(it[1] == json(5));
CHECK(it[2] == json(3)); │ CHECK(it[2] == json(4));
CHECK(it[3] == json(4)); │ CHECK(it[3] == json(3));
CHECK(it[4] == json(5)); │ CHECK(it[4] == json(2));
CHECK(it[5] == json(6)); │ CHECK(it[5] == json(1));
} │ }
} │ }
│
SECTION("null") │ SECTION("null")
{ │ {
{ │ {
auto it = j_null.begin(); │ auto it = j_null.rbegin();
CHECK_THROWS_WITH_AS(it[0], "[json.exception.invalid_iterator.214] c │ CHECK_THROWS_WITH_AS(it[0], "[json.exception.invalid_iterator.214] c
CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.214] c │ CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.214] c
} │ }
{ │ {
auto it = j_null.cbegin(); │ auto it = j_null.crbegin();
CHECK_THROWS_WITH_AS(it[0], "[json.exception.invalid_iterator.214] c │ CHECK_THROWS_WITH_AS(it[0], "[json.exception.invalid_iterator.214] c
CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.214] c │ CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.214] c
} │ }
} │ }
│
SECTION("value") │ SECTION("value")
{ │ {
{ │ {
auto it = j_value.begin(); │ auto it = j_value.rbegin();
CHECK(it[0] == json(42)); │ CHECK(it[0] == json(42));
CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.214] c │ CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.214] c
} │ }
{ │ {
auto it = j_value.cbegin(); │ auto it = j_value.crbegin();
CHECK(it[0] == json(42)); │ CHECK(it[0] == json(42));
CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.214] c │ CHECK_THROWS_WITH_AS(it[1], "[json.exception.invalid_iterator.214] c
} │ }
} │ }
} │ }
} │
next prev up json/tests/src/unit-class_iterator.cpp:203 │ json/tests/src/unit-class_const_iterator.cpp:213
│
SECTION("post-increment") │ SECTION("post-increment")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j(json::value_t::null); │ json j(json::value_t::null);
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK((it.m_it.primitive_iterator.m_it == 1)); │ CHECK((it.m_it.primitive_iterator.m_it == 1));
it++; │ it++;
CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato │ CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato
} │ }
│
SECTION("number") │ SECTION("number")
{ │ {
json j(17); │ json j(17);
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK((it.m_it.primitive_iterator.m_it == 0)); │ CHECK((it.m_it.primitive_iterator.m_it == 0));
it++; │ it++;
CHECK((it.m_it.primitive_iterator.m_it == 1)); │ CHECK((it.m_it.primitive_iterator.m_it == 1));
it++; │ it++;
CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato │ CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato
} │ }
│
SECTION("object") │ SECTION("object")
{ │ {
json j({{"foo", "bar"}}); │ json j({{"foo", "bar"}});
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin())) │ CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin()))
it++; │ it++;
CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end())); │ CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end()));
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j({1, 2, 3, 4}); │ json j({1, 2, 3, 4});
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin()));
it++; │ it++;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
it++; │ it++;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
it++; │ it++;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
it++; │ it++;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end()));
} │ }
} │ }
│
SECTION("pre-increment") │ SECTION("pre-increment")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j(json::value_t::null); │ json j(json::value_t::null);
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK((it.m_it.primitive_iterator.m_it == 1)); │ CHECK((it.m_it.primitive_iterator.m_it == 1));
++it; │ ++it;
CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato │ CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato
} │ }
│
SECTION("number") │ SECTION("number")
{ │ {
json j(17); │ json j(17);
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK((it.m_it.primitive_iterator.m_it == 0)); │ CHECK((it.m_it.primitive_iterator.m_it == 0));
++it; │ ++it;
CHECK((it.m_it.primitive_iterator.m_it == 1)); │ CHECK((it.m_it.primitive_iterator.m_it == 1));
++it; │ ++it;
CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato │ CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato
} │ }
│
SECTION("object") │ SECTION("object")
{ │ {
json j({{"foo", "bar"}}); │ json j({{"foo", "bar"}});
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin())) │ CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin()))
++it; │ ++it;
CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end())); │ CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end()));
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j({1, 2, 3, 4}); │ json j({1, 2, 3, 4});
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin()));
++it; │ ++it;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
++it; │ ++it;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
++it; │ ++it;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
++it; │ ++it;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end()));
} │ }
} │ }
│
SECTION("post-decrement") │ SECTION("post-decrement")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j(json::value_t::null); │ json j(json::value_t::null);
json::iterator it = j.end(); │ json::const_iterator it = j.cend();
CHECK((it.m_it.primitive_iterator.m_it == 1)); │ CHECK((it.m_it.primitive_iterator.m_it == 1));
} │ }
│
SECTION("number") │ SECTION("number")
{ │ {
json j(17); │ json j(17);
json::iterator it = j.end(); │ json::const_iterator it = j.cend();
CHECK((it.m_it.primitive_iterator.m_it == 1)); │ CHECK((it.m_it.primitive_iterator.m_it == 1));
it--; │ it--;
CHECK((it.m_it.primitive_iterator.m_it == 0)); │ CHECK((it.m_it.primitive_iterator.m_it == 0));
it--; │ it--;
CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato │ CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato
} │ }
│
SECTION("object") │ SECTION("object")
{ │ {
json j({{"foo", "bar"}}); │ json j({{"foo", "bar"}});
json::iterator it = j.end(); │ json::const_iterator it = j.cend();
CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end())); │ CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end()));
it--; │ it--;
CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin())) │ CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin()))
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j({1, 2, 3, 4}); │ json j({1, 2, 3, 4});
json::iterator it = j.end(); │ json::const_iterator it = j.cend();
CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end()));
it--; │ it--;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
it--; │ it--;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
it--; │ it--;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
it--; │ it--;
CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
} │ }
} │ }
│
SECTION("pre-decrement") │ SECTION("pre-decrement")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j(json::value_t::null); │ json j(json::value_t::null);
json::iterator it = j.end(); │ json::const_iterator it = j.cend();
CHECK((it.m_it.primitive_iterator.m_it == 1)); │ CHECK((it.m_it.primitive_iterator.m_it == 1));
} │ }
│
SECTION("number") │ SECTION("number")
{ │ {
json j(17); │ json j(17);
json::iterator it = j.end(); │ json::const_iterator it = j.cend();
CHECK((it.m_it.primitive_iterator.m_it == 1)); │ CHECK((it.m_it.primitive_iterator.m_it == 1));
--it; │ --it;
CHECK((it.m_it.primitive_iterator.m_it == 0)); │ CHECK((it.m_it.primitive_iterator.m_it == 0));
--it; │ --it;
CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato │ CHECK((it.m_it.primitive_iterator.m_it != 0 && it.m_it.primitive_iterato
} │ }
│
SECTION("object") │ SECTION("object")
{ │ {
json j({{"foo", "bar"}}); │ json j({{"foo", "bar"}});
json::iterator it = j.end(); │ json::const_iterator it = j.cend();
CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end())); │ CHECK((it.m_it.object_iterator == it.m_object->m_value.object->end()));
--it; │ --it;
CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin())) │ CHECK((it.m_it.object_iterator == it.m_object->m_value.object->begin()))
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j({1, 2, 3, 4}); │ json j({1, 2, 3, 4});
json::iterator it = j.end(); │ json::const_iterator it = j.cend();
CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator == it.m_object->m_value.array->end()));
--it; │ --it;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
--it; │ --it;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
--it; │ --it;
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
--it; │ --it;
CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin())); │ CHECK((it.m_it.array_iterator == it.m_object->m_value.array->begin()));
CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end())); │ CHECK((it.m_it.array_iterator != it.m_object->m_value.array->end()));
} │ }
} │ }
} │
next prev up json/tests/src/unit-iterators1.cpp:1318 │ json/tests/src/unit-iterators1.cpp:356
│
json j = 23.42; │ json j = "hello world";
json j_const(j); │ json j_const(j);
│
SECTION("json + begin/end") │ SECTION("json + begin/end")
{ │ {
json::iterator it = j.begin(); │ json::iterator it = j.begin();
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
it--; │ it--;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
--it; │ --it;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + begin/end") │ SECTION("const json + begin/end")
{ │ {
json::const_iterator it = j_const.begin(); │ json::const_iterator it = j_const.begin();
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
it--; │ it--;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
--it; │ --it;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + cbegin/cend") │ SECTION("json + cbegin/cend")
{ │ {
json::const_iterator it = j.cbegin(); │ json::const_iterator it = j.cbegin();
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
it--; │ it--;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
--it; │ --it;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + cbegin/cend") │ SECTION("const json + cbegin/cend")
{ │ {
json::const_iterator it = j_const.cbegin(); │ json::const_iterator it = j_const.cbegin();
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
it--; │ it--;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
--it; │ --it;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + rbegin/rend") │ SECTION("json + rbegin/rend")
{ │ {
json::reverse_iterator it = j.rbegin(); │ json::reverse_iterator it = j.rbegin();
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
it--; │ it--;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
--it; │ --it;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("json + crbegin/crend") │ SECTION("json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j.crbegin(); │ json::const_reverse_iterator it = j.crbegin();
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
it--; │ it--;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
--it; │ --it;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + crbegin/crend") │ SECTION("const json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j_const.crbegin(); │ json::const_reverse_iterator it = j_const.crbegin();
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
it--; │ it--;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
--it; │ --it;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("key/value") │ SECTION("key/value")
{ │ {
auto it = j.begin(); │ auto it = j.begin();
auto cit = j_const.cbegin(); │ auto cit = j_const.cbegin();
CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca │ CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca
CHECK(it.value() == json(23.42)); │ CHECK(it.value() == json("hello world"));
CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c
CHECK(cit.value() == json(23.42)); │ CHECK(cit.value() == json("hello world"));
│
auto rit = j.rend(); │ auto rit = j.rend();
auto crit = j.crend(); │ auto crit = j.crend();
CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c
CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] │ CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214]
CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] │ CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207]
CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214 │ CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214
} │ }
} │
next prev up json/tests/src/unit-iterators1.cpp:1120 │ json/tests/src/unit-iterators1.cpp:356
│
json j = 23u; │ json j = "hello world";
json j_const(j); │ json j_const(j);
│
SECTION("json + begin/end") │ SECTION("json + begin/end")
{ │ {
json::iterator it = j.begin(); │ json::iterator it = j.begin();
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
it--; │ it--;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
--it; │ --it;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + begin/end") │ SECTION("const json + begin/end")
{ │ {
json::const_iterator it = j_const.begin(); │ json::const_iterator it = j_const.begin();
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
it--; │ it--;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
--it; │ --it;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + cbegin/cend") │ SECTION("json + cbegin/cend")
{ │ {
json::const_iterator it = j.cbegin(); │ json::const_iterator it = j.cbegin();
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
it--; │ it--;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
--it; │ --it;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + cbegin/cend") │ SECTION("const json + cbegin/cend")
{ │ {
json::const_iterator it = j_const.cbegin(); │ json::const_iterator it = j_const.cbegin();
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
it--; │ it--;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
--it; │ --it;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + rbegin/rend") │ SECTION("json + rbegin/rend")
{ │ {
json::reverse_iterator it = j.rbegin(); │ json::reverse_iterator it = j.rbegin();
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
it--; │ it--;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
--it; │ --it;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("json + crbegin/crend") │ SECTION("json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j.crbegin(); │ json::const_reverse_iterator it = j.crbegin();
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
it--; │ it--;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
--it; │ --it;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + crbegin/crend") │ SECTION("const json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j_const.crbegin(); │ json::const_reverse_iterator it = j_const.crbegin();
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
it--; │ it--;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
--it; │ --it;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("key/value") │ SECTION("key/value")
{ │ {
auto it = j.begin(); │ auto it = j.begin();
auto cit = j_const.cbegin(); │ auto cit = j_const.cbegin();
CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca │ CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca
CHECK(it.value() == json(23)); │ CHECK(it.value() == json("hello world"));
CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c
CHECK(cit.value() == json(23)); │ CHECK(cit.value() == json("hello world"));
│
auto rit = j.rend(); │ auto rit = j.rend();
auto crit = j.crend(); │ auto crit = j.crend();
CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c
CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] │ CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214]
CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] │ CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207]
CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214 │ CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214
} │ }
} │
next prev up json/tests/src/unit-iterators1.cpp:1120 │ json/tests/src/unit-iterators1.cpp:1318
│
json j = 23u; │ json j = 23.42;
json j_const(j); │ json j_const(j);
│
SECTION("json + begin/end") │ SECTION("json + begin/end")
{ │ {
json::iterator it = j.begin(); │ json::iterator it = j.begin();
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
it--; │ it--;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
--it; │ --it;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + begin/end") │ SECTION("const json + begin/end")
{ │ {
json::const_iterator it = j_const.begin(); │ json::const_iterator it = j_const.begin();
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
it--; │ it--;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
--it; │ --it;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + cbegin/cend") │ SECTION("json + cbegin/cend")
{ │ {
json::const_iterator it = j.cbegin(); │ json::const_iterator it = j.cbegin();
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
it--; │ it--;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
--it; │ --it;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + cbegin/cend") │ SECTION("const json + cbegin/cend")
{ │ {
json::const_iterator it = j_const.cbegin(); │ json::const_iterator it = j_const.cbegin();
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
it--; │ it--;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
--it; │ --it;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + rbegin/rend") │ SECTION("json + rbegin/rend")
{ │ {
json::reverse_iterator it = j.rbegin(); │ json::reverse_iterator it = j.rbegin();
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
it--; │ it--;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
--it; │ --it;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("json + crbegin/crend") │ SECTION("json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j.crbegin(); │ json::const_reverse_iterator it = j.crbegin();
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
it--; │ it--;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
--it; │ --it;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + crbegin/crend") │ SECTION("const json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j_const.crbegin(); │ json::const_reverse_iterator it = j_const.crbegin();
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
it--; │ it--;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
--it; │ --it;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("key/value") │ SECTION("key/value")
{ │ {
auto it = j.begin(); │ auto it = j.begin();
auto cit = j_const.cbegin(); │ auto cit = j_const.cbegin();
CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca │ CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca
CHECK(it.value() == json(23)); │ CHECK(it.value() == json(23.42));
CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c
CHECK(cit.value() == json(23)); │ CHECK(cit.value() == json(23.42));
│
auto rit = j.rend(); │ auto rit = j.rend();
auto crit = j.crend(); │ auto crit = j.crend();
CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c
CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] │ CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214]
CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] │ CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207]
CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214 │ CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214
} │ }
} │
next prev up json/tests/src/unit-iterators1.cpp:922 │ json/tests/src/unit-iterators1.cpp:356
│
json j = 23; │ json j = "hello world";
json j_const(j); │ json j_const(j);
│
SECTION("json + begin/end") │ SECTION("json + begin/end")
{ │ {
json::iterator it = j.begin(); │ json::iterator it = j.begin();
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
it--; │ it--;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
--it; │ --it;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + begin/end") │ SECTION("const json + begin/end")
{ │ {
json::const_iterator it = j_const.begin(); │ json::const_iterator it = j_const.begin();
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
it--; │ it--;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
--it; │ --it;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + cbegin/cend") │ SECTION("json + cbegin/cend")
{ │ {
json::const_iterator it = j.cbegin(); │ json::const_iterator it = j.cbegin();
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
it--; │ it--;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
--it; │ --it;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + cbegin/cend") │ SECTION("const json + cbegin/cend")
{ │ {
json::const_iterator it = j_const.cbegin(); │ json::const_iterator it = j_const.cbegin();
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
it--; │ it--;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
--it; │ --it;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + rbegin/rend") │ SECTION("json + rbegin/rend")
{ │ {
json::reverse_iterator it = j.rbegin(); │ json::reverse_iterator it = j.rbegin();
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
it--; │ it--;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
--it; │ --it;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("json + crbegin/crend") │ SECTION("json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j.crbegin(); │ json::const_reverse_iterator it = j.crbegin();
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
it--; │ it--;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
--it; │ --it;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + crbegin/crend") │ SECTION("const json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j_const.crbegin(); │ json::const_reverse_iterator it = j_const.crbegin();
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
it--; │ it--;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
--it; │ --it;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("key/value") │ SECTION("key/value")
{ │ {
auto it = j.begin(); │ auto it = j.begin();
auto cit = j_const.cbegin(); │ auto cit = j_const.cbegin();
CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca │ CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca
CHECK(it.value() == json(23)); │ CHECK(it.value() == json("hello world"));
CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c
CHECK(cit.value() == json(23)); │ CHECK(cit.value() == json("hello world"));
│
auto rit = j.rend(); │ auto rit = j.rend();
auto crit = j.crend(); │ auto crit = j.crend();
CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c
CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] │ CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214]
CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] │ CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207]
CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214 │ CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214
} │ }
} │
next prev up json/tests/src/unit-iterators1.cpp:922 │ json/tests/src/unit-iterators1.cpp:1318
│
json j = 23; │ json j = 23.42;
json j_const(j); │ json j_const(j);
│
SECTION("json + begin/end") │ SECTION("json + begin/end")
{ │ {
json::iterator it = j.begin(); │ json::iterator it = j.begin();
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
it--; │ it--;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
--it; │ --it;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + begin/end") │ SECTION("const json + begin/end")
{ │ {
json::const_iterator it = j_const.begin(); │ json::const_iterator it = j_const.begin();
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
it--; │ it--;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
--it; │ --it;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + cbegin/cend") │ SECTION("json + cbegin/cend")
{ │ {
json::const_iterator it = j.cbegin(); │ json::const_iterator it = j.cbegin();
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
it--; │ it--;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
--it; │ --it;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + cbegin/cend") │ SECTION("const json + cbegin/cend")
{ │ {
json::const_iterator it = j_const.cbegin(); │ json::const_iterator it = j_const.cbegin();
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
it--; │ it--;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
--it; │ --it;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + rbegin/rend") │ SECTION("json + rbegin/rend")
{ │ {
json::reverse_iterator it = j.rbegin(); │ json::reverse_iterator it = j.rbegin();
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
it--; │ it--;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
--it; │ --it;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("json + crbegin/crend") │ SECTION("json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j.crbegin(); │ json::const_reverse_iterator it = j.crbegin();
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
it--; │ it--;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
--it; │ --it;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + crbegin/crend") │ SECTION("const json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j_const.crbegin(); │ json::const_reverse_iterator it = j_const.crbegin();
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
it--; │ it--;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
--it; │ --it;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("key/value") │ SECTION("key/value")
{ │ {
auto it = j.begin(); │ auto it = j.begin();
auto cit = j_const.cbegin(); │ auto cit = j_const.cbegin();
CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca │ CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca
CHECK(it.value() == json(23)); │ CHECK(it.value() == json(23.42));
CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c
CHECK(cit.value() == json(23)); │ CHECK(cit.value() == json(23.42));
│
auto rit = j.rend(); │ auto rit = j.rend();
auto crit = j.crend(); │ auto crit = j.crend();
CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c
CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] │ CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214]
CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] │ CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207]
CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214 │ CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214
} │ }
} │
next prev up json/tests/src/unit-iterators1.cpp:922 │ json/tests/src/unit-iterators1.cpp:1120
│
json j = 23; │ json j = 23u;
json j_const(j); │ json j_const(j);
│
SECTION("json + begin/end") │ SECTION("json + begin/end")
{ │ {
json::iterator it = j.begin(); │ json::iterator it = j.begin();
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
it--; │ it--;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.begin()); │ CHECK(it != j.begin());
CHECK(it == j.end()); │ CHECK(it == j.end());
│
--it; │ --it;
CHECK(it == j.begin()); │ CHECK(it == j.begin());
CHECK(it != j.end()); │ CHECK(it != j.end());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + begin/end") │ SECTION("const json + begin/end")
{ │ {
json::const_iterator it = j_const.begin(); │ json::const_iterator it = j_const.begin();
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
it--; │ it--;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.begin()); │ CHECK(it != j_const.begin());
CHECK(it == j_const.end()); │ CHECK(it == j_const.end());
│
--it; │ --it;
CHECK(it == j_const.begin()); │ CHECK(it == j_const.begin());
CHECK(it != j_const.end()); │ CHECK(it != j_const.end());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + cbegin/cend") │ SECTION("json + cbegin/cend")
{ │ {
json::const_iterator it = j.cbegin(); │ json::const_iterator it = j.cbegin();
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
it--; │ it--;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.cbegin()); │ CHECK(it != j.cbegin());
CHECK(it == j.cend()); │ CHECK(it == j.cend());
│
--it; │ --it;
CHECK(it == j.cbegin()); │ CHECK(it == j.cbegin());
CHECK(it != j.cend()); │ CHECK(it != j.cend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + cbegin/cend") │ SECTION("const json + cbegin/cend")
{ │ {
json::const_iterator it = j_const.cbegin(); │ json::const_iterator it = j_const.cbegin();
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
it--; │ it--;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.cbegin()); │ CHECK(it != j_const.cbegin());
CHECK(it == j_const.cend()); │ CHECK(it == j_const.cend());
│
--it; │ --it;
CHECK(it == j_const.cbegin()); │ CHECK(it == j_const.cbegin());
CHECK(it != j_const.cend()); │ CHECK(it != j_const.cend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("json + rbegin/rend") │ SECTION("json + rbegin/rend")
{ │ {
json::reverse_iterator it = j.rbegin(); │ json::reverse_iterator it = j.rbegin();
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
it--; │ it--;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.rbegin()); │ CHECK(it != j.rbegin());
CHECK(it == j.rend()); │ CHECK(it == j.rend());
│
--it; │ --it;
CHECK(it == j.rbegin()); │ CHECK(it == j.rbegin());
CHECK(it != j.rend()); │ CHECK(it != j.rend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("json + crbegin/crend") │ SECTION("json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j.crbegin(); │ json::const_reverse_iterator it = j.crbegin();
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
it++; │ it++;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
it--; │ it--;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
│
++it; │ ++it;
CHECK(it != j.crbegin()); │ CHECK(it != j.crbegin());
CHECK(it == j.crend()); │ CHECK(it == j.crend());
│
--it; │ --it;
CHECK(it == j.crbegin()); │ CHECK(it == j.crbegin());
CHECK(it != j.crend()); │ CHECK(it != j.crend());
CHECK(*it == j); │ CHECK(*it == j);
} │ }
│
SECTION("const json + crbegin/crend") │ SECTION("const json + crbegin/crend")
{ │ {
json::const_reverse_iterator it = j_const.crbegin(); │ json::const_reverse_iterator it = j_const.crbegin();
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
it++; │ it++;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
it--; │ it--;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
│
++it; │ ++it;
CHECK(it != j_const.crbegin()); │ CHECK(it != j_const.crbegin());
CHECK(it == j_const.crend()); │ CHECK(it == j_const.crend());
│
--it; │ --it;
CHECK(it == j_const.crbegin()); │ CHECK(it == j_const.crbegin());
CHECK(it != j_const.crend()); │ CHECK(it != j_const.crend());
CHECK(*it == j_const); │ CHECK(*it == j_const);
} │ }
│
SECTION("key/value") │ SECTION("key/value")
{ │ {
auto it = j.begin(); │ auto it = j.begin();
auto cit = j_const.cbegin(); │ auto cit = j_const.cbegin();
CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca │ CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca
CHECK(it.value() == json(23)); │ CHECK(it.value() == json(23));
CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c
CHECK(cit.value() == json(23)); │ CHECK(cit.value() == json(23));
│
auto rit = j.rend(); │ auto rit = j.rend();
auto crit = j.crend(); │ auto crit = j.crend();
CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c │ CHECK_THROWS_WITH_AS(rit.key(), "[json.exception.invalid_iterator.207] c
CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214] │ CHECK_THROWS_WITH_AS(rit.value(), "[json.exception.invalid_iterator.214]
CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207] │ CHECK_THROWS_WITH_AS(crit.key(), "[json.exception.invalid_iterator.207]
CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214 │ CHECK_THROWS_WITH_AS(crit.value(), "[json.exception.invalid_iterator.214
} │ }
} │
next prev up json/tests/src/unit-unicode5.cpp:191 │ json/tests/src/unit-unicode4.cpp:191
│
SECTION("RFC 3629") │ SECTION("RFC 3629")
{ │ {
/* │ /*
RFC 3629 describes in Sect. 4 the syntax of UTF-8 byte sequences as │ RFC 3629 describes in Sect. 4 the syntax of UTF-8 byte sequences as
follows: │ follows:
│
A UTF-8 string is a sequence of octets representing a sequence of UCS │ A UTF-8 string is a sequence of octets representing a sequence of UCS
characters. An octet sequence is valid UTF-8 only if it matches the │ characters. An octet sequence is valid UTF-8 only if it matches the
following syntax, which is derived from the rules for encoding UTF-8 │ following syntax, which is derived from the rules for encoding UTF-8
and is expressed in the ABNF of [RFC2234]. │ and is expressed in the ABNF of [RFC2234].
│
UTF8-octets = *( UTF8-char ) │ UTF8-octets = *( UTF8-char )
UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4 │ UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4
UTF8-1 = %x00-7F │ UTF8-1 = %x00-7F
UTF8-2 = %xC2-DF UTF8-tail │ UTF8-2 = %xC2-DF UTF8-tail
UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) / │ UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) /
%xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail ) │ %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )
UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) / │ UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
%xF4 %x80-8F 2( UTF8-tail ) │ %xF4 %x80-8F 2( UTF8-tail )
UTF8-tail = %x80-BF │ UTF8-tail = %x80-BF
*/ │ */
│
SECTION("UTF8-4 (xF1-F3 UTF8-tail UTF8-tail UTF8-tail)") │ SECTION("UTF8-4 (xF1-F3 UTF8-tail UTF8-tail UTF8-tail)")
{ │ {
SECTION("well-formed") │ SECTION("well-formed")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4) │ for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4)
{ │ {
check_utf8string(true, byte1, byte2, byte3, byte4); │ check_utf8string(true, byte1, byte2, byte3, byte4);
check_utf8dump(true, byte1, byte2, byte3, byte4); │ check_utf8dump(true, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing second byte") │ SECTION("ill-formed: missing second byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
check_utf8string(false, byte1); │ check_utf8string(false, byte1);
check_utf8dump(false, byte1); │ check_utf8dump(false, byte1);
} │ }
} │ }
│
SECTION("ill-formed: missing third byte") │ SECTION("ill-formed: missing third byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
check_utf8string(false, byte1, byte2); │ check_utf8string(false, byte1, byte2);
check_utf8dump(false, byte1, byte2); │ check_utf8dump(false, byte1, byte2);
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing fourth byte") │ SECTION("ill-formed: missing fourth byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong second byte") │ SECTION("ill-formed: wrong second byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) │ for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ │ {
// skip correct second byte │ // skip correct second byte
if (0x80 <= byte2 && byte2 <= 0xBF) │ if (0x80 <= byte2 && byte2 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4) │ for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4)
{ │ {
check_utf8string(false, byte1, byte2, byte3, byte4); │ check_utf8string(false, byte1, byte2, byte3, byte4);
check_utf8dump(false, byte1, byte2, byte3, byte4); │ check_utf8dump(false, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong third byte") │ SECTION("ill-formed: wrong third byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) │ for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ │ {
// skip correct third byte │ // skip correct third byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4) │ for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4)
{ │ {
check_utf8string(false, byte1, byte2, byte3, byte4); │ check_utf8string(false, byte1, byte2, byte3, byte4);
check_utf8dump(false, byte1, byte2, byte3, byte4); │ check_utf8dump(false, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong fourth byte") │ SECTION("ill-formed: wrong fourth byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4) │ for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4)
{ │ {
// skip correct fourth byte │ // skip correct fourth byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
check_utf8string(false, byte1, byte2, byte3, byte4); │ check_utf8string(false, byte1, byte2, byte3, byte4);
check_utf8dump(false, byte1, byte2, byte3, byte4); │ check_utf8dump(false, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode3.cpp:191 │ json/tests/src/unit-unicode4.cpp:191
│
SECTION("RFC 3629") │ SECTION("RFC 3629")
{ │ {
/* │ /*
RFC 3629 describes in Sect. 4 the syntax of UTF-8 byte sequences as │ RFC 3629 describes in Sect. 4 the syntax of UTF-8 byte sequences as
follows: │ follows:
│
A UTF-8 string is a sequence of octets representing a sequence of UCS │ A UTF-8 string is a sequence of octets representing a sequence of UCS
characters. An octet sequence is valid UTF-8 only if it matches the │ characters. An octet sequence is valid UTF-8 only if it matches the
following syntax, which is derived from the rules for encoding UTF-8 │ following syntax, which is derived from the rules for encoding UTF-8
and is expressed in the ABNF of [RFC2234]. │ and is expressed in the ABNF of [RFC2234].
│
UTF8-octets = *( UTF8-char ) │ UTF8-octets = *( UTF8-char )
UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4 │ UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4
UTF8-1 = %x00-7F │ UTF8-1 = %x00-7F
UTF8-2 = %xC2-DF UTF8-tail │ UTF8-2 = %xC2-DF UTF8-tail
UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) / │ UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) /
%xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail ) │ %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )
UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) / │ UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
%xF4 %x80-8F 2( UTF8-tail ) │ %xF4 %x80-8F 2( UTF8-tail )
UTF8-tail = %x80-BF │ UTF8-tail = %x80-BF
*/ │ */
│
SECTION("UTF8-4 (xF1-F3 UTF8-tail UTF8-tail UTF8-tail)") │ SECTION("UTF8-4 (xF1-F3 UTF8-tail UTF8-tail UTF8-tail)")
{ │ {
SECTION("well-formed") │ SECTION("well-formed")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4) │ for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4)
{ │ {
check_utf8string(true, byte1, byte2, byte3, byte4); │ check_utf8string(true, byte1, byte2, byte3, byte4);
check_utf8dump(true, byte1, byte2, byte3, byte4); │ check_utf8dump(true, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing second byte") │ SECTION("ill-formed: missing second byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
check_utf8string(false, byte1); │ check_utf8string(false, byte1);
check_utf8dump(false, byte1); │ check_utf8dump(false, byte1);
} │ }
} │ }
│
SECTION("ill-formed: missing third byte") │ SECTION("ill-formed: missing third byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
check_utf8string(false, byte1, byte2); │ check_utf8string(false, byte1, byte2);
check_utf8dump(false, byte1, byte2); │ check_utf8dump(false, byte1, byte2);
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing fourth byte") │ SECTION("ill-formed: missing fourth byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong second byte") │ SECTION("ill-formed: wrong second byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) │ for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ │ {
// skip correct second byte │ // skip correct second byte
if (0x80 <= byte2 && byte2 <= 0xBF) │ if (0x80 <= byte2 && byte2 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4) │ for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4)
{ │ {
check_utf8string(false, byte1, byte2, byte3, byte4); │ check_utf8string(false, byte1, byte2, byte3, byte4);
check_utf8dump(false, byte1, byte2, byte3, byte4); │ check_utf8dump(false, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong third byte") │ SECTION("ill-formed: wrong third byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) │ for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ │ {
// skip correct third byte │ // skip correct third byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4) │ for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4)
{ │ {
check_utf8string(false, byte1, byte2, byte3, byte4); │ check_utf8string(false, byte1, byte2, byte3, byte4);
check_utf8dump(false, byte1, byte2, byte3, byte4); │ check_utf8dump(false, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong fourth byte") │ SECTION("ill-formed: wrong fourth byte")
{ │ {
for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1) │ for (int byte1 = 0xF1; byte1 <= 0xF3; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4) │ for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4)
{ │ {
// skip correct fourth byte │ // skip correct fourth byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
check_utf8string(false, byte1, byte2, byte3, byte4); │ check_utf8string(false, byte1, byte2, byte3, byte4);
check_utf8dump(false, byte1, byte2, byte3, byte4); │ check_utf8dump(false, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode3.cpp:191 │ json/tests/src/unit-unicode5.cpp:191
│
SECTION("RFC 3629") │ SECTION("RFC 3629")
{ │ {
/* │ /*
RFC 3629 describes in Sect. 4 the syntax of UTF-8 byte sequences as │ RFC 3629 describes in Sect. 4 the syntax of UTF-8 byte sequences as
follows: │ follows:
│
A UTF-8 string is a sequence of octets representing a sequence of UCS │ A UTF-8 string is a sequence of octets representing a sequence of UCS
characters. An octet sequence is valid UTF-8 only if it matches the │ characters. An octet sequence is valid UTF-8 only if it matches the
following syntax, which is derived from the rules for encoding UTF-8 │ following syntax, which is derived from the rules for encoding UTF-8
and is expressed in the ABNF of [RFC2234]. │ and is expressed in the ABNF of [RFC2234].
│
UTF8-octets = *( UTF8-char ) │ UTF8-octets = *( UTF8-char )
UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4 │ UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4
UTF8-1 = %x00-7F │ UTF8-1 = %x00-7F
UTF8-2 = %xC2-DF UTF8-tail │ UTF8-2 = %xC2-DF UTF8-tail
UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) / │ UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) /
%xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail ) │ %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )
UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) / │ UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
%xF4 %x80-8F 2( UTF8-tail ) │ %xF4 %x80-8F 2( UTF8-tail )
UTF8-tail = %x80-BF │ UTF8-tail = %x80-BF
*/ │ */
│
SECTION("UTF8-4 (xF4 x80-8F UTF8-tail UTF8-tail)") │ SECTION("UTF8-4 (xF4 x80-8F UTF8-tail UTF8-tail)")
{ │ {
SECTION("well-formed") │ SECTION("well-formed")
{ │ {
for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1) │ for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0x8F; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0x8F; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4) │ for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4)
{ │ {
check_utf8string(true, byte1, byte2, byte3, byte4); │ check_utf8string(true, byte1, byte2, byte3, byte4);
check_utf8dump(true, byte1, byte2, byte3, byte4); │ check_utf8dump(true, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing second byte") │ SECTION("ill-formed: missing second byte")
{ │ {
for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1) │ for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1)
{ │ {
check_utf8string(false, byte1); │ check_utf8string(false, byte1);
check_utf8dump(false, byte1); │ check_utf8dump(false, byte1);
} │ }
} │ }
│
SECTION("ill-formed: missing third byte") │ SECTION("ill-formed: missing third byte")
{ │ {
for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1) │ for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0x8F; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0x8F; ++byte2)
{ │ {
check_utf8string(false, byte1, byte2); │ check_utf8string(false, byte1, byte2);
check_utf8dump(false, byte1, byte2); │ check_utf8dump(false, byte1, byte2);
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing fourth byte") │ SECTION("ill-formed: missing fourth byte")
{ │ {
for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1) │ for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0x8F; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0x8F; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong second byte") │ SECTION("ill-formed: wrong second byte")
{ │ {
for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1) │ for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1)
{ │ {
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) │ for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ │ {
// skip correct second byte │ // skip correct second byte
if (0x80 <= byte2 && byte2 <= 0x8F) │ if (0x80 <= byte2 && byte2 <= 0x8F)
{ │ {
continue; │ continue;
} │ }
│
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4) │ for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4)
{ │ {
check_utf8string(false, byte1, byte2, byte3, byte4); │ check_utf8string(false, byte1, byte2, byte3, byte4);
check_utf8dump(false, byte1, byte2, byte3, byte4); │ check_utf8dump(false, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong third byte") │ SECTION("ill-formed: wrong third byte")
{ │ {
for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1) │ for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0x8F; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0x8F; ++byte2)
{ │ {
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) │ for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ │ {
// skip correct third byte │ // skip correct third byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4) │ for (int byte4 = 0x80; byte4 <= 0xBF; ++byte4)
{ │ {
check_utf8string(false, byte1, byte2, byte3, byte4); │ check_utf8string(false, byte1, byte2, byte3, byte4);
check_utf8dump(false, byte1, byte2, byte3, byte4); │ check_utf8dump(false, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong fourth byte") │ SECTION("ill-formed: wrong fourth byte")
{ │ {
for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1) │ for (int byte1 = 0xF4; byte1 <= 0xF4; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0x8F; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0x8F; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4) │ for (int byte4 = 0x00; byte4 <= 0xFF; ++byte4)
{ │ {
// skip correct fourth byte │ // skip correct fourth byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
check_utf8string(false, byte1, byte2, byte3, byte4); │ check_utf8string(false, byte1, byte2, byte3, byte4);
check_utf8dump(false, byte1, byte2, byte3, byte4); │ check_utf8dump(false, byte1, byte2, byte3, byte4);
} │ }
} │ }
} │ }
} │ }
} │ }
} │ }
} │ }
} │
next prev up json/tests/src/unit-iterators1.cpp:738 │ json/tests/src/unit-iterators1.cpp:554
│
json j = {{"A", 1}, {"B", 2}, {"C", 3}}; │ json j = {1, 2, 3};
json j_const(j); │ json j_const(j);
│
SECTION("json + begin/end") │ SECTION("json + begin/end")
{ │ {
json::iterator it_begin = j.begin(); │ json::iterator it_begin = j.begin();
json::iterator it_end = j.end(); │ json::iterator it_end = j.end();
│
auto it = it_begin; │ auto it = it_begin;
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["A"]); │ CHECK(*it == j[0]);
│
it++; │ it++;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["B"]); │ CHECK(*it == j[1]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["C"]); │ CHECK(*it == j[2]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it == it_end); │ CHECK(it == it_end);
} │ }
│
SECTION("const json + begin/end") │ SECTION("const json + begin/end")
{ │ {
json::const_iterator it_begin = j_const.begin(); │ json::const_iterator it_begin = j_const.begin();
json::const_iterator it_end = j_const.end(); │ json::const_iterator it_end = j_const.end();
│
auto it = it_begin; │ auto it = it_begin;
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j_const["A"]); │ CHECK(*it == j_const[0]);
│
it++; │ it++;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j_const["B"]); │ CHECK(*it == j_const[1]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j_const["C"]); │ CHECK(*it == j_const[2]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it == it_end); │ CHECK(it == it_end);
} │ }
│
SECTION("json + cbegin/cend") │ SECTION("json + cbegin/cend")
{ │ {
json::const_iterator it_begin = j.cbegin(); │ json::const_iterator it_begin = j.cbegin();
json::const_iterator it_end = j.cend(); │ json::const_iterator it_end = j.cend();
│
auto it = it_begin; │ auto it = it_begin;
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["A"]); │ CHECK(*it == j[0]);
│
it++; │ it++;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["B"]); │ CHECK(*it == j[1]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["C"]); │ CHECK(*it == j[2]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it == it_end); │ CHECK(it == it_end);
} │ }
│
SECTION("const json + cbegin/cend") │ SECTION("const json + cbegin/cend")
{ │ {
json::const_iterator it_begin = j_const.cbegin(); │ json::const_iterator it_begin = j_const.cbegin();
json::const_iterator it_end = j_const.cend(); │ json::const_iterator it_end = j_const.cend();
│
auto it = it_begin; │ auto it = it_begin;
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j_const["A"]); │ CHECK(*it == j[0]);
│
it++; │ it++;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j_const["B"]); │ CHECK(*it == j[1]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j_const["C"]); │ CHECK(*it == j[2]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it == it_end); │ CHECK(it == it_end);
} │ }
│
SECTION("json + rbegin/rend") │ SECTION("json + rbegin/rend")
{ │ {
json::reverse_iterator it_begin = j.rbegin(); │ json::reverse_iterator it_begin = j.rbegin();
json::reverse_iterator it_end = j.rend(); │ json::reverse_iterator it_end = j.rend();
│
auto it = it_begin; │ auto it = it_begin;
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["C"]); │ CHECK(*it == j[2]);
│
it++; │ it++;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["B"]); │ CHECK(*it == j[1]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["A"]); │ CHECK(*it == j[0]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it == it_end); │ CHECK(it == it_end);
} │ }
│
SECTION("json + crbegin/crend") │ SECTION("json + crbegin/crend")
{ │ {
json::const_reverse_iterator it_begin = j.crbegin(); │ json::const_reverse_iterator it_begin = j.crbegin();
json::const_reverse_iterator it_end = j.crend(); │ json::const_reverse_iterator it_end = j.crend();
│
auto it = it_begin; │ auto it = it_begin;
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["C"]); │ CHECK(*it == j[2]);
│
it++; │ it++;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["B"]); │ CHECK(*it == j[1]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["A"]); │ CHECK(*it == j[0]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it == it_end); │ CHECK(it == it_end);
} │ }
│
SECTION("const json + crbegin/crend") │ SECTION("const json + crbegin/crend")
{ │ {
json::const_reverse_iterator it_begin = j_const.crbegin(); │ json::const_reverse_iterator it_begin = j_const.crbegin();
json::const_reverse_iterator it_end = j_const.crend(); │ json::const_reverse_iterator it_end = j_const.crend();
│
auto it = it_begin; │ auto it = it_begin;
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["C"]); │ CHECK(*it == j[2]);
│
it++; │ it++;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["B"]); │ CHECK(*it == j[1]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it != it_end); │ CHECK(it != it_end);
CHECK(*it == j["A"]); │ CHECK(*it == j[0]);
│
++it; │ ++it;
CHECK(it != it_begin); │ CHECK(it != it_begin);
CHECK(it == it_end); │ CHECK(it == it_end);
} │ }
│
SECTION("key/value") │ SECTION("key/value")
{ │ {
auto it = j.begin(); │ auto it = j.begin();
auto cit = j_const.cbegin(); │ auto cit = j_const.cbegin();
CHECK(it.key() == "A"); │ CHECK_THROWS_WITH_AS(it.key(), "[json.exception.invalid_iterator.207] ca
CHECK(it.value() == json(1)); │ CHECK(it.value() == json(1));
CHECK(cit.key() == "A"); │ CHECK_THROWS_WITH_AS(cit.key(), "[json.exception.invalid_iterator.207] c
CHECK(cit.value() == json(1)); │ CHECK(cit.value() == json(1));
} │ }
} │
next prev up json/tests/src/unit-element_access2.cpp:1164 │ json/tests/src/unit-element_access2.cpp:1313
│
SECTION("existing element") │ SECTION("existing element")
{ │ {
for (const auto* key : │ for (const auto* key :
{"integer", "unsigned", "floating", "null", "string", "boolean", │ {"integer", "unsigned", "floating", "null", "string", "boolean",
}) │ })
{ │ {
CHECK(j.count(key) == 1); │ CHECK(j.contains(key) == true);
CHECK(j_const.count(key) == 1); │ CHECK(j_const.contains(key) == true);
} │ }
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
for (const std::string_view key : │ for (const std::string_view key :
{"integer", "unsigned", "floating", "null", "string", "boolean", │ {"integer", "unsigned", "floating", "null", "string", "boolean",
}) │ })
{ │ {
CHECK(j.count(key) == 1); │ CHECK(j.contains(key) == true);
CHECK(j_const.count(key) == 1); │ CHECK(j_const.contains(key) == true);
} │ }
#endif │ #endif
} │ }
│
SECTION("nonexisting element") │ SECTION("nonexisting element")
{ │ {
CHECK(j.count("foo") == 0); │ CHECK(j.contains("foo") == false);
CHECK(j_const.count("foo") == 0); │ CHECK(j_const.contains("foo") == false);
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK(j.count(std::string_view("foo")) == 0); │ CHECK(j.contains(std::string_view("foo")) == false);
CHECK(j_const.count(std::string_view("foo")) == 0); │ CHECK(j_const.contains(std::string_view("foo")) == false);
#endif │ #endif
} │ }
│
SECTION("all types") │ SECTION("all types")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j_nonobject(json::value_t::null); │ json j_nonobject(json::value_t::null);
const json j_nonobject_const(json::value_t::null); │ const json j_nonobject_const(json::value_t::null);
│
CHECK(j_nonobject.count("foo") == 0); │ CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.count("foo") == 0); │ CHECK(j_nonobject_const.contains("foo") == false);
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK(j.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject.contains(std::string_view("foo")) == false);
CHECK(j_const.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject_const.contains(std::string_view("foo")) == false);
#endif │ #endif
} │ }
│
SECTION("string") │ SECTION("string")
{ │ {
json j_nonobject(json::value_t::string); │ json j_nonobject(json::value_t::string);
const json j_nonobject_const(json::value_t::string); │ const json j_nonobject_const(json::value_t::string);
│
CHECK(j_nonobject.count("foo") == 0); │ CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.count("foo") == 0); │ CHECK(j_nonobject_const.contains("foo") == false);
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK(j.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject.contains(std::string_view("foo")) == false);
CHECK(j_const.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject_const.contains(std::string_view("foo")) == false);
#endif │ #endif
} │ }
│
SECTION("object") │ SECTION("object")
{ │ {
json j_nonobject(json::value_t::object); │ json j_nonobject(json::value_t::object);
const json j_nonobject_const(json::value_t::object); │ const json j_nonobject_const(json::value_t::object);
│
CHECK(j_nonobject.count("foo") == 0); │ CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.count("foo") == 0); │ CHECK(j_nonobject_const.contains("foo") == false);
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK(j.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject.contains(std::string_view("foo")) == false);
CHECK(j_const.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject_const.contains(std::string_view("foo")) == false);
#endif │ #endif
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j_nonobject(json::value_t::array); │ json j_nonobject(json::value_t::array);
const json j_nonobject_const(json::value_t::array); │ const json j_nonobject_const(json::value_t::array);
│
CHECK(j_nonobject.count("foo") == 0); │ CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.count("foo") == 0); │ CHECK(j_nonobject_const.contains("foo") == false);
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK(j.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject.contains(std::string_view("foo")) == false);
CHECK(j_const.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject_const.contains(std::string_view("foo")) == false);
#endif │ #endif
} │ }
│
SECTION("boolean") │ SECTION("boolean")
{ │ {
json j_nonobject(json::value_t::boolean); │ json j_nonobject(json::value_t::boolean);
const json j_nonobject_const(json::value_t::boolean); │ const json j_nonobject_const(json::value_t::boolean);
│
CHECK(j_nonobject.count("foo") == 0); │ CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.count("foo") == 0); │ CHECK(j_nonobject_const.contains("foo") == false);
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK(j.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject.contains(std::string_view("foo")) == false);
CHECK(j_const.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject_const.contains(std::string_view("foo")) == false);
#endif │ #endif
} │ }
│
SECTION("number (integer)") │ SECTION("number (integer)")
{ │ {
json j_nonobject(json::value_t::number_integer); │ json j_nonobject(json::value_t::number_integer);
const json j_nonobject_const(json::value_t::number_integer); │ const json j_nonobject_const(json::value_t::number_integer);
│
CHECK(j_nonobject.count("foo") == 0); │ CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.count("foo") == 0); │ CHECK(j_nonobject_const.contains("foo") == false);
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK(j.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject.contains(std::string_view("foo")) == false);
CHECK(j_const.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject_const.contains(std::string_view("foo")) == false);
#endif │ #endif
} │ }
│
SECTION("number (unsigned)") │ SECTION("number (unsigned)")
{ │ {
json j_nonobject(json::value_t::number_unsigned); │ json j_nonobject(json::value_t::number_unsigned);
const json j_nonobject_const(json::value_t::number_unsigned); │ const json j_nonobject_const(json::value_t::number_unsigned);
│
CHECK(j_nonobject.count("foo") == 0); │ CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.count("foo") == 0); │ CHECK(j_nonobject_const.contains("foo") == false);
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK(j.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject.contains(std::string_view("foo")) == false);
CHECK(j_const.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject_const.contains(std::string_view("foo")) == false);
#endif │ #endif
} │ }
│
SECTION("number (floating-point)") │ SECTION("number (floating-point)")
{ │ {
json j_nonobject(json::value_t::number_float); │ json j_nonobject(json::value_t::number_float);
const json j_nonobject_const(json::value_t::number_float); │ const json j_nonobject_const(json::value_t::number_float);
│ CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject.count("foo") == 0); │ CHECK(j_nonobject_const.contains("foo") == false);
CHECK(j_nonobject_const.count("foo") == 0); │
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK(j.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject.contains(std::string_view("foo")) == false);
CHECK(j_const.count(std::string_view("foo")) == 0); │ CHECK(j_nonobject_const.contains(std::string_view("foo")) == false);
#endif │ #endif
} │ }
} │ }
} │
next prev up json/tests/src/unit-testsuites.cpp:1254 │ json/tests/src/unit-testsuites.cpp:1305
│
for (const auto* filename : │ for (const auto* filename :
{ │ {
TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_ │ //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_numbe
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_numbe │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_numbe │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_numbe │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_numbe │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_numbe │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_
TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_ │ //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_numbe
TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_ │ //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_numbe
TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_ │ //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_numbe
TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_number_ │ //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_numbe
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_objec │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_object_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
//TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_strin │ TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_string_
TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_structu │ //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_struc
TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_structu │ //TEST_DATA_DIRECTORY "/nst_json_testsuite2/test_parsing/i_struc
} │ }
) │ )
{ │ {
CAPTURE(filename) │ CAPTURE(filename)
std::ifstream f(filename); │ std::ifstream f(filename);
json _; │ json _;
CHECK_NOTHROW(_ = json::parse(f)); │ CHECK_THROWS_AS(_ = json::parse(f), json::exception&); // could be parse
std::ifstream f2(filename); │ std::ifstream f2(filename);
CHECK(json::accept(f2)); │ CHECK(!json::accept(f2));
} │ }
} │
next prev up json/tests/src/unit-unicode4.cpp:49 │ json/tests/src/unit-unicode5.cpp:49
│
extern size_t calls; │ extern size_t calls;
size_t calls = 0; │ size_t calls = 0;
│
void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4); │ void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4);
│
void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in │ void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in
{ │ {
static std::string json_string; │ static std::string json_string;
json_string.clear(); │ json_string.clear();
│
CAPTURE(byte1) │ CAPTURE(byte1)
CAPTURE(byte2) │ CAPTURE(byte2)
CAPTURE(byte3) │ CAPTURE(byte3)
CAPTURE(byte4) │ CAPTURE(byte4)
│
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
// store the string in a JSON value │ // store the string in a JSON value
static json j; │ static json j;
static json j2; │ static json j2;
j = json_string; │ j = json_string;
j2 = "abc" + json_string + "xyz"; │ j2 = "abc" + json_string + "xyz";
│
static std::string s_ignored; │ static std::string s_ignored;
static std::string s_ignored2; │ static std::string s_ignored2;
static std::string s_ignored_ascii; │ static std::string s_ignored_ascii;
static std::string s_ignored2_ascii; │ static std::string s_ignored2_ascii;
static std::string s_replaced; │ static std::string s_replaced;
static std::string s_replaced2; │ static std::string s_replaced2;
static std::string s_replaced_ascii; │ static std::string s_replaced_ascii;
static std::string s_replaced2_ascii; │ static std::string s_replaced2_ascii;
│
// dumping with ignore/replace must not throw in any case │ // dumping with ignore/replace must not throw in any case
s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore);
s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore);
s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace);
s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace);
│
if (success_expected) │ if (success_expected)
{ │ {
static std::string s_strict; │ static std::string s_strict;
// strict mode must not throw if success is expected │ // strict mode must not throw if success is expected
s_strict = j.dump(); │ s_strict = j.dump();
// all dumps should agree on the string │ // all dumps should agree on the string
CHECK(s_strict == s_ignored); │ CHECK(s_strict == s_ignored);
CHECK(s_strict == s_replaced); │ CHECK(s_strict == s_replaced);
} │ }
else │ else
{ │ {
// strict mode must throw if success is not expected │ // strict mode must throw if success is not expected
CHECK_THROWS_AS(j.dump(), json::type_error&); │ CHECK_THROWS_AS(j.dump(), json::type_error&);
// ignore and replace must create different dumps │ // ignore and replace must create different dumps
CHECK(s_ignored != s_replaced); │ CHECK(s_ignored != s_replaced);
│
// check that replace string contains a replacement character │ // check that replace string contains a replacement character
CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos); │ CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos);
} │ }
│
// check that prefix and suffix are preserved │ // check that prefix and suffix are preserved
CHECK(s_ignored2.substr(1, 3) == "abc"); │ CHECK(s_ignored2.substr(1, 3) == "abc");
CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz");
CHECK(s_ignored2_ascii.substr(1, 3) == "abc"); │ CHECK(s_ignored2_ascii.substr(1, 3) == "abc");
CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz");
CHECK(s_replaced2.substr(1, 3) == "abc"); │ CHECK(s_replaced2.substr(1, 3) == "abc");
CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz");
CHECK(s_replaced2_ascii.substr(1, 3) == "abc"); │ CHECK(s_replaced2_ascii.substr(1, 3) == "abc");
CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz");
} │ }
│
void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4) │ void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4)
│
// create and check a JSON string with up to four UTF-8 bytes │ // create and check a JSON string with up to four UTF-8 bytes
void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, │ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1,
{ │ {
if (++calls % 100000 == 0) │ if (++calls % 100000 == 0)
{ │ {
std::cout << calls << " of 1246225 UTF-8 strings checked" << std::endl; │ std::cout << calls << " of 1246225 UTF-8 strings checked" << std::endl;
} │ }
│
static std::string json_string; │ static std::string json_string;
json_string = "\""; │ json_string = "\"";
│
CAPTURE(byte1) │ CAPTURE(byte1)
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
CAPTURE(byte2) │ CAPTURE(byte2)
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
CAPTURE(byte3) │ CAPTURE(byte3)
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
CAPTURE(byte4) │ CAPTURE(byte4)
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
json_string += "\""; │ json_string += "\"";
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
json _; │ json _;
if (success_expected) │ if (success_expected)
{ │ {
CHECK_NOTHROW(_ = json::parse(json_string)); │ CHECK_NOTHROW(_ = json::parse(json_string));
} │ }
else │ else
{ │ {
CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&); │ CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&);
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode3.cpp:49 │ json/tests/src/unit-unicode5.cpp:49
│
extern size_t calls; │ extern size_t calls;
size_t calls = 0; │ size_t calls = 0;
│
void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4); │ void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4);
│
void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in │ void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in
{ │ {
static std::string json_string; │ static std::string json_string;
json_string.clear(); │ json_string.clear();
│
CAPTURE(byte1) │ CAPTURE(byte1)
CAPTURE(byte2) │ CAPTURE(byte2)
CAPTURE(byte3) │ CAPTURE(byte3)
CAPTURE(byte4) │ CAPTURE(byte4)
│
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
// store the string in a JSON value │ // store the string in a JSON value
static json j; │ static json j;
static json j2; │ static json j2;
j = json_string; │ j = json_string;
j2 = "abc" + json_string + "xyz"; │ j2 = "abc" + json_string + "xyz";
│
static std::string s_ignored; │ static std::string s_ignored;
static std::string s_ignored2; │ static std::string s_ignored2;
static std::string s_ignored_ascii; │ static std::string s_ignored_ascii;
static std::string s_ignored2_ascii; │ static std::string s_ignored2_ascii;
static std::string s_replaced; │ static std::string s_replaced;
static std::string s_replaced2; │ static std::string s_replaced2;
static std::string s_replaced_ascii; │ static std::string s_replaced_ascii;
static std::string s_replaced2_ascii; │ static std::string s_replaced2_ascii;
│
// dumping with ignore/replace must not throw in any case │ // dumping with ignore/replace must not throw in any case
s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore);
s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore);
s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace);
s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace);
│
if (success_expected) │ if (success_expected)
{ │ {
static std::string s_strict; │ static std::string s_strict;
// strict mode must not throw if success is expected │ // strict mode must not throw if success is expected
s_strict = j.dump(); │ s_strict = j.dump();
// all dumps should agree on the string │ // all dumps should agree on the string
CHECK(s_strict == s_ignored); │ CHECK(s_strict == s_ignored);
CHECK(s_strict == s_replaced); │ CHECK(s_strict == s_replaced);
} │ }
else │ else
{ │ {
// strict mode must throw if success is not expected │ // strict mode must throw if success is not expected
CHECK_THROWS_AS(j.dump(), json::type_error&); │ CHECK_THROWS_AS(j.dump(), json::type_error&);
// ignore and replace must create different dumps │ // ignore and replace must create different dumps
CHECK(s_ignored != s_replaced); │ CHECK(s_ignored != s_replaced);
│
// check that replace string contains a replacement character │ // check that replace string contains a replacement character
CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos); │ CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos);
} │ }
│
// check that prefix and suffix are preserved │ // check that prefix and suffix are preserved
CHECK(s_ignored2.substr(1, 3) == "abc"); │ CHECK(s_ignored2.substr(1, 3) == "abc");
CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz");
CHECK(s_ignored2_ascii.substr(1, 3) == "abc"); │ CHECK(s_ignored2_ascii.substr(1, 3) == "abc");
CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz");
CHECK(s_replaced2.substr(1, 3) == "abc"); │ CHECK(s_replaced2.substr(1, 3) == "abc");
CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz");
CHECK(s_replaced2_ascii.substr(1, 3) == "abc"); │ CHECK(s_replaced2_ascii.substr(1, 3) == "abc");
CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz");
} │ }
│
void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4) │ void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4)
│
// create and check a JSON string with up to four UTF-8 bytes │ // create and check a JSON string with up to four UTF-8 bytes
void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, │ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1,
{ │ {
if (++calls % 100000 == 0) │ if (++calls % 100000 == 0)
{ │ {
std::cout << calls << " of 1246225 UTF-8 strings checked" << std::endl; │ std::cout << calls << " of 1246225 UTF-8 strings checked" << std::endl;
} │ }
│
static std::string json_string; │ static std::string json_string;
json_string = "\""; │ json_string = "\"";
│
CAPTURE(byte1) │ CAPTURE(byte1)
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
CAPTURE(byte2) │ CAPTURE(byte2)
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
CAPTURE(byte3) │ CAPTURE(byte3)
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
CAPTURE(byte4) │ CAPTURE(byte4)
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
json_string += "\""; │ json_string += "\"";
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
json _; │ json _;
if (success_expected) │ if (success_expected)
{ │ {
CHECK_NOTHROW(_ = json::parse(json_string)); │ CHECK_NOTHROW(_ = json::parse(json_string));
} │ }
else │ else
{ │ {
CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&); │ CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&);
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode3.cpp:49 │ json/tests/src/unit-unicode4.cpp:49
│
extern size_t calls; │ extern size_t calls;
size_t calls = 0; │ size_t calls = 0;
│
void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4); │ void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4);
│
void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in │ void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in
{ │ {
static std::string json_string; │ static std::string json_string;
json_string.clear(); │ json_string.clear();
│
CAPTURE(byte1) │ CAPTURE(byte1)
CAPTURE(byte2) │ CAPTURE(byte2)
CAPTURE(byte3) │ CAPTURE(byte3)
CAPTURE(byte4) │ CAPTURE(byte4)
│
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
// store the string in a JSON value │ // store the string in a JSON value
static json j; │ static json j;
static json j2; │ static json j2;
j = json_string; │ j = json_string;
j2 = "abc" + json_string + "xyz"; │ j2 = "abc" + json_string + "xyz";
│
static std::string s_ignored; │ static std::string s_ignored;
static std::string s_ignored2; │ static std::string s_ignored2;
static std::string s_ignored_ascii; │ static std::string s_ignored_ascii;
static std::string s_ignored2_ascii; │ static std::string s_ignored2_ascii;
static std::string s_replaced; │ static std::string s_replaced;
static std::string s_replaced2; │ static std::string s_replaced2;
static std::string s_replaced_ascii; │ static std::string s_replaced_ascii;
static std::string s_replaced2_ascii; │ static std::string s_replaced2_ascii;
│
// dumping with ignore/replace must not throw in any case │ // dumping with ignore/replace must not throw in any case
s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore);
s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore);
s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace);
s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace);
│
if (success_expected) │ if (success_expected)
{ │ {
static std::string s_strict; │ static std::string s_strict;
// strict mode must not throw if success is expected │ // strict mode must not throw if success is expected
s_strict = j.dump(); │ s_strict = j.dump();
// all dumps should agree on the string │ // all dumps should agree on the string
CHECK(s_strict == s_ignored); │ CHECK(s_strict == s_ignored);
CHECK(s_strict == s_replaced); │ CHECK(s_strict == s_replaced);
} │ }
else │ else
{ │ {
// strict mode must throw if success is not expected │ // strict mode must throw if success is not expected
CHECK_THROWS_AS(j.dump(), json::type_error&); │ CHECK_THROWS_AS(j.dump(), json::type_error&);
// ignore and replace must create different dumps │ // ignore and replace must create different dumps
CHECK(s_ignored != s_replaced); │ CHECK(s_ignored != s_replaced);
│
// check that replace string contains a replacement character │ // check that replace string contains a replacement character
CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos); │ CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos);
} │ }
│
// check that prefix and suffix are preserved │ // check that prefix and suffix are preserved
CHECK(s_ignored2.substr(1, 3) == "abc"); │ CHECK(s_ignored2.substr(1, 3) == "abc");
CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz");
CHECK(s_ignored2_ascii.substr(1, 3) == "abc"); │ CHECK(s_ignored2_ascii.substr(1, 3) == "abc");
CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz");
CHECK(s_replaced2.substr(1, 3) == "abc"); │ CHECK(s_replaced2.substr(1, 3) == "abc");
CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz");
CHECK(s_replaced2_ascii.substr(1, 3) == "abc"); │ CHECK(s_replaced2_ascii.substr(1, 3) == "abc");
CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz");
} │ }
│
void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4) │ void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4)
│
// create and check a JSON string with up to four UTF-8 bytes │ // create and check a JSON string with up to four UTF-8 bytes
void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, │ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1,
{ │ {
if (++calls % 100000 == 0) │ if (++calls % 100000 == 0)
{ │ {
std::cout << calls << " of 5517507 UTF-8 strings checked" << std::endl; │ std::cout << calls << " of 5517507 UTF-8 strings checked" << std::endl;
} │ }
│
static std::string json_string; │ static std::string json_string;
json_string = "\""; │ json_string = "\"";
│
CAPTURE(byte1) │ CAPTURE(byte1)
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
CAPTURE(byte2) │ CAPTURE(byte2)
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
CAPTURE(byte3) │ CAPTURE(byte3)
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
CAPTURE(byte4) │ CAPTURE(byte4)
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
json_string += "\""; │ json_string += "\"";
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
json _; │ json _;
if (success_expected) │ if (success_expected)
{ │ {
CHECK_NOTHROW(_ = json::parse(json_string)); │ CHECK_NOTHROW(_ = json::parse(json_string));
} │ }
else │ else
{ │ {
CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&); │ CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&);
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode2.cpp:49 │ json/tests/src/unit-unicode5.cpp:49
│
extern size_t calls; │ extern size_t calls;
size_t calls = 0; │ size_t calls = 0;
│
void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4); │ void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4);
│
void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in │ void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in
{ │ {
static std::string json_string; │ static std::string json_string;
json_string.clear(); │ json_string.clear();
│
CAPTURE(byte1) │ CAPTURE(byte1)
CAPTURE(byte2) │ CAPTURE(byte2)
CAPTURE(byte3) │ CAPTURE(byte3)
CAPTURE(byte4) │ CAPTURE(byte4)
│
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
// store the string in a JSON value │ // store the string in a JSON value
static json j; │ static json j;
static json j2; │ static json j2;
j = json_string; │ j = json_string;
j2 = "abc" + json_string + "xyz"; │ j2 = "abc" + json_string + "xyz";
│
static std::string s_ignored; │ static std::string s_ignored;
static std::string s_ignored2; │ static std::string s_ignored2;
static std::string s_ignored_ascii; │ static std::string s_ignored_ascii;
static std::string s_ignored2_ascii; │ static std::string s_ignored2_ascii;
static std::string s_replaced; │ static std::string s_replaced;
static std::string s_replaced2; │ static std::string s_replaced2;
static std::string s_replaced_ascii; │ static std::string s_replaced_ascii;
static std::string s_replaced2_ascii; │ static std::string s_replaced2_ascii;
│
// dumping with ignore/replace must not throw in any case │ // dumping with ignore/replace must not throw in any case
s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore);
s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore);
s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace);
s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace);
│
if (success_expected) │ if (success_expected)
{ │ {
static std::string s_strict; │ static std::string s_strict;
// strict mode must not throw if success is expected │ // strict mode must not throw if success is expected
s_strict = j.dump(); │ s_strict = j.dump();
// all dumps should agree on the string │ // all dumps should agree on the string
CHECK(s_strict == s_ignored); │ CHECK(s_strict == s_ignored);
CHECK(s_strict == s_replaced); │ CHECK(s_strict == s_replaced);
} │ }
else │ else
{ │ {
// strict mode must throw if success is not expected │ // strict mode must throw if success is not expected
CHECK_THROWS_AS(j.dump(), json::type_error&); │ CHECK_THROWS_AS(j.dump(), json::type_error&);
// ignore and replace must create different dumps │ // ignore and replace must create different dumps
CHECK(s_ignored != s_replaced); │ CHECK(s_ignored != s_replaced);
│
// check that replace string contains a replacement character │ // check that replace string contains a replacement character
CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos); │ CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos);
} │ }
│
// check that prefix and suffix are preserved │ // check that prefix and suffix are preserved
CHECK(s_ignored2.substr(1, 3) == "abc"); │ CHECK(s_ignored2.substr(1, 3) == "abc");
CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz");
CHECK(s_ignored2_ascii.substr(1, 3) == "abc"); │ CHECK(s_ignored2_ascii.substr(1, 3) == "abc");
CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz");
CHECK(s_replaced2.substr(1, 3) == "abc"); │ CHECK(s_replaced2.substr(1, 3) == "abc");
CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz");
CHECK(s_replaced2_ascii.substr(1, 3) == "abc"); │ CHECK(s_replaced2_ascii.substr(1, 3) == "abc");
CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz");
} │ }
│
void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4) │ void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4)
│
// create and check a JSON string with up to four UTF-8 bytes │ // create and check a JSON string with up to four UTF-8 bytes
void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, │ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1,
{ │ {
if (++calls % 100000 == 0) │ if (++calls % 100000 == 0)
{ │ {
std::cout << calls << " of 1246225 UTF-8 strings checked" << std::endl; │ std::cout << calls << " of 1246225 UTF-8 strings checked" << std::endl;
} │ }
│
static std::string json_string; │ static std::string json_string;
json_string = "\""; │ json_string = "\"";
│
CAPTURE(byte1) │ CAPTURE(byte1)
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
CAPTURE(byte2) │ CAPTURE(byte2)
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
CAPTURE(byte3) │ CAPTURE(byte3)
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
CAPTURE(byte4) │ CAPTURE(byte4)
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
json_string += "\""; │ json_string += "\"";
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
json _; │ json _;
if (success_expected) │ if (success_expected)
{ │ {
CHECK_NOTHROW(_ = json::parse(json_string)); │ CHECK_NOTHROW(_ = json::parse(json_string));
} │ }
else │ else
{ │ {
CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&); │ CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&);
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode2.cpp:49 │ json/tests/src/unit-unicode4.cpp:49
│
extern size_t calls; │ extern size_t calls;
size_t calls = 0; │ size_t calls = 0;
│
void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4); │ void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4);
│
void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in │ void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in
{ │ {
static std::string json_string; │ static std::string json_string;
json_string.clear(); │ json_string.clear();
│
CAPTURE(byte1) │ CAPTURE(byte1)
CAPTURE(byte2) │ CAPTURE(byte2)
CAPTURE(byte3) │ CAPTURE(byte3)
CAPTURE(byte4) │ CAPTURE(byte4)
│
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
// store the string in a JSON value │ // store the string in a JSON value
static json j; │ static json j;
static json j2; │ static json j2;
j = json_string; │ j = json_string;
j2 = "abc" + json_string + "xyz"; │ j2 = "abc" + json_string + "xyz";
│
static std::string s_ignored; │ static std::string s_ignored;
static std::string s_ignored2; │ static std::string s_ignored2;
static std::string s_ignored_ascii; │ static std::string s_ignored_ascii;
static std::string s_ignored2_ascii; │ static std::string s_ignored2_ascii;
static std::string s_replaced; │ static std::string s_replaced;
static std::string s_replaced2; │ static std::string s_replaced2;
static std::string s_replaced_ascii; │ static std::string s_replaced_ascii;
static std::string s_replaced2_ascii; │ static std::string s_replaced2_ascii;
│
// dumping with ignore/replace must not throw in any case │ // dumping with ignore/replace must not throw in any case
s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore);
s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore);
s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace);
s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace);
│
if (success_expected) │ if (success_expected)
{ │ {
static std::string s_strict; │ static std::string s_strict;
// strict mode must not throw if success is expected │ // strict mode must not throw if success is expected
s_strict = j.dump(); │ s_strict = j.dump();
// all dumps should agree on the string │ // all dumps should agree on the string
CHECK(s_strict == s_ignored); │ CHECK(s_strict == s_ignored);
CHECK(s_strict == s_replaced); │ CHECK(s_strict == s_replaced);
} │ }
else │ else
{ │ {
// strict mode must throw if success is not expected │ // strict mode must throw if success is not expected
CHECK_THROWS_AS(j.dump(), json::type_error&); │ CHECK_THROWS_AS(j.dump(), json::type_error&);
// ignore and replace must create different dumps │ // ignore and replace must create different dumps
CHECK(s_ignored != s_replaced); │ CHECK(s_ignored != s_replaced);
│
// check that replace string contains a replacement character │ // check that replace string contains a replacement character
CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos); │ CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos);
} │ }
│
// check that prefix and suffix are preserved │ // check that prefix and suffix are preserved
CHECK(s_ignored2.substr(1, 3) == "abc"); │ CHECK(s_ignored2.substr(1, 3) == "abc");
CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz");
CHECK(s_ignored2_ascii.substr(1, 3) == "abc"); │ CHECK(s_ignored2_ascii.substr(1, 3) == "abc");
CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz");
CHECK(s_replaced2.substr(1, 3) == "abc"); │ CHECK(s_replaced2.substr(1, 3) == "abc");
CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz");
CHECK(s_replaced2_ascii.substr(1, 3) == "abc"); │ CHECK(s_replaced2_ascii.substr(1, 3) == "abc");
CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz");
} │ }
│
void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4) │ void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4)
│
// create and check a JSON string with up to four UTF-8 bytes │ // create and check a JSON string with up to four UTF-8 bytes
void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, │ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1,
{ │ {
if (++calls % 100000 == 0) │ if (++calls % 100000 == 0)
{ │ {
std::cout << calls << " of 5517507 UTF-8 strings checked" << std::endl; │ std::cout << calls << " of 5517507 UTF-8 strings checked" << std::endl;
} │ }
│
static std::string json_string; │ static std::string json_string;
json_string = "\""; │ json_string = "\"";
│
CAPTURE(byte1) │ CAPTURE(byte1)
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
CAPTURE(byte2) │ CAPTURE(byte2)
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
CAPTURE(byte3) │ CAPTURE(byte3)
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
CAPTURE(byte4) │ CAPTURE(byte4)
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
json_string += "\""; │ json_string += "\"";
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
json _; │ json _;
if (success_expected) │ if (success_expected)
{ │ {
CHECK_NOTHROW(_ = json::parse(json_string)); │ CHECK_NOTHROW(_ = json::parse(json_string));
} │ }
else │ else
{ │ {
CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&); │ CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&);
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode2.cpp:49 │ json/tests/src/unit-unicode3.cpp:49
│
extern size_t calls; │ extern size_t calls;
size_t calls = 0; │ size_t calls = 0;
│
void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4); │ void check_utf8dump(bool success_expected, int byte1, int byte2, int byte3, int byte4);
│
void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in │ void check_utf8dump(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, in
{ │ {
static std::string json_string; │ static std::string json_string;
json_string.clear(); │ json_string.clear();
│
CAPTURE(byte1) │ CAPTURE(byte1)
CAPTURE(byte2) │ CAPTURE(byte2)
CAPTURE(byte3) │ CAPTURE(byte3)
CAPTURE(byte4) │ CAPTURE(byte4)
│
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
// store the string in a JSON value │ // store the string in a JSON value
static json j; │ static json j;
static json j2; │ static json j2;
j = json_string; │ j = json_string;
j2 = "abc" + json_string + "xyz"; │ j2 = "abc" + json_string + "xyz";
│
static std::string s_ignored; │ static std::string s_ignored;
static std::string s_ignored2; │ static std::string s_ignored2;
static std::string s_ignored_ascii; │ static std::string s_ignored_ascii;
static std::string s_ignored2_ascii; │ static std::string s_ignored2_ascii;
static std::string s_replaced; │ static std::string s_replaced;
static std::string s_replaced2; │ static std::string s_replaced2;
static std::string s_replaced_ascii; │ static std::string s_replaced_ascii;
static std::string s_replaced2_ascii; │ static std::string s_replaced2_ascii;
│
// dumping with ignore/replace must not throw in any case │ // dumping with ignore/replace must not throw in any case
s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored = j.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore); │ s_ignored2 = j2.dump(-1, ' ', false, json::error_handler_t::ignore);
s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored_ascii = j.dump(-1, ' ', true, json::error_handler_t::ignore);
s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore); │ s_ignored2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::ignore);
s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced = j.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace); │ s_replaced2 = j2.dump(-1, ' ', false, json::error_handler_t::replace);
s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced_ascii = j.dump(-1, ' ', true, json::error_handler_t::replace);
s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace); │ s_replaced2_ascii = j2.dump(-1, ' ', true, json::error_handler_t::replace);
│
if (success_expected) │ if (success_expected)
{ │ {
static std::string s_strict; │ static std::string s_strict;
// strict mode must not throw if success is expected │ // strict mode must not throw if success is expected
s_strict = j.dump(); │ s_strict = j.dump();
// all dumps should agree on the string │ // all dumps should agree on the string
CHECK(s_strict == s_ignored); │ CHECK(s_strict == s_ignored);
CHECK(s_strict == s_replaced); │ CHECK(s_strict == s_replaced);
} │ }
else │ else
{ │ {
// strict mode must throw if success is not expected │ // strict mode must throw if success is not expected
CHECK_THROWS_AS(j.dump(), json::type_error&); │ CHECK_THROWS_AS(j.dump(), json::type_error&);
// ignore and replace must create different dumps │ // ignore and replace must create different dumps
CHECK(s_ignored != s_replaced); │ CHECK(s_ignored != s_replaced);
│
// check that replace string contains a replacement character │ // check that replace string contains a replacement character
CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos); │ CHECK(s_replaced.find("\xEF\xBF\xBD") != std::string::npos);
} │ }
│
// check that prefix and suffix are preserved │ // check that prefix and suffix are preserved
CHECK(s_ignored2.substr(1, 3) == "abc"); │ CHECK(s_ignored2.substr(1, 3) == "abc");
CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2.substr(s_ignored2.size() - 4, 3) == "xyz");
CHECK(s_ignored2_ascii.substr(1, 3) == "abc"); │ CHECK(s_ignored2_ascii.substr(1, 3) == "abc");
CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_ignored2_ascii.substr(s_ignored2_ascii.size() - 4, 3) == "xyz");
CHECK(s_replaced2.substr(1, 3) == "abc"); │ CHECK(s_replaced2.substr(1, 3) == "abc");
CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2.substr(s_replaced2.size() - 4, 3) == "xyz");
CHECK(s_replaced2_ascii.substr(1, 3) == "abc"); │ CHECK(s_replaced2_ascii.substr(1, 3) == "abc");
CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz"); │ CHECK(s_replaced2_ascii.substr(s_replaced2_ascii.size() - 4, 3) == "xyz");
} │ }
│
void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4) │ void check_utf8string(bool success_expected, int byte1, int byte2, int byte3, int byte4)
│
// create and check a JSON string with up to four UTF-8 bytes │ // create and check a JSON string with up to four UTF-8 bytes
void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1, │ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte3 = -1,
{ │ {
if (++calls % 100000 == 0) │ if (++calls % 100000 == 0)
{ │ {
std::cout << calls << " of 1641521 UTF-8 strings checked" << std::endl; │ std::cout << calls << " of 1641521 UTF-8 strings checked" << std::endl;
} │ }
│
static std::string json_string; │ static std::string json_string;
json_string = "\""; │ json_string = "\"";
│
CAPTURE(byte1) │ CAPTURE(byte1)
json_string += std::string(1, static_cast<char>(byte1)); │ json_string += std::string(1, static_cast<char>(byte1));
│
if (byte2 != -1) │ if (byte2 != -1)
{ │ {
CAPTURE(byte2) │ CAPTURE(byte2)
json_string += std::string(1, static_cast<char>(byte2)); │ json_string += std::string(1, static_cast<char>(byte2));
} │ }
│
if (byte3 != -1) │ if (byte3 != -1)
{ │ {
CAPTURE(byte3) │ CAPTURE(byte3)
json_string += std::string(1, static_cast<char>(byte3)); │ json_string += std::string(1, static_cast<char>(byte3));
} │ }
│
if (byte4 != -1) │ if (byte4 != -1)
{ │ {
CAPTURE(byte4) │ CAPTURE(byte4)
json_string += std::string(1, static_cast<char>(byte4)); │ json_string += std::string(1, static_cast<char>(byte4));
} │ }
│
json_string += "\""; │ json_string += "\"";
│
CAPTURE(json_string) │ CAPTURE(json_string)
│
json _; │ json _;
if (success_expected) │ if (success_expected)
{ │ {
CHECK_NOTHROW(_ = json::parse(json_string)); │ CHECK_NOTHROW(_ = json::parse(json_string));
} │ }
else │ else
{ │ {
CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&); │ CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&);
} │ }
} │ }
} │
next prev up json/tests/src/unit-modifiers.cpp:404 │ json/tests/src/unit-modifiers.cpp:176
│
SECTION("to array") │ SECTION("to array")
{ │ {
SECTION("json&&") │ SECTION("json&&")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j; │ json j;
j += 1; │ j.push_back(1);
j += 2; │ j.push_back(2);
CHECK(j.type() == json::value_t::array); │ CHECK(j.type() == json::value_t::array);
CHECK(j == json({1, 2})); │ CHECK(j == json({1, 2}));
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j = {1, 2, 3}; │ json j = {1, 2, 3};
j += "Hello"; │ j.push_back("Hello");
CHECK(j.type() == json::value_t::array); │ CHECK(j.type() == json::value_t::array);
CHECK(j == json({1, 2, 3, "Hello"})); │ CHECK(j == json({1, 2, 3, "Hello"}));
} │ }
│
SECTION("other type") │ SECTION("other type")
{ │ {
json j = 1; │ json j = 1;
CHECK_THROWS_WITH_AS(j += "Hello", "[json.exception.type_error.308] │ CHECK_THROWS_WITH_AS(j.push_back("Hello"), "[json.exception.type_err
} │ }
} │ }
│
SECTION("const json&") │ SECTION("const json&")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j; │ json j;
json k(1); │ json k(1);
j += k; │ j.push_back(k);
j += k; │ j.push_back(k);
CHECK(j.type() == json::value_t::array); │ CHECK(j.type() == json::value_t::array);
CHECK(j == json({1, 1})); │ CHECK(j == json({1, 1}));
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j = {1, 2, 3}; │ json j = {1, 2, 3};
json k("Hello"); │ json k("Hello");
j += k; │ j.push_back(k);
CHECK(j.type() == json::value_t::array); │ CHECK(j.type() == json::value_t::array);
CHECK(j == json({1, 2, 3, "Hello"})); │ CHECK(j == json({1, 2, 3, "Hello"}));
} │ }
│
SECTION("other type") │ SECTION("other type")
{ │ {
json j = 1; │ json j = 1;
json k("Hello"); │ json k("Hello");
CHECK_THROWS_WITH_AS(j += k, "[json.exception.type_error.308] cannot │ CHECK_THROWS_WITH_AS(j.push_back(k), "[json.exception.type_error.308
} │ }
} │ }
} │ }
│
SECTION("to object") │ SECTION("to object")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j; │ json j;
j += json::object_t::value_type({"one", 1}); │ j.push_back(json::object_t::value_type({"one", 1}));
j += json::object_t::value_type({"two", 2}); │ j.push_back(json::object_t::value_type({"two", 2}));
CHECK(j.type() == json::value_t::object); │ CHECK(j.type() == json::value_t::object);
CHECK(j.size() == 2); │ CHECK(j.size() == 2);
CHECK(j["one"] == json(1)); │ CHECK(j["one"] == json(1));
CHECK(j["two"] == json(2)); │ CHECK(j["two"] == json(2));
} │ }
│
SECTION("object") │ SECTION("object")
{ │ {
json j(json::value_t::object); │ json j(json::value_t::object);
j += json::object_t::value_type({"one", 1}); │ j.push_back(json::object_t::value_type({"one", 1}));
j += json::object_t::value_type({"two", 2}); │ j.push_back(json::object_t::value_type({"two", 2}));
CHECK(j.size() == 2); │ CHECK(j.size() == 2);
CHECK(j["one"] == json(1)); │ CHECK(j["one"] == json(1));
CHECK(j["two"] == json(2)); │ CHECK(j["two"] == json(2));
} │ }
│
SECTION("other type") │ SECTION("other type")
{ │ {
json j = 1; │ json j = 1;
json k("Hello"); │ json k("Hello");
CHECK_THROWS_WITH_AS(j += json::object_t::value_type({"one", 1}), "[json │ CHECK_THROWS_WITH_AS(j.push_back(json::object_t::value_type({"one", 1}))
} │ }
} │ }
│
SECTION("with initializer_list") │ SECTION("with initializer_list")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j; │ json j;
j += {"foo", "bar"}; │ j.push_back({"foo", "bar"});
CHECK(j == json::array({{"foo", "bar"}})); │ CHECK(j == json::array({{"foo", "bar"}}));
│
json k; │ json k;
k += {1, 2, 3}; │ k.push_back({1, 2, 3});
CHECK(k == json::array({{1, 2, 3}})); │ CHECK(k == json::array({{1, 2, 3}}));
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j = {1, 2, 3}; │ json j = {1, 2, 3};
j += {"foo", "bar"}; │ j.push_back({"foo", "bar"});
CHECK(j == json({1, 2, 3, {"foo", "bar"}})); │ CHECK(j == json({1, 2, 3, {"foo", "bar"}}));
│
json k = {1, 2, 3}; │ json k = {1, 2, 3};
k += {1, 2, 3}; │ k.push_back({1, 2, 3});
CHECK(k == json({1, 2, 3, {1, 2, 3}})); │ CHECK(k == json({1, 2, 3, {1, 2, 3}}));
} │ }
│
SECTION("object") │ SECTION("object")
{ │ {
json j = {{"key1", 1}}; │ json j = {{"key1", 1}};
j += {"key2", "bar"}; │ j.push_back({"key2", "bar"});
CHECK(j == json({{"key1", 1}, {"key2", "bar"}})); │ CHECK(j == json({{"key1", 1}, {"key2", "bar"}}));
│
json k = {{"key1", 1}}; │ // invalid values (no string/val pair)
CHECK_THROWS_WITH_AS((k += {1, 2, 3, 4}), "[json.exception.type_error.30 │ CHECK_THROWS_WITH_AS(j.push_back({1}), "[json.exception.type_error.308]
│ CHECK_THROWS_WITH_AS(j.push_back({1, 2}), "[json.exception.type_error.30
│ CHECK_THROWS_WITH_AS(j.push_back({1, 2, 3, 4}), "[json.exception.type_er
} │ }
} │ }
} │
next prev up json/tests/src/unit-element_access1.cpp:543 │ json/tests/src/unit-element_access1.cpp:718
│
SECTION("null") │ SECTION("null")
{ │ {
{ │ {
json j; │ json j;
CHECK_THROWS_WITH_AS(j.erase(j.begin()), "[json.exception.type_error │ CHECK_THROWS_WITH_AS(j.erase(j.begin(), j.end()), "[json.exception.t
} │ }
{ │ {
json j; │ json j;
CHECK_THROWS_WITH_AS(j.erase(j.begin()), │ CHECK_THROWS_WITH_AS(j.erase(j.cbegin(), j.cend()), "[json.exception
"[json.exception.type_error.307] cannot use era │
} │ }
} │ }
│
SECTION("string") │ SECTION("string")
{ │ {
{ │ {
json j = "foo"; │ json j = "foo";
json::iterator it = j.erase(j.begin()); │ json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ CHECK(it == j.end());
} │ }
{ │ {
json j = "bar"; │ json j = "bar";
json::const_iterator it = j.erase(j.cbegin()); │ json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ CHECK(it == j.end());
} │ }
} │ }
│
SECTION("number (boolean)") │ SECTION("number (boolean)")
{ │ {
{ │ {
json j = false; │ json j = false;
json::iterator it = j.erase(j.begin()); │ json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ CHECK(it == j.end());
} │ }
{ │ {
json j = true; │ json j = true;
json::const_iterator it = j.erase(j.cbegin()); │ json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ CHECK(it == j.end());
} │ }
} │ }
│
SECTION("number (integer)") │ SECTION("number (integer)")
{ │ {
{ │ {
json j = 17; │ json j = 17;
json::iterator it = j.erase(j.begin()); │ json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ CHECK(it == j.end());
} │ }
{ │ {
json j = 17; │ json j = 17;
json::const_iterator it = j.erase(j.cbegin()); │ json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ CHECK(it == j.end());
} │ }
} │ }
│
SECTION("number (unsigned)") │ SECTION("number (unsigned)")
{ │ {
{ │ {
json j = 17u; │ json j = 17u;
json::iterator it = j.erase(j.begin()); │ json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ CHECK(it == j.end());
} │ }
{ │ {
json j = 17u; │ json j = 17u;
json::const_iterator it = j.erase(j.cbegin()); │ json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ CHECK(it == j.end());
} │ }
} │ }
│
SECTION("number (floating point)") │ SECTION("number (floating point)")
{ │ {
{ │ {
json j = 23.42; │ json j = 23.42;
json::iterator it = j.erase(j.begin()); │ json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ CHECK(it == j.end());
} │ }
{ │ {
json j = 23.42; │ json j = 23.42;
json::const_iterator it = j.erase(j.cbegin()); │ json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ CHECK(it == j.end());
} │ }
} │ }
│
SECTION("binary") │ SECTION("binary")
{ │ {
{ │ {
json j = json::binary({1, 2, 3}); │ json j = json::binary({1, 2, 3});
json::iterator it = j.erase(j.begin()); │ json::iterator it = j.erase(j.begin(), j.end());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ 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()); │ json::const_iterator it = j.erase(j.cbegin(), j.cend());
CHECK(j.type() == json::value_t::null); │ CHECK(j.type() == json::value_t::null);
CHECK(it == j.end()); │ CHECK(it == j.end());
} │ }
} │ }
} │
next prev up json/tests/src/unit-deserialization.cpp:360 │ json/tests/src/unit-deserialization.cpp:455
│
SECTION("from std::vector") │ 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(v) == json(true)); │ CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
CHECK(json::accept(v)); │ CHECK(json::accept(std::begin(v), std::end(v)));
│
SaxEventLogger l; │ SaxEventLogger l;
CHECK(json::sax_parse(v, &l)); │ CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); │ 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") │ 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(v) == json(true)); │ CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
CHECK(json::accept(v)); │ CHECK(json::accept(std::begin(v), std::end(v)));
│
SaxEventLogger l; │ SaxEventLogger l;
CHECK(json::sax_parse(v, &l)); │ CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); │ 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") │ SECTION("from array")
{ │ {
uint8_t v[] = {'t', 'r', 'u', 'e'}; // NOLINT(cppcoreguidelines-avoid-c- │ uint8_t v[] = {'t', 'r', 'u', 'e'}; // NOLINT(cppcoreguidelines-avoid-c-
CHECK(json::parse(v) == json(true)); │ CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
CHECK(json::accept(v)); │ CHECK(json::accept(std::begin(v), std::end(v)));
│
SaxEventLogger l; │ SaxEventLogger l;
CHECK(json::sax_parse(v, &l)); │ CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); │ 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") │ SECTION("from std::string")
{ │ {
auto* v = new uint8_t[5]; // NOLINT(cppcoreguidelines-owning-memory) │ std::string v = {'t', 'r', 'u', 'e'};
v[0] = 't'; │ CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
v[1] = 'r'; │ CHECK(json::accept(std::begin(v), std::end(v)));
v[2] = 'u'; │
v[3] = 'e'; │
v[4] = '\0'; │
CHECK(json::parse(v) == json(true)); │
CHECK(json::accept(v)); │
│
SaxEventLogger l; │ SaxEventLogger l;
CHECK(json::sax_parse(v, &l)); │ CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); │ 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") │ SECTION("from std::initializer_list")
{ │ {
std::string v = {'t', 'r', 'u', 'e'}; │ std::initializer_list<uint8_t> v = {'t', 'r', 'u', 'e'};
CHECK(json::parse(v) == json(true)); │ CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
CHECK(json::accept(v)); │ CHECK(json::accept(std::begin(v), std::end(v)));
│
SaxEventLogger l; │ SaxEventLogger l;
CHECK(json::sax_parse(v, &l)); │ CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); │ 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") │ SECTION("from std::valarray")
{ │ {
std::initializer_list<uint8_t> v = {'t', 'r', 'u', 'e'}; │ std::valarray<uint8_t> v = {'t', 'r', 'u', 'e'};
CHECK(json::parse(v) == json(true)); │ CHECK(json::parse(std::begin(v), std::end(v)) == json(true));
CHECK(json::accept(v)); │ CHECK(json::accept(std::begin(v), std::end(v)));
│
SaxEventLogger l; │ SaxEventLogger l;
CHECK(json::sax_parse(v, &l)); │ CHECK(json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); │ 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") │ SECTION("with empty range")
{ │ {
std::vector<uint8_t> v; │ std::vector<uint8_t> v;
json _; │ json _;
CHECK_THROWS_AS(_ = json::parse(v), json::parse_error&); │ CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse
CHECK(!json::accept(v)); │ CHECK(!json::accept(std::begin(v), std::end(v)));
│
SaxEventLogger l; │ SaxEventLogger l;
CHECK(!json::sax_parse(v, &l)); │ CHECK(!json::sax_parse(std::begin(v), std::end(v), &l));
CHECK(l.events.size() == 1); │ 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)"}));
} │ }
} │
next prev up json/tests/src/unit-unicode2.cpp:387 │ json/tests/src/unit-unicode2.cpp:306
│
SECTION("well-formed") │ SECTION("well-formed")
{ │ {
for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0xA0; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(true, byte1, byte2, byte3); │ check_utf8string(true, byte1, byte2, byte3);
check_utf8dump(true, byte1, byte2, byte3); │ check_utf8dump(true, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing second byte") │ SECTION("ill-formed: missing second byte")
{ │ {
for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
check_utf8string(false, byte1); │ check_utf8string(false, byte1);
check_utf8dump(false, byte1); │ check_utf8dump(false, byte1);
} │ }
} │ }
│
SECTION("ill-formed: missing third byte") │ SECTION("ill-formed: missing third byte")
{ │ {
for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0xA0; byte2 <= 0xBF; ++byte2)
{ │ {
check_utf8string(false, byte1, byte2); │ check_utf8string(false, byte1, byte2);
check_utf8dump(false, byte1, byte2); │ check_utf8dump(false, byte1, byte2);
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong second byte") │ SECTION("ill-formed: wrong second byte")
{ │ {
for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) │ for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ │ {
// skip correct second byte │ // skip correct second byte
if (0x80 <= byte2 && byte2 <= 0xBF) │ if (0xA0 <= byte2 && byte2 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong third byte") │ SECTION("ill-formed: wrong third byte")
{ │ {
for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0xA0; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) │ for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ │ {
// skip correct third byte │ // skip correct third byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode2.cpp:468 │ json/tests/src/unit-unicode2.cpp:306
│
SECTION("well-formed") │ SECTION("well-formed")
{ │ {
for (int byte1 = 0xED; byte1 <= 0xED; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0x9F; ++byte2) │ for (int byte2 = 0xA0; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(true, byte1, byte2, byte3); │ check_utf8string(true, byte1, byte2, byte3);
check_utf8dump(true, byte1, byte2, byte3); │ check_utf8dump(true, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing second byte") │ SECTION("ill-formed: missing second byte")
{ │ {
for (int byte1 = 0xED; byte1 <= 0xED; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
check_utf8string(false, byte1); │ check_utf8string(false, byte1);
check_utf8dump(false, byte1); │ check_utf8dump(false, byte1);
} │ }
} │ }
│
SECTION("ill-formed: missing third byte") │ SECTION("ill-formed: missing third byte")
{ │ {
for (int byte1 = 0xED; byte1 <= 0xED; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0x9F; ++byte2) │ for (int byte2 = 0xA0; byte2 <= 0xBF; ++byte2)
{ │ {
check_utf8string(false, byte1, byte2); │ check_utf8string(false, byte1, byte2);
check_utf8dump(false, byte1, byte2); │ check_utf8dump(false, byte1, byte2);
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong second byte") │ SECTION("ill-formed: wrong second byte")
{ │ {
for (int byte1 = 0xED; byte1 <= 0xED; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) │ for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ │ {
// skip correct second byte │ // skip correct second byte
if (0x80 <= byte2 && byte2 <= 0x9F) │ if (0xA0 <= byte2 && byte2 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong third byte") │ SECTION("ill-formed: wrong third byte")
{ │ {
for (int byte1 = 0xED; byte1 <= 0xED; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0x9F; ++byte2) │ for (int byte2 = 0xA0; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) │ for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ │ {
// skip correct third byte │ // skip correct third byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode2.cpp:549 │ json/tests/src/unit-unicode2.cpp:306
│
SECTION("well-formed") │ SECTION("well-formed")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0xA0; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(true, byte1, byte2, byte3); │ check_utf8string(true, byte1, byte2, byte3);
check_utf8dump(true, byte1, byte2, byte3); │ check_utf8dump(true, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing second byte") │ SECTION("ill-formed: missing second byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
check_utf8string(false, byte1); │ check_utf8string(false, byte1);
check_utf8dump(false, byte1); │ check_utf8dump(false, byte1);
} │ }
} │ }
│
SECTION("ill-formed: missing third byte") │ SECTION("ill-formed: missing third byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0xA0; byte2 <= 0xBF; ++byte2)
{ │ {
check_utf8string(false, byte1, byte2); │ check_utf8string(false, byte1, byte2);
check_utf8dump(false, byte1, byte2); │ check_utf8dump(false, byte1, byte2);
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong second byte") │ SECTION("ill-formed: wrong second byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) │ for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ │ {
// skip correct second byte │ // skip correct second byte
if (0x80 <= byte2 && byte2 <= 0xBF) │ if (0xA0 <= byte2 && byte2 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong third byte") │ SECTION("ill-formed: wrong third byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xE0; byte1 <= 0xE0; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0xA0; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) │ for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ │ {
// skip correct third byte │ // skip correct third byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode2.cpp:468 │ json/tests/src/unit-unicode2.cpp:387
│
SECTION("well-formed") │ SECTION("well-formed")
{ │ {
for (int byte1 = 0xED; byte1 <= 0xED; ++byte1) │ for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0x9F; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(true, byte1, byte2, byte3); │ check_utf8string(true, byte1, byte2, byte3);
check_utf8dump(true, byte1, byte2, byte3); │ check_utf8dump(true, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing second byte") │ SECTION("ill-formed: missing second byte")
{ │ {
for (int byte1 = 0xED; byte1 <= 0xED; ++byte1) │ for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1)
{ │ {
check_utf8string(false, byte1); │ check_utf8string(false, byte1);
check_utf8dump(false, byte1); │ check_utf8dump(false, byte1);
} │ }
} │ }
│
SECTION("ill-formed: missing third byte") │ SECTION("ill-formed: missing third byte")
{ │ {
for (int byte1 = 0xED; byte1 <= 0xED; ++byte1) │ for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0x9F; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
check_utf8string(false, byte1, byte2); │ check_utf8string(false, byte1, byte2);
check_utf8dump(false, byte1, byte2); │ check_utf8dump(false, byte1, byte2);
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong second byte") │ SECTION("ill-formed: wrong second byte")
{ │ {
for (int byte1 = 0xED; byte1 <= 0xED; ++byte1) │ for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1)
{ │ {
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) │ for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ │ {
// skip correct second byte │ // skip correct second byte
if (0x80 <= byte2 && byte2 <= 0x9F) │ if (0x80 <= byte2 && byte2 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong third byte") │ SECTION("ill-formed: wrong third byte")
{ │ {
for (int byte1 = 0xED; byte1 <= 0xED; ++byte1) │ for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0x9F; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) │ for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ │ {
// skip correct third byte │ // skip correct third byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode2.cpp:549 │ json/tests/src/unit-unicode2.cpp:387
│
SECTION("well-formed") │ SECTION("well-formed")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(true, byte1, byte2, byte3); │ check_utf8string(true, byte1, byte2, byte3);
check_utf8dump(true, byte1, byte2, byte3); │ check_utf8dump(true, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing second byte") │ SECTION("ill-formed: missing second byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1)
{ │ {
check_utf8string(false, byte1); │ check_utf8string(false, byte1);
check_utf8dump(false, byte1); │ check_utf8dump(false, byte1);
} │ }
} │ }
│
SECTION("ill-formed: missing third byte") │ SECTION("ill-formed: missing third byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
check_utf8string(false, byte1, byte2); │ check_utf8string(false, byte1, byte2);
check_utf8dump(false, byte1, byte2); │ check_utf8dump(false, byte1, byte2);
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong second byte") │ SECTION("ill-formed: wrong second byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1)
{ │ {
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) │ for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ │ {
// skip correct second byte │ // skip correct second byte
if (0x80 <= byte2 && byte2 <= 0xBF) │ if (0x80 <= byte2 && byte2 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong third byte") │ SECTION("ill-formed: wrong third byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xE1; byte1 <= 0xEC; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2)
{ │ {
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) │ for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ │ {
// skip correct third byte │ // skip correct third byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
} │
next prev up json/tests/src/unit-unicode2.cpp:549 │ json/tests/src/unit-unicode2.cpp:468
│
SECTION("well-formed") │ SECTION("well-formed")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xED; byte1 <= 0xED; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0x9F; ++byte2)
{ │ {
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(true, byte1, byte2, byte3); │ check_utf8string(true, byte1, byte2, byte3);
check_utf8dump(true, byte1, byte2, byte3); │ check_utf8dump(true, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: missing second byte") │ SECTION("ill-formed: missing second byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xED; byte1 <= 0xED; ++byte1)
{ │ {
check_utf8string(false, byte1); │ check_utf8string(false, byte1);
check_utf8dump(false, byte1); │ check_utf8dump(false, byte1);
} │ }
} │ }
│
SECTION("ill-formed: missing third byte") │ SECTION("ill-formed: missing third byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xED; byte1 <= 0xED; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0x9F; ++byte2)
{ │ {
check_utf8string(false, byte1, byte2); │ check_utf8string(false, byte1, byte2);
check_utf8dump(false, byte1, byte2); │ check_utf8dump(false, byte1, byte2);
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong second byte") │ SECTION("ill-formed: wrong second byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xED; byte1 <= 0xED; ++byte1)
{ │ {
for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2) │ for (int byte2 = 0x00; byte2 <= 0xFF; ++byte2)
{ │ {
// skip correct second byte │ // skip correct second byte
if (0x80 <= byte2 && byte2 <= 0xBF) │ if (0x80 <= byte2 && byte2 <= 0x9F)
{ │ {
continue; │ continue;
} │ }
│
for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3) │ for (int byte3 = 0x80; byte3 <= 0xBF; ++byte3)
{ │ {
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
│
SECTION("ill-formed: wrong third byte") │ SECTION("ill-formed: wrong third byte")
{ │ {
for (int byte1 = 0xEE; byte1 <= 0xEF; ++byte1) │ for (int byte1 = 0xED; byte1 <= 0xED; ++byte1)
{ │ {
for (int byte2 = 0x80; byte2 <= 0xBF; ++byte2) │ for (int byte2 = 0x80; byte2 <= 0x9F; ++byte2)
{ │ {
for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3) │ for (int byte3 = 0x00; byte3 <= 0xFF; ++byte3)
{ │ {
// skip correct third byte │ // skip correct third byte
if (0x80 <= byte3 && byte3 <= 0xBF) │ if (0x80 <= byte3 && byte3 <= 0xBF)
{ │ {
continue; │ continue;
} │ }
│
check_utf8string(false, byte1, byte2, byte3); │ check_utf8string(false, byte1, byte2, byte3);
check_utf8dump(false, byte1, byte2, byte3); │ check_utf8dump(false, byte1, byte2, byte3);
} │ }
} │ }
} │ }
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:2342 │ json/tests/src/unit-bjdata.cpp:2263
│
// create vector with two elements of the same type │ // create vector with two elements of the same type
std::vector<uint8_t> v_0 = {'[', '$', 'i', '#', '[', ']'}; │ std::vector<uint8_t> v_0 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_i = {'[', '$', 'i', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_1 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_U = {'[', '$', 'U', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_i = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_I = {'[', '$', 'I', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_U = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_u = {'[', '$', 'u', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_I = {'[', '$', 'I', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_l = {'[', '$', 'l', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_u = {'[', '$', 'u', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_m = {'[', '$', 'm', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_l = {'[', '$', 'l', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_L = {'[', '$', 'L', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_m = {'[', '$', 'm', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_M = {'[', '$', 'M', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_L = {'[', '$', 'L', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_D = {'[', '$', 'D', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_M = {'[', '$', 'M', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_S = {'[', '#', '[', 'i', 1, 'i', 2, ']', 'S', 'i' │ std::vector<uint8_t> v_D = {'[', '$', 'D', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_C = {'[', '$', 'C', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_S = {'[', '#', '[', '$', 'i', '#', 'i', 2, 1, 2,
│ std::vector<uint8_t> v_C = {'[', '$', 'C', '#', '[', '$', 'i', '#', 'i',
│
// check if vector is parsed correctly │ // check if vector is parsed correctly
CHECK(json::from_bjdata(v_0) == json::array()); │ 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_i) == json({127, 127}));
CHECK(json::from_bjdata(v_U) == json({255, 255})); │ CHECK(json::from_bjdata(v_U) == json({255, 255}));
CHECK(json::from_bjdata(v_I) == json({32767, 32767})); │ CHECK(json::from_bjdata(v_I) == json({32767, 32767}));
CHECK(json::from_bjdata(v_u) == json({42767, 42767})); │ CHECK(json::from_bjdata(v_u) == json({42767, 42767}));
CHECK(json::from_bjdata(v_l) == json({2147483647, 2147483647})); │ CHECK(json::from_bjdata(v_l) == json({2147483647, 2147483647}));
CHECK(json::from_bjdata(v_m) == json({3147483647, 3147483647})); │ CHECK(json::from_bjdata(v_m) == json({3147483647, 3147483647}));
CHECK(json::from_bjdata(v_L) == json({9223372036854775807, 9223372036854 │ CHECK(json::from_bjdata(v_L) == json({9223372036854775807, 9223372036854
CHECK(json::from_bjdata(v_M) == json({10223372036854775807ull, 102233720 │ CHECK(json::from_bjdata(v_M) == json({10223372036854775807ull, 102233720
CHECK(json::from_bjdata(v_D) == json({3.1415926, 3.1415926})); │ 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_S) == json({"a", "a"}));
CHECK(json::from_bjdata(v_C) == json({"a", "a"})); │ CHECK(json::from_bjdata(v_C) == json({"a", "a"}));
} │
next prev up json/tests/src/unit-bjdata.cpp:2373 │ json/tests/src/unit-bjdata.cpp:2263
│
// create vector with two elements of the same type │ // create vector with two elements of the same type
std::vector<uint8_t> v_i = {'[', '$', 'i', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_0 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_U = {'[', '$', 'U', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_1 = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_I = {'[', '$', 'I', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_i = {'[', '$', 'i', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_u = {'[', '$', 'u', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_U = {'[', '$', 'U', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_l = {'[', '$', 'l', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_I = {'[', '$', 'I', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_m = {'[', '$', 'm', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_u = {'[', '$', 'u', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_L = {'[', '$', 'L', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_l = {'[', '$', 'l', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_M = {'[', '$', 'M', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_m = {'[', '$', 'm', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_D = {'[', '$', 'D', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_L = {'[', '$', 'L', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_S = {'[', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, │ std::vector<uint8_t> v_M = {'[', '$', 'M', '#', '[', '$', 'i', '#', 'i',
std::vector<uint8_t> v_C = {'[', '$', 'C', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_D = {'[', '$', 'D', '#', '[', '$', 'i', '#', 'i',
│ std::vector<uint8_t> v_S = {'[', '#', '[', '$', 'i', '#', 'i', 2, 1, 2,
│ std::vector<uint8_t> v_C = {'[', '$', 'C', '#', '[', '$', 'i', '#', 'i',
│
// check if vector is parsed correctly │ // 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_i) == json({127, 127}));
CHECK(json::from_bjdata(v_U) == json({255, 255})); │ CHECK(json::from_bjdata(v_U) == json({255, 255}));
CHECK(json::from_bjdata(v_I) == json({32767, 32767})); │ CHECK(json::from_bjdata(v_I) == json({32767, 32767}));
CHECK(json::from_bjdata(v_u) == json({42767, 42767})); │ CHECK(json::from_bjdata(v_u) == json({42767, 42767}));
CHECK(json::from_bjdata(v_l) == json({2147483647, 2147483647})); │ CHECK(json::from_bjdata(v_l) == json({2147483647, 2147483647}));
CHECK(json::from_bjdata(v_m) == json({3147483647, 3147483647})); │ CHECK(json::from_bjdata(v_m) == json({3147483647, 3147483647}));
CHECK(json::from_bjdata(v_L) == json({9223372036854775807, 9223372036854 │ CHECK(json::from_bjdata(v_L) == json({9223372036854775807, 9223372036854
CHECK(json::from_bjdata(v_M) == json({10223372036854775807ull, 102233720 │ CHECK(json::from_bjdata(v_M) == json({10223372036854775807ull, 102233720
CHECK(json::from_bjdata(v_D) == json({3.1415926, 3.1415926})); │ 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_S) == json({"a", "a"}));
CHECK(json::from_bjdata(v_C) == json({"a", "a"})); │ CHECK(json::from_bjdata(v_C) == json({"a", "a"}));
} │
next prev up json/tests/src/unit-bjdata.cpp:2373 │ json/tests/src/unit-bjdata.cpp:2342
│
// create vector with two elements of the same type │ // create vector with two elements of the same type
std::vector<uint8_t> v_i = {'[', '$', 'i', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_0 = {'[', '$', 'i', '#', '[', ']'};
std::vector<uint8_t> v_U = {'[', '$', 'U', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_i = {'[', '$', 'i', '#', '[', 'i', 1, 'i', 2, ']'
std::vector<uint8_t> v_I = {'[', '$', 'I', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_U = {'[', '$', 'U', '#', '[', 'i', 1, 'i', 2, ']'
std::vector<uint8_t> v_u = {'[', '$', 'u', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_I = {'[', '$', 'I', '#', '[', 'i', 1, 'i', 2, ']'
std::vector<uint8_t> v_l = {'[', '$', 'l', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_u = {'[', '$', 'u', '#', '[', 'i', 1, 'i', 2, ']'
std::vector<uint8_t> v_m = {'[', '$', 'm', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_l = {'[', '$', 'l', '#', '[', 'i', 1, 'i', 2, ']'
std::vector<uint8_t> v_L = {'[', '$', 'L', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_m = {'[', '$', 'm', '#', '[', 'i', 1, 'i', 2, ']'
std::vector<uint8_t> v_M = {'[', '$', 'M', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_L = {'[', '$', 'L', '#', '[', 'i', 1, 'i', 2, ']'
std::vector<uint8_t> v_D = {'[', '$', 'D', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_M = {'[', '$', 'M', '#', '[', 'i', 1, 'i', 2, ']'
std::vector<uint8_t> v_S = {'[', '#', '[', '#', 'i', 2, 'i', 1, 'i', 2, │ std::vector<uint8_t> v_D = {'[', '$', 'D', '#', '[', 'i', 1, 'i', 2, ']'
std::vector<uint8_t> v_C = {'[', '$', 'C', '#', '[', '#', 'i', 2, 'i', 1 │ std::vector<uint8_t> v_S = {'[', '#', '[', 'i', 1, 'i', 2, ']', 'S', 'i'
│ std::vector<uint8_t> v_C = {'[', '$', 'C', '#', '[', 'i', 1, 'i', 2, ']'
│
// check if vector is parsed correctly │ // check if vector is parsed correctly
│ CHECK(json::from_bjdata(v_0) == json::array());
CHECK(json::from_bjdata(v_i) == 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_U) == json({255, 255}));
CHECK(json::from_bjdata(v_I) == json({32767, 32767})); │ CHECK(json::from_bjdata(v_I) == json({32767, 32767}));
CHECK(json::from_bjdata(v_u) == json({42767, 42767})); │ CHECK(json::from_bjdata(v_u) == json({42767, 42767}));
CHECK(json::from_bjdata(v_l) == json({2147483647, 2147483647})); │ CHECK(json::from_bjdata(v_l) == json({2147483647, 2147483647}));
CHECK(json::from_bjdata(v_m) == json({3147483647, 3147483647})); │ CHECK(json::from_bjdata(v_m) == json({3147483647, 3147483647}));
CHECK(json::from_bjdata(v_L) == json({9223372036854775807, 9223372036854 │ CHECK(json::from_bjdata(v_L) == json({9223372036854775807, 9223372036854
CHECK(json::from_bjdata(v_M) == json({10223372036854775807ull, 102233720 │ CHECK(json::from_bjdata(v_M) == json({10223372036854775807ull, 102233720
CHECK(json::from_bjdata(v_D) == json({3.1415926, 3.1415926})); │ 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_S) == json({"a", "a"}));
CHECK(json::from_bjdata(v_C) == json({"a", "a"})); │ CHECK(json::from_bjdata(v_C) == json({"a", "a"}));
} │
next prev up json/tests/src/unit-msgpack.cpp:527 │ json/tests/src/unit-msgpack.cpp:349
│
std::vector<int64_t> numbers; │ for (uint64_t i :
numbers.push_back(INT64_MIN); │ {
numbers.push_back(-2147483649LL); │ 4294967296LU, 9223372036854775807LU
for (auto i : numbers) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xd3); │ expected.push_back(0xcf);
expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 9); │ CHECK(result.size() == 9);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xd3); │ CHECK(result[0] == 0xcf);
int64_t restored = (static_cast<int64_t>(result[1]) << 070) + │ uint64_t restored = (static_cast<uint64_t>(result[1]) << 070) +
(static_cast<int64_t>(result[2]) << 060) + │ (static_cast<uint64_t>(result[2]) << 060) +
(static_cast<int64_t>(result[3]) << 050) + │ (static_cast<uint64_t>(result[3]) << 050) +
(static_cast<int64_t>(result[4]) << 040) + │ (static_cast<uint64_t>(result[4]) << 040) +
(static_cast<int64_t>(result[5]) << 030) + │ (static_cast<uint64_t>(result[5]) << 030) +
(static_cast<int64_t>(result[6]) << 020) + │ (static_cast<uint64_t>(result[6]) << 020) +
(static_cast<int64_t>(result[7]) << 010) + │ (static_cast<uint64_t>(result[7]) << 010) +
static_cast<int64_t>(result[8]); │ static_cast<uint64_t>(result[8]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:719 │ json/tests/src/unit-msgpack.cpp:349
│
for (uint64_t i : │ for (uint64_t i :
{ │ {
4294967296LU, 18446744073709551615LU │ 4294967296LU, 9223372036854775807LU
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xcf); │ expected.push_back(0xcf);
expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 9); │ CHECK(result.size() == 9);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xcf); │ CHECK(result[0] == 0xcf);
uint64_t restored = (static_cast<uint64_t>(result[1]) << 070) + │ uint64_t restored = (static_cast<uint64_t>(result[1]) << 070) +
(static_cast<uint64_t>(result[2]) << 060) + │ (static_cast<uint64_t>(result[2]) << 060) +
(static_cast<uint64_t>(result[3]) << 050) + │ (static_cast<uint64_t>(result[3]) << 050) +
(static_cast<uint64_t>(result[4]) << 040) + │ (static_cast<uint64_t>(result[4]) << 040) +
(static_cast<uint64_t>(result[5]) << 030) + │ (static_cast<uint64_t>(result[5]) << 030) +
(static_cast<uint64_t>(result[6]) << 020) + │ (static_cast<uint64_t>(result[6]) << 020) +
(static_cast<uint64_t>(result[7]) << 010) + │ (static_cast<uint64_t>(result[7]) << 010) +
static_cast<uint64_t>(result[8]); │ static_cast<uint64_t>(result[8]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:719 │ json/tests/src/unit-msgpack.cpp:527
│
for (uint64_t i : │ std::vector<int64_t> numbers;
{ │ numbers.push_back(INT64_MIN);
4294967296LU, 18446744073709551615LU │ numbers.push_back(-2147483649LL);
}) │ for (auto i : numbers)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xcf); │ expected.push_back(0xd3);
expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 9); │ CHECK(result.size() == 9);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xcf); │ CHECK(result[0] == 0xd3);
uint64_t restored = (static_cast<uint64_t>(result[1]) << 070) + │ int64_t restored = (static_cast<int64_t>(result[1]) << 070) +
(static_cast<uint64_t>(result[2]) << 060) + │ (static_cast<int64_t>(result[2]) << 060) +
(static_cast<uint64_t>(result[3]) << 050) + │ (static_cast<int64_t>(result[3]) << 050) +
(static_cast<uint64_t>(result[4]) << 040) + │ (static_cast<int64_t>(result[4]) << 040) +
(static_cast<uint64_t>(result[5]) << 030) + │ (static_cast<int64_t>(result[5]) << 030) +
(static_cast<uint64_t>(result[6]) << 020) + │ (static_cast<int64_t>(result[6]) << 020) +
(static_cast<uint64_t>(result[7]) << 010) + │ (static_cast<int64_t>(result[7]) << 010) +
static_cast<uint64_t>(result[8]); │ static_cast<int64_t>(result[8]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:787 │ json/tests/src/unit-cbor.cpp:561
│
for (uint64_t i : │ for (uint64_t i :
{ │ {
4294967296ul, 4611686018427387903ul │ 4294967296ul, 4611686018427387903ul
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0x1b); │ expected.push_back(0x1b);
expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 9); │ CHECK(result.size() == 9);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0x1b); │ CHECK(result[0] == 0x1b);
uint64_t restored = (static_cast<uint64_t>(result[1]) << 070) + │ uint64_t restored = (static_cast<uint64_t>(result[1]) << 070) +
(static_cast<uint64_t>(result[2]) << 060) + │ (static_cast<uint64_t>(result[2]) << 060) +
(static_cast<uint64_t>(result[3]) << 050) + │ (static_cast<uint64_t>(result[3]) << 050) +
(static_cast<uint64_t>(result[4]) << 040) + │ (static_cast<uint64_t>(result[4]) << 040) +
(static_cast<uint64_t>(result[5]) << 030) + │ (static_cast<uint64_t>(result[5]) << 030) +
(static_cast<uint64_t>(result[6]) << 020) + │ (static_cast<uint64_t>(result[6]) << 020) +
(static_cast<uint64_t>(result[7]) << 010) + │ (static_cast<uint64_t>(result[7]) << 010) +
static_cast<uint64_t>(result[8]); │ static_cast<uint64_t>(result[8]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:641 │ json/tests/src/unit-bjdata.cpp:592
│
std::vector<uint64_t> v = {9223372036854775808ull, 18446744073709551 │ std::vector<uint64_t> v = {4294967296LU, 9223372036854775807LU};
for (uint64_t i : v) │ for (uint64_t i : v)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('M'); │ expected.push_back('L');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 9); │ CHECK(result.size() == 9);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'M'); │ CHECK(result[0] == 'L');
uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) + │ uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) +
(static_cast<uint64_t>(result[7]) << 060) + │ (static_cast<uint64_t>(result[7]) << 060) +
(static_cast<uint64_t>(result[6]) << 050) + │ (static_cast<uint64_t>(result[6]) << 050) +
(static_cast<uint64_t>(result[5]) << 040) + │ (static_cast<uint64_t>(result[5]) << 040) +
(static_cast<uint64_t>(result[4]) << 030) + │ (static_cast<uint64_t>(result[4]) << 030) +
(static_cast<uint64_t>(result[3]) << 020) + │ (static_cast<uint64_t>(result[3]) << 020) +
(static_cast<uint64_t>(result[2]) << 010) + │ (static_cast<uint64_t>(result[2]) << 010) +
static_cast<uint64_t>(result[1]); │ static_cast<uint64_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:960 │ json/tests/src/unit-bjdata.cpp:592
│
std::vector<uint64_t> v = {9223372036854775808ull, 18446744073709551 │ std::vector<uint64_t> v = {4294967296LU, 9223372036854775807LU};
for (uint64_t i : v) │ for (uint64_t i : v)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('M'); │ expected.push_back('L');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 9); │ CHECK(result.size() == 9);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'M'); │ CHECK(result[0] == 'L');
uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) + │ uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) +
(static_cast<uint64_t>(result[7]) << 060) + │ (static_cast<uint64_t>(result[7]) << 060) +
(static_cast<uint64_t>(result[6]) << 050) + │ (static_cast<uint64_t>(result[6]) << 050) +
(static_cast<uint64_t>(result[5]) << 040) + │ (static_cast<uint64_t>(result[5]) << 040) +
(static_cast<uint64_t>(result[4]) << 030) + │ (static_cast<uint64_t>(result[4]) << 030) +
(static_cast<uint64_t>(result[3]) << 020) + │ (static_cast<uint64_t>(result[3]) << 020) +
(static_cast<uint64_t>(result[2]) << 010) + │ (static_cast<uint64_t>(result[2]) << 010) +
static_cast<uint64_t>(result[1]); │ static_cast<uint64_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:960 │ json/tests/src/unit-bjdata.cpp:641
│
std::vector<uint64_t> v = {9223372036854775808ull, 18446744073709551 │ std::vector<uint64_t> v = {9223372036854775808ull, 18446744073709551
for (uint64_t i : v) │ for (uint64_t i : v)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('M'); │ expected.push_back('M');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 9); │ CHECK(result.size() == 9);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'M'); │ CHECK(result[0] == 'M');
uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) + │ uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) +
(static_cast<uint64_t>(result[7]) << 060) + │ (static_cast<uint64_t>(result[7]) << 060) +
(static_cast<uint64_t>(result[6]) << 050) + │ (static_cast<uint64_t>(result[6]) << 050) +
(static_cast<uint64_t>(result[5]) << 040) + │ (static_cast<uint64_t>(result[5]) << 040) +
(static_cast<uint64_t>(result[4]) << 030) + │ (static_cast<uint64_t>(result[4]) << 030) +
(static_cast<uint64_t>(result[3]) << 020) + │ (static_cast<uint64_t>(result[3]) << 020) +
(static_cast<uint64_t>(result[2]) << 010) + │ (static_cast<uint64_t>(result[2]) << 010) +
static_cast<uint64_t>(result[1]); │ static_cast<uint64_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:705 │ json/tests/src/unit-ubjson.cpp:511
│
std::vector<uint64_t> v = {2147483648ul, 9223372036854775807ul}; │ std::vector<uint64_t> v = {2147483648ul, 9223372036854775807ul};
for (uint64_t i : v) │ for (uint64_t i : v)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('L'); │ expected.push_back('L');
expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 9); │ CHECK(result.size() == 9);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'L'); │ CHECK(result[0] == 'L');
uint64_t restored = (static_cast<uint64_t>(result[1]) << 070) + │ uint64_t restored = (static_cast<uint64_t>(result[1]) << 070) +
(static_cast<uint64_t>(result[2]) << 060) + │ (static_cast<uint64_t>(result[2]) << 060) +
(static_cast<uint64_t>(result[3]) << 050) + │ (static_cast<uint64_t>(result[3]) << 050) +
(static_cast<uint64_t>(result[4]) << 040) + │ (static_cast<uint64_t>(result[4]) << 040) +
(static_cast<uint64_t>(result[5]) << 030) + │ (static_cast<uint64_t>(result[5]) << 030) +
(static_cast<uint64_t>(result[6]) << 020) + │ (static_cast<uint64_t>(result[6]) << 020) +
(static_cast<uint64_t>(result[7]) << 010) + │ (static_cast<uint64_t>(result[7]) << 010) +
static_cast<uint64_t>(result[8]); │ static_cast<uint64_t>(result[8]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:912 │ json/tests/src/unit-bjdata.cpp:592
│
std::vector<uint64_t> v = {4294967296ul, 9223372036854775807ul}; │ std::vector<uint64_t> v = {4294967296LU, 9223372036854775807LU};
for (uint64_t i : v) │ for (uint64_t i : v)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('L'); │ expected.push_back('L');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 9); │ CHECK(result.size() == 9);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'L'); │ CHECK(result[0] == 'L');
uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) + │ uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) +
(static_cast<uint64_t>(result[7]) << 060) + │ (static_cast<uint64_t>(result[7]) << 060) +
(static_cast<uint64_t>(result[6]) << 050) + │ (static_cast<uint64_t>(result[6]) << 050) +
(static_cast<uint64_t>(result[5]) << 040) + │ (static_cast<uint64_t>(result[5]) << 040) +
(static_cast<uint64_t>(result[4]) << 030) + │ (static_cast<uint64_t>(result[4]) << 030) +
(static_cast<uint64_t>(result[3]) << 020) + │ (static_cast<uint64_t>(result[3]) << 020) +
(static_cast<uint64_t>(result[2]) << 010) + │ (static_cast<uint64_t>(result[2]) << 010) +
static_cast<uint64_t>(result[1]); │ static_cast<uint64_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:912 │ json/tests/src/unit-bjdata.cpp:641
│
std::vector<uint64_t> v = {4294967296ul, 9223372036854775807ul}; │ std::vector<uint64_t> v = {9223372036854775808ull, 18446744073709551
for (uint64_t i : v) │ for (uint64_t i : v)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('L'); │ expected.push_back('M');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 9); │ CHECK(result.size() == 9);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'L'); │ CHECK(result[0] == 'M');
uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) + │ uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) +
(static_cast<uint64_t>(result[7]) << 060) + │ (static_cast<uint64_t>(result[7]) << 060) +
(static_cast<uint64_t>(result[6]) << 050) + │ (static_cast<uint64_t>(result[6]) << 050) +
(static_cast<uint64_t>(result[5]) << 040) + │ (static_cast<uint64_t>(result[5]) << 040) +
(static_cast<uint64_t>(result[4]) << 030) + │ (static_cast<uint64_t>(result[4]) << 030) +
(static_cast<uint64_t>(result[3]) << 020) + │ (static_cast<uint64_t>(result[3]) << 020) +
(static_cast<uint64_t>(result[2]) << 010) + │ (static_cast<uint64_t>(result[2]) << 010) +
static_cast<uint64_t>(result[1]); │ static_cast<uint64_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:912 │ json/tests/src/unit-bjdata.cpp:960
│
std::vector<uint64_t> v = {4294967296ul, 9223372036854775807ul}; │ std::vector<uint64_t> v = {9223372036854775808ull, 18446744073709551
for (uint64_t i : v) │ for (uint64_t i : v)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('L'); │ expected.push_back('M');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 010) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 020) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 030) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 040) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 050) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 060) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 070) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 9); │ CHECK(result.size() == 9);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'L'); │ CHECK(result[0] == 'M');
uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) + │ uint64_t restored = (static_cast<uint64_t>(result[8]) << 070) +
(static_cast<uint64_t>(result[7]) << 060) + │ (static_cast<uint64_t>(result[7]) << 060) +
(static_cast<uint64_t>(result[6]) << 050) + │ (static_cast<uint64_t>(result[6]) << 050) +
(static_cast<uint64_t>(result[5]) << 040) + │ (static_cast<uint64_t>(result[5]) << 040) +
(static_cast<uint64_t>(result[4]) << 030) + │ (static_cast<uint64_t>(result[4]) << 030) +
(static_cast<uint64_t>(result[3]) << 020) + │ (static_cast<uint64_t>(result[3]) << 020) +
(static_cast<uint64_t>(result[2]) << 010) + │ (static_cast<uint64_t>(result[2]) << 010) +
static_cast<uint64_t>(result[1]); │ static_cast<uint64_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-element_access1.cpp:376 │ json/tests/src/unit-element_access2.cpp:918
│
{ │ {
json jarray = {1, 1u, true, nullptr, "string", 42.23, json::obje │ json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false},
json jarray2 = {"foo", "bar"}; │ json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}};
│ CHECK_THROWS_WITH_AS(jobject.erase(jobject2.begin()),
CHECK_THROWS_WITH_AS(jarray.erase(jarray2.begin()), │
"[json.exception.invalid_iterator.202] iter │ "[json.exception.invalid_iterator.202] iter
CHECK_THROWS_WITH_AS(jarray.erase(jarray.begin(), jarray2.end()) │ CHECK_THROWS_WITH_AS(jobject.erase(jobject.begin(), jobject2.end
"[json.exception.invalid_iterator.203] iter │ "[json.exception.invalid_iterator.203] iter
CHECK_THROWS_WITH_AS(jarray.erase(jarray2.begin(), jarray.end()) │ CHECK_THROWS_WITH_AS(jobject.erase(jobject2.begin(), jobject.end
"[json.exception.invalid_iterator.203] iter │ "[json.exception.invalid_iterator.203] iter
CHECK_THROWS_WITH_AS(jarray.erase(jarray2.begin(), jarray2.end() │ CHECK_THROWS_WITH_AS(jobject.erase(jobject2.begin(), jobject2.en
"[json.exception.invalid_iterator.203] iter │ "[json.exception.invalid_iterator.203] iter
} │ }
{ │ {
json jarray = {1, 1u, true, nullptr, "string", 42.23, json::obje │ json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false},
json jarray2 = {"foo", "bar"}; │ json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}};
│ CHECK_THROWS_WITH_AS(jobject.erase(jobject2.cbegin()),
CHECK_THROWS_WITH_AS(jarray.erase(jarray2.cbegin()), │
"[json.exception.invalid_iterator.202] iter │ "[json.exception.invalid_iterator.202] iter
CHECK_THROWS_WITH_AS(jarray.erase(jarray.cbegin(), jarray2.cend( │ CHECK_THROWS_WITH_AS(jobject.erase(jobject.cbegin(), jobject2.ce
"[json.exception.invalid_iterator.203] iter │ "[json.exception.invalid_iterator.203] iter
CHECK_THROWS_WITH_AS(jarray.erase(jarray2.cbegin(), jarray.cend( │ CHECK_THROWS_WITH_AS(jobject.erase(jobject2.cbegin(), jobject.ce
"[json.exception.invalid_iterator.203] iter │ "[json.exception.invalid_iterator.203] iter
CHECK_THROWS_WITH_AS(jarray.erase(jarray2.cbegin(), jarray2.cend │ CHECK_THROWS_WITH_AS(jobject.erase(jobject2.cbegin(), jobject2.c
"[json.exception.invalid_iterator.203] iter │ "[json.exception.invalid_iterator.203] iter
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:2123 │ json/tests/src/unit-bson.cpp:1246
│
CAPTURE(filename) │ CAPTURE(filename)
│
{ │ {
INFO_WITH_TEMP(filename + ": std::vector<uint8_t>"); │ INFO_WITH_TEMP(filename + ": std::vector<std::uint8_t>");
// parse JSON file │ // parse JSON file
std::ifstream f_json(filename); │ std::ifstream f_json(filename);
json j1 = json::parse(f_json); │ json j1 = json::parse(f_json);
│
// parse CBOR file │ // parse BSON file
auto packed = utils::read_binary_file(filename + ".cbor"); │ auto packed = utils::read_binary_file(filename + ".bson");
json j2; │ json j2;
CHECK_NOTHROW(j2 = json::from_cbor(packed)); │ CHECK_NOTHROW(j2 = json::from_bson(packed));
│
// compare parsed JSON values │ // compare parsed JSON values
CHECK(j1 == j2); │ CHECK(j1 == j2);
} │ }
│
{ │ {
INFO_WITH_TEMP(filename + ": std::ifstream"); │ INFO_WITH_TEMP(filename + ": std::ifstream");
// parse JSON file │ // parse JSON file
std::ifstream f_json(filename); │ std::ifstream f_json(filename);
json j1 = json::parse(f_json); │ json j1 = json::parse(f_json);
│
// parse CBOR file │ // parse BSON file
std::ifstream f_cbor(filename + ".cbor", std::ios::binary); │ std::ifstream f_bson(filename + ".bson", std::ios::binary);
json j2; │ json j2;
CHECK_NOTHROW(j2 = json::from_cbor(f_cbor)); │ CHECK_NOTHROW(j2 = json::from_bson(f_bson));
│
// compare parsed JSON values │ // compare parsed JSON values
CHECK(j1 == j2); │ CHECK(j1 == j2);
} │ }
│
{ │ {
INFO_WITH_TEMP(filename + ": uint8_t* and size"); │ INFO_WITH_TEMP(filename + ": uint8_t* and size");
// parse JSON file │ // parse JSON file
std::ifstream f_json(filename); │ std::ifstream f_json(filename);
json j1 = json::parse(f_json); │ json j1 = json::parse(f_json);
│
// parse CBOR file │ // parse BSON file
auto packed = utils::read_binary_file(filename + ".cbor"); │ auto packed = utils::read_binary_file(filename + ".bson");
json j2; │ json j2;
CHECK_NOTHROW(j2 = json::from_cbor({packed.data(), packed.size()})); │ CHECK_NOTHROW(j2 = json::from_bson({packed.data(), packed.size()}));
│
// compare parsed JSON values │ // compare parsed JSON values
CHECK(j1 == j2); │ CHECK(j1 == j2);
} │ }
│
{ │ {
INFO_WITH_TEMP(filename + ": output to output adapters"); │ INFO_WITH_TEMP(filename + ": output to output adapters");
// parse JSON file │ // parse JSON file
std::ifstream f_json(filename); │ std::ifstream f_json(filename);
json j1 = json::parse(f_json); │ json j1 = json::parse(f_json);
│
// parse CBOR file │ // parse BSON file
auto packed = utils::read_binary_file(filename + ".cbor"); │ auto packed = utils::read_binary_file(filename + ".bson");
│
if (exclude_packed.count(filename) == 0u) │
{ │ {
│ INFO_WITH_TEMP(filename + ": output adapters: std::vector<std::uint8
│ std::vector<std::uint8_t> vec;
│ json::to_bson(j1, vec);
│
│ if (vec != packed)
{ │ {
INFO_WITH_TEMP(filename + ": output adapters: std::vector<uint8_ │ // the exact serializations may differ due to the order of
std::vector<uint8_t> vec; │ // object keys; in these cases, just compare whether both
json::to_cbor(j1, vec); │ // serializations create the same JSON value
CHECK(vec == packed); │ CHECK(json::from_bson(vec) == json::from_bson(packed));
} │ }
} │ }
} │ }
} │
next prev up json/include/nlohmann/detail/input/binary_reader.hpp:825 │ json/include/nlohmann/detail/input/binary_reader.hpp:2296
│
│ if (input_format != input_format_t::bjdata)
│ {
│ break;
│ }
const auto byte1_raw = get(); │ const auto byte1_raw = get();
if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) │ if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number")))
{ │ {
return false; │ return false;
} │ }
const auto byte2_raw = get(); │ const auto byte2_raw = get();
if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) │ if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number")))
{ │ {
return false; │ return false;
} │ }
│
const auto byte1 = static_cast<unsigned char>(byte1_raw); │ const auto byte1 = static_cast<unsigned char>(byte1_raw);
const auto byte2 = static_cast<unsigned char>(byte2_raw); │ const auto byte2 = static_cast<unsigned char>(byte2_raw);
│
// code from RFC 7049, Appendix D, Figure 3: │ // code from RFC 7049, Appendix D, Figure 3:
// As half-precision floating-point numbers were only added │ // As half-precision floating-point numbers were only added
// to IEEE 754 in 2008, today's programming platforms often │ // to IEEE 754 in 2008, today's programming platforms often
// still only have limited support for them. It is very │ // still only have limited support for them. It is very
// easy to include at least decoding support for them even │ // easy to include at least decoding support for them even
// without such support. An example of a small decoder for │ // without such support. An example of a small decoder for
// half-precision floating-point numbers in the C language │ // half-precision floating-point numbers in the C language
// is shown in Fig. 3. │ // is shown in Fig. 3.
const auto half = static_cast<unsigned int>((byte1 << 8u) + byte2); │ const auto half = static_cast<unsigned int>((byte2 << 8u) + byte1);
const double val = [&half] │ const double val = [&half]
{ │ {
const int exp = (half >> 10u) & 0x1Fu; │ const int exp = (half >> 10u) & 0x1Fu;
const unsigned int mant = half & 0x3FFu; │ const unsigned int mant = half & 0x3FFu;
JSON_ASSERT(0 <= exp&& exp <= 32); │ JSON_ASSERT(0 <= exp&& exp <= 32);
JSON_ASSERT(mant <= 1024); │ JSON_ASSERT(mant <= 1024);
switch (exp) │ switch (exp)
{ │ {
case 0: │ case 0:
return std::ldexp(mant, -24); │ return std::ldexp(mant, -24);
case 31: │ case 31:
return (mant == 0) │ return (mant == 0)
? std::numeric_limits<double>::infinity() │ ? std::numeric_limits<double>::infinity()
: std::numeric_limits<double>::quiet_NaN(); │ : std::numeric_limits<double>::quiet_NaN();
default: │ default:
return std::ldexp(mant + 1024, exp - 25); │ return std::ldexp(mant + 1024, exp - 25);
} │ }
}(); │ }();
return sax->number_float((half & 0x8000u) != 0 │ return sax->number_float((half & 0x8000u) != 0
? static_cast<number_float_t>(-val) │ ? static_cast<number_float_t>(-val)
: static_cast<number_float_t>(val), ""); │ : static_cast<number_float_t>(val), "");
} │
next prev up json/single_include/nlohmann/json.hpp:9299 │ json/single_include/nlohmann/json.hpp:10770
│
│ if (input_format != input_format_t::bjdata)
│ {
│ break;
│ }
const auto byte1_raw = get(); │ const auto byte1_raw = get();
if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) │ if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number")))
{ │ {
return false; │ return false;
} │ }
const auto byte2_raw = get(); │ const auto byte2_raw = get();
if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) │ if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number")))
{ │ {
return false; │ return false;
} │ }
│
const auto byte1 = static_cast<unsigned char>(byte1_raw); │ const auto byte1 = static_cast<unsigned char>(byte1_raw);
const auto byte2 = static_cast<unsigned char>(byte2_raw); │ const auto byte2 = static_cast<unsigned char>(byte2_raw);
│
// code from RFC 7049, Appendix D, Figure 3: │ // code from RFC 7049, Appendix D, Figure 3:
// As half-precision floating-point numbers were only added │ // As half-precision floating-point numbers were only added
// to IEEE 754 in 2008, today's programming platforms often │ // to IEEE 754 in 2008, today's programming platforms often
// still only have limited support for them. It is very │ // still only have limited support for them. It is very
// easy to include at least decoding support for them even │ // easy to include at least decoding support for them even
// without such support. An example of a small decoder for │ // without such support. An example of a small decoder for
// half-precision floating-point numbers in the C language │ // half-precision floating-point numbers in the C language
// is shown in Fig. 3. │ // is shown in Fig. 3.
const auto half = static_cast<unsigned int>((byte1 << 8u) + byte2); │ const auto half = static_cast<unsigned int>((byte2 << 8u) + byte1);
const double val = [&half] │ const double val = [&half]
{ │ {
const int exp = (half >> 10u) & 0x1Fu; │ const int exp = (half >> 10u) & 0x1Fu;
const unsigned int mant = half & 0x3FFu; │ const unsigned int mant = half & 0x3FFu;
JSON_ASSERT(0 <= exp&& exp <= 32); │ JSON_ASSERT(0 <= exp&& exp <= 32);
JSON_ASSERT(mant <= 1024); │ JSON_ASSERT(mant <= 1024);
switch (exp) │ switch (exp)
{ │ {
case 0: │ case 0:
return std::ldexp(mant, -24); │ return std::ldexp(mant, -24);
case 31: │ case 31:
return (mant == 0) │ return (mant == 0)
? std::numeric_limits<double>::infinity() │ ? std::numeric_limits<double>::infinity()
: std::numeric_limits<double>::quiet_NaN(); │ : std::numeric_limits<double>::quiet_NaN();
default: │ default:
return std::ldexp(mant + 1024, exp - 25); │ return std::ldexp(mant + 1024, exp - 25);
} │ }
}(); │ }();
return sax->number_float((half & 0x8000u) != 0 │ return sax->number_float((half & 0x8000u) != 0
? static_cast<number_float_t>(-val) │ ? static_cast<number_float_t>(-val)
: static_cast<number_float_t>(val), ""); │ : static_cast<number_float_t>(val), "");
} │
next prev up json/tests/src/unit-bson.cpp:1011 │ json/tests/src/unit-bson.cpp:886
│
std::vector<int64_t> numbers │ std::vector<int64_t> numbers
{ │ {
INT64_MAX, │ INT64_MIN,
1000000000000000000LL, │ -1000000000000000000LL,
100000000000000000LL, │ -100000000000000000LL,
10000000000000000LL, │ -10000000000000000LL,
1000000000000000LL, │ -1000000000000000LL,
100000000000000LL, │ -100000000000000LL,
10000000000000LL, │ -10000000000000LL,
1000000000000LL, │ -1000000000000LL,
100000000000LL, │ -100000000000LL,
10000000000LL, │ -10000000000LL,
static_cast<std::int64_t>(INT32_MAX) + 1, │ static_cast<std::int64_t>(INT32_MIN) - 1,
}; │ };
│
for (auto i : numbers) │ for (auto i : numbers)
{ │ {
│
CAPTURE(i) │ CAPTURE(i)
│
json j = │ json j =
{ │ {
{ "entry", i } │ { "entry", i }
}; │ };
CHECK(j.at("entry").is_number_integer()); │ CHECK(j.at("entry").is_number_integer());
│
std::uint64_t iu = *reinterpret_cast<std::uint64_t*>(&i); │ std::uint64_t iu = *reinterpret_cast<std::uint64_t*>(&i);
std::vector<std::uint8_t> expected_bson = │ std::vector<std::uint8_t> expected_bson =
{ │ {
0x14u, 0x00u, 0x00u, 0x00u, // size (little endian) │ 0x14u, 0x00u, 0x00u, 0x00u, // size (little endian)
0x12u, /// entry: int64 │ 0x12u, /// entry: int64
'e', 'n', 't', 'r', 'y', '\x00', │ 'e', 'n', 't', 'r', 'y', '\x00',
static_cast<std::uint8_t>((iu >> (8u * 0u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 0u)) & 0xffu),
static_cast<std::uint8_t>((iu >> (8u * 1u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 1u)) & 0xffu),
static_cast<std::uint8_t>((iu >> (8u * 2u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 2u)) & 0xffu),
static_cast<std::uint8_t>((iu >> (8u * 3u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 3u)) & 0xffu),
static_cast<std::uint8_t>((iu >> (8u * 4u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 4u)) & 0xffu),
static_cast<std::uint8_t>((iu >> (8u * 5u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 5u)) & 0xffu),
static_cast<std::uint8_t>((iu >> (8u * 6u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 6u)) & 0xffu),
static_cast<std::uint8_t>((iu >> (8u * 7u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 7u)) & 0xffu),
0x00u // end marker │ 0x00u // end marker
}; │ };
│
const auto bson = json::to_bson(j); │ const auto bson = json::to_bson(j);
CHECK(bson == expected_bson); │ CHECK(bson == expected_bson);
│
auto j_roundtrip = json::from_bson(bson); │ auto j_roundtrip = json::from_bson(bson);
│
CHECK(j_roundtrip.at("entry").is_number_integer()); │ CHECK(j_roundtrip.at("entry").is_number_integer());
CHECK(j_roundtrip == j); │ CHECK(j_roundtrip == j);
CHECK(json::from_bson(bson, true, false) == j); │ CHECK(json::from_bson(bson, true, false) == j);
│
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:2472 │ json/tests/src/unit-bson.cpp:1246
│
CAPTURE(filename) │ CAPTURE(filename)
│
{ │ {
INFO_WITH_TEMP(filename + ": std::vector<uint8_t>"); │ INFO_WITH_TEMP(filename + ": std::vector<std::uint8_t>");
// parse JSON file │ // parse JSON file
std::ifstream f_json(filename); │ std::ifstream f_json(filename);
json j1 = json::parse(f_json); │ json j1 = json::parse(f_json);
│
// parse UBJSON file │ // parse BSON file
auto packed = utils::read_binary_file(filename + ".ubjson"); │ auto packed = utils::read_binary_file(filename + ".bson");
json j2; │ json j2;
CHECK_NOTHROW(j2 = json::from_ubjson(packed)); │ CHECK_NOTHROW(j2 = json::from_bson(packed));
│
// compare parsed JSON values │ // compare parsed JSON values
CHECK(j1 == j2); │ CHECK(j1 == j2);
} │ }
│
{ │ {
INFO_WITH_TEMP(filename + ": std::ifstream"); │ INFO_WITH_TEMP(filename + ": std::ifstream");
// parse JSON file │ // parse JSON file
std::ifstream f_json(filename); │ std::ifstream f_json(filename);
json j1 = json::parse(f_json); │ json j1 = json::parse(f_json);
│
// parse UBJSON file │ // parse BSON file
std::ifstream f_ubjson(filename + ".ubjson", std::ios::binary); │ std::ifstream f_bson(filename + ".bson", std::ios::binary);
json j2; │ json j2;
CHECK_NOTHROW(j2 = json::from_ubjson(f_ubjson)); │ CHECK_NOTHROW(j2 = json::from_bson(f_bson));
│
// compare parsed JSON values │ // compare parsed JSON values
CHECK(j1 == j2); │ CHECK(j1 == j2);
} │ }
│
{ │ {
INFO_WITH_TEMP(filename + ": uint8_t* and size"); │ INFO_WITH_TEMP(filename + ": uint8_t* and size");
// parse JSON file │ // parse JSON file
std::ifstream f_json(filename); │ std::ifstream f_json(filename);
json j1 = json::parse(f_json); │ json j1 = json::parse(f_json);
│
// parse UBJSON file │ // parse BSON file
auto packed = utils::read_binary_file(filename + ".ubjson"); │ auto packed = utils::read_binary_file(filename + ".bson");
json j2; │ json j2;
CHECK_NOTHROW(j2 = json::from_ubjson({packed.data(), packed.size()})); │ CHECK_NOTHROW(j2 = json::from_bson({packed.data(), packed.size()}));
│
// compare parsed JSON values │ // compare parsed JSON values
CHECK(j1 == j2); │ CHECK(j1 == j2);
} │ }
│
{ │ {
INFO_WITH_TEMP(filename + ": output to output adapters"); │ INFO_WITH_TEMP(filename + ": output to output adapters");
// parse JSON file │ // parse JSON file
std::ifstream f_json(filename); │ std::ifstream f_json(filename);
json j1 = json::parse(f_json); │ json j1 = json::parse(f_json);
│
// parse UBJSON file │ // parse BSON file
auto packed = utils::read_binary_file(filename + ".ubjson"); │ auto packed = utils::read_binary_file(filename + ".bson");
│
{ │ {
INFO_WITH_TEMP(filename + ": output adapters: std::vector<uint8_t>") │ INFO_WITH_TEMP(filename + ": output adapters: std::vector<std::uint8
std::vector<uint8_t> vec; │ std::vector<std::uint8_t> vec;
json::to_ubjson(j1, vec); │ json::to_bson(j1, vec);
CHECK(vec == packed); │
│ if (vec != packed)
│ {
│ // the exact serializations may differ due to the order of
│ // object keys; in these cases, just compare whether both
│ // serializations create the same JSON value
│ CHECK(json::from_bson(vec) == json::from_bson(packed));
│ }
} │ }
} │ }
} │
next prev up json/include/nlohmann/json.hpp:2401 │ json/include/nlohmann/json.hpp:2471
│
// make sure iterator fits the current value │ // make sure iterator fits the current value
if (JSON_HEDLEY_UNLIKELY(this != pos.m_object)) │ if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object))
{ │ {
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current valu │ JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value
} │ }
│
IteratorType result = end(); │ IteratorType result = end();
│
switch (m_type) │ switch (m_type)
{ │ {
case value_t::boolean: │ case value_t::boolean:
case value_t::number_float: │ case value_t::number_float:
case value_t::number_integer: │ case value_t::number_integer:
case value_t::number_unsigned: │ case value_t::number_unsigned:
case value_t::string: │ case value_t::string:
case value_t::binary: │ case value_t::binary:
{ │ {
if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin())) │ if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin()
│ || !last.m_it.primitive_iterator.is_end()))
{ │ {
JSON_THROW(invalid_iterator::create(205, "iterator out of range", th │ JSON_THROW(invalid_iterator::create(204, "iterators out of range", t
} │ }
│
if (is_string()) │ if (is_string())
{ │ {
AllocatorType<string_t> alloc; │ AllocatorType<string_t> alloc;
std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.strin │ std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.strin
std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.st │ std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.st
m_value.string = nullptr; │ m_value.string = nullptr;
} │ }
else if (is_binary()) │ else if (is_binary())
{ │ {
AllocatorType<binary_t> alloc; │ AllocatorType<binary_t> alloc;
std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binar │ std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binar
std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.bi │ std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.bi
m_value.binary = nullptr; │ m_value.binary = nullptr;
} │ }
│
m_type = value_t::null; │ m_type = value_t::null;
assert_invariant(); │ assert_invariant();
break; │ break;
} │ }
│
case value_t::object: │ case value_t::object:
{ │ {
result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iter │ result.m_it.object_iterator = m_value.object->erase(first.m_it.object_it
│ last.m_it.object_iterator);
break; │ break;
} │ }
│
case value_t::array: │ case value_t::array:
{ │ {
result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterato │ result.m_it.array_iterator = m_value.array->erase(first.m_it.array_itera
│ last.m_it.array_iterator);
break; │ break;
} │ }
│
case value_t::null: │ case value_t::null:
case value_t::discarded: │ case value_t::discarded:
default: │ default:
JSON_THROW(type_error::create(307, detail::concat("cannot use erase() wi │ JSON_THROW(type_error::create(307, detail::concat("cannot use erase() wi
} │ }
│
return result; │ return result;
} │
next prev up json/single_include/nlohmann/json.hpp:20485 │ json/single_include/nlohmann/json.hpp:20555
│
// make sure iterator fits the current value │ // make sure iterator fits the current value
if (JSON_HEDLEY_UNLIKELY(this != pos.m_object)) │ if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object))
{ │ {
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current valu │ JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value
} │ }
│
IteratorType result = end(); │ IteratorType result = end();
│
switch (m_type) │ switch (m_type)
{ │ {
case value_t::boolean: │ case value_t::boolean:
case value_t::number_float: │ case value_t::number_float:
case value_t::number_integer: │ case value_t::number_integer:
case value_t::number_unsigned: │ case value_t::number_unsigned:
case value_t::string: │ case value_t::string:
case value_t::binary: │ case value_t::binary:
{ │ {
if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin())) │ if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin()
│ || !last.m_it.primitive_iterator.is_end()))
{ │ {
JSON_THROW(invalid_iterator::create(205, "iterator out of range", th │ JSON_THROW(invalid_iterator::create(204, "iterators out of range", t
} │ }
│
if (is_string()) │ if (is_string())
{ │ {
AllocatorType<string_t> alloc; │ AllocatorType<string_t> alloc;
std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.strin │ std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.strin
std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.st │ std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.st
m_value.string = nullptr; │ m_value.string = nullptr;
} │ }
else if (is_binary()) │ else if (is_binary())
{ │ {
AllocatorType<binary_t> alloc; │ AllocatorType<binary_t> alloc;
std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binar │ std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binar
std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.bi │ std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.bi
m_value.binary = nullptr; │ m_value.binary = nullptr;
} │ }
│
m_type = value_t::null; │ m_type = value_t::null;
assert_invariant(); │ assert_invariant();
break; │ break;
} │ }
│
case value_t::object: │ case value_t::object:
{ │ {
result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iter │ result.m_it.object_iterator = m_value.object->erase(first.m_it.object_it
│ last.m_it.object_iterator);
break; │ break;
} │ }
│
case value_t::array: │ case value_t::array:
{ │ {
result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterato │ result.m_it.array_iterator = m_value.array->erase(first.m_it.array_itera
│ last.m_it.array_iterator);
break; │ break;
} │ }
│
case value_t::null: │ case value_t::null:
case value_t::discarded: │ case value_t::discarded:
default: │ default:
JSON_THROW(type_error::create(307, detail::concat("cannot use erase() wi │ JSON_THROW(type_error::create(307, detail::concat("cannot use erase() wi
} │ }
│
return result; │ return result;
} │
next prev up json/tests/src/unit-class_iterator.cpp:134 │ json/tests/src/unit-class_const_iterator.cpp:144
│
SECTION("operator*") │ SECTION("operator*")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j(json::value_t::null); │ json j(json::value_t::null);
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK_THROWS_WITH_AS(*it, "[json.exception.invalid_iterator.214] cannot │ CHECK_THROWS_WITH_AS(*it, "[json.exception.invalid_iterator.214] cannot
} │ }
│
SECTION("number") │ SECTION("number")
{ │ {
json j(17); │ json j(17);
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK(*it == json(17)); │ CHECK(*it == json(17));
it = j.end(); │ it = j.cend();
CHECK_THROWS_WITH_AS(*it, "[json.exception.invalid_iterator.214] cannot │ CHECK_THROWS_WITH_AS(*it, "[json.exception.invalid_iterator.214] cannot
} │ }
│
SECTION("object") │ SECTION("object")
{ │ {
json j({{"foo", "bar"}}); │ json j({{"foo", "bar"}});
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK(*it == json("bar")); │ CHECK(*it == json("bar"));
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j({1, 2, 3, 4}); │ json j({1, 2, 3, 4});
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK(*it == json(1)); │ CHECK(*it == json(1));
} │ }
} │ }
│
SECTION("operator->") │ SECTION("operator->")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j(json::value_t::null); │ json j(json::value_t::null);
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK_THROWS_WITH_AS(std::string(it->type_name()), "[json.exception.inva │ CHECK_THROWS_WITH_AS(std::string(it->type_name()), "[json.exception.inva
} │ }
│
SECTION("number") │ SECTION("number")
{ │ {
json j(17); │ json j(17);
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK(std::string(it->type_name()) == "number"); │ CHECK(std::string(it->type_name()) == "number");
it = j.end(); │ it = j.cend();
CHECK_THROWS_WITH_AS(std::string(it->type_name()), "[json.exception.inva │ CHECK_THROWS_WITH_AS(std::string(it->type_name()), "[json.exception.inva
} │ }
│
SECTION("object") │ SECTION("object")
{ │ {
json j({{"foo", "bar"}}); │ json j({{"foo", "bar"}});
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK(std::string(it->type_name()) == "string"); │ CHECK(std::string(it->type_name()) == "string");
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j({1, 2, 3, 4}); │ json j({1, 2, 3, 4});
json::iterator it = j.begin(); │ json::const_iterator it = j.cbegin();
CHECK(std::string(it->type_name()) == "number"); │ CHECK(std::string(it->type_name()) == "number");
} │ }
} │ }
} │
next prev up json/include/nlohmann/detail/input/input_adapters.hpp:184 │ json/include/nlohmann/detail/input/input_adapters.hpp:242
│
// get the current character │ // get the current character
const auto wc = input.get_character(); │ const auto wc = input.get_character();
│
// UTF-32 to UTF-8 encoding │ // UTF-16 to UTF-8 encoding
if (wc < 0x80) │ if (wc < 0x80)
{ │ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc); │ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
utf8_bytes_filled = 1; │ utf8_bytes_filled = 1;
} │ }
else if (wc <= 0x7FF) │ else if (wc <= 0x7FF)
{ │ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | (( │ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (s │ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (s
utf8_bytes_filled = 2; │ utf8_bytes_filled = 2;
} │ }
else if (wc <= 0xFFFF) │ else if (0xD800 > wc || wc >= 0xE000)
{ │ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | (( │ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (( │ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((
utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (s │ utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (s
utf8_bytes_filled = 3; │ utf8_bytes_filled = 3;
} │ }
else if (wc <= 0x10FFFF) │
{ │
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | (( │
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (( │
utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (( │
utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (s │
utf8_bytes_filled = 4; │
} │
else │ else
{ │ {
// unknown character │ if (JSON_HEDLEY_UNLIKELY(!input.empty()))
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc); │ {
utf8_bytes_filled = 1; │ const auto wc2 = static_cast<unsigned int>(input.get_character());
│ const auto charcode = 0x10000u + (((static_cast<unsigned int>(wc) &
│ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u
│ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u
│ utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u
│ utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u
│ utf8_bytes_filled = 4;
│ }
│ else
│ {
│ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
│ utf8_bytes_filled = 1;
│ }
} │ }
} │
next prev up json/single_include/nlohmann/json.hpp:5693 │ json/single_include/nlohmann/json.hpp:5751
│
// get the current character │ // get the current character
const auto wc = input.get_character(); │ const auto wc = input.get_character();
│
// UTF-32 to UTF-8 encoding │ // UTF-16 to UTF-8 encoding
if (wc < 0x80) │ if (wc < 0x80)
{ │ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc); │ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
utf8_bytes_filled = 1; │ utf8_bytes_filled = 1;
} │ }
else if (wc <= 0x7FF) │ else if (wc <= 0x7FF)
{ │ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | (( │ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (s │ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (s
utf8_bytes_filled = 2; │ utf8_bytes_filled = 2;
} │ }
else if (wc <= 0xFFFF) │ else if (0xD800 > wc || wc >= 0xE000)
{ │ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | (( │ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (( │ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((
utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (s │ utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (s
utf8_bytes_filled = 3; │ utf8_bytes_filled = 3;
} │ }
else if (wc <= 0x10FFFF) │
{ │
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | (( │
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (( │
utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (( │
utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (s │
utf8_bytes_filled = 4; │
} │
else │ else
{ │ {
// unknown character │ if (JSON_HEDLEY_UNLIKELY(!input.empty()))
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc); │ {
utf8_bytes_filled = 1; │ const auto wc2 = static_cast<unsigned int>(input.get_character());
│ const auto charcode = 0x10000u + (((static_cast<unsigned int>(wc) &
│ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u
│ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u
│ utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u
│ utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u
│ utf8_bytes_filled = 4;
│ }
│ else
│ {
│ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
│ utf8_bytes_filled = 1;
│ }
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:306 │ json/tests/src/unit-msgpack.cpp:482
│
for (uint32_t i : │ std::vector<int32_t> numbers;
{ │ numbers.push_back(-32769);
65536u, 77777u, 1048576u, 4294967295u │ numbers.push_back(-65536);
}) │ numbers.push_back(-77777);
│ numbers.push_back(-1048576);
│ numbers.push_back(-2147483648LL);
│ for (auto i : numbers)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = i;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xce); │ expected.push_back(0xd2);
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xce); │ CHECK(result[0] == 0xd2);
uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) + │ uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) +
(static_cast<uint32_t>(result[2]) << 020) + │ (static_cast<uint32_t>(result[2]) << 020) +
(static_cast<uint32_t>(result[3]) << 010) + │ (static_cast<uint32_t>(result[3]) << 010) +
static_cast<uint32_t>(result[4]); │ static_cast<uint32_t>(result[4]);
CHECK(restored == i); │ CHECK(static_cast<std::int32_t>(restored) == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:549 │ json/tests/src/unit-bjdata.cpp:234
│
for (uint32_t i : │ std::vector<int32_t> numbers;
{ │ numbers.push_back(-32769);
2147483648u, 3333333333u, 4294967295u │ numbers.push_back(-100000);
}) │ numbers.push_back(-1000000);
│ numbers.push_back(-10000000);
│ numbers.push_back(-100000000);
│ numbers.push_back(-1000000000);
│ numbers.push_back(-2147483647 - 1); // https://stackoverflow.com/a/2
│ for (auto i : numbers)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = i;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('m'); │ expected.push_back(static_cast<uint8_t>('l'));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'm'); │ CHECK(result[0] == 'l');
uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) + │ int32_t restored = (static_cast<int32_t>(result[4]) << 030) +
(static_cast<uint32_t>(result[3]) << 020) + │ (static_cast<int32_t>(result[3]) << 020) +
(static_cast<uint32_t>(result[2]) << 010) + │ (static_cast<int32_t>(result[2]) << 010) +
static_cast<uint32_t>(result[1]); │ static_cast<int32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:506 │ json/tests/src/unit-bjdata.cpp:234
│
for (uint32_t i : │ std::vector<int32_t> numbers;
{ │ numbers.push_back(-32769);
65536u, 77777u, 2147483647u │ numbers.push_back(-100000);
}) │ numbers.push_back(-1000000);
│ numbers.push_back(-10000000);
│ numbers.push_back(-100000000);
│ numbers.push_back(-1000000000);
│ numbers.push_back(-2147483647 - 1); // https://stackoverflow.com/a/2
│ for (auto i : numbers)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = i;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('l'); │ expected.push_back(static_cast<uint8_t>('l'));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'l'); │ CHECK(result[0] == 'l');
uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) + │ int32_t restored = (static_cast<int32_t>(result[4]) << 030) +
(static_cast<uint32_t>(result[3]) << 020) + │ (static_cast<int32_t>(result[3]) << 020) +
(static_cast<uint32_t>(result[2]) << 010) + │ (static_cast<int32_t>(result[2]) << 010) +
static_cast<uint32_t>(result[1]); │ static_cast<int32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:506 │ json/tests/src/unit-bjdata.cpp:549
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
65536u, 77777u, 2147483647u │ 2147483648u, 3333333333u, 4294967295u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = -1;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('l'); │ expected.push_back('m');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'l'); │ CHECK(result[0] == 'm');
uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) + │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
(static_cast<uint32_t>(result[3]) << 020) + │ (static_cast<uint32_t>(result[3]) << 020) +
(static_cast<uint32_t>(result[2]) << 010) + │ (static_cast<uint32_t>(result[2]) << 010) +
static_cast<uint32_t>(result[1]); │ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:468 │ json/tests/src/unit-ubjson.cpp:234
│
for (uint32_t i : │ std::vector<int32_t> numbers;
{ │ numbers.push_back(-32769);
65536u, 77777u, 1048576u │ numbers.push_back(-100000);
}) │ numbers.push_back(-1000000);
│ numbers.push_back(-10000000);
│ numbers.push_back(-100000000);
│ numbers.push_back(-1000000000);
│ numbers.push_back(-2147483647 - 1); // https://stackoverflow.com/a/2
│ for (auto i : numbers)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = i;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('l'); │ expected.push_back(static_cast<uint8_t>('l'));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'l'); │ CHECK(result[0] == 'l');
uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) + │ int32_t restored = (static_cast<int32_t>(result[1]) << 030) +
(static_cast<uint32_t>(result[2]) << 020) + │ (static_cast<int32_t>(result[2]) << 020) +
(static_cast<uint32_t>(result[3]) << 010) + │ (static_cast<int32_t>(result[3]) << 010) +
static_cast<uint32_t>(result[4]); │ static_cast<int32_t>(result[4]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:2517 │ json/tests/src/unit-bjdata.cpp:2492
│
json _; │ json _;
std::vector<uint8_t> v_N = {'[', '$', 'N', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_N = {'[', '$', 'N', '#', '[', '#', 'i', 2, 'i', 1
std::vector<uint8_t> v_T = {'[', '$', 'T', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_T = {'[', '$', 'T', '#', '[', '#', 'i', 2, 'i', 1
std::vector<uint8_t> v_F = {'[', '$', 'F', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_F = {'[', '$', 'F', '#', '[', '#', 'i', 2, 'i', 1
std::vector<uint8_t> v_Z = {'[', '$', 'Z', '#', '[', 'i', 1, 'i', 2, ']' │ std::vector<uint8_t> v_Z = {'[', '$', 'Z', '#', '[', '#', 'i', 2, 'i', 1
│
CHECK_THROWS_AS(_ = json::from_bjdata(v_N), json::parse_error&); │ CHECK_THROWS_AS(_ = json::from_bjdata(v_N), json::parse_error&);
CHECK_THROWS_WITH(_ = json::from_bjdata(v_N), "[json.exception.parse_err │ CHECK_THROWS_WITH(_ = json::from_bjdata(v_N), "[json.exception.parse_err
CHECK(json::from_bjdata(v_N, true, false).is_discarded()); │ CHECK(json::from_bjdata(v_N, true, false).is_discarded());
│
CHECK_THROWS_AS(_ = json::from_bjdata(v_T), json::parse_error&); │ CHECK_THROWS_AS(_ = json::from_bjdata(v_T), json::parse_error&);
CHECK_THROWS_WITH(_ = json::from_bjdata(v_T), "[json.exception.parse_err │ CHECK_THROWS_WITH(_ = json::from_bjdata(v_T), "[json.exception.parse_err
CHECK(json::from_bjdata(v_T, true, false).is_discarded()); │ CHECK(json::from_bjdata(v_T, true, false).is_discarded());
│
CHECK_THROWS_AS(_ = json::from_bjdata(v_F), json::parse_error&); │ CHECK_THROWS_AS(_ = json::from_bjdata(v_F), json::parse_error&);
CHECK_THROWS_WITH(_ = json::from_bjdata(v_F), "[json.exception.parse_err │ CHECK_THROWS_WITH(_ = json::from_bjdata(v_F), "[json.exception.parse_err
CHECK(json::from_bjdata(v_F, true, false).is_discarded()); │ CHECK(json::from_bjdata(v_F, true, false).is_discarded());
│
CHECK_THROWS_AS(_ = json::from_bjdata(v_Z), json::parse_error&); │ CHECK_THROWS_AS(_ = json::from_bjdata(v_Z), json::parse_error&);
CHECK_THROWS_WITH(_ = json::from_bjdata(v_Z), "[json.exception.parse_err │ CHECK_THROWS_WITH(_ = json::from_bjdata(v_Z), "[json.exception.parse_err
CHECK(json::from_bjdata(v_Z, true, false).is_discarded()); │ CHECK(json::from_bjdata(v_Z, true, false).is_discarded());
} │
next prev up json/tests/src/unit-ubjson.cpp:1360 │ json/tests/src/unit-ubjson.cpp:1406
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j(257, nullptr); │ json j(65793, nullptr);
std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null │ std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null
expected[0] = '['; // opening array │ expected[0] = '['; // opening array
expected[258] = ']'; // closing array │ expected[65794] = ']'; // closing array
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j(257, nullptr); │ json j(65793, nullptr);
std::vector<uint8_t> expected(j.size() + 5, 'Z'); // all null │ std::vector<uint8_t> expected(j.size() + 7, 'Z'); // all null
expected[0] = '['; // opening array │ expected[0] = '['; // opening array
expected[1] = '#'; // array size │ expected[1] = '#'; // array size
expected[2] = 'I'; // int16 │ expected[2] = 'l'; // int32
expected[3] = 0x01; // 0x0101, first byte │ expected[3] = 0x00; // 0x00010101, first byte
expected[4] = 0x01; // 0x0101, second byte │ expected[4] = 0x01; // 0x00010101, second byte
│ expected[5] = 0x01; // 0x00010101, third byte
│ expected[6] = 0x01; // 0x00010101, fourth byte
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j(257, nullptr); │ json j(65793, nullptr);
std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'I', 0x01, 0x01 │ std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'l', 0x00, 0x01
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:677 │ json/tests/src/unit-msgpack.cpp:482
│
for (uint32_t i : │ std::vector<int32_t> numbers;
{ │ numbers.push_back(-32769);
65536u, 77777u, 1048576u, 4294967295u │ numbers.push_back(-65536);
}) │ numbers.push_back(-77777);
│ numbers.push_back(-1048576);
│ numbers.push_back(-2147483648LL);
│ for (auto i : numbers)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xce); │ expected.push_back(0xd2);
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xce); │ CHECK(result[0] == 0xd2);
uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) + │ uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) +
(static_cast<uint32_t>(result[2]) << 020) + │ (static_cast<uint32_t>(result[2]) << 020) +
(static_cast<uint32_t>(result[3]) << 010) + │ (static_cast<uint32_t>(result[3]) << 010) +
static_cast<uint32_t>(result[4]); │ static_cast<uint32_t>(result[4]);
CHECK(restored == i); │ CHECK(static_cast<std::int32_t>(restored) == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:677 │ json/tests/src/unit-msgpack.cpp:306
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
65536u, 77777u, 1048576u, 4294967295u │ 65536u, 77777u, 1048576u, 4294967295u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xce); │ expected.push_back(0xce);
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xce); │ CHECK(result[0] == 0xce);
uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) + │ uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) +
(static_cast<uint32_t>(result[2]) << 020) + │ (static_cast<uint32_t>(result[2]) << 020) +
(static_cast<uint32_t>(result[3]) << 010) + │ (static_cast<uint32_t>(result[3]) << 010) +
static_cast<uint32_t>(result[4]); │ static_cast<uint32_t>(result[4]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:870 │ json/tests/src/unit-bjdata.cpp:234
│
for (uint32_t i : │ std::vector<int32_t> numbers;
{ │ numbers.push_back(-32769);
2147483648u, 3333333333u, 4294967295u │ numbers.push_back(-100000);
}) │ numbers.push_back(-1000000);
│ numbers.push_back(-10000000);
│ numbers.push_back(-100000000);
│ numbers.push_back(-1000000000);
│ numbers.push_back(-2147483647 - 1); // https://stackoverflow.com/a/2
│ for (auto i : numbers)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('m'); │ expected.push_back(static_cast<uint8_t>('l'));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'm'); │ CHECK(result[0] == 'l');
uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) + │ int32_t restored = (static_cast<int32_t>(result[4]) << 030) +
(static_cast<uint32_t>(result[3]) << 020) + │ (static_cast<int32_t>(result[3]) << 020) +
(static_cast<uint32_t>(result[2]) << 010) + │ (static_cast<int32_t>(result[2]) << 010) +
static_cast<uint32_t>(result[1]); │ static_cast<int32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:870 │ json/tests/src/unit-bjdata.cpp:549
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
2147483648u, 3333333333u, 4294967295u │ 2147483648u, 3333333333u, 4294967295u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('m'); │ expected.push_back('m');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'm'); │ CHECK(result[0] == 'm');
uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) + │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
(static_cast<uint32_t>(result[3]) << 020) + │ (static_cast<uint32_t>(result[3]) << 020) +
(static_cast<uint32_t>(result[2]) << 010) + │ (static_cast<uint32_t>(result[2]) << 010) +
static_cast<uint32_t>(result[1]); │ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:870 │ json/tests/src/unit-bjdata.cpp:506
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
2147483648u, 3333333333u, 4294967295u │ 65536u, 77777u, 2147483647u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('m'); │ expected.push_back('l');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'm'); │ CHECK(result[0] == 'l');
uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) + │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
(static_cast<uint32_t>(result[3]) << 020) + │ (static_cast<uint32_t>(result[3]) << 020) +
(static_cast<uint32_t>(result[2]) << 010) + │ (static_cast<uint32_t>(result[2]) << 010) +
static_cast<uint32_t>(result[1]); │ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-reference_access.cpp:157 │ json/tests/src/unit-reference_access.cpp:53
│
using test_type = json::boolean_t; │ using test_type = json::object_t;
json value = false; │ json value = {{"one", 1}, {"two", 2}};
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_NOTHROW(value.get_ref<json::object_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::boolean_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:187 │ json/tests/src/unit-reference_access.cpp:53
│
using test_type = json::number_integer_t; │ using test_type = json::object_t;
json value = -23; │ json value = {{"one", 1}, {"two", 2}};
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_NOTHROW(value.get_ref<json::object_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::number_integer_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:187 │ json/tests/src/unit-reference_access.cpp:157
│
using test_type = json::number_integer_t; │ using test_type = json::boolean_t;
json value = -23; │ json value = false;
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_NOTHROW(value.get_ref<json::boolean_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
CHECK_NOTHROW(value.get_ref<json::number_integer_t&>()); │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:127 │ json/tests/src/unit-reference_access.cpp:53
│
using test_type = json::string_t; │ using test_type = json::object_t;
json value = "hello"; │ json value = {{"one", 1}, {"two", 2}};
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_NOTHROW(value.get_ref<json::object_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::string_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:127 │ json/tests/src/unit-reference_access.cpp:157
│
using test_type = json::string_t; │ using test_type = json::boolean_t;
json value = "hello"; │ json value = false;
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::string_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ "[json.exception.type_error.303] incompatible ReferenceType
"[json.exception.type_error.303] incompatible ReferenceType │ CHECK_NOTHROW(value.get_ref<json::boolean_t&>());
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:127 │ json/tests/src/unit-reference_access.cpp:187
│
using test_type = json::string_t; │ using test_type = json::number_integer_t;
json value = "hello"; │ json value = -23;
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::string_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_NOTHROW(value.get_ref<json::number_integer_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:97 │ json/tests/src/unit-reference_access.cpp:53
│
using test_type = json::array_t; │ using test_type = json::object_t;
json value = {1, 2, 3, 4}; │ json value = {{"one", 1}, {"two", 2}};
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_NOTHROW(value.get_ref<json::object_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
CHECK_NOTHROW(value.get_ref<json::array_t&>()); │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:97 │ json/tests/src/unit-reference_access.cpp:157
│
using test_type = json::array_t; │ using test_type = json::boolean_t;
json value = {1, 2, 3, 4}; │ json value = false;
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::array_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_NOTHROW(value.get_ref<json::boolean_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:97 │ json/tests/src/unit-reference_access.cpp:187
│
using test_type = json::array_t; │ using test_type = json::number_integer_t;
json value = {1, 2, 3, 4}; │ json value = -23;
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::array_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_NOTHROW(value.get_ref<json::number_integer_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:97 │ json/tests/src/unit-reference_access.cpp:127
│
using test_type = json::array_t; │ using test_type = json::string_t;
json value = {1, 2, 3, 4}; │ json value = "hello";
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::array_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ "[json.exception.type_error.303] incompatible ReferenceType
"[json.exception.type_error.303] incompatible ReferenceType │ CHECK_NOTHROW(value.get_ref<json::string_t&>());
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-bjdata.cpp:828 │ json/tests/src/unit-bjdata.cpp:234
│
for (uint32_t i : │ std::vector<int32_t> numbers;
{ │ numbers.push_back(-32769);
65536u, 77777u, 2147483647u │ numbers.push_back(-100000);
}) │ numbers.push_back(-1000000);
│ numbers.push_back(-10000000);
│ numbers.push_back(-100000000);
│ numbers.push_back(-1000000000);
│ numbers.push_back(-2147483647 - 1); // https://stackoverflow.com/a/2
│ for (auto i : numbers)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('l'); │ expected.push_back(static_cast<uint8_t>('l'));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'l'); │ CHECK(result[0] == 'l');
uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) + │ int32_t restored = (static_cast<int32_t>(result[4]) << 030) +
(static_cast<uint32_t>(result[3]) << 020) + │ (static_cast<int32_t>(result[3]) << 020) +
(static_cast<uint32_t>(result[2]) << 010) + │ (static_cast<int32_t>(result[2]) << 010) +
static_cast<uint32_t>(result[1]); │ static_cast<int32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:828 │ json/tests/src/unit-bjdata.cpp:549
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
65536u, 77777u, 2147483647u │ 2147483648u, 3333333333u, 4294967295u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('l'); │ expected.push_back('m');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'l'); │ CHECK(result[0] == 'm');
uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) + │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
(static_cast<uint32_t>(result[3]) << 020) + │ (static_cast<uint32_t>(result[3]) << 020) +
(static_cast<uint32_t>(result[2]) << 010) + │ (static_cast<uint32_t>(result[2]) << 010) +
static_cast<uint32_t>(result[1]); │ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:828 │ json/tests/src/unit-bjdata.cpp:506
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
65536u, 77777u, 2147483647u │ 65536u, 77777u, 2147483647u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('l'); │ expected.push_back('l');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'l'); │ CHECK(result[0] == 'l');
uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) + │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
(static_cast<uint32_t>(result[3]) << 020) + │ (static_cast<uint32_t>(result[3]) << 020) +
(static_cast<uint32_t>(result[2]) << 010) + │ (static_cast<uint32_t>(result[2]) << 010) +
static_cast<uint32_t>(result[1]); │ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:828 │ json/tests/src/unit-bjdata.cpp:870
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
65536u, 77777u, 2147483647u │ 2147483648u, 3333333333u, 4294967295u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('l'); │ expected.push_back('m');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'l'); │ CHECK(result[0] == 'm');
uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) + │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
(static_cast<uint32_t>(result[3]) << 020) + │ (static_cast<uint32_t>(result[3]) << 020) +
(static_cast<uint32_t>(result[2]) << 010) + │ (static_cast<uint32_t>(result[2]) << 010) +
static_cast<uint32_t>(result[1]); │ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:663 │ json/tests/src/unit-ubjson.cpp:234
│
for (uint32_t i : │ std::vector<int32_t> numbers;
{ │ numbers.push_back(-32769);
65536u, 77777u, 1048576u │ numbers.push_back(-100000);
}) │ numbers.push_back(-1000000);
│ numbers.push_back(-10000000);
│ numbers.push_back(-100000000);
│ numbers.push_back(-1000000000);
│ numbers.push_back(-2147483647 - 1); // https://stackoverflow.com/a/2
│ for (auto i : numbers)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('l'); │ expected.push_back(static_cast<uint8_t>('l'));
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'l'); │ CHECK(result[0] == 'l');
uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) + │ int32_t restored = (static_cast<int32_t>(result[1]) << 030) +
(static_cast<uint32_t>(result[2]) << 020) + │ (static_cast<int32_t>(result[2]) << 020) +
(static_cast<uint32_t>(result[3]) << 010) + │ (static_cast<int32_t>(result[3]) << 010) +
static_cast<uint32_t>(result[4]); │ static_cast<int32_t>(result[4]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:663 │ json/tests/src/unit-ubjson.cpp:468
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
65536u, 77777u, 1048576u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('l'); │ expected.push_back('l');
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'l'); │ CHECK(result[0] == 'l');
uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) + │ uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) +
(static_cast<uint32_t>(result[2]) << 020) + │ (static_cast<uint32_t>(result[2]) << 020) +
(static_cast<uint32_t>(result[3]) << 010) + │ (static_cast<uint32_t>(result[3]) << 010) +
static_cast<uint32_t>(result[4]); │ static_cast<uint32_t>(result[4]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:745 │ json/tests/src/unit-cbor.cpp:518
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
65536u, 77777u, 1048576u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0x1a); │ expected.push_back(0x1a);
expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 5); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0x1a); │ CHECK(result[0] == 0x1a);
uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) + │ uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) +
(static_cast<uint32_t>(result[2]) << 020) + │ (static_cast<uint32_t>(result[2]) << 020) +
(static_cast<uint32_t>(result[3]) << 010) + │ (static_cast<uint32_t>(result[3]) << 010) +
static_cast<uint32_t>(result[4]); │ static_cast<uint32_t>(result[4]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-reference_access.cpp:217 │ json/tests/src/unit-reference_access.cpp:53
│
using test_type = json::number_unsigned_t; │ using test_type = json::object_t;
json value = 23u; │ json value = {{"one", 1}, {"two", 2}};
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_NOTHROW(value.get_ref<json::object_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
//CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
// "[json.exception.type_error.303] incompatible ReferenceType for get_ref, a │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::number_unsigned_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), "[json.exception.ty │ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:217 │ json/tests/src/unit-reference_access.cpp:157
│
using test_type = json::number_unsigned_t; │ using test_type = json::boolean_t;
json value = 23u; │ json value = false;
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_NOTHROW(value.get_ref<json::boolean_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
//CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ "[json.exception.type_error.303] incompatible ReferenceType
// "[json.exception.type_error.303] incompatible ReferenceType for get_ref, a │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
CHECK_NOTHROW(value.get_ref<json::number_unsigned_t&>()); │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), "[json.exception.ty │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:217 │ json/tests/src/unit-reference_access.cpp:187
│
using test_type = json::number_unsigned_t; │ using test_type = json::number_integer_t;
json value = 23u; │ json value = -23;
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
//CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_NOTHROW(value.get_ref<json::number_integer_t&>());
// "[json.exception.type_error.303] incompatible ReferenceType for get_ref, a │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
CHECK_NOTHROW(value.get_ref<json::number_unsigned_t&>()); │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), "[json.exception.ty │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:217 │ json/tests/src/unit-reference_access.cpp:127
│
using test_type = json::number_unsigned_t; │ using test_type = json::string_t;
json value = 23u; │ json value = "hello";
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ CHECK_NOTHROW(value.get_ref<json::string_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
//CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
// "[json.exception.type_error.303] incompatible ReferenceType for get_ref, a │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::number_unsigned_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), "[json.exception.ty │ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:217 │ json/tests/src/unit-reference_access.cpp:97
│
using test_type = json::number_unsigned_t; │ using test_type = json::array_t;
json value = 23u; │ json value = {1, 2, 3, 4};
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), │ CHECK_NOTHROW(value.get_ref<json::array_t&>());
"[json.exception.type_error.303] incompatible ReferenceType │
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType │ "[json.exception.type_error.303] incompatible ReferenceType
//CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
// "[json.exception.type_error.303] incompatible ReferenceType for get_ref, a │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::number_unsigned_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), "[json.exception.ty │ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:246 │ json/tests/src/unit-reference_access.cpp:53
│
using test_type = json::number_float_t; │ using test_type = json::object_t;
json value = 42.23; │ json value = {{"one", 1}, {"two", 2}};
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), "[json.exception.type_err │ CHECK_NOTHROW(value.get_ref<json::object_t&>());
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), "[json.exception.type_erro │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), "[json.exception.type_err │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), "[json.exception.type_er │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), "[json.exception. │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), "[json.exception │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
CHECK_NOTHROW(value.get_ref<json::number_float_t&>()); │ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:246 │ json/tests/src/unit-reference_access.cpp:157
│
using test_type = json::number_float_t; │ using test_type = json::boolean_t;
json value = 42.23; │ json value = false;
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), "[json.exception.type_err │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), "[json.exception.type_erro │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), "[json.exception.type_err │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), "[json.exception.type_er │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), "[json.exception. │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), "[json.exception │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::number_float_t&>()); │ CHECK_NOTHROW(value.get_ref<json::boolean_t&>());
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:246 │ json/tests/src/unit-reference_access.cpp:187
│
using test_type = json::number_float_t; │ using test_type = json::number_integer_t;
json value = 42.23; │ json value = -23;
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), "[json.exception.type_err │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), "[json.exception.type_erro │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), "[json.exception.type_err │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), "[json.exception.type_er │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), "[json.exception. │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), "[json.exception │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::number_float_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_NOTHROW(value.get_ref<json::number_integer_t&>());
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:246 │ json/tests/src/unit-reference_access.cpp:127
│
using test_type = json::number_float_t; │ using test_type = json::string_t;
json value = 42.23; │ json value = "hello";
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), "[json.exception.type_err │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), "[json.exception.type_erro │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), "[json.exception.type_err │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), "[json.exception.type_er │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), "[json.exception. │ CHECK_NOTHROW(value.get_ref<json::string_t&>());
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), "[json.exception │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
CHECK_NOTHROW(value.get_ref<json::number_float_t&>()); │ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:246 │ json/tests/src/unit-reference_access.cpp:97
│
using test_type = json::number_float_t; │ using test_type = json::array_t;
json value = 42.23; │ json value = {1, 2, 3, 4};
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), "[json.exception.type_err │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), "[json.exception.type_erro │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), "[json.exception.type_err │ CHECK_NOTHROW(value.get_ref<json::array_t&>());
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), "[json.exception.type_er │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), "[json.exception. │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), "[json.exception │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
CHECK_NOTHROW(value.get_ref<json::number_float_t&>()); │ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
} │
next prev up json/tests/src/unit-reference_access.cpp:246 │ json/tests/src/unit-reference_access.cpp:217
│
using test_type = json::number_float_t; │ using test_type = json::number_unsigned_t;
json value = 42.23; │ json value = 23u;
│
// check if references are returned correctly │ // check if references are returned correctly
auto& p1 = value.get_ref<test_type&>(); │ auto& p1 = value.get_ref<test_type&>();
CHECK(&p1 == value.get_ptr<test_type*>()); │ CHECK(&p1 == value.get_ptr<test_type*>());
CHECK(p1 == value.get<test_type>()); │ CHECK(p1 == value.get<test_type>());
│
const auto& p2 = value.get_ref<const test_type&>(); │ const auto& p2 = value.get_ref<const test_type&>();
CHECK(&p2 == value.get_ptr<const test_type*>()); │ CHECK(&p2 == value.get_ptr<const test_type*>());
CHECK(p2 == value.get<test_type>()); │ CHECK(p2 == value.get<test_type>());
│
// check if mismatching references throw correctly │ // check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), "[json.exception.type_err │ CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), "[json.exception.type_erro │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), "[json.exception.type_err │ CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), "[json.exception.type_er │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), "[json.exception. │ CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), "[json.exception │ "[json.exception.type_error.303] incompatible ReferenceType
CHECK_NOTHROW(value.get_ref<json::number_float_t&>()); │ CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
│ "[json.exception.type_error.303] incompatible ReferenceType
│ //CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
│ // "[json.exception.type_error.303] incompatible ReferenceType for get_ref, a
│ CHECK_NOTHROW(value.get_ref<json::number_unsigned_t&>());
│ CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), "[json.exception.ty
} │
next prev up json/tests/src/unit-ubjson.cpp:1321 │ json/tests/src/unit-ubjson.cpp:1535
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::parse("[[[[]]]]"); │ json j = json::parse(R"({"a": {"b": {"c": {}}}})");
std::vector<uint8_t> expected = {'[', '[', '[', '[', ']', ']', ']', │ std::vector<uint8_t> expected =
│ {
│ '{', 'i', 1, 'a', '{', 'i', 1, 'b', '{', 'i', 1, 'c', '{', '}',
│ };
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::parse("[[[[]]]]"); │ json j = json::parse(R"({"a": {"b": {"c": {}}}})");
std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1, │ std::vector<uint8_t> expected =
│ {
│ '{', '#', 'i', 1, 'i', 1, 'a', '{', '#', 'i', 1, 'i', 1, 'b', '{
│ };
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::parse("[[[[]]]]"); │ json j = json::parse(R"({"a": {"b": {"c": {}}}})");
std::vector<uint8_t> expected = {'[', '$', '[', '#', 'i', 1, '$', '[ │ std::vector<uint8_t> expected =
│ {
│ '{', '$', '{', '#', 'i', 1, 'i', 1, 'a', '$', '{', '#', 'i', 1,
│ };
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/include/nlohmann/detail/json_pointer.hpp:509 │ json/include/nlohmann/detail/json_pointer.hpp:402
│
for (const auto& reference_token : reference_tokens) │ for (const auto& reference_token : reference_tokens)
{ │ {
switch (ptr->type()) │ switch (ptr->type())
{ │ {
case detail::value_t::object: │ case detail::value_t::object:
{ │ {
// note: at performs range check │ // note: at performs range check
ptr = &ptr->at(reference_token); │ ptr = &ptr->at(reference_token);
break; │ break;
} │ }
│
case detail::value_t::array: │ case detail::value_t::array:
{ │ {
if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) │ if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
{ │ {
// "-" always fails the range check │ // "-" always fails the range check
JSON_THROW(detail::out_of_range::create(402, detail::concat( │ JSON_THROW(detail::out_of_range::create(402, detail::concat(
"array index '-' (", std::to_string(ptr->m_value.array-> │ "array index '-' (", std::to_string(ptr->m_value.array->
") is out of range"), ptr)); │ ") is out of range"), ptr));
} │ }
│
// note: at performs range check │ // note: at performs range check
ptr = &ptr->at(array_index<BasicJsonType>(reference_token)); │ ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
break; │ break;
} │ }
│
case detail::value_t::null: │ case detail::value_t::null:
case detail::value_t::string: │ case detail::value_t::string:
case detail::value_t::boolean: │ case detail::value_t::boolean:
case detail::value_t::number_integer: │ case detail::value_t::number_integer:
case detail::value_t::number_unsigned: │ case detail::value_t::number_unsigned:
case detail::value_t::number_float: │ case detail::value_t::number_float:
case detail::value_t::binary: │ case detail::value_t::binary:
case detail::value_t::discarded: │ case detail::value_t::discarded:
default: │ default:
JSON_THROW(detail::out_of_range::create(404, detail::concat("unresol │ JSON_THROW(detail::out_of_range::create(404, detail::concat("unresol
} │ }
} │ }
│
return *ptr; │ return *ptr;
} │
next prev up json/tests/src/unit-ubjson.cpp:1282 │ json/tests/src/unit-ubjson.cpp:1535
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j = json::parse(R"({"a": {"b": {"c": {}}}})");
std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4 │ std::vector<uint8_t> expected =
│ {
│ '{', 'i', 1, 'a', '{', 'i', 1, 'b', '{', 'i', 1, 'c', '{', '}',
│ };
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j = json::parse(R"({"a": {"b": {"c": {}}}})");
std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, ' │ std::vector<uint8_t> expected =
│ {
│ '{', '#', 'i', 1, 'i', 1, 'a', '{', '#', 'i', 1, 'i', 1, 'b', '{
│ };
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j = json::parse(R"({"a": {"b": {"c": {}}}})");
std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3 │ std::vector<uint8_t> expected =
│ {
│ '{', '$', '{', '#', 'i', 1, 'i', 1, 'a', '$', '{', '#', 'i', 1,
│ };
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1282 │ json/tests/src/unit-ubjson.cpp:1360
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j(257, nullptr);
std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4 │ std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null
│ expected[0] = '['; // opening array
│ expected[258] = ']'; // closing array
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j(257, nullptr);
std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, ' │ std::vector<uint8_t> expected(j.size() + 5, 'Z'); // all null
│ expected[0] = '['; // opening array
│ expected[1] = '#'; // array size
│ expected[2] = 'I'; // int16
│ expected[3] = 0x01; // 0x0101, first byte
│ expected[4] = 0x01; // 0x0101, second byte
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j(257, nullptr);
std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3 │ std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'I', 0x01, 0x01
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1282 │ json/tests/src/unit-ubjson.cpp:1321
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4 │ std::vector<uint8_t> expected = {'[', '[', '[', '[', ']', ']', ']',
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, ' │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3 │ std::vector<uint8_t> expected = {'[', '$', '[', '#', 'i', 1, '$', '[
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1711 │ json/tests/src/unit-bjdata.cpp:1750
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4 │ std::vector<uint8_t> expected = {'[', '[', '[', '[', ']', ']', ']',
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, ' │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::parse("[1,2,3,4,5]"); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3 │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1030 │ json/tests/src/unit-ubjson.cpp:979
│
for (std::size_t N = 128; N <= 255; ++N) │ for (std::size_t N = 0; N <= 127; ++N)
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with byte array containing of N * 'x' │ // create JSON value with byte array containing of N * 'x'
const auto s = std::vector<std::uint8_t>(N, 'x'); │ const auto s = std::vector<std::uint8_t>(N, 'x');
json j = json::binary(s); │ json j = json::binary(s);
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<std::uint8_t> expected;
expected.push_back(static_cast<std::uint8_t>('[')); │ expected.push_back(static_cast<std::uint8_t>('['));
expected.push_back(static_cast<std::uint8_t>('$')); │ if (N != 0)
expected.push_back(static_cast<std::uint8_t>('U')); │ {
│ expected.push_back(static_cast<std::uint8_t>('$'));
│ expected.push_back(static_cast<std::uint8_t>('U'));
│ }
expected.push_back(static_cast<std::uint8_t>('#')); │ expected.push_back(static_cast<std::uint8_t>('#'));
expected.push_back(static_cast<std::uint8_t>('U')); │ expected.push_back(static_cast<std::uint8_t>('i'));
expected.push_back(static_cast<std::uint8_t>(N)); │ expected.push_back(static_cast<std::uint8_t>(N));
for (size_t i = 0; i < N; ++i) │ for (size_t i = 0; i < N; ++i)
{ │ {
expected.push_back(0x78); │ expected.push_back(0x78);
} │ }
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 6); │ if (N == 0)
│ {
│ CHECK(result.size() == N + 4);
│ }
│ else
│ {
│ CHECK(result.size() == N + 6);
│ }
│
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ if (N > 0)
│ {
│ CHECK(result.back() != '\x00');
│ }
│
// roundtrip only works to an array of numbers │ // roundtrip only works to an array of numbers
json j_out = s; │ json j_out = s;
CHECK(json::from_ubjson(result) == j_out); │ CHECK(json::from_ubjson(result) == j_out);
CHECK(json::from_ubjson(result, true, false) == j_out); │ CHECK(json::from_ubjson(result, true, false) == j_out);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1423 │ json/tests/src/unit-bjdata.cpp:1372
│
for (std::size_t N = 128; N <= 255; ++N) │ for (std::size_t N = 0; N <= 127; ++N)
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with byte array containing of N * 'x' │ // create JSON value with byte array containing of N * 'x'
const auto s = std::vector<std::uint8_t>(N, 'x'); │ const auto s = std::vector<std::uint8_t>(N, 'x');
json j = json::binary(s); │ json j = json::binary(s);
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<std::uint8_t> expected;
expected.push_back(static_cast<std::uint8_t>('[')); │ expected.push_back(static_cast<std::uint8_t>('['));
expected.push_back(static_cast<std::uint8_t>('$')); │ if (N != 0)
expected.push_back(static_cast<std::uint8_t>('U')); │ {
│ expected.push_back(static_cast<std::uint8_t>('$'));
│ expected.push_back(static_cast<std::uint8_t>('U'));
│ }
expected.push_back(static_cast<std::uint8_t>('#')); │ expected.push_back(static_cast<std::uint8_t>('#'));
expected.push_back(static_cast<std::uint8_t>('U')); │ expected.push_back(static_cast<std::uint8_t>('i'));
expected.push_back(static_cast<std::uint8_t>(N)); │ expected.push_back(static_cast<std::uint8_t>(N));
for (size_t i = 0; i < N; ++i) │ for (size_t i = 0; i < N; ++i)
{ │ {
expected.push_back(0x78); │ expected.push_back(0x78);
} │ }
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 6); │ if (N == 0)
│ {
│ CHECK(result.size() == N + 4);
│ }
│ else
│ {
│ CHECK(result.size() == N + 6);
│ }
│
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ if (N > 0)
│ {
│ CHECK(result.back() != '\x00');
│ }
│
// roundtrip only works to an array of numbers │ // roundtrip only works to an array of numbers
json j_out = s; │ json j_out = s;
CHECK(json::from_bjdata(result) == j_out); │ CHECK(json::from_bjdata(result) == j_out);
CHECK(json::from_bjdata(result, true, false) == j_out); │ CHECK(json::from_bjdata(result, true, false) == j_out);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:468 │ json/tests/src/unit-bjdata.cpp:549
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
32768u, 55555u, 65535u │ 2147483648u, 3333333333u, 4294967295u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = -1;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('u')); │ expected.push_back('m');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'u'); │ CHECK(result[0] == 'm');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
│ (static_cast<uint32_t>(result[3]) << 020) +
│ (static_cast<uint32_t>(result[2]) << 010) +
│ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:468 │ json/tests/src/unit-bjdata.cpp:506
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
32768u, 55555u, 65535u │ 65536u, 77777u, 2147483647u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = -1;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('u')); │ expected.push_back('l');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'u'); │ CHECK(result[0] == 'l');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
│ (static_cast<uint32_t>(result[3]) << 020) +
│ (static_cast<uint32_t>(result[2]) << 010) +
│ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:468 │ json/tests/src/unit-bjdata.cpp:870
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
32768u, 55555u, 65535u │ 2147483648u, 3333333333u, 4294967295u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = -1; │ json j = i;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('u')); │ expected.push_back('m');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'u'); │ CHECK(result[0] == 'm');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
│ (static_cast<uint32_t>(result[3]) << 020) +
│ (static_cast<uint32_t>(result[2]) << 010) +
│ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:468 │ json/tests/src/unit-bjdata.cpp:828
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
32768u, 55555u, 65535u │ 65536u, 77777u, 2147483647u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = -1; │ json j = i;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('u')); │ expected.push_back('l');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'u'); │ CHECK(result[0] == 'l');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
│ (static_cast<uint32_t>(result[3]) << 020) +
│ (static_cast<uint32_t>(result[2]) << 010) +
│ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/include/nlohmann/detail/json_pointer.hpp:460 │ json/include/nlohmann/detail/json_pointer.hpp:402
│
for (const auto& reference_token : reference_tokens) │ for (const auto& reference_token : reference_tokens)
{ │ {
switch (ptr->type()) │ switch (ptr->type())
{ │ {
case detail::value_t::object: │ case detail::value_t::object:
{ │ {
// use unchecked object access │ // note: at performs range check
ptr = &ptr->operator[](reference_token); │ ptr = &ptr->at(reference_token);
break; │ break;
} │ }
│
case detail::value_t::array: │ case detail::value_t::array:
{ │ {
if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) │ if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
{ │ {
// "-" cannot be used for const access │ // "-" always fails the range check
JSON_THROW(detail::out_of_range::create(402, detail::concat("arr │ JSON_THROW(detail::out_of_range::create(402, detail::concat(
│ "array index '-' (", std::to_string(ptr->m_value.array->
│ ") is out of range"), ptr));
} │ }
│
// use unchecked array access │ // note: at performs range check
ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token)); │ ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
break; │ break;
} │ }
│
case detail::value_t::null: │ case detail::value_t::null:
case detail::value_t::string: │ case detail::value_t::string:
case detail::value_t::boolean: │ case detail::value_t::boolean:
case detail::value_t::number_integer: │ case detail::value_t::number_integer:
case detail::value_t::number_unsigned: │ case detail::value_t::number_unsigned:
case detail::value_t::number_float: │ case detail::value_t::number_float:
case detail::value_t::binary: │ case detail::value_t::binary:
case detail::value_t::discarded: │ case detail::value_t::discarded:
default: │ default:
JSON_THROW(detail::out_of_range::create(404, detail::concat("unresol │ JSON_THROW(detail::out_of_range::create(404, detail::concat("unresol
} │ }
} │ }
│
return *ptr; │ return *ptr;
} │
next prev up json/include/nlohmann/detail/json_pointer.hpp:460 │ json/include/nlohmann/detail/json_pointer.hpp:509
│
for (const auto& reference_token : reference_tokens) │ for (const auto& reference_token : reference_tokens)
{ │ {
switch (ptr->type()) │ switch (ptr->type())
{ │ {
case detail::value_t::object: │ case detail::value_t::object:
{ │ {
// use unchecked object access │ // note: at performs range check
ptr = &ptr->operator[](reference_token); │ ptr = &ptr->at(reference_token);
break; │ break;
} │ }
│
case detail::value_t::array: │ case detail::value_t::array:
{ │ {
if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) │ if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
{ │ {
// "-" cannot be used for const access │ // "-" always fails the range check
JSON_THROW(detail::out_of_range::create(402, detail::concat("arr │ JSON_THROW(detail::out_of_range::create(402, detail::concat(
│ "array index '-' (", std::to_string(ptr->m_value.array->
│ ") is out of range"), ptr));
} │ }
│
// use unchecked array access │ // note: at performs range check
ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token)); │ ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
break; │ break;
} │ }
│
case detail::value_t::null: │ case detail::value_t::null:
case detail::value_t::string: │ case detail::value_t::string:
case detail::value_t::boolean: │ case detail::value_t::boolean:
case detail::value_t::number_integer: │ case detail::value_t::number_integer:
case detail::value_t::number_unsigned: │ case detail::value_t::number_unsigned:
case detail::value_t::number_float: │ case detail::value_t::number_float:
case detail::value_t::binary: │ case detail::value_t::binary:
case detail::value_t::discarded: │ case detail::value_t::discarded:
default: │ default:
JSON_THROW(detail::out_of_range::create(404, detail::concat("unresol │ JSON_THROW(detail::out_of_range::create(404, detail::concat("unresol
} │ }
} │ }
│
return *ptr; │ return *ptr;
} │
next prev up json/tests/src/unit-msgpack.cpp:1235 │ json/tests/src/unit-msgpack.cpp:1271
│
for (std::size_t N : │ for (std::size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::vector<uint8_t>(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = json::binary(s); │ json j = json::binary(s);
std::uint8_t subtype = 42; │ std::uint8_t subtype = 42;
j.get_binary().set_subtype(subtype); │ j.get_binary().set_subtype(subtype);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), subtype); │ expected.insert(expected.begin(), subtype);
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), 0xC8); │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
│ expected.insert(expected.begin(), 0xC9);
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 4); │ CHECK(result.size() == N + 6);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:1235 │ json/tests/src/unit-msgpack.cpp:1380
│
for (std::size_t N : │ for (std::size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::vector<uint8_t>(N, 'x'); │ const auto s = std::vector<std::uint8_t>(N, 'x');
json j = json::binary(s); │ json j = json::binary(s);
std::uint8_t subtype = 42; │
j.get_binary().set_subtype(subtype); │
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), subtype); │ expected.insert(expected.begin(), static_cast<std::uint8_t>(N & 0xff
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 8)
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 16
expected.insert(expected.begin(), 0xC8); │ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 24
│ expected.insert(expected.begin(), 0xC6);
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 4); │ CHECK(result.size() == N + 5);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/include/nlohmann/detail/output/binary_writer.hpp:217 │ json/include/nlohmann/detail/output/binary_writer.hpp:357
│
// step 1: write control byte and the string length │ // step 1: write control byte and the object size
const auto N = j.m_value.string->size(); │ const auto N = j.m_value.object->size();
if (N <= 0x17) │ if (N <= 0x17)
{ │ {
write_number(static_cast<std::uint8_t>(0x60 + N)); │ write_number(static_cast<std::uint8_t>(0xA0 + N));
} │ }
else if (N <= (std::numeric_limits<std::uint8_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint8_t>::max)())
{ │ {
oa->write_character(to_char_type(0x78)); │ oa->write_character(to_char_type(0xB8));
write_number(static_cast<std::uint8_t>(N)); │ write_number(static_cast<std::uint8_t>(N));
} │ }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint16_t>::max)())
{ │ {
oa->write_character(to_char_type(0x79)); │ oa->write_character(to_char_type(0xB9));
write_number(static_cast<std::uint16_t>(N)); │ write_number(static_cast<std::uint16_t>(N));
} │ }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint32_t>::max)())
{ │ {
oa->write_character(to_char_type(0x7A)); │ oa->write_character(to_char_type(0xBA));
write_number(static_cast<std::uint32_t>(N)); │ write_number(static_cast<std::uint32_t>(N));
} │ }
// LCOV_EXCL_START │ // LCOV_EXCL_START
else if (N <= (std::numeric_limits<std::uint64_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint64_t>::max)())
{ │ {
oa->write_character(to_char_type(0x7B)); │ oa->write_character(to_char_type(0xBB));
write_number(static_cast<std::uint64_t>(N)); │ write_number(static_cast<std::uint64_t>(N));
} │ }
// LCOV_EXCL_STOP │ // LCOV_EXCL_STOP
│
// step 2: write the string │ // step 2: write each element
oa->write_characters( │ for (const auto& el : *j.m_value.object)
reinterpret_cast<const CharType*>(j.m_value.string->c_str()), │ {
j.m_value.string->size()); │ write_cbor(el.first);
│ write_cbor(el.second);
│ }
break; │ break;
} │
next prev up json/tests/src/unit-msgpack.cpp:938 │ json/tests/src/unit-msgpack.cpp:1271
│
for (size_t N : │ for (std::size_t N :
{ │ {
65536u, 77777u, 1048576u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│ std::uint8_t subtype = 42;
│ j.get_binary().set_subtype(subtype);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
│ expected.insert(expected.begin(), subtype);
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0 │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0 │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
expected.insert(expected.begin(), 0xdb); │ expected.insert(expected.begin(), 0xC9);
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 5); │ CHECK(result.size() == N + 6);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:938 │ json/tests/src/unit-msgpack.cpp:1380
│
for (size_t N : │ for (std::size_t N :
{ │ {
65536u, 77777u, 1048576u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<std::uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<std::uint8_t>(N & 0xff
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 8)
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0 │ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 16
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0 │ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 24
expected.insert(expected.begin(), 0xdb); │ expected.insert(expected.begin(), 0xC6);
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 5); │ CHECK(result.size() == N + 5);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:938 │ json/tests/src/unit-msgpack.cpp:1235
│
for (size_t N : │ for (std::size_t N :
{ │ {
65536u, 77777u, 1048576u │ 256u, 999u, 1025u, 3333u, 2048u, 65535u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│ std::uint8_t subtype = 42;
│ j.get_binary().set_subtype(subtype);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
│ expected.insert(expected.begin(), subtype);
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0 │ expected.insert(expected.begin(), 0xC8);
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0 │
expected.insert(expected.begin(), 0xdb); │
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 5); │ CHECK(result.size() == N + 4);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-conversions.cpp:432 │ json/tests/src/unit-conversions.cpp:96
│
CHECK_THROWS_WITH_AS( │ CHECK_THROWS_WITH_AS(
json(json::value_t::null).get<json::string_t>(), │ json(json::value_t::null).get<json::object_t>(),
"[json.exception.type_error.302] type must be string, but is null", json │ "[json.exception.type_error.302] type must be object, but is null", json
CHECK_THROWS_WITH_AS( │ CHECK_THROWS_WITH_AS(
json(json::value_t::object).get<json::string_t>(), │ json(json::value_t::array).get<json::object_t>(),
"[json.exception.type_error.302] type must be string, but is object", js │ "[json.exception.type_error.302] type must be object, but is array", jso
CHECK_THROWS_WITH_AS( │ CHECK_THROWS_WITH_AS(
json(json::value_t::array).get<json::string_t>(), │ json(json::value_t::string).get<json::object_t>(),
"[json.exception.type_error.302] type must be string, but is array", jso │ "[json.exception.type_error.302] type must be object, but is string", js
CHECK_THROWS_WITH_AS(json(json::value_t::boolean).get<json::string_t>(), │ CHECK_THROWS_WITH_AS(json(json::value_t::boolean).get<json::object_t>(),
"[json.exception.type_error.302] type must be string, " │ "[json.exception.type_error.302] type must be object, "
"but is boolean", json::type_error&); │ "but is boolean", json::type_error&);
CHECK_THROWS_WITH_AS( │ CHECK_THROWS_WITH_AS(
json(json::value_t::number_integer).get<json::string_t>(), │ json(json::value_t::number_integer).get<json::object_t>(),
"[json.exception.type_error.302] type must be string, but is number", js │ "[json.exception.type_error.302] type must be object, but is number", js
CHECK_THROWS_WITH_AS( │ CHECK_THROWS_WITH_AS(
json(json::value_t::number_unsigned).get<json::string_t>(), │ json(json::value_t::number_unsigned).get<json::object_t>(),
"[json.exception.type_error.302] type must be string, but is number", js │ "[json.exception.type_error.302] type must be object, but is number", js
CHECK_THROWS_WITH_AS( │ CHECK_THROWS_WITH_AS(
json(json::value_t::number_float).get<json::string_t>(), │ json(json::value_t::number_float).get<json::object_t>(),
"[json.exception.type_error.302] type must be string, but is number", js │ "[json.exception.type_error.302] type must be object, but is number", js
} │
next prev up json/tests/src/unit-cbor.cpp:1192 │ json/tests/src/unit-cbor.cpp:1541
│
for (size_t N : │ for (size_t N :
{ │ {
65536u, 77777u, 1048576u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0 │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0 │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
expected.insert(expected.begin(), 0x7a); │ expected.insert(expected.begin(), 0x5a);
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 5); │ CHECK(result.size() == N + 5);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1496 │ json/tests/src/unit-ubjson.cpp:1360
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = {{"", nullptr}}; │ json j(257, nullptr);
std::vector<uint8_t> expected = {'{', 'i', 0, 'Z', '}'}; │ std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null
│ expected[0] = '['; // opening array
│ expected[258] = ']'; // closing array
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = {{"", nullptr}}; │ json j(257, nullptr);
std::vector<uint8_t> expected = {'{', '#', 'i', 1, 'i', 0, 'Z'}; │ std::vector<uint8_t> expected(j.size() + 5, 'Z'); // all null
│ expected[0] = '['; // opening array
│ expected[1] = '#'; // array size
│ expected[2] = 'I'; // int16
│ expected[3] = 0x01; // 0x0101, first byte
│ expected[4] = 0x01; // 0x0101, second byte
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = {{"", nullptr}}; │ json j(257, nullptr);
std::vector<uint8_t> expected = {'{', '$', 'Z', '#', 'i', 1, 'i', 0} │ std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'I', 0x01, 0x01
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1496 │ json/tests/src/unit-ubjson.cpp:1321
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = {{"", nullptr}}; │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'{', 'i', 0, 'Z', '}'}; │ std::vector<uint8_t> expected = {'[', '[', '[', '[', ']', ']', ']',
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = {{"", nullptr}}; │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'{', '#', 'i', 1, 'i', 0, 'Z'}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = {{"", nullptr}}; │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'{', '$', 'Z', '#', 'i', 1, 'i', 0} │ std::vector<uint8_t> expected = {'[', '$', '[', '#', 'i', 1, '$', '[
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1496 │ json/tests/src/unit-ubjson.cpp:1282
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = {{"", nullptr}}; │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'{', 'i', 0, 'Z', '}'}; │ std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = {{"", nullptr}}; │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'{', '#', 'i', 1, 'i', 0, 'Z'}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, '
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = {{"", nullptr}}; │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'{', '$', 'Z', '#', 'i', 1, 'i', 0} │ std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-conversions.cpp:458 │ json/tests/src/unit-conversions.cpp:432
│
CHECK_THROWS_WITH_AS(json(json::value_t::null).get<std::string_view>(), │ CHECK_THROWS_WITH_AS(
"[json.exception.type_error.302] type must be string, b │ json(json::value_t::null).get<json::string_t>(),
CHECK_THROWS_WITH_AS(json(json::value_t::object).get<std::string_view>(), │ "[json.exception.type_error.302] type must be string, but is null", json
"[json.exception.type_error.302] type must be string, b │ CHECK_THROWS_WITH_AS(
CHECK_THROWS_WITH_AS(json(json::value_t::array).get<std::string_view>(), │ json(json::value_t::object).get<json::string_t>(),
"[json.exception.type_error.302] type must be string, b │ "[json.exception.type_error.302] type must be string, but is object", js
CHECK_THROWS_WITH_AS(json(json::value_t::boolean).get<std::string_view>(), │ CHECK_THROWS_WITH_AS(
"[json.exception.type_error.302] type must be string, b │ json(json::value_t::array).get<json::string_t>(),
CHECK_THROWS_WITH_AS(json(json::value_t::number_integer).get<std::string_vie │ "[json.exception.type_error.302] type must be string, but is array", jso
"[json.exception.type_error.302] type must be string, b │ CHECK_THROWS_WITH_AS(json(json::value_t::boolean).get<json::string_t>(),
CHECK_THROWS_WITH_AS(json(json::value_t::number_unsigned).get<std::string_vi │ "[json.exception.type_error.302] type must be string, "
"[json.exception.type_error.302] type must be string, b │ "but is boolean", json::type_error&);
CHECK_THROWS_WITH_AS(json(json::value_t::number_float).get<std::string_view> │ CHECK_THROWS_WITH_AS(
"[json.exception.type_error.302] type must be string, b │ json(json::value_t::number_integer).get<json::string_t>(),
│ "[json.exception.type_error.302] type must be string, but is number", js
│ CHECK_THROWS_WITH_AS(
│ json(json::value_t::number_unsigned).get<json::string_t>(),
│ "[json.exception.type_error.302] type must be string, but is number", js
│ CHECK_THROWS_WITH_AS(
│ json(json::value_t::number_float).get<json::string_t>(),
│ "[json.exception.type_error.302] type must be string, but is number", js
} │
next prev up json/tests/src/unit-element_access2.cpp:685 │ json/tests/src/unit-element_access2.cpp:704
│
json j_nonobject(json::value_t::number_integer); │ json j_nonobject(json::value_t::number_unsigned);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:629 │ json/tests/src/unit-element_access2.cpp:704
│
json j_nonobject(json::value_t::boolean); │ json j_nonobject(json::value_t::number_unsigned);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:629 │ json/tests/src/unit-element_access2.cpp:685
│
json j_nonobject(json::value_t::boolean); │ json j_nonobject(json::value_t::number_integer);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:723 │ json/tests/src/unit-element_access2.cpp:704
│
json j_nonobject(json::value_t::number_float); │ json j_nonobject(json::value_t::number_unsigned);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:723 │ json/tests/src/unit-element_access2.cpp:685
│
json j_nonobject(json::value_t::number_float); │ json j_nonobject(json::value_t::number_integer);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:723 │ json/tests/src/unit-element_access2.cpp:629
│
json j_nonobject(json::value_t::number_float); │ json j_nonobject(json::value_t::boolean);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/include/nlohmann/detail/output/binary_writer.hpp:255 │ json/include/nlohmann/detail/output/binary_writer.hpp:357
│
// step 1: write control byte and the array size │ // step 1: write control byte and the object size
const auto N = j.m_value.array->size(); │ const auto N = j.m_value.object->size();
if (N <= 0x17) │ if (N <= 0x17)
{ │ {
write_number(static_cast<std::uint8_t>(0x80 + N)); │ write_number(static_cast<std::uint8_t>(0xA0 + N));
} │ }
else if (N <= (std::numeric_limits<std::uint8_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint8_t>::max)())
{ │ {
oa->write_character(to_char_type(0x98)); │ oa->write_character(to_char_type(0xB8));
write_number(static_cast<std::uint8_t>(N)); │ write_number(static_cast<std::uint8_t>(N));
} │ }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint16_t>::max)())
{ │ {
oa->write_character(to_char_type(0x99)); │ oa->write_character(to_char_type(0xB9));
write_number(static_cast<std::uint16_t>(N)); │ write_number(static_cast<std::uint16_t>(N));
} │ }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint32_t>::max)())
{ │ {
oa->write_character(to_char_type(0x9A)); │ oa->write_character(to_char_type(0xBA));
write_number(static_cast<std::uint32_t>(N)); │ write_number(static_cast<std::uint32_t>(N));
} │ }
// LCOV_EXCL_START │ // LCOV_EXCL_START
else if (N <= (std::numeric_limits<std::uint64_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint64_t>::max)())
{ │ {
oa->write_character(to_char_type(0x9B)); │ oa->write_character(to_char_type(0xBB));
write_number(static_cast<std::uint64_t>(N)); │ write_number(static_cast<std::uint64_t>(N));
} │ }
// LCOV_EXCL_STOP │ // LCOV_EXCL_STOP
│
// step 2: write each element │ // step 2: write each element
for (const auto& el : *j.m_value.array) │ for (const auto& el : *j.m_value.object)
{ │ {
write_cbor(el); │ write_cbor(el.first);
│ write_cbor(el.second);
} │ }
break; │ break;
} │
next prev up json/include/nlohmann/detail/output/binary_writer.hpp:255 │ json/include/nlohmann/detail/output/binary_writer.hpp:217
│
// step 1: write control byte and the array size │ // step 1: write control byte and the string length
const auto N = j.m_value.array->size(); │ const auto N = j.m_value.string->size();
if (N <= 0x17) │ if (N <= 0x17)
{ │ {
write_number(static_cast<std::uint8_t>(0x80 + N)); │ write_number(static_cast<std::uint8_t>(0x60 + N));
} │ }
else if (N <= (std::numeric_limits<std::uint8_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint8_t>::max)())
{ │ {
oa->write_character(to_char_type(0x98)); │ oa->write_character(to_char_type(0x78));
write_number(static_cast<std::uint8_t>(N)); │ write_number(static_cast<std::uint8_t>(N));
} │ }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint16_t>::max)())
{ │ {
oa->write_character(to_char_type(0x99)); │ oa->write_character(to_char_type(0x79));
write_number(static_cast<std::uint16_t>(N)); │ write_number(static_cast<std::uint16_t>(N));
} │ }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint32_t>::max)())
{ │ {
oa->write_character(to_char_type(0x9A)); │ oa->write_character(to_char_type(0x7A));
write_number(static_cast<std::uint32_t>(N)); │ write_number(static_cast<std::uint32_t>(N));
} │ }
// LCOV_EXCL_START │ // LCOV_EXCL_START
else if (N <= (std::numeric_limits<std::uint64_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint64_t>::max)())
{ │ {
oa->write_character(to_char_type(0x9B)); │ oa->write_character(to_char_type(0x7B));
write_number(static_cast<std::uint64_t>(N)); │ write_number(static_cast<std::uint64_t>(N));
} │ }
// LCOV_EXCL_STOP │ // LCOV_EXCL_STOP
│
// step 2: write each element │ // step 2: write the string
for (const auto& el : *j.m_value.array) │ oa->write_characters(
{ │ reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
write_cbor(el); │ j.m_value.string->size());
} │
break; │ break;
} │
next prev up json/tests/src/unit-element_access2.cpp:648 │ json/tests/src/unit-element_access2.cpp:704
│
json j_nonobject(json::value_t::string); │ json j_nonobject(json::value_t::number_unsigned);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:648 │ json/tests/src/unit-element_access2.cpp:685
│
json j_nonobject(json::value_t::string); │ json j_nonobject(json::value_t::number_integer);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:648 │ json/tests/src/unit-element_access2.cpp:629
│
json j_nonobject(json::value_t::string); │ json j_nonobject(json::value_t::boolean);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:648 │ json/tests/src/unit-element_access2.cpp:723
│
json j_nonobject(json::value_t::string); │ json j_nonobject(json::value_t::number_float);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-capacity.cpp:269 │ json/tests/src/unit-capacity.cpp:312
│
SECTION("empty array") │ SECTION("empty object")
{ │ {
json j = json::array(); │ json j = json::object();
const json j_const(j); │ const json j_const(j);
│
SECTION("result of size") │ SECTION("result of size")
{ │ {
CHECK(j.size() == 0); │ CHECK(j.size() == 0);
CHECK(j_const.size() == 0); │ CHECK(j_const.size() == 0);
} │ }
│
SECTION("definition of size") │ SECTION("definition of size")
{ │ {
CHECK(std::distance(j.begin(), j.end()) == j.size()); │ CHECK(std::distance(j.begin(), j.end()) == j.size());
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size( │ CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size(
CHECK(std::distance(j.rbegin(), j.rend()) == j.size()); │ CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.s │ CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.s
} │ }
} │ }
│
SECTION("filled array") │ SECTION("filled object")
{ │ {
json j = {1, 2, 3}; │ json j = {{"one", 1}, {"two", 2}, {"three", 3}};
const json j_const(j); │ const json j_const(j);
│
SECTION("result of size") │ SECTION("result of size")
{ │ {
CHECK(j.size() == 3); │ CHECK(j.size() == 3);
CHECK(j_const.size() == 3); │ CHECK(j_const.size() == 3);
} │ }
│
SECTION("definition of size") │ SECTION("definition of size")
{ │ {
CHECK(std::distance(j.begin(), j.end()) == j.size()); │ CHECK(std::distance(j.begin(), j.end()) == j.size());
CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size( │ CHECK(std::distance(j_const.begin(), j_const.end()) == j_const.size(
CHECK(std::distance(j.rbegin(), j.rend()) == j.size()); │ CHECK(std::distance(j.rbegin(), j.rend()) == j.size());
CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.s │ CHECK(std::distance(j_const.crbegin(), j_const.crend()) == j_const.s
} │ }
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:433 │ json/tests/src/unit-bjdata.cpp:549
│
for (size_t i = 256; i <= 32767; ++i) │ for (uint32_t i :
│ {
│ 2147483648u, 3333333333u, 4294967295u
│ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = -1;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('I')); │ expected.push_back('m');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'm');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
│ (static_cast<uint32_t>(result[3]) << 020) +
│ (static_cast<uint32_t>(result[2]) << 010) +
│ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:433 │ json/tests/src/unit-bjdata.cpp:506
│
for (size_t i = 256; i <= 32767; ++i) │ for (uint32_t i :
│ {
│ 65536u, 77777u, 2147483647u
│ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = -1;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('I')); │ expected.push_back('l');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'l');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
│ (static_cast<uint32_t>(result[3]) << 020) +
│ (static_cast<uint32_t>(result[2]) << 010) +
│ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:433 │ json/tests/src/unit-ubjson.cpp:468
│
for (size_t i = 256; i <= 32767; ++i) │ for (uint32_t i :
│ {
│ 65536u, 77777u, 1048576u
│ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = -1;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('I')); │ expected.push_back('l');
│ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'l');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) +
│ (static_cast<uint32_t>(result[2]) << 020) +
│ (static_cast<uint32_t>(result[3]) << 010) +
│ static_cast<uint32_t>(result[4]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:433 │ json/tests/src/unit-bjdata.cpp:468
│
for (size_t i = 256; i <= 32767; ++i) │ for (uint32_t i :
│ {
│ 32768u, 55555u, 65535u
│ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = -1;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('I')); │ expected.push_back(static_cast<uint8_t>('u'));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'u');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1067 │ json/tests/src/unit-ubjson.cpp:1104
│
for (std::size_t N : │ for (std::size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 32767u │ 32768u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with byte array containing of N * 'x' │ // create JSON value with byte array containing of N * 'x'
const auto s = std::vector<std::uint8_t>(N, 'x'); │ const auto s = std::vector<std::uint8_t>(N, 'x');
json j = json::binary(s); │ json j = json::binary(s);
│
// create expected byte vector │ // create expected byte vector
std::vector<std::uint8_t> expected(N + 7, 'x'); │ std::vector<std::uint8_t> expected(N + 9, 'x');
expected[0] = '['; │ expected[0] = '[';
expected[1] = '$'; │ expected[1] = '$';
expected[2] = 'U'; │ expected[2] = 'U';
expected[3] = '#'; │ expected[3] = '#';
expected[4] = 'I'; │ expected[4] = 'l';
expected[5] = static_cast<std::uint8_t>((N >> 8) & 0xFF); │ expected[5] = static_cast<std::uint8_t>((N >> 24) & 0xFF);
expected[6] = static_cast<std::uint8_t>(N & 0xFF); │ expected[6] = static_cast<std::uint8_t>((N >> 16) & 0xFF);
│ expected[7] = static_cast<std::uint8_t>((N >> 8) & 0xFF);
│ expected[8] = static_cast<std::uint8_t>(N & 0xFF);
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 7); │ CHECK(result.size() == N + 9);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip only works to an array of numbers │ // roundtrip only works to an array of numbers
json j_out = s; │ json j_out = s;
CHECK(json::from_ubjson(result) == j_out); │ CHECK(json::from_ubjson(result) == j_out);
CHECK(json::from_ubjson(result, true, false) == j_out); │ CHECK(json::from_ubjson(result, true, false) == j_out);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1460 │ json/tests/src/unit-bjdata.cpp:1534
│
for (std::size_t N : │ for (std::size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 32767u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with byte array containing of N * 'x' │ // create JSON value with byte array containing of N * 'x'
const auto s = std::vector<std::uint8_t>(N, 'x'); │ const auto s = std::vector<std::uint8_t>(N, 'x');
json j = json::binary(s); │ json j = json::binary(s);
│
// create expected byte vector │ // create expected byte vector
std::vector<std::uint8_t> expected(N + 7, 'x'); │ std::vector<std::uint8_t> expected(N + 9, 'x');
expected[0] = '['; │ expected[0] = '[';
expected[1] = '$'; │ expected[1] = '$';
expected[2] = 'U'; │ expected[2] = 'U';
expected[3] = '#'; │ expected[3] = '#';
expected[4] = 'I'; │ expected[4] = 'l';
expected[5] = static_cast<std::uint8_t>(N & 0xFF); │ expected[5] = static_cast<std::uint8_t>(N & 0xFF);
expected[6] = static_cast<std::uint8_t>((N >> 8) & 0xFF); │ expected[6] = static_cast<std::uint8_t>((N >> 8) & 0xFF);
│ expected[7] = static_cast<std::uint8_t>((N >> 16) & 0xFF);
│ expected[8] = static_cast<std::uint8_t>((N >> 24) & 0xFF);
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 7); │ CHECK(result.size() == N + 9);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip only works to an array of numbers │ // roundtrip only works to an array of numbers
json j_out = s; │ json j_out = s;
CHECK(json::from_bjdata(result) == j_out); │ CHECK(json::from_bjdata(result) == j_out);
CHECK(json::from_bjdata(result, true, false) == j_out); │ CHECK(json::from_bjdata(result, true, false) == j_out);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:483 │ json/tests/src/unit-cbor.cpp:305
│
for (size_t i = 256; i <= 65535; ++i) │ for (int32_t i = -65536; i <= -257; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = i;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(0x19)); │ expected.push_back(static_cast<uint8_t>(0x39));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ auto positive = static_cast<uint16_t>(-1 - i);
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>((positive >> 8) & 0xff))
│ expected.push_back(static_cast<uint8_t>(positive & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0x19); │ CHECK(result[0] == 0x39);
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == positive);
│ CHECK(-1 - restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1497 │ json/tests/src/unit-bjdata.cpp:1534
│
for (std::size_t N : │ for (std::size_t N :
{ │ {
32768u, 55555u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with byte array containing of N * 'x' │ // create JSON value with byte array containing of N * 'x'
const auto s = std::vector<std::uint8_t>(N, 'x'); │ const auto s = std::vector<std::uint8_t>(N, 'x');
json j = json::binary(s); │ json j = json::binary(s);
│
// create expected byte vector │ // create expected byte vector
std::vector<std::uint8_t> expected(N + 7, 'x'); │ std::vector<std::uint8_t> expected(N + 9, 'x');
expected[0] = '['; │ expected[0] = '[';
expected[1] = '$'; │ expected[1] = '$';
expected[2] = 'U'; │ expected[2] = 'U';
expected[3] = '#'; │ expected[3] = '#';
expected[4] = 'u'; │ expected[4] = 'l';
expected[5] = static_cast<std::uint8_t>(N & 0xFF); │ expected[5] = static_cast<std::uint8_t>(N & 0xFF);
expected[6] = static_cast<std::uint8_t>((N >> 8) & 0xFF); │ expected[6] = static_cast<std::uint8_t>((N >> 8) & 0xFF);
│ expected[7] = static_cast<std::uint8_t>((N >> 16) & 0xFF);
│ expected[8] = static_cast<std::uint8_t>((N >> 24) & 0xFF);
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 7); │ CHECK(result.size() == N + 9);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip only works to an array of numbers │ // roundtrip only works to an array of numbers
json j_out = s; │ json j_out = s;
CHECK(json::from_bjdata(result) == j_out); │ CHECK(json::from_bjdata(result) == j_out);
CHECK(json::from_bjdata(result, true, false) == j_out); │ CHECK(json::from_bjdata(result, true, false) == j_out);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1497 │ json/tests/src/unit-bjdata.cpp:1460
│
for (std::size_t N : │ for (std::size_t N :
{ │ {
32768u, 55555u, 65535u │ 256u, 999u, 1025u, 3333u, 2048u, 32767u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with byte array containing of N * 'x' │ // create JSON value with byte array containing of N * 'x'
const auto s = std::vector<std::uint8_t>(N, 'x'); │ const auto s = std::vector<std::uint8_t>(N, 'x');
json j = json::binary(s); │ json j = json::binary(s);
│
// create expected byte vector │ // create expected byte vector
std::vector<std::uint8_t> expected(N + 7, 'x'); │ std::vector<std::uint8_t> expected(N + 7, 'x');
expected[0] = '['; │ expected[0] = '[';
expected[1] = '$'; │ expected[1] = '$';
expected[2] = 'U'; │ expected[2] = 'U';
expected[3] = '#'; │ expected[3] = '#';
expected[4] = 'u'; │ expected[4] = 'I';
expected[5] = static_cast<std::uint8_t>(N & 0xFF); │ expected[5] = static_cast<std::uint8_t>(N & 0xFF);
expected[6] = static_cast<std::uint8_t>((N >> 8) & 0xFF); │ expected[6] = static_cast<std::uint8_t>((N >> 8) & 0xFF);
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 7); │ CHECK(result.size() == N + 7);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip only works to an array of numbers │ // roundtrip only works to an array of numbers
json j_out = s; │ json j_out = s;
CHECK(json::from_bjdata(result) == j_out); │ CHECK(json::from_bjdata(result) == j_out);
CHECK(json::from_bjdata(result, true, false) == j_out); │ CHECK(json::from_bjdata(result, true, false) == j_out);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:792 │ json/tests/src/unit-bjdata.cpp:549
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
32768u, 55555u, 65535u │ 2147483648u, 3333333333u, 4294967295u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('u'); │ expected.push_back('m');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'u'); │ CHECK(result[0] == 'm');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
│ (static_cast<uint32_t>(result[3]) << 020) +
│ (static_cast<uint32_t>(result[2]) << 010) +
│ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:792 │ json/tests/src/unit-bjdata.cpp:506
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
32768u, 55555u, 65535u │ 65536u, 77777u, 2147483647u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('u'); │ expected.push_back('l');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'u'); │ CHECK(result[0] == 'l');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
│ (static_cast<uint32_t>(result[3]) << 020) +
│ (static_cast<uint32_t>(result[2]) << 010) +
│ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1243 │ json/tests/src/unit-ubjson.cpp:1360
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = {nullptr}; │ json j(257, nullptr);
std::vector<uint8_t> expected = {'[', 'Z', ']'}; │ std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null
│ expected[0] = '['; // opening array
│ expected[258] = ']'; // closing array
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = {nullptr}; │ json j(257, nullptr);
std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'}; │ std::vector<uint8_t> expected(j.size() + 5, 'Z'); // all null
│ expected[0] = '['; // opening array
│ expected[1] = '#'; // array size
│ expected[2] = 'I'; // int16
│ expected[3] = 0x01; // 0x0101, first byte
│ expected[4] = 0x01; // 0x0101, second byte
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = {nullptr}; │ json j(257, nullptr);
std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'i', 1}; │ std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'I', 0x01, 0x01
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:792 │ json/tests/src/unit-bjdata.cpp:870
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
32768u, 55555u, 65535u │ 2147483648u, 3333333333u, 4294967295u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('u'); │ expected.push_back('m');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'u'); │ CHECK(result[0] == 'm');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
│ (static_cast<uint32_t>(result[3]) << 020) +
│ (static_cast<uint32_t>(result[2]) << 010) +
│ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:792 │ json/tests/src/unit-bjdata.cpp:828
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
32768u, 55555u, 65535u │ 65536u, 77777u, 2147483647u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('u'); │ expected.push_back('l');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 16) & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 24) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'u'); │ CHECK(result[0] == 'l');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[4]) << 030) +
│ (static_cast<uint32_t>(result[3]) << 020) +
│ (static_cast<uint32_t>(result[2]) << 010) +
│ static_cast<uint32_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1243 │ json/tests/src/unit-ubjson.cpp:1321
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = {nullptr}; │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', 'Z', ']'}; │ std::vector<uint8_t> expected = {'[', '[', '[', '[', ']', ']', ']',
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = {nullptr}; │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = {nullptr}; │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'i', 1}; │ std::vector<uint8_t> expected = {'[', '$', '[', '#', 'i', 1, '$', '[
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1243 │ json/tests/src/unit-ubjson.cpp:1282
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = {nullptr}; │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', 'Z', ']'}; │ std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = {nullptr}; │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, '
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = {nullptr}; │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'i', 1}; │ std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:792 │ json/tests/src/unit-bjdata.cpp:468
│
for (uint32_t i : │ for (uint32_t i :
{ │ {
32768u, 55555u, 65535u │ 32768u, 55555u, 65535u
}) │ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('u'); │ expected.push_back(static_cast<uint8_t>('u'));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'u'); │ CHECK(result[0] == 'u');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1243 │ json/tests/src/unit-ubjson.cpp:1496
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = {nullptr}; │ json j = {{"", nullptr}};
std::vector<uint8_t> expected = {'[', 'Z', ']'}; │ std::vector<uint8_t> expected = {'{', 'i', 0, 'Z', '}'};
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = {nullptr}; │ json j = {{"", nullptr}};
std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'}; │ std::vector<uint8_t> expected = {'{', '#', 'i', 1, 'i', 0, 'Z'};
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = {nullptr}; │ json j = {{"", nullptr}};
std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'i', 1}; │ std::vector<uint8_t> expected = {'{', '$', 'Z', '#', 'i', 1, 'i', 0}
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:792 │ json/tests/src/unit-bjdata.cpp:433
│
for (uint32_t i : │ for (size_t i = 256; i <= 32767; ++i)
{ │
32768u, 55555u, 65535u │
}) │
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('u'); │ expected.push_back(static_cast<uint8_t>('I'));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'u'); │ CHECK(result[0] == 'I');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:2548 │ json/tests/src/unit-cbor.cpp:2583
│
SECTION("success") │ SECTION("success")
{ │ {
// add tag to value │ // add tag to value
auto v_tagged = v; │ auto v_tagged = v;
v_tagged.insert(v_tagged.begin(), 0x42); // 1 byte │ v_tagged.insert(v_tagged.begin(), 0x42); // 1 byte
v_tagged.insert(v_tagged.begin(), 0x23); // 1 byte │ v_tagged.insert(v_tagged.begin(), 0x23); // 1 byte
v_tagged.insert(v_tagged.begin(), 0xD9); // tag │ v_tagged.insert(v_tagged.begin(), 0x22); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0x11); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0xDA); // tag
│
// check that parsing fails in error mode │ // check that parsing fails in error mode
json _; │ json _;
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error); │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han
│
// check that parsing succeeds and gets original value in ignore mode │ // check that parsing succeeds and gets original value in ignore mode
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler │ auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler
CHECK(j_tagged == j); │ CHECK(j_tagged == j);
} │ }
│
SECTION("missing byte after tag") │ SECTION("missing bytes after tag")
{ │ {
// add tag to value │ // add tag to value
auto v_tagged = v; │ auto v_tagged = v;
v_tagged.insert(v_tagged.begin(), 0x23); // 1 byte │ v_tagged.insert(v_tagged.begin(), 0x23); // 1 byte
v_tagged.insert(v_tagged.begin(), 0xD9); // tag │ v_tagged.insert(v_tagged.begin(), 0x22); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0x11); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0xDA); // tag
│
// check that parsing fails in all modes │ // check that parsing fails in all modes
json _; │ json _;
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error); │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1457 │ json/tests/src/unit-ubjson.cpp:1360
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::object(); │ json j(257, nullptr);
std::vector<uint8_t> expected = {'{', '}'}; │ std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null
│ expected[0] = '['; // opening array
│ expected[258] = ']'; // closing array
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::object(); │ json j(257, nullptr);
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected(j.size() + 5, 'Z'); // all null
│ expected[0] = '['; // opening array
│ expected[1] = '#'; // array size
│ expected[2] = 'I'; // int16
│ expected[3] = 0x01; // 0x0101, first byte
│ expected[4] = 0x01; // 0x0101, second byte
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::object(); │ json j(257, nullptr);
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'I', 0x01, 0x01
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1457 │ json/tests/src/unit-ubjson.cpp:1321
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::object(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'{', '}'}; │ std::vector<uint8_t> expected = {'[', '[', '[', '[', ']', ']', ']',
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::object(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::object(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '$', '[', '#', 'i', 1, '$', '[
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1672 │ json/tests/src/unit-bjdata.cpp:1750
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = {nullptr}; │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', 'Z', ']'}; │ std::vector<uint8_t> expected = {'[', '[', '[', '[', ']', ']', ']',
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = {nullptr}; │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = {nullptr}; │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1896 │ json/tests/src/unit-bjdata.cpp:1750
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::object(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'{', '}'}; │ std::vector<uint8_t> expected = {'[', '[', '[', '[', ']', ']', ']',
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::object(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::object(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1457 │ json/tests/src/unit-ubjson.cpp:1282
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::object(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'{', '}'}; │ std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::object(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, '
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::object(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1672 │ json/tests/src/unit-bjdata.cpp:1711
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = {nullptr}; │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', 'Z', ']'}; │ std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = {nullptr}; │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, '
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = {nullptr}; │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'}; │ std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1896 │ json/tests/src/unit-bjdata.cpp:1711
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::object(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'{', '}'}; │ std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::object(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, '
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::object(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1457 │ json/tests/src/unit-ubjson.cpp:1496
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::object(); │ json j = {{"", nullptr}};
std::vector<uint8_t> expected = {'{', '}'}; │ std::vector<uint8_t> expected = {'{', 'i', 0, 'Z', '}'};
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::object(); │ json j = {{"", nullptr}};
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'{', '#', 'i', 1, 'i', 0, 'Z'};
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::object(); │ json j = {{"", nullptr}};
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'{', '$', 'Z', '#', 'i', 1, 'i', 0}
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1457 │ json/tests/src/unit-ubjson.cpp:1243
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::object(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'{', '}'}; │ std::vector<uint8_t> expected = {'[', 'Z', ']'};
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::object(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'};
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::object(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'i', 1};
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1896 │ json/tests/src/unit-bjdata.cpp:1672
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::object(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'{', '}'}; │ std::vector<uint8_t> expected = {'[', 'Z', ']'};
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::object(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'};
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::object(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'{', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'};
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1204 │ json/tests/src/unit-ubjson.cpp:1360
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::array(); │ json j(257, nullptr);
std::vector<uint8_t> expected = {'[', ']'}; │ std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null
│ expected[0] = '['; // opening array
│ expected[258] = ']'; // closing array
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::array(); │ json j(257, nullptr);
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected(j.size() + 5, 'Z'); // all null
│ expected[0] = '['; // opening array
│ expected[1] = '#'; // array size
│ expected[2] = 'I'; // int16
│ expected[3] = 0x01; // 0x0101, first byte
│ expected[4] = 0x01; // 0x0101, second byte
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::array(); │ json j(257, nullptr);
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'I', 0x01, 0x01
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1204 │ json/tests/src/unit-ubjson.cpp:1321
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::array(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', ']'}; │ std::vector<uint8_t> expected = {'[', '[', '[', '[', ']', ']', ']',
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::array(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::array(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '$', '[', '#', 'i', 1, '$', '[
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1633 │ json/tests/src/unit-bjdata.cpp:1750
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::array(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', ']'}; │ std::vector<uint8_t> expected = {'[', '[', '[', '[', ']', ']', ']',
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::array(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::array(); │ json j = json::parse("[[[[]]]]");
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, '[', '#', 'i', 1,
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1204 │ json/tests/src/unit-ubjson.cpp:1282
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::array(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', ']'}; │ std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::array(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, '
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::array(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1633 │ json/tests/src/unit-bjdata.cpp:1711
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::array(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', ']'}; │ std::vector<uint8_t> expected = {'[', 'i', 1, 'i', 2, 'i', 3, 'i', 4
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::array(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 5, 'i', 1, 'i', 2, '
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::array(); │ json j = json::parse("[1,2,3,4,5]");
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '$', 'i', '#', 'i', 5, 1, 2, 3
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1204 │ json/tests/src/unit-ubjson.cpp:1496
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::array(); │ json j = {{"", nullptr}};
std::vector<uint8_t> expected = {'[', ']'}; │ std::vector<uint8_t> expected = {'{', 'i', 0, 'Z', '}'};
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::array(); │ json j = {{"", nullptr}};
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'{', '#', 'i', 1, 'i', 0, 'Z'};
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::array(); │ json j = {{"", nullptr}};
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'{', '$', 'Z', '#', 'i', 1, 'i', 0}
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1204 │ json/tests/src/unit-ubjson.cpp:1243
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::array(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'[', ']'}; │ std::vector<uint8_t> expected = {'[', 'Z', ']'};
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::array(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'};
const auto result = json::to_ubjson(j, true); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::array(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '$', 'Z', '#', 'i', 1};
const auto result = json::to_ubjson(j, true, true); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1204 │ json/tests/src/unit-ubjson.cpp:1457
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::array(); │ json j = json::object();
std::vector<uint8_t> expected = {'[', ']'}; │ std::vector<uint8_t> expected = {'{', '}'};
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::array(); │ json 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); │ const auto result = json::to_ubjson(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::array(); │ json 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); │ const auto result = json::to_ubjson(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1633 │ json/tests/src/unit-bjdata.cpp:1672
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::array(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'[', ']'}; │ std::vector<uint8_t> expected = {'[', 'Z', ']'};
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::array(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'};
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::array(); │ json j = {nullptr};
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'[', '#', 'i', 1, 'Z'};
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1633 │ json/tests/src/unit-bjdata.cpp:1896
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j = json::array(); │ json j = json::object();
std::vector<uint8_t> expected = {'[', ']'}; │ std::vector<uint8_t> expected = {'{', '}'};
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j = json::array(); │ json j = json::object();
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'{', '#', 'i', 0};
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=true") │ SECTION("size=true type=true")
{ │ {
json j = json::array(); │ json j = json::object();
std::vector<uint8_t> expected = {'[', '#', 'i', 0}; │ std::vector<uint8_t> expected = {'{', '#', 'i', 0};
const auto result = json::to_bjdata(j, true, true); │ const auto result = json::to_bjdata(j, true, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bson.cpp:669 │ json/tests/src/unit-cbor.cpp:44
│
class SaxCountdown │ class SaxCountdown
{ │ {
public: │ public:
explicit SaxCountdown(const int count) : events_left(count) │ explicit SaxCountdown(const int count) : events_left(count)
{} │ {}
│
bool null() │ bool null()
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool boolean(bool /*unused*/) │ bool boolean(bool /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool number_integer(json::number_integer_t /*unused*/) │ bool number_integer(json::number_integer_t /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool number_unsigned(json::number_unsigned_t /*unused*/) │ bool number_unsigned(json::number_unsigned_t /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool number_float(json::number_float_t /*unused*/, const std::string& /*unused*/) │ bool number_float(json::number_float_t /*unused*/, const std::string& /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool string(std::string& /*unused*/) │ bool string(std::string& /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool binary(std::vector<std::uint8_t>& /*unused*/) │ bool binary(std::vector<std::uint8_t>& /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool start_object(std::size_t /*unused*/) │ bool start_object(std::size_t /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool key(std::string& /*unused*/) │ bool key(std::string& /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool end_object() │ bool end_object()
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool start_array(std::size_t /*unused*/) │ bool start_array(std::size_t /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool end_array() │ bool end_array()
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json:: │ bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::
{ │ {
return false; │ return false;
} │ }
│
private: │ private:
int events_left = 0; │ int events_left = 0;
}; │ };
} │
next prev up json/tests/src/unit-bson.cpp:669 │ json/tests/src/unit-ubjson.cpp:42
│
class SaxCountdown │ class SaxCountdown
{ │ {
public: │ public:
explicit SaxCountdown(const int count) : events_left(count) │ explicit SaxCountdown(const int count) : events_left(count)
{} │ {}
│
bool null() │ bool null()
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool boolean(bool /*unused*/) │ bool boolean(bool /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool number_integer(json::number_integer_t /*unused*/) │ bool number_integer(json::number_integer_t /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool number_unsigned(json::number_unsigned_t /*unused*/) │ bool number_unsigned(json::number_unsigned_t /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool number_float(json::number_float_t /*unused*/, const std::string& /*unused*/) │ bool number_float(json::number_float_t /*unused*/, const std::string& /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool string(std::string& /*unused*/) │ bool string(std::string& /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool binary(std::vector<std::uint8_t>& /*unused*/) │ bool binary(std::vector<std::uint8_t>& /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool start_object(std::size_t /*unused*/) │ bool start_object(std::size_t /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool key(std::string& /*unused*/) │ bool key(std::string& /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool end_object() │ bool end_object()
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool start_array(std::size_t /*unused*/) │ bool start_array(std::size_t /*unused*/)
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool end_array() │ bool end_array()
{ │ {
return events_left-- > 0; │ return events_left-- > 0;
} │ }
│
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json:: │ bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::
{ │ {
return false; │ return false;
} │ }
│
private: │ private:
int events_left = 0; │ int events_left = 0;
}; │ };
} │
next prev up json/tests/src/unit-element_access2.cpp:667 │ json/tests/src/unit-element_access2.cpp:704
│
json j_nonobject(json::value_t::array); │ json j_nonobject(json::value_t::number_unsigned);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], " │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
│ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:667 │ json/tests/src/unit-element_access2.cpp:685
│
json j_nonobject(json::value_t::array); │ json j_nonobject(json::value_t::number_integer);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], " │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
│ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:667 │ json/tests/src/unit-element_access2.cpp:629
│
json j_nonobject(json::value_t::array); │ json j_nonobject(json::value_t::boolean);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], " │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
│ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:667 │ json/tests/src/unit-element_access2.cpp:723
│
json j_nonobject(json::value_t::array); │ json j_nonobject(json::value_t::number_float);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], " │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
│ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/src/unit-element_access2.cpp:667 │ json/tests/src/unit-element_access2.cpp:648
│
json j_nonobject(json::value_t::array); │ json j_nonobject(json::value_t::string);
const json j_const_nonobject(j_nonobject); │ const json j_const_nonobject(j_nonobject);
CHECK_THROWS_WITH_AS(j_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")], " │ CHECK_THROWS_WITH_AS(j_nonobject[json::object_t::key_type("foo")],
│ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject["foo"], │ CHECK_THROWS_WITH_AS(j_const_nonobject["foo"],
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo │ CHECK_THROWS_WITH_AS(j_const_nonobject[json::object_t::key_type("foo
"[json.exception.type_error.305] cannot use ope │ "[json.exception.type_error.305] cannot use ope
│
#ifdef JSON_HAS_CPP_17 │ #ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex │ CHECK_THROWS_WITH_AS(j_nonobject[std::string_view("foo")], "[json.ex
CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j │ CHECK_THROWS_WITH_AS(j_const_nonobject[std::string_view("foo")], "[j
#endif │ #endif
} │
next prev up json/tests/thirdparty/Fuzzer/test/FuzzerUnittest.cpp:230 │ json/tests/thirdparty/Fuzzer/test/FuzzerUnittest.cpp:150
│
std::unique_ptr<ExternalFunctions> t(new ExternalFunctions()); │ std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());
fuzzer::EF = t.get(); │ fuzzer::EF = t.get();
Random Rand(0); │ Random Rand(0);
MutationDispatcher MD(Rand, {}); │ MutationDispatcher MD(Rand, {});
int FoundMask = 0; │ int FoundMask = 0;
uint8_t CH0[8] = {0xF0, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; │ uint8_t INS0[8] = {0xF1, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
uint8_t CH1[8] = {0x00, 0xF1, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; │ uint8_t INS1[8] = {0x00, 0xF2, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
uint8_t CH2[8] = {0x00, 0x11, 0xF2, 0x33, 0x44, 0x55, 0x66, 0x77}; │ uint8_t INS2[8] = {0x00, 0x11, 0xF3, 0x22, 0x33, 0x44, 0x55, 0x66};
uint8_t CH3[8] = {0x00, 0x11, 0x22, 0xF3, 0x44, 0x55, 0x66, 0x77}; │ uint8_t INS3[8] = {0x00, 0x11, 0x22, 0xF4, 0x33, 0x44, 0x55, 0x66};
uint8_t CH4[8] = {0x00, 0x11, 0x22, 0x33, 0xF4, 0x55, 0x66, 0x77}; │ uint8_t INS4[8] = {0x00, 0x11, 0x22, 0x33, 0xF5, 0x44, 0x55, 0x66};
uint8_t CH5[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xF5, 0x66, 0x77}; │ uint8_t INS5[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xF6, 0x55, 0x66};
uint8_t CH6[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0xF5, 0x77}; │ uint8_t INS6[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0xF7, 0x66};
uint8_t CH7[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xF7}; │ uint8_t INS7[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xF8};
for (int i = 0; i < NumIter; i++) { │ for (int i = 0; i < NumIter; i++) {
uint8_t T[9] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; │ uint8_t T[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
size_t NewSize = (MD.*M)(T, 8, 9); │ size_t NewSize = (MD.*M)(T, 7, 8);
if (NewSize == 8 && !memcmp(CH0, T, 8)) FoundMask |= 1 << 0; │ if (NewSize == 8 && !memcmp(INS0, T, 8)) FoundMask |= 1 << 0;
if (NewSize == 8 && !memcmp(CH1, T, 8)) FoundMask |= 1 << 1; │ if (NewSize == 8 && !memcmp(INS1, T, 8)) FoundMask |= 1 << 1;
if (NewSize == 8 && !memcmp(CH2, T, 8)) FoundMask |= 1 << 2; │ if (NewSize == 8 && !memcmp(INS2, T, 8)) FoundMask |= 1 << 2;
if (NewSize == 8 && !memcmp(CH3, T, 8)) FoundMask |= 1 << 3; │ if (NewSize == 8 && !memcmp(INS3, T, 8)) FoundMask |= 1 << 3;
if (NewSize == 8 && !memcmp(CH4, T, 8)) FoundMask |= 1 << 4; │ if (NewSize == 8 && !memcmp(INS4, T, 8)) FoundMask |= 1 << 4;
if (NewSize == 8 && !memcmp(CH5, T, 8)) FoundMask |= 1 << 5; │ if (NewSize == 8 && !memcmp(INS5, T, 8)) FoundMask |= 1 << 5;
if (NewSize == 8 && !memcmp(CH6, T, 8)) FoundMask |= 1 << 6; │ if (NewSize == 8 && !memcmp(INS6, T, 8)) FoundMask |= 1 << 6;
if (NewSize == 8 && !memcmp(CH7, T, 8)) FoundMask |= 1 << 7; │ if (NewSize == 8 && !memcmp(INS7, T, 8)) FoundMask |= 1 << 7;
} │ }
EXPECT_EQ(FoundMask, 255); │ EXPECT_EQ(FoundMask, 255);
} │
next prev up json/tests/thirdparty/Fuzzer/test/FuzzerUnittest.cpp:266 │ json/tests/thirdparty/Fuzzer/test/FuzzerUnittest.cpp:230
│
std::unique_ptr<ExternalFunctions> t(new ExternalFunctions()); │ std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());
fuzzer::EF = t.get(); │ fuzzer::EF = t.get();
Random Rand(0); │ Random Rand(0);
MutationDispatcher MD(Rand, {}); │ MutationDispatcher MD(Rand, {});
int FoundMask = 0; │ int FoundMask = 0;
uint8_t CH0[8] = {0x01, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; │ uint8_t CH0[8] = {0xF0, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
uint8_t CH1[8] = {0x00, 0x13, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; │ uint8_t CH1[8] = {0x00, 0xF1, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
uint8_t CH2[8] = {0x00, 0x11, 0x02, 0x33, 0x44, 0x55, 0x66, 0x77}; │ uint8_t CH2[8] = {0x00, 0x11, 0xF2, 0x33, 0x44, 0x55, 0x66, 0x77};
uint8_t CH3[8] = {0x00, 0x11, 0x22, 0x37, 0x44, 0x55, 0x66, 0x77}; │ uint8_t CH3[8] = {0x00, 0x11, 0x22, 0xF3, 0x44, 0x55, 0x66, 0x77};
uint8_t CH4[8] = {0x00, 0x11, 0x22, 0x33, 0x54, 0x55, 0x66, 0x77}; │ uint8_t CH4[8] = {0x00, 0x11, 0x22, 0x33, 0xF4, 0x55, 0x66, 0x77};
uint8_t CH5[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x54, 0x66, 0x77}; │ uint8_t CH5[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xF5, 0x66, 0x77};
uint8_t CH6[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x76, 0x77}; │ uint8_t CH6[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0xF5, 0x77};
uint8_t CH7[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xF7}; │ uint8_t CH7[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xF7};
for (int i = 0; i < NumIter; i++) { │ for (int i = 0; i < NumIter; i++) {
uint8_t T[9] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; │ uint8_t T[9] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
size_t NewSize = (MD.*M)(T, 8, 9); │ size_t NewSize = (MD.*M)(T, 8, 9);
if (NewSize == 8 && !memcmp(CH0, T, 8)) FoundMask |= 1 << 0; │ if (NewSize == 8 && !memcmp(CH0, T, 8)) FoundMask |= 1 << 0;
if (NewSize == 8 && !memcmp(CH1, T, 8)) FoundMask |= 1 << 1; │ if (NewSize == 8 && !memcmp(CH1, T, 8)) FoundMask |= 1 << 1;
if (NewSize == 8 && !memcmp(CH2, T, 8)) FoundMask |= 1 << 2; │ if (NewSize == 8 && !memcmp(CH2, T, 8)) FoundMask |= 1 << 2;
if (NewSize == 8 && !memcmp(CH3, T, 8)) FoundMask |= 1 << 3; │ if (NewSize == 8 && !memcmp(CH3, T, 8)) FoundMask |= 1 << 3;
if (NewSize == 8 && !memcmp(CH4, T, 8)) FoundMask |= 1 << 4; │ if (NewSize == 8 && !memcmp(CH4, T, 8)) FoundMask |= 1 << 4;
if (NewSize == 8 && !memcmp(CH5, T, 8)) FoundMask |= 1 << 5; │ if (NewSize == 8 && !memcmp(CH5, T, 8)) FoundMask |= 1 << 5;
if (NewSize == 8 && !memcmp(CH6, T, 8)) FoundMask |= 1 << 6; │ if (NewSize == 8 && !memcmp(CH6, T, 8)) FoundMask |= 1 << 6;
if (NewSize == 8 && !memcmp(CH7, T, 8)) FoundMask |= 1 << 7; │ if (NewSize == 8 && !memcmp(CH7, T, 8)) FoundMask |= 1 << 7;
} │ }
EXPECT_EQ(FoundMask, 255); │ EXPECT_EQ(FoundMask, 255);
} │
next prev up json/tests/src/unit-cbor.cpp:307 │ json/tests/src/unit-cbor.cpp:266
│
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(0x39)); │ expected.push_back(static_cast<uint8_t>(0x3a));
auto positive = static_cast<uint16_t>(-1 - i); │ auto positive = static_cast<uint32_t>(static_cast<uint64_t>(-1 -
│ expected.push_back(static_cast<uint8_t>((positive >> 24) & 0xff)
│ expected.push_back(static_cast<uint8_t>((positive >> 16) & 0xff)
expected.push_back(static_cast<uint8_t>((positive >> 8) & 0xff)) │ expected.push_back(static_cast<uint8_t>((positive >> 8) & 0xff))
expected.push_back(static_cast<uint8_t>(positive & 0xff)); │ expected.push_back(static_cast<uint8_t>(positive & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 5);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0x39); │ CHECK(result[0] == 0x3a);
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ uint32_t restored = (static_cast<uint32_t>(result[1]) << 030) +
│ (static_cast<uint32_t>(result[2]) << 020) +
│ (static_cast<uint32_t>(result[3]) << 010) +
│ static_cast<uint32_t>(result[4]);
CHECK(restored == positive); │ CHECK(restored == positive);
CHECK(-1 - restored == i); │ CHECK(-1LL - restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │
next prev up json/tests/src/unit-ubjson.cpp:906 │ json/tests/src/unit-ubjson.cpp:940
│
for (size_t N : │ for (size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 32767u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::string(N, 'x');
json j = s; │ json j = s;
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), 'I'); │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
│ expected.insert(expected.begin(), 'l');
expected.insert(expected.begin(), 'S'); │ expected.insert(expected.begin(), 'S');
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 4); │ CHECK(result.size() == N + 6);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1264 │ json/tests/src/unit-bjdata.cpp:1332
│
for (size_t N : │ for (size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 32767u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::string(N, 'x');
json j = s; │ json j = s;
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), 'I'); │ expected.insert(expected.begin(), 'l');
expected.insert(expected.begin(), 'S'); │ expected.insert(expected.begin(), 'S');
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 4); │ CHECK(result.size() == N + 6);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-class_iterator.cpp:77 │ json/tests/src/unit-class_const_iterator.cpp:87
│
SECTION("set_begin") │ SECTION("set_begin")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j(json::value_t::null); │ json j(json::value_t::null);
json::iterator it(&j); │ json::const_iterator it(&j);
it.set_begin(); │ it.set_begin();
CHECK((it == j.begin())); │ CHECK((it == j.cbegin()));
} │ }
│
SECTION("object") │ SECTION("object")
{ │ {
json j(json::value_t::object); │ json j(json::value_t::object);
json::iterator it(&j); │ json::const_iterator it(&j);
it.set_begin(); │ it.set_begin();
CHECK((it == j.begin())); │ CHECK((it == j.cbegin()));
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j(json::value_t::array); │ json j(json::value_t::array);
json::iterator it(&j); │ json::const_iterator it(&j);
it.set_begin(); │ it.set_begin();
CHECK((it == j.begin())); │ CHECK((it == j.cbegin()));
} │ }
} │ }
│
SECTION("set_end") │ SECTION("set_end")
{ │ {
SECTION("null") │ SECTION("null")
{ │ {
json j(json::value_t::null); │ json j(json::value_t::null);
json::iterator it(&j); │ json::const_iterator it(&j);
it.set_end(); │ it.set_end();
CHECK((it == j.end())); │ CHECK((it == j.cend()));
} │ }
│
SECTION("object") │ SECTION("object")
{ │ {
json j(json::value_t::object); │ json j(json::value_t::object);
json::iterator it(&j); │ json::const_iterator it(&j);
it.set_end(); │ it.set_end();
CHECK((it == j.end())); │ CHECK((it == j.cend()));
} │ }
│
SECTION("array") │ SECTION("array")
{ │ {
json j(json::value_t::array); │ json j(json::value_t::array);
json::iterator it(&j); │ json::const_iterator it(&j);
it.set_end(); │ it.set_end();
CHECK((it == j.end())); │ CHECK((it == j.cend()));
} │ }
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:1347 │ json/tests/src/unit-msgpack.cpp:1380
│
for (std::size_t N : │ for (std::size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::vector<std::uint8_t>(N, 'x'); │ const auto s = std::vector<std::uint8_t>(N, 'x');
json j = json::binary(s); │ json j = json::binary(s);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<std::uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<std::uint8_t>(N & 0xff │ expected.insert(expected.begin(), static_cast<std::uint8_t>(N & 0xff
expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 8) │ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 8)
expected.insert(expected.begin(), 0xC5); │ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 16
│ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 24
│ expected.insert(expected.begin(), 0xC6);
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 5);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:1347 │ json/tests/src/unit-msgpack.cpp:938
│
for (std::size_t N : │ for (size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::vector<std::uint8_t>(N, 'x'); │ const auto s = std::string(N, 'x');
json j = json::binary(s); │ json j = s;
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<std::uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<std::uint8_t>(N & 0xff │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 8) │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), 0xC5); │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
│ expected.insert(expected.begin(), 0xdb);
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 5);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1823 │ json/tests/src/unit-bjdata.cpp:1857
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j(32768, nullptr); │ json j(65793, nullptr);
std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null │ std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null
expected[0] = '['; // opening array │ expected[0] = '['; // opening array
expected[32769] = ']'; // closing array │ expected[65794] = ']'; // closing array
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j(32768, nullptr); │ json j(65793, nullptr);
std::vector<uint8_t> expected(j.size() + 5, 'Z'); // all null │ std::vector<uint8_t> expected(j.size() + 7, 'Z'); // all null
expected[0] = '['; // opening array │ expected[0] = '['; // opening array
expected[1] = '#'; // array size │ expected[1] = '#'; // array size
expected[2] = 'u'; // int16 │ expected[2] = 'l'; // int32
expected[3] = 0x00; // 0x0101, first byte │ expected[3] = 0x01; // 0x00010101, fourth byte
expected[4] = 0x80; // 0x0101, second byte │ expected[4] = 0x01; // 0x00010101, third byte
│ expected[5] = 0x01; // 0x00010101, second byte
│ expected[6] = 0x00; // 0x00010101, first byte
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1298 │ json/tests/src/unit-bjdata.cpp:1332
│
for (size_t N : │ for (size_t N :
{ │ {
32768u, 55555u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::string(N, 'x');
json j = s; │ json j = s;
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), 'u'); │ expected.insert(expected.begin(), 'l');
expected.insert(expected.begin(), 'S'); │ expected.insert(expected.begin(), 'S');
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 4); │ CHECK(result.size() == N + 6);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1298 │ json/tests/src/unit-bjdata.cpp:1264
│
for (size_t N : │ for (size_t N :
{ │ {
32768u, 55555u, 65535u │ 256u, 999u, 1025u, 3333u, 2048u, 32767u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::string(N, 'x');
json j = s; │ json j = s;
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), 'u'); │ expected.insert(expected.begin(), 'I');
expected.insert(expected.begin(), 'S'); │ expected.insert(expected.begin(), 'S');
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 4); │ CHECK(result.size() == N + 4);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1789 │ json/tests/src/unit-bjdata.cpp:1857
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j(257, nullptr); │ json j(65793, nullptr);
std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null │ std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null
expected[0] = '['; // opening array │ expected[0] = '['; // opening array
expected[258] = ']'; // closing array │ expected[65794] = ']'; // closing array
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j(257, nullptr); │ json j(65793, nullptr);
std::vector<uint8_t> expected(j.size() + 5, 'Z'); // all null │ std::vector<uint8_t> expected(j.size() + 7, 'Z'); // all null
expected[0] = '['; // opening array │ expected[0] = '['; // opening array
expected[1] = '#'; // array size │ expected[1] = '#'; // array size
expected[2] = 'I'; // int16 │ expected[2] = 'l'; // int32
expected[3] = 0x01; // 0x0101, first byte │ expected[3] = 0x01; // 0x00010101, fourth byte
expected[4] = 0x01; // 0x0101, second byte │ expected[4] = 0x01; // 0x00010101, third byte
│ expected[5] = 0x01; // 0x00010101, second byte
│ expected[6] = 0x00; // 0x00010101, first byte
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1789 │ json/tests/src/unit-bjdata.cpp:1823
│
SECTION("size=false type=false") │ SECTION("size=false type=false")
{ │ {
json j(257, nullptr); │ json j(32768, nullptr);
std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null │ std::vector<uint8_t> expected(j.size() + 2, 'Z'); // all null
expected[0] = '['; // opening array │ expected[0] = '['; // opening array
expected[258] = ']'; // closing array │ expected[32769] = ']'; // closing array
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
│
SECTION("size=true type=false") │ SECTION("size=true type=false")
{ │ {
json j(257, nullptr); │ json j(32768, nullptr);
std::vector<uint8_t> expected(j.size() + 5, 'Z'); // all null │ std::vector<uint8_t> expected(j.size() + 5, 'Z'); // all null
expected[0] = '['; // opening array │ expected[0] = '['; // opening array
expected[1] = '#'; // array size │ expected[1] = '#'; // array size
expected[2] = 'I'; // int16 │ expected[2] = 'u'; // int16
expected[3] = 0x01; // 0x0101, first byte │ expected[3] = 0x00; // 0x0101, first byte
expected[4] = 0x01; // 0x0101, second byte │ expected[4] = 0x80; // 0x0101, second byte
const auto result = json::to_bjdata(j, true); │ const auto result = json::to_bjdata(j, true);
CHECK(result == expected); │ CHECK(result == expected);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:643 │ json/tests/src/unit-msgpack.cpp:271
│
for (size_t i = 256; i <= 65535; ++i) │ for (size_t i = 256; i <= 65535; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xcd); │ expected.push_back(0xcd);
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xcd); │ CHECK(result[0] == 0xcd);
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:1508 │ json/tests/src/unit-cbor.cpp:1541
│
for (size_t N : │ for (size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::vector<uint8_t>(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = json::binary(s); │ json j = json::binary(s);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), 0x59); │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
│ expected.insert(expected.begin(), 0x5a);
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 5);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:1508 │ json/tests/src/unit-cbor.cpp:1192
│
for (size_t N : │ for (size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::vector<uint8_t>(N, 'x'); │ const auto s = std::string(N, 'x');
json j = json::binary(s); │ json j = s;
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), 0x59); │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
│ expected.insert(expected.begin(), 0x7a);
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 5);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:758 │ json/tests/src/unit-bjdata.cpp:468
│
for (size_t i = 256; i <= 32767; ++i) │ for (uint32_t i :
│ {
│ 32768u, 55555u, 65535u
│ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('I'); │ expected.push_back(static_cast<uint8_t>('u'));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'u');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:629 │ json/tests/src/unit-ubjson.cpp:433
│
for (size_t i = 256; i <= 32767; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('I'); │ expected.push_back(static_cast<uint8_t>('I'));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'I');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:758 │ json/tests/src/unit-bjdata.cpp:433
│
for (size_t i = 256; i <= 32767; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('I'); │ expected.push_back(static_cast<uint8_t>('I'));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'I');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:758 │ json/tests/src/unit-bjdata.cpp:792
│
for (size_t i = 256; i <= 32767; ++i) │ for (uint32_t i :
│ {
│ 32768u, 55555u, 65535u
│ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('I'); │ expected.push_back('u');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'u');
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:711 │ json/tests/src/unit-cbor.cpp:305
│
for (size_t i = 256; i <= 65535; ++i) │ for (int32_t i = -65536; i <= -257; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0x19); │ expected.push_back(static_cast<uint8_t>(0x39));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ auto positive = static_cast<uint16_t>(-1 - i);
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>((positive >> 8) & 0xff))
│ expected.push_back(static_cast<uint8_t>(positive & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0x19); │ CHECK(result[0] == 0x39);
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == positive);
│ CHECK(-1 - restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:711 │ json/tests/src/unit-cbor.cpp:483
│
for (size_t i = 256; i <= 65535; ++i) │ for (size_t i = 256; i <= 65535; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0x19); │ expected.push_back(static_cast<uint8_t>(0x19));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0x19); │ CHECK(result[0] == 0x19);
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:905 │ json/tests/src/unit-msgpack.cpp:1271
│
for (size_t N : │ for (std::size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│ std::uint8_t subtype = 42;
│ j.get_binary().set_subtype(subtype);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
│ expected.insert(expected.begin(), subtype);
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), 0xda); │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
│ expected.insert(expected.begin(), 0xC9);
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 6);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:905 │ json/tests/src/unit-msgpack.cpp:1380
│
for (size_t N : │ for (std::size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<std::uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<std::uint8_t>(N & 0xff
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 8)
expected.insert(expected.begin(), 0xda); │ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 16
│ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 24
│ expected.insert(expected.begin(), 0xC6);
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 5);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:905 │ json/tests/src/unit-msgpack.cpp:1235
│
for (size_t N : │ for (std::size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 256u, 999u, 1025u, 3333u, 2048u, 65535u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│ std::uint8_t subtype = 42;
│ j.get_binary().set_subtype(subtype);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
│ expected.insert(expected.begin(), subtype);
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), 0xda); │ expected.insert(expected.begin(), 0xC8);
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 4);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:905 │ json/tests/src/unit-msgpack.cpp:938
│
for (size_t N : │ for (size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::string(N, 'x');
json j = s; │ json j = s;
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), 0xda); │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
│ expected.insert(expected.begin(), 0xdb);
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 5);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:905 │ json/tests/src/unit-msgpack.cpp:1347
│
for (size_t N : │ for (std::size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 256u, 999u, 1025u, 3333u, 2048u, 65535u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<std::uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<std::uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<std::uint8_t>(N & 0xff
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<std::uint8_t>((N >> 8)
expected.insert(expected.begin(), 0xda); │ expected.insert(expected.begin(), 0xC5);
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 3);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:448 │ json/tests/src/unit-msgpack.cpp:271
│
for (int16_t i = -32768; i <= static_cast<std::int16_t>(-129); ++i) │ for (size_t i = 256; i <= 65535; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xd1); │ expected.push_back(0xcd);
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xd1); │ CHECK(result[0] == 0xcd);
auto restored = static_cast<int16_t>((result[1] << 8) + result[2 │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:448 │ json/tests/src/unit-msgpack.cpp:643
│
for (int16_t i = -32768; i <= static_cast<std::int16_t>(-129); ++i) │ for (size_t i = 256; i <= 65535; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xd1); │ expected.push_back(0xcd);
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xd1); │ CHECK(result[0] == 0xcd);
auto restored = static_cast<int16_t>((result[1] << 8) + result[2 │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:1159 │ json/tests/src/unit-cbor.cpp:1541
│
for (size_t N : │ for (size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), 0x79); │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
│ expected.insert(expected.begin(), 0x5a);
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 5);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:1159 │ json/tests/src/unit-cbor.cpp:1192
│
for (size_t N : │ for (size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 65536u, 77777u, 1048576u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::string(N, 'x');
json j = s; │ json j = s;
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), 0x79); │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 16) & 0
│ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 24) & 0
│ expected.insert(expected.begin(), 0x7a);
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 5);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:1159 │ json/tests/src/unit-cbor.cpp:1508
│
for (size_t N : │ for (size_t N :
{ │ {
256u, 999u, 1025u, 3333u, 2048u, 65535u │ 256u, 999u, 1025u, 3333u, 2048u, 65535u
}) │ })
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│
// create expected byte vector (hack: create string first) │ // create expected byte vector (hack: create string first)
std::vector<uint8_t> expected(N, 'x'); │ std::vector<uint8_t> expected(N, 'x');
// reverse order of commands, because we insert at begin() │ // reverse order of commands, because we insert at begin()
expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff)); │ expected.insert(expected.begin(), static_cast<uint8_t>(N & 0xff));
expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x │ expected.insert(expected.begin(), static_cast<uint8_t>((N >> 8) & 0x
expected.insert(expected.begin(), 0x79); │ expected.insert(expected.begin(), 0x59);
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 3);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:281 │ json/tests/src/unit-bjdata.cpp:468
│
for (int32_t i = -32768; i <= -129; ++i) │ for (uint32_t i :
│ {
│ 32768u, 55555u, 65535u
│ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('I')); │ expected.push_back(static_cast<uint8_t>('u'));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'u');
auto restored = static_cast<int16_t>(((result[2] << 8) + result[ │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:281 │ json/tests/src/unit-ubjson.cpp:433
│
for (int32_t i = -32768; i <= -129; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('I')); │ expected.push_back(static_cast<uint8_t>('I'));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'I');
auto restored = static_cast<int16_t>(((result[1] << 8) + result[ │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:281 │ json/tests/src/unit-bjdata.cpp:433
│
for (int32_t i = -32768; i <= -129; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('I')); │ expected.push_back(static_cast<uint8_t>('I'));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'I');
auto restored = static_cast<int16_t>(((result[2] << 8) + result[ │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:281 │ json/tests/src/unit-bjdata.cpp:792
│
for (int32_t i = -32768; i <= -129; ++i) │ for (uint32_t i :
│ {
│ 32768u, 55555u, 65535u
│ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('I')); │ expected.push_back('u');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'u');
auto restored = static_cast<int16_t>(((result[2] << 8) + result[ │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:281 │ json/tests/src/unit-ubjson.cpp:629
│
for (int32_t i = -32768; i <= -129; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('I')); │ expected.push_back('I');
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'I');
auto restored = static_cast<int16_t>(((result[1] << 8) + result[ │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:281 │ json/tests/src/unit-bjdata.cpp:758
│
for (int32_t i = -32768; i <= -129; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('I')); │ expected.push_back('I');
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'I'); │ CHECK(result[0] == 'I');
auto restored = static_cast<int16_t>(((result[2] << 8) + result[ │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:2515 │ json/tests/src/unit-cbor.cpp:2583
│
SECTION("success") │ SECTION("success")
{ │ {
// add tag to value │ // add tag to value
auto v_tagged = v; │ auto v_tagged = v;
v_tagged.insert(v_tagged.begin(), 0x42); // 1 byte │ v_tagged.insert(v_tagged.begin(), 0x42); // 1 byte
v_tagged.insert(v_tagged.begin(), 0xD8); // tag │ v_tagged.insert(v_tagged.begin(), 0x23); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0x22); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0x11); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0xDA); // tag
│
// check that parsing fails in error mode │ // check that parsing fails in error mode
json _; │ json _;
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error); │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han
│
// check that parsing succeeds and gets original value in ignore mode │ // check that parsing succeeds and gets original value in ignore mode
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler │ auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler
CHECK(j_tagged == j); │ CHECK(j_tagged == j);
} │ }
│
SECTION("missing byte after tag") │ SECTION("missing bytes after tag")
{ │ {
// add tag to value │ // add tag to value
auto v_tagged = v; │ auto v_tagged = v;
v_tagged.insert(v_tagged.begin(), 0xD8); // tag │ v_tagged.insert(v_tagged.begin(), 0x23); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0x22); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0x11); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0xDA); // tag
│
// check that parsing fails in all modes │ // check that parsing fails in all modes
json _; │ json _;
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error); │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:2515 │ json/tests/src/unit-cbor.cpp:2548
│
SECTION("success") │ SECTION("success")
{ │ {
// add tag to value │ // add tag to value
auto v_tagged = v; │ auto v_tagged = v;
v_tagged.insert(v_tagged.begin(), 0x42); // 1 byte │ v_tagged.insert(v_tagged.begin(), 0x42); // 1 byte
v_tagged.insert(v_tagged.begin(), 0xD8); // tag │ v_tagged.insert(v_tagged.begin(), 0x23); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0xD9); // tag
│
// check that parsing fails in error mode │ // check that parsing fails in error mode
json _; │ json _;
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error); │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han
│
// check that parsing succeeds and gets original value in ignore mode │ // check that parsing succeeds and gets original value in ignore mode
auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler │ auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler
CHECK(j_tagged == j); │ CHECK(j_tagged == j);
} │ }
│
SECTION("missing byte after tag") │ SECTION("missing byte after tag")
{ │ {
// add tag to value │ // add tag to value
auto v_tagged = v; │ auto v_tagged = v;
v_tagged.insert(v_tagged.begin(), 0xD8); // tag │ v_tagged.insert(v_tagged.begin(), 0x23); // 1 byte
│ v_tagged.insert(v_tagged.begin(), 0xD9); // tag
│
// check that parsing fails in all modes │ // check that parsing fails in all modes
json _; │ json _;
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error); │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han
CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han │ CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_han
} │ }
} │
next prev up json/tests/src/unit-conversions.cpp:1108 │ json/tests/src/unit-conversions.cpp:845
│
CHECK_THROWS_WITH_AS( │ CHECK_THROWS_WITH_AS(
json(json::value_t::null).get<json::number_float_t>(), │ json(json::value_t::null).get<json::number_integer_t>(),
"[json.exception.type_error.302] type must be number, but is null", json │ "[json.exception.type_error.302] type must be number, but is null", json
CHECK_THROWS_WITH_AS( │ CHECK_THROWS_WITH_AS(
json(json::value_t::object).get<json::number_float_t>(), │ json(json::value_t::object).get<json::number_integer_t>(),
"[json.exception.type_error.302] type must be number, but is object", js │ "[json.exception.type_error.302] type must be number, but is object", js
CHECK_THROWS_WITH_AS( │ CHECK_THROWS_WITH_AS(
json(json::value_t::array).get<json::number_float_t>(), │ json(json::value_t::array).get<json::number_integer_t>(),
"[json.exception.type_error.302] type must be number, but is array", jso │ "[json.exception.type_error.302] type must be number, but is array", jso
CHECK_THROWS_WITH_AS( │ CHECK_THROWS_WITH_AS(
json(json::value_t::string).get<json::number_float_t>(), │ json(json::value_t::string).get<json::number_integer_t>(),
"[json.exception.type_error.302] type must be number, but is string", js │ "[json.exception.type_error.302] type must be number, but is string", js
CHECK_THROWS_WITH_AS( │ CHECK_THROWS_WITH_AS(
json(json::value_t::boolean).get<json::number_float_t>(), │ json(json::value_t::boolean).get<json::number_integer_t>(),
"[json.exception.type_error.302] type must be number, but is " │ "[json.exception.type_error.302] type must be number, but is "
"boolean", json::type_error&); │ "boolean", json::type_error&);
│
CHECK_NOTHROW( │ CHECK_NOTHROW(
json(json::value_t::number_integer).get<json::number_float_t>()); │ json(json::value_t::number_float).get<json::number_integer_t>());
CHECK_NOTHROW( │ CHECK_NOTHROW(
json(json::value_t::number_unsigned).get<json::number_float_t>()); │ json(json::value_t::number_float).get<json::number_unsigned_t>());
} │
next prev up json/tests/src/unit-pointer_access.cpp:473 │ json/tests/src/unit-pointer_access.cpp:444
│
using test_type = const json::binary_t; │ using test_type = const json::binary_t;
const json value = json::binary({}); │ const json value = json::binary({1, 2, 3});
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<const json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<const json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<const json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<const json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<const json::binary_t*>() != nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() != nullptr);
} │
next prev up json/tests/src/unit-bson.cpp:1090 │ json/tests/src/unit-bson.cpp:1145
│
│
CAPTURE(i) │ CAPTURE(i)
│
json j = │ json j =
{ │ {
{ "entry", i } │ { "entry", i }
}; │ };
│
auto iu = i; │ auto iu = i;
std::vector<std::uint8_t> expected_bson = │ std::vector<std::uint8_t> expected_bson =
{ │ {
0x10u, 0x00u, 0x00u, 0x00u, // size (little endian) │ 0x14u, 0x00u, 0x00u, 0x00u, // size (little endian)
0x10u, /// entry: int32 │ 0x12u, /// entry: int64
'e', 'n', 't', 'r', 'y', '\x00', │ 'e', 'n', 't', 'r', 'y', '\x00',
static_cast<std::uint8_t>((iu >> (8u * 0u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 0u)) & 0xffu),
static_cast<std::uint8_t>((iu >> (8u * 1u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 1u)) & 0xffu),
static_cast<std::uint8_t>((iu >> (8u * 2u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 2u)) & 0xffu),
static_cast<std::uint8_t>((iu >> (8u * 3u)) & 0xffu), │ static_cast<std::uint8_t>((iu >> (8u * 3u)) & 0xffu),
│ static_cast<std::uint8_t>((iu >> (8u * 4u)) & 0xffu),
│ static_cast<std::uint8_t>((iu >> (8u * 5u)) & 0xffu),
│ static_cast<std::uint8_t>((iu >> (8u * 6u)) & 0xffu),
│ static_cast<std::uint8_t>((iu >> (8u * 7u)) & 0xffu),
0x00u // end marker │ 0x00u // end marker
}; │ };
│
const auto bson = json::to_bson(j); │ const auto bson = json::to_bson(j);
CHECK(bson == expected_bson); │ CHECK(bson == expected_bson);
│
auto j_roundtrip = json::from_bson(bson); │ auto j_roundtrip = json::from_bson(bson);
│
CHECK(j.at("entry").is_number_unsigned()); │ CHECK(j.at("entry").is_number_unsigned());
CHECK(j_roundtrip.at("entry").is_number_integer()); │ CHECK(j_roundtrip.at("entry").is_number_integer());
CHECK(j_roundtrip == j); │ CHECK(j_roundtrip == j);
CHECK(json::from_bson(bson, true, false) == j); │ CHECK(json::from_bson(bson, true, false) == j);
│
} │
next prev up json/tests/src/unit-pointer_access.cpp:357 │ json/tests/src/unit-pointer_access.cpp:415
│
using test_type = const json::number_unsigned_t; │ using test_type = const json::number_float_t;
const json value = 23u; │ const json value = 42.23;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == Approx(value.get<test_type>()));
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == Approx(value.get<test_type>()));
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == Approx(value.get<test_type>()));
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<const json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<const json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<const json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<const json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_unsigned_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() != nullptr);
CHECK(value.get_ptr<const json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:125 │ json/tests/src/unit-pointer_access.cpp:444
│
using test_type = const json::array_t; │ using test_type = const json::binary_t;
const json value = {1, 2, 3, 4}; │ const json value = json::binary({1, 2, 3});
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<const json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<const json::array_t*>() != nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<const json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<const json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<const json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() != nullptr);
} │
next prev up json/tests/src/unit-cbor.cpp:612 │ json/tests/src/unit-cbor.cpp:483
│
for (int16_t i = -32768; i <= static_cast<std::int16_t>(-129); ++i) │ for (size_t i = 256; i <= 65535; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xd1); │ expected.push_back(static_cast<uint8_t>(0x19));
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xd1); │ CHECK(result[0] == 0x19);
auto restored = static_cast<int16_t>((result[1] << 8) + result[2 │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_cbor(result) == j);
│ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:612 │ json/tests/src/unit-cbor.cpp:711
│
for (int16_t i = -32768; i <= static_cast<std::int16_t>(-129); ++i) │ for (size_t i = 256; i <= 65535; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xd1); │ expected.push_back(0x19);
expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
expected.push_back(static_cast<uint8_t>(i & 0xff)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 3); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xd1); │ CHECK(result[0] == 0x19);
auto restored = static_cast<int16_t>((result[1] << 8) + result[2 │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_cbor(result) == j);
│ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-pointer_access.cpp:299 │ json/tests/src/unit-pointer_access.cpp:415
│
using test_type = const json::number_integer_t; │ using test_type = const json::number_float_t;
const json value = 23; │ const json value = 42.23;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == Approx(value.get<test_type>()));
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == Approx(value.get<test_type>()));
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == Approx(value.get<test_type>()));
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<const json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<const json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<const json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<const json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() != nullptr);
CHECK(value.get_ptr<const json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:299 │ json/tests/src/unit-pointer_access.cpp:357
│
using test_type = const json::number_integer_t; │ using test_type = const json::number_unsigned_t;
const json value = 23; │ const json value = 23u;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<const json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<const json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<const json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<const json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() != nullptr);
CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() != nullptr);
CHECK(value.get_ptr<const json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<const json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:299 │ json/tests/src/unit-pointer_access.cpp:125
│
using test_type = const json::number_integer_t; │ using test_type = const json::array_t;
const json value = 23; │ const json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<const json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<const json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() != nullptr);
CHECK(value.get_ptr<const json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<const json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<const json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:183 │ json/tests/src/unit-pointer_access.cpp:125
│
using test_type = const json::string_t; │ using test_type = const json::array_t;
const json value = "hello"; │ const json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<const json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<const json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() != nullptr);
CHECK(value.get_ptr<const json::string_t*>() != nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<const json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<const json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<const json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-ubjson.cpp:367 │ json/tests/src/unit-ubjson.cpp:400
│
for (size_t i = 0; i <= 127; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = -1;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('i')); │ expected.push_back(static_cast<uint8_t>('U'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'U');
CHECK(result[1] == i); │ CHECK(result[1] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:367 │ json/tests/src/unit-bjdata.cpp:400
│
for (size_t i = 0; i <= 127; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = -1;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>('i')); │ expected.push_back(static_cast<uint8_t>('U'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'U');
CHECK(result[1] == i); │ CHECK(result[1] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:1379 │ json/tests/src/unit-cbor.cpp:1408
│
json j; │ json j;
for (auto i = 0; i < 256; ++i) │ for (auto i = 0; i < 65536; ++i)
{ │ {
// format i to a fixed width of 5 │ // format i to a fixed width of 5
// each entry will need 7 bytes: 6 for string, 1 for null │ // each entry will need 7 bytes: 6 for string, 1 for null
std::stringstream ss; │ std::stringstream ss;
ss << std::setw(5) << std::setfill('0') << i; │ ss << std::setw(5) << std::setfill('0') << i;
j.emplace(ss.str(), nullptr); │ j.emplace(ss.str(), nullptr);
} │ }
│
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
│
// Checking against an expected vector byte by byte is │ // Checking against an expected vector byte by byte is
// difficult, because no assumption on the order of key/value │ // difficult, because no assumption on the order of key/value
// pairs are made. We therefore only check the prefix (type and │ // pairs are made. We therefore only check the prefix (type and
// size and the overall size. The rest is then handled in the │ // size and the overall size. The rest is then handled in the
// roundtrip check. │ // roundtrip check.
CHECK(result.size() == 1795); // 1 type, 2 size, 256*7 content │ CHECK(result.size() == 458757); // 1 type, 4 size, 65536*7 content
CHECK(result[0] == 0xb9); // map 16 bit │ CHECK(result[0] == 0xba); // map 32 bit
CHECK(result[1] == 0x01); // byte 0 of size (0x0100) │ CHECK(result[1] == 0x00); // byte 0 of size (0x00010000)
CHECK(result[2] == 0x00); // byte 1 of size (0x0100) │ CHECK(result[2] == 0x01); // byte 1 of size (0x00010000)
│ CHECK(result[3] == 0x00); // byte 2 of size (0x00010000)
│ CHECK(result[4] == 0x00); // byte 3 of size (0x00010000)
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │
next prev up json/tests/src/unit-pointer_access.cpp:386 │ json/tests/src/unit-pointer_access.cpp:415
│
using test_type = json::number_float_t; │ using test_type = const json::number_float_t;
json value = 42.23; │ const json value = 42.23;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == Approx(value.get<test_type>())); │ CHECK(*p1 == Approx(value.get<test_type>()));
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == Approx(value.get<test_type>())); │ CHECK(*p2 == Approx(value.get<test_type>()));
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == Approx(value.get<test_type>())); │ CHECK(*p3 == Approx(value.get<test_type>()));
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() != nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:386 │ json/tests/src/unit-pointer_access.cpp:357
│
using test_type = json::number_float_t; │ using test_type = const json::number_unsigned_t;
json value = 42.23; │ const json value = 23u;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == Approx(value.get<test_type>())); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == Approx(value.get<test_type>())); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == Approx(value.get<test_type>())); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() != nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() != nullptr);
CHECK(value.get_ptr<json::number_float_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:386 │ json/tests/src/unit-pointer_access.cpp:125
│
using test_type = json::number_float_t; │ using test_type = const json::array_t;
json value = 42.23; │ const json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == Approx(value.get<test_type>())); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == Approx(value.get<test_type>())); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == Approx(value.get<test_type>())); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() != nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:386 │ json/tests/src/unit-pointer_access.cpp:299
│
using test_type = json::number_float_t; │ using test_type = const json::number_integer_t;
json value = 42.23; │ const json value = 23;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == Approx(value.get<test_type>())); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == Approx(value.get<test_type>())); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == Approx(value.get<test_type>())); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() != nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:386 │ json/tests/src/unit-pointer_access.cpp:183
│
using test_type = json::number_float_t; │ using test_type = const json::string_t;
json value = 42.23; │ const json value = "hello";
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == Approx(value.get<test_type>())); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == Approx(value.get<test_type>())); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == Approx(value.get<test_type>())); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() != nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-bjdata.cpp:2659 │ json/tests/src/unit-bjdata.cpp:2635
│
std::vector<uint8_t> vST = {'[', '$', 'i', '#', 'i', 2, 1}; │ std::vector<uint8_t> v0 = {'[', '$'};
json _; │ json _;
CHECK_THROWS_AS(_ = json::from_bjdata(vST), json::parse_error&); │ CHECK_THROWS_AS(_ = json::from_bjdata(v0), json::parse_error&);
CHECK_THROWS_WITH(_ = json::from_bjdata(vST), "[json.exception.parse_error.1 │ CHECK_THROWS_WITH(_ = json::from_bjdata(v0), "[json.exception.parse_error.11
CHECK(json::from_bjdata(vST, true, false).is_discarded()); │ CHECK(json::from_bjdata(v0, true, false).is_discarded());
│
std::vector<uint8_t> vS = {'[', '#', 'i', 2, 'i', 1}; │ std::vector<uint8_t> vi = {'[', '$', '#'};
CHECK_THROWS_AS(_ = json::from_bjdata(vS), json::parse_error&); │ CHECK_THROWS_AS(_ = json::from_bjdata(vi), json::parse_error&);
CHECK_THROWS_WITH(_ = json::from_bjdata(vS), "[json.exception.parse_error.11 │ CHECK_THROWS_WITH(_ = json::from_bjdata(vi), "[json.exception.parse_error.11
CHECK(json::from_bjdata(vS, true, false).is_discarded()); │ CHECK(json::from_bjdata(vi, true, false).is_discarded());
│
std::vector<uint8_t> v = {'[', 'i', 2, 'i', 1}; │ std::vector<uint8_t> vU = {'[', '$', 'U'};
CHECK_THROWS_AS(_ = json::from_bjdata(v), json::parse_error&); │ CHECK_THROWS_AS(_ = json::from_bjdata(vU), json::parse_error&);
CHECK_THROWS_WITH(_ = json::from_bjdata(v), "[json.exception.parse_error.110 │ CHECK_THROWS_WITH(_ = json::from_bjdata(vU), "[json.exception.parse_error.11
CHECK(json::from_bjdata(v, true, false).is_discarded()); │ CHECK(json::from_bjdata(vU, true, false).is_discarded());
│
│ std::vector<uint8_t> v1 = {'[', '$', '['};
│ CHECK_THROWS_AS(_ = json::from_bjdata(v1), json::parse_error&);
│ CHECK_THROWS_WITH(_ = json::from_bjdata(v1), "[json.exception.parse_error.11
│ CHECK(json::from_bjdata(v1, true, false).is_discarded());
} │
next prev up json/tests/src/unit-pointer_access.cpp:38 │ json/tests/src/unit-pointer_access.cpp:67
│
using test_type = json::object_t; │ using test_type = const json::object_t;
json value = {{"one", 1}, {"two", 2}}; │ const json value = {{"one", 1}, {"two", 2}};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() != nullptr); │ CHECK(value.get_ptr<const json::object_t*>() != nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:38 │ json/tests/src/unit-pointer_access.cpp:125
│
using test_type = json::object_t; │ using test_type = const json::array_t;
json value = {{"one", 1}, {"two", 2}}; │ const json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() != nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() != nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:38 │ json/tests/src/unit-pointer_access.cpp:183
│
using test_type = json::object_t; │ using test_type = const json::string_t;
json value = {{"one", 1}, {"two", 2}}; │ const json value = "hello";
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() != nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() != nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-msgpack.cpp:610 │ json/tests/src/unit-msgpack.cpp:237
│
for (size_t i = 128; i <= 255; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xcc); │ expected.push_back(0xcc);
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xcc); │ CHECK(result[0] == 0xcc);
auto restored = static_cast<uint8_t>(result[1]); │ auto restored = static_cast<uint8_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-pointer_access.cpp:328 │ json/tests/src/unit-pointer_access.cpp:415
│
using test_type = json::number_unsigned_t; │ using test_type = const json::number_float_t;
json value = 23u; │ const json value = 42.23;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == Approx(value.get<test_type>()));
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == Approx(value.get<test_type>()));
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == Approx(value.get<test_type>()));
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() != nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:328 │ json/tests/src/unit-pointer_access.cpp:357
│
using test_type = json::number_unsigned_t; │ using test_type = const json::number_unsigned_t;
json value = 23u; │ const json value = 23u;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() != nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() != nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:328 │ json/tests/src/unit-pointer_access.cpp:125
│
using test_type = json::number_unsigned_t; │ using test_type = const json::array_t;
json value = 23u; │ const json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() != nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:328 │ json/tests/src/unit-pointer_access.cpp:299
│
using test_type = json::number_unsigned_t; │ using test_type = const json::number_integer_t;
json value = 23u; │ const json value = 23;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() != nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:328 │ json/tests/src/unit-pointer_access.cpp:183
│
using test_type = json::number_unsigned_t; │ using test_type = const json::string_t;
json value = 23u; │ const json value = "hello";
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() != nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:328 │ json/tests/src/unit-pointer_access.cpp:386
│
using test_type = json::number_unsigned_t; │ using test_type = json::number_float_t;
json value = 23u; │ json value = 42.23;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == Approx(value.get<test_type>()));
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == Approx(value.get<test_type>()));
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == Approx(value.get<test_type>()));
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() != nullptr); │ CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_float_t*>() != nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-ubjson.cpp:596 │ json/tests/src/unit-ubjson.cpp:629
│
for (size_t i = 128; i <= 255; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('U'); │ expected.push_back('I');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'U'); │ CHECK(result[0] == 'I');
auto restored = static_cast<uint8_t>(result[1]); │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:725 │ json/tests/src/unit-bjdata.cpp:758
│
for (size_t i = 128; i <= 255; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('U'); │ expected.push_back('I');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'U'); │ CHECK(result[0] == 'I');
auto restored = static_cast<uint8_t>(result[1]); │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-pointer_access.cpp:96 │ json/tests/src/unit-pointer_access.cpp:444
│
using test_type = json::array_t; │ using test_type = const json::binary_t;
json value = {1, 2, 3, 4}; │ const json value = json::binary({1, 2, 3});
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() != nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() != nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:96 │ json/tests/src/unit-pointer_access.cpp:125
│
using test_type = json::array_t; │ using test_type = const json::array_t;
json value = {1, 2, 3, 4}; │ const json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() != nullptr); │ CHECK(value.get_ptr<const json::array_t*>() != nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:96 │ json/tests/src/unit-pointer_access.cpp:183
│
using test_type = json::array_t; │ using test_type = const json::string_t;
json value = {1, 2, 3, 4}; │ const json value = "hello";
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() != nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() != nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-ubjson.cpp:596 │ json/tests/src/unit-ubjson.cpp:400
│
for (size_t i = 128; i <= 255; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('U'); │ expected.push_back(static_cast<uint8_t>('U'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'U'); │ CHECK(result[0] == 'U');
auto restored = static_cast<uint8_t>(result[1]); │ CHECK(result[1] == i);
CHECK(restored == i); │
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:725 │ json/tests/src/unit-bjdata.cpp:400
│
for (size_t i = 128; i <= 255; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('U'); │ expected.push_back(static_cast<uint8_t>('U'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'U'); │ CHECK(result[0] == 'U');
auto restored = static_cast<uint8_t>(result[1]); │ CHECK(result[1] == i);
CHECK(restored == i); │
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:596 │ json/tests/src/unit-ubjson.cpp:367
│
for (size_t i = 128; i <= 255; ++i) │ for (size_t i = 0; i <= 127; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('U'); │ expected.push_back(static_cast<uint8_t>('i'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'U'); │ CHECK(result[0] == 'i');
auto restored = static_cast<uint8_t>(result[1]); │ CHECK(result[1] == i);
CHECK(restored == i); │
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:725 │ json/tests/src/unit-bjdata.cpp:367
│
for (size_t i = 128; i <= 255; ++i) │ for (size_t i = 0; i <= 127; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('U'); │ expected.push_back(static_cast<uint8_t>('i'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'U'); │ CHECK(result[0] == 'i');
auto restored = static_cast<uint8_t>(result[1]); │ CHECK(result[1] == i);
CHECK(restored == i); │
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-pointer_access.cpp:270 │ json/tests/src/unit-pointer_access.cpp:415
│
using test_type = json::number_integer_t; │ using test_type = const json::number_float_t;
json value = 23; │ const json value = 42.23;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == Approx(value.get<test_type>()));
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == Approx(value.get<test_type>()));
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == Approx(value.get<test_type>()));
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() != nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:270 │ json/tests/src/unit-pointer_access.cpp:357
│
using test_type = json::number_integer_t; │ using test_type = const json::number_unsigned_t;
json value = 23; │ const json value = 23u;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() != nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() != nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:270 │ json/tests/src/unit-pointer_access.cpp:125
│
using test_type = json::number_integer_t; │ using test_type = const json::array_t;
json value = 23; │ const json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() != nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:270 │ json/tests/src/unit-pointer_access.cpp:299
│
using test_type = json::number_integer_t; │ using test_type = const json::number_integer_t;
json value = 23; │ const json value = 23;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() != nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:270 │ json/tests/src/unit-pointer_access.cpp:183
│
using test_type = json::number_integer_t; │ using test_type = const json::string_t;
json value = 23; │ const json value = "hello";
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() != nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:270 │ json/tests/src/unit-pointer_access.cpp:386
│
using test_type = json::number_integer_t; │ using test_type = json::number_float_t;
json value = 23; │ json value = 42.23;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == Approx(value.get<test_type>()));
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == Approx(value.get<test_type>()));
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == Approx(value.get<test_type>()));
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_float_t*>() != nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:270 │ json/tests/src/unit-pointer_access.cpp:328
│
using test_type = json::number_integer_t; │ using test_type = json::number_unsigned_t;
json value = 23; │ json value = 23u;
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<json::number_integer_t*>() != nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_unsigned_t*>() != nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:270 │ json/tests/src/unit-pointer_access.cpp:96
│
using test_type = json::number_integer_t; │ using test_type = json::array_t;
json value = 23; │ json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<json::array_t*>() != nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() != nullptr); │ CHECK(value.get_ptr<json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-ubjson.cpp:563 │ json/tests/src/unit-ubjson.cpp:629
│
for (size_t i = 0; i <= 127; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back('I');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'I');
auto restored = static_cast<uint8_t>(result[1]); │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:692 │ json/tests/src/unit-bjdata.cpp:758
│
for (size_t i = 0; i <= 127; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back('I');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'I');
auto restored = static_cast<uint8_t>(result[1]); │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:563 │ json/tests/src/unit-ubjson.cpp:400
│
for (size_t i = 0; i <= 127; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back(static_cast<uint8_t>('U'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'U');
auto restored = static_cast<uint8_t>(result[1]); │ CHECK(result[1] == i);
CHECK(restored == i); │
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:692 │ json/tests/src/unit-bjdata.cpp:400
│
for (size_t i = 0; i <= 127; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back(static_cast<uint8_t>('U'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'U');
auto restored = static_cast<uint8_t>(result[1]); │ CHECK(result[1] == i);
CHECK(restored == i); │
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:563 │ json/tests/src/unit-ubjson.cpp:367
│
for (size_t i = 0; i <= 127; ++i) │ for (size_t i = 0; i <= 127; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back(static_cast<uint8_t>('i'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'i');
auto restored = static_cast<uint8_t>(result[1]); │ CHECK(result[1] == i);
CHECK(restored == i); │
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:692 │ json/tests/src/unit-bjdata.cpp:367
│
for (size_t i = 0; i <= 127; ++i) │ for (size_t i = 0; i <= 127; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back(static_cast<uint8_t>('i'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'i');
auto restored = static_cast<uint8_t>(result[1]); │ CHECK(result[1] == i);
CHECK(restored == i); │
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:563 │ json/tests/src/unit-ubjson.cpp:596
│
for (size_t i = 0; i <= 127; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back('U');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'U');
auto restored = static_cast<uint8_t>(result[1]); │ auto restored = static_cast<uint8_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:692 │ json/tests/src/unit-bjdata.cpp:725
│
for (size_t i = 0; i <= 127; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back('U');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'U');
auto restored = static_cast<uint8_t>(result[1]); │ auto restored = static_cast<uint8_t>(result[1]);
CHECK(restored == i); │ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-pointer_access.cpp:154 │ json/tests/src/unit-pointer_access.cpp:125
│
using test_type = json::string_t; │ using test_type = const json::array_t;
json value = "hello"; │ const json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() != nullptr);
CHECK(value.get_ptr<json::string_t*>() != nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:154 │ json/tests/src/unit-pointer_access.cpp:183
│
using test_type = json::string_t; │ using test_type = const json::string_t;
json value = "hello"; │ const json value = "hello";
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() != nullptr); │ CHECK(value.get_ptr<const json::string_t*>() != nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:154 │ json/tests/src/unit-pointer_access.cpp:96
│
using test_type = json::string_t; │ using test_type = json::array_t;
json value = "hello"; │ json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<json::array_t*>() != nullptr);
CHECK(value.get_ptr<json::string_t*>() != nullptr); │ CHECK(value.get_ptr<json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() == nullptr); │ CHECK(value.get_ptr<json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:212 │ json/tests/src/unit-pointer_access.cpp:125
│
using test_type = json::boolean_t; │ using test_type = const json::array_t;
json value = false; │ const json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() != nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() != nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:212 │ json/tests/src/unit-pointer_access.cpp:183
│
using test_type = json::boolean_t; │ using test_type = const json::string_t;
json value = false; │ const json value = "hello";
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<const json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<const json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<const json::string_t*>() != nullptr);
CHECK(value.get_ptr<json::boolean_t*>() != nullptr); │ CHECK(value.get_ptr<const json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<const json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<const json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-cbor.cpp:678 │ json/tests/src/unit-cbor.cpp:450
│
for (size_t i = 24; i <= 255; ++i) │ for (size_t i = 24; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0x18); │ expected.push_back(static_cast<uint8_t>(0x18));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0x18); │ CHECK(result[0] == 0x18);
auto restored = static_cast<uint8_t>(result[1]); │ CHECK(result[1] == i);
CHECK(restored == i); │
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-pointer_access.cpp:212 │ json/tests/src/unit-pointer_access.cpp:96
│
using test_type = json::boolean_t; │ using test_type = json::array_t;
json value = false; │ json value = {1, 2, 3, 4};
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<json::array_t*>() != nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<json::string_t*>() == nullptr);
CHECK(value.get_ptr<json::boolean_t*>() != nullptr); │ CHECK(value.get_ptr<json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-pointer_access.cpp:212 │ json/tests/src/unit-pointer_access.cpp:154
│
using test_type = json::boolean_t; │ using test_type = json::string_t;
json value = false; │ json value = "hello";
│
// check if pointers are returned correctly │ // check if pointers are returned correctly
test_type* p1 = value.get_ptr<test_type*>(); │ test_type* p1 = value.get_ptr<test_type*>();
CHECK(p1 == value.get_ptr<test_type*>()); │ CHECK(p1 == value.get_ptr<test_type*>());
CHECK(*p1 == value.get<test_type>()); │ CHECK(*p1 == value.get<test_type>());
│
const test_type* p2 = value.get_ptr<const test_type*>(); │ const test_type* p2 = value.get_ptr<const test_type*>();
CHECK(p2 == value.get_ptr<const test_type*>()); │ CHECK(p2 == value.get_ptr<const test_type*>());
CHECK(*p2 == value.get<test_type>()); │ CHECK(*p2 == value.get<test_type>());
│
const test_type* const p3 = value.get_ptr<const test_type* const>(); │ const test_type* const p3 = value.get_ptr<const test_type* const>();
CHECK(p3 == value.get_ptr<const test_type* const>()); │ CHECK(p3 == value.get_ptr<const test_type* const>());
CHECK(*p3 == value.get<test_type>()); │ CHECK(*p3 == value.get<test_type>());
│
// check if null pointers are returned correctly │ // check if null pointers are returned correctly
CHECK(value.get_ptr<json::object_t*>() == nullptr); │ CHECK(value.get_ptr<json::object_t*>() == nullptr);
CHECK(value.get_ptr<json::array_t*>() == nullptr); │ CHECK(value.get_ptr<json::array_t*>() == nullptr);
CHECK(value.get_ptr<json::string_t*>() == nullptr); │ CHECK(value.get_ptr<json::string_t*>() != nullptr);
CHECK(value.get_ptr<json::boolean_t*>() != nullptr); │ CHECK(value.get_ptr<json::boolean_t*>() == nullptr);
CHECK(value.get_ptr<json::number_integer_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_integer_t*>() == nullptr);
CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_unsigned_t*>() == nullptr);
CHECK(value.get_ptr<json::number_float_t*>() == nullptr); │ CHECK(value.get_ptr<json::number_float_t*>() == nullptr);
CHECK(value.get_ptr<json::binary_t*>() == nullptr); │ CHECK(value.get_ptr<json::binary_t*>() == nullptr);
} │
next prev up json/tests/src/unit-ubjson.cpp:873 │ json/tests/src/unit-ubjson.cpp:837
│
for (size_t N = 128; N <= 255; ++N) │ for (size_t N = 0; N <= 127; ++N)
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::string(N, 'x');
json j = s; │ json j = s;
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('S'); │ expected.push_back('S');
expected.push_back('U'); │ expected.push_back('i');
expected.push_back(static_cast<uint8_t>(N)); │ expected.push_back(static_cast<uint8_t>(N));
for (size_t i = 0; i < N; ++i) │ for (size_t i = 0; i < N; ++i)
{ │ {
expected.push_back('x'); │ expected.push_back('x');
} │ }
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 3);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ if (N > 0)
│ {
│ CHECK(result.back() != '\x00');
│ }
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:1231 │ json/tests/src/unit-bjdata.cpp:1195
│
for (size_t N = 128; N <= 255; ++N) │ for (size_t N = 0; N <= 127; ++N)
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::string(N, 'x');
json j = s; │ json j = s;
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('S'); │ expected.push_back('S');
expected.push_back('U'); │ expected.push_back('i');
expected.push_back(static_cast<uint8_t>(N)); │ expected.push_back(static_cast<uint8_t>(N));
for (size_t i = 0; i < N; ++i) │ for (size_t i = 0; i < N; ++i)
{ │ {
expected.push_back('x'); │ expected.push_back('x');
} │ }
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 3); │ CHECK(result.size() == N + 3);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ if (N > 0)
│ {
│ CHECK(result.back() != '\x00');
│ }
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:1352 │ json/tests/src/unit-cbor.cpp:1408
│
json j; │ json j;
for (auto i = 0; i < 255; ++i) │ for (auto i = 0; i < 65536; ++i)
{ │ {
// format i to a fixed width of 5 │ // format i to a fixed width of 5
// each entry will need 7 bytes: 6 for string, 1 for null │ // each entry will need 7 bytes: 6 for string, 1 for null
std::stringstream ss; │ std::stringstream ss;
ss << std::setw(5) << std::setfill('0') << i; │ ss << std::setw(5) << std::setfill('0') << i;
j.emplace(ss.str(), nullptr); │ j.emplace(ss.str(), nullptr);
} │ }
│
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
│
// Checking against an expected vector byte by byte is │ // Checking against an expected vector byte by byte is
// difficult, because no assumption on the order of key/value │ // difficult, because no assumption on the order of key/value
// pairs are made. We therefore only check the prefix (type and │ // pairs are made. We therefore only check the prefix (type and
// size and the overall size. The rest is then handled in the │ // size and the overall size. The rest is then handled in the
// roundtrip check. │ // roundtrip check.
CHECK(result.size() == 1787); // 1 type, 1 size, 255*7 content │ CHECK(result.size() == 458757); // 1 type, 4 size, 65536*7 content
CHECK(result[0] == 0xb8); // map 8 bit │ CHECK(result[0] == 0xba); // map 32 bit
CHECK(result[1] == 0xff); // size byte (0xff) │ CHECK(result[1] == 0x00); // byte 0 of size (0x00010000)
│ CHECK(result[2] == 0x01); // byte 1 of size (0x00010000)
│ CHECK(result[3] == 0x00); // byte 2 of size (0x00010000)
│ CHECK(result[4] == 0x00); // byte 3 of size (0x00010000)
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │
next prev up json/tests/src/unit-cbor.cpp:1352 │ json/tests/src/unit-cbor.cpp:1379
│
json j; │ json j;
for (auto i = 0; i < 255; ++i) │ for (auto i = 0; i < 256; ++i)
{ │ {
// format i to a fixed width of 5 │ // format i to a fixed width of 5
// each entry will need 7 bytes: 6 for string, 1 for null │ // each entry will need 7 bytes: 6 for string, 1 for null
std::stringstream ss; │ std::stringstream ss;
ss << std::setw(5) << std::setfill('0') << i; │ ss << std::setw(5) << std::setfill('0') << i;
j.emplace(ss.str(), nullptr); │ j.emplace(ss.str(), nullptr);
} │ }
│
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
│
// Checking against an expected vector byte by byte is │ // Checking against an expected vector byte by byte is
// difficult, because no assumption on the order of key/value │ // difficult, because no assumption on the order of key/value
// pairs are made. We therefore only check the prefix (type and │ // pairs are made. We therefore only check the prefix (type and
// size and the overall size. The rest is then handled in the │ // size and the overall size. The rest is then handled in the
// roundtrip check. │ // roundtrip check.
CHECK(result.size() == 1787); // 1 type, 1 size, 255*7 content │ CHECK(result.size() == 1795); // 1 type, 2 size, 256*7 content
CHECK(result[0] == 0xb8); // map 8 bit │ CHECK(result[0] == 0xb9); // map 16 bit
CHECK(result[1] == 0xff); // size byte (0xff) │ CHECK(result[1] == 0x01); // byte 0 of size (0x0100)
│ CHECK(result[2] == 0x00); // byte 1 of size (0x0100)
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │
next prev up json/tests/src/unit-cbor.cpp:1476 │ json/tests/src/unit-cbor.cpp:1442
│
for (size_t N = 24; N <= 255; ++N) │ for (size_t N = 0; N <= 0x17; ++N)
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with byte array containing of N * 'x'
const auto s = std::vector<uint8_t>(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = json::binary(s); │ json j = json::binary(s);
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0x58); │ expected.push_back(static_cast<uint8_t>(0x40 + N));
expected.push_back(static_cast<uint8_t>(N)); │
for (size_t i = 0; i < N; ++i) │ for (size_t i = 0; i < N; ++i)
{ │ {
expected.push_back('x'); │ expected.push_back(0x78);
} │ }
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 2); │ CHECK(result.size() == N + 1);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ if (N > 0)
│ {
│ CHECK(result.back() != '\x00');
│ }
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:1476 │ json/tests/src/unit-cbor.cpp:1093
│
for (size_t N = 24; N <= 255; ++N) │ for (size_t N = 0; N <= 0x17; ++N)
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::vector<uint8_t>(N, 'x'); │ const auto s = std::string(N, 'x');
json j = json::binary(s); │ json j = s;
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0x58); │ expected.push_back(static_cast<uint8_t>(0x60 + N));
expected.push_back(static_cast<uint8_t>(N)); │
for (size_t i = 0; i < N; ++i) │ for (size_t i = 0; i < N; ++i)
{ │ {
expected.push_back('x'); │ expected.push_back('x');
} │ }
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 2); │ CHECK(result.size() == N + 1);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ if (N > 0)
│ {
│ CHECK(result.back() != '\x00');
│ }
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:357 │ json/tests/src/unit-cbor.cpp:450
│
for (auto i = -256; i < -24; ++i) │ for (size_t i = 24; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0x38); │ expected.push_back(static_cast<uint8_t>(0x18));
expected.push_back(static_cast<uint8_t>(-1 - i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0x38); │ CHECK(result[0] == 0x18);
CHECK(static_cast<int16_t>(-1 - result[1]) == i); │ CHECK(result[1] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:357 │ json/tests/src/unit-cbor.cpp:678
│
for (auto i = -256; i < -24; ++i) │ for (size_t i = 24; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0x38); │ expected.push_back(0x18);
expected.push_back(static_cast<uint8_t>(-1 - i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0x38); │ CHECK(result[0] == 0x18);
CHECK(static_cast<int16_t>(-1 - result[1]) == i); │ auto restored = static_cast<uint8_t>(result[1]);
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:400 │ json/tests/src/unit-msgpack.cpp:271
│
for (auto i = -128; i <= -33; ++i) │ for (size_t i = 256; i <= 65535; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xd0); │ expected.push_back(0xcd);
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xd0); │ CHECK(result[0] == 0xcd);
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:400 │ json/tests/src/unit-msgpack.cpp:643
│
for (auto i = -128; i <= -33; ++i) │ for (size_t i = 256; i <= 65535; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xd0); │ expected.push_back(0xcd);
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xd0); │ CHECK(result[0] == 0xcd);
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:400 │ json/tests/src/unit-msgpack.cpp:448
│
for (auto i = -128; i <= -33; ++i) │ for (int16_t i = -32768; i <= static_cast<std::int16_t>(-129); ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xd0); │ expected.push_back(0xd1);
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xd0); │ CHECK(result[0] == 0xd1);
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<int16_t>((result[1] << 8) + result[2
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:400 │ json/tests/src/unit-msgpack.cpp:237
│
for (auto i = -128; i <= -33; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xd0); │ expected.push_back(0xcc);
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xd0); │ CHECK(result[0] == 0xcc);
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint8_t>(result[1]);
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:400 │ json/tests/src/unit-msgpack.cpp:610
│
for (auto i = -128; i <= -33; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0xd0); │ expected.push_back(0xcc);
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 0xd0); │ CHECK(result[0] == 0xcc);
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint8_t>(result[1]);
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:335 │ json/tests/src/unit-bjdata.cpp:468
│
for (auto i = -128; i <= -1; ++i) │ for (uint32_t i :
│ {
│ 32768u, 55555u, 65535u
│ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back(static_cast<uint8_t>('u'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'u');
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:335 │ json/tests/src/unit-bjdata.cpp:433
│
for (auto i = -128; i <= -1; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back(static_cast<uint8_t>('I'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'I');
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:335 │ json/tests/src/unit-bjdata.cpp:792
│
for (auto i = -128; i <= -1; ++i) │ for (uint32_t i :
│ {
│ 32768u, 55555u, 65535u
│ })
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back('u');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'u');
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:335 │ json/tests/src/unit-bjdata.cpp:758
│
for (auto i = -128; i <= -1; ++i) │ for (size_t i = 256; i <= 32767; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back('I');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'I');
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:335 │ json/tests/src/unit-bjdata.cpp:281
│
for (auto i = -128; i <= -1; ++i) │ for (int32_t i = -32768; i <= -129; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back(static_cast<uint8_t>('I'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i & 0xff));
│ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'I');
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<int16_t>(((result[2] << 8) + result[
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:335 │ json/tests/src/unit-ubjson.cpp:400
│
for (auto i = -128; i <= -1; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back(static_cast<uint8_t>('U'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'U');
CHECK(static_cast<int8_t>(result[1]) == i); │ CHECK(result[1] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:335 │ json/tests/src/unit-bjdata.cpp:400
│
for (auto i = -128; i <= -1; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back(static_cast<uint8_t>('U'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'U');
CHECK(static_cast<int8_t>(result[1]) == i); │ CHECK(result[1] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:335 │ json/tests/src/unit-ubjson.cpp:367
│
for (auto i = -128; i <= -1; ++i) │ for (size_t i = 0; i <= 127; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back(static_cast<uint8_t>('i'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'i');
CHECK(static_cast<int8_t>(result[1]) == i); │ CHECK(result[1] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:335 │ json/tests/src/unit-bjdata.cpp:367
│
for (auto i = -128; i <= -1; ++i) │ for (size_t i = 0; i <= 127; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back(static_cast<uint8_t>('i'));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'i');
CHECK(static_cast<int8_t>(result[1]) == i); │ CHECK(result[1] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:335 │ json/tests/src/unit-ubjson.cpp:596
│
for (auto i = -128; i <= -1; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back('U');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'U');
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint8_t>(result[1]);
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:335 │ json/tests/src/unit-bjdata.cpp:725
│
for (auto i = -128; i <= -1; ++i) │ for (size_t i = 128; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back('U');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'U');
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint8_t>(result[1]);
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:335 │ json/tests/src/unit-ubjson.cpp:563
│
for (auto i = -128; i <= -1; ++i) │ for (size_t i = 0; i <= 127; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back('i');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j); │ const auto result = json::to_ubjson(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'i');
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint8_t>(result[1]);
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_ubjson(result) == j); │ CHECK(json::from_ubjson(result) == j);
CHECK(json::from_ubjson(result, true, false) == j); │ CHECK(json::from_ubjson(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:335 │ json/tests/src/unit-bjdata.cpp:692
│
for (auto i = -128; i <= -1; ++i) │ for (size_t i = 0; i <= 127; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back('i'); │ expected.push_back('i');
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j); │ const auto result = json::to_bjdata(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 2); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == 'i'); │ CHECK(result[0] == 'i');
CHECK(static_cast<int8_t>(result[1]) == i); │ auto restored = static_cast<uint8_t>(result[1]);
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_bjdata(result) == j); │ CHECK(json::from_bjdata(result) == j);
CHECK(json::from_bjdata(result, true, false) == j); │ CHECK(json::from_bjdata(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-to_chars.cpp:110 │ json/tests/src/unit-to_chars.cpp:58
│
constexpr uint64_t kHiddenBit = 0x0010000000000000; │ constexpr uint64_t kHiddenBit = 0x00800000;
constexpr uint64_t kSignificandMask = 0x000FFFFFFFFFFFFF; │ constexpr uint64_t kSignificandMask = 0x007FFFFF;
constexpr int kPhysicalSignificandSize = 52; // Excludes the hidden bit. │ constexpr int kPhysicalSignificandSize = 23; // Excludes the hidden bit.
constexpr int kExponentBias = 0x3FF + kPhysicalSignificandSize; │ constexpr int kExponentBias = 0x7F + kPhysicalSignificandSize;
constexpr int kDenormalExponent = 1 - kExponentBias; │ constexpr int kDenormalExponent = 1 - kExponentBias;
constexpr int kMaxExponent = 0x7FF - kExponentBias; │ constexpr int kMaxExponent = 0xFF - kExponentBias;
│
while (f > kHiddenBit + kSignificandMask) │ while (f > kHiddenBit + kSignificandMask)
{ │ {
f >>= 1; │ f >>= 1;
e++; │ e++;
} │ }
if (e >= kMaxExponent) │ if (e >= kMaxExponent)
{ │ {
return std::numeric_limits<double>::infinity(); │ return std::numeric_limits<float>::infinity();
} │ }
if (e < kDenormalExponent) │ if (e < kDenormalExponent)
{ │ {
return 0.0; │ return 0.0;
} │ }
while (e > kDenormalExponent && (f & kHiddenBit) == 0) │ while (e > kDenormalExponent && (f & kHiddenBit) == 0)
{ │ {
f <<= 1; │ f <<= 1;
e--; │ e--;
} │ }
│
uint64_t biased_exponent = (e == kDenormalExponent && (f & kHiddenBit) == 0) │ uint64_t biased_exponent = (e == kDenormalExponent && (f & kHiddenBit) == 0)
? 0 │ ? 0
: static_cast<uint64_t>(e + kExponentBias); │ : static_cast<uint64_t>(e + kExponentBias);
│
uint64_t bits = (f & kSignificandMask) | (biased_exponent << kPhysicalSignificandSiz │ uint64_t bits = (f & kSignificandMask) | (biased_exponent << kPhysicalSignificandSiz
return reinterpret_bits<double>(bits); │ return reinterpret_bits<float>(static_cast<uint32_t>(bits));
} │
next prev up json/tests/src/unit-cbor.cpp:1127 │ json/tests/src/unit-cbor.cpp:1093
│
for (size_t N = 24; N <= 255; ++N) │ for (size_t N = 0; N <= 0x17; ++N)
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::string(N, 'x');
json j = s; │ json j = s;
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0x78); │ expected.push_back(static_cast<uint8_t>(0x60 + N));
expected.push_back(static_cast<uint8_t>(N)); │
for (size_t i = 0; i < N; ++i) │ for (size_t i = 0; i < N; ++i)
{ │ {
expected.push_back('x'); │ expected.push_back('x');
} │ }
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 2); │ CHECK(result.size() == N + 1);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ if (N > 0)
│ {
│ CHECK(result.back() != '\x00');
│ }
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:1127 │ json/tests/src/unit-cbor.cpp:1476
│
for (size_t N = 24; N <= 255; ++N) │ for (size_t N = 24; N <= 255; ++N)
{ │ {
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with string containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(0x78); │ expected.push_back(0x58);
expected.push_back(static_cast<uint8_t>(N)); │ expected.push_back(static_cast<uint8_t>(N));
for (size_t i = 0; i < N; ++i) │ for (size_t i = 0; i < N; ++i)
{ │ {
expected.push_back('x'); │ expected.push_back('x');
} │ }
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 2); │ CHECK(result.size() == N + 2);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:419 │ json/tests/src/unit-cbor.cpp:483
│
for (size_t i = 0; i <= 23; ++i) │ for (size_t i = 256; i <= 65535; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = -1;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(0x19));
│ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(result[0] == 0x19);
│ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:419 │ json/tests/src/unit-cbor.cpp:711
│
for (size_t i = 0; i <= 23; ++i) │ for (size_t i = 256; i <= 65535; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = -1; │ json j = i;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(0x19);
│ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(result[0] == 0x19);
│ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:419 │ json/tests/src/unit-cbor.cpp:450
│
for (size_t i = 0; i <= 23; ++i) │ for (size_t i = 24; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = -1;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
│ expected.push_back(static_cast<uint8_t>(0x18));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(result[0] == 0x18);
│ CHECK(result[1] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:419 │ json/tests/src/unit-cbor.cpp:678
│
for (size_t i = 0; i <= 23; ++i) │ for (size_t i = 24; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with unsigned integer number
json j = -1; │ json j = i;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
│ expected.push_back(0x18);
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(result[0] == 0x18);
│ auto restored = static_cast<uint8_t>(result[1]);
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:419 │ json/tests/src/unit-cbor.cpp:357
│
for (size_t i = 0; i <= 23; ++i) │ for (auto i = -256; i < -24; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = -1; │ json j = i;
j.get_ref<json::number_integer_t&>() = static_cast<json::number_ │
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(0x38);
│ expected.push_back(static_cast<uint8_t>(-1 - i));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(result[0] == 0x38);
│ CHECK(static_cast<int16_t>(-1 - result[1]) == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-capacity.cpp:76 │ json/tests/src/unit-capacity.cpp:115
│
SECTION("empty array") │ SECTION("empty object")
{ │ {
json j = json::array(); │ json j = json::object();
const json j_const(j); │ const json j_const(j);
│
SECTION("result of empty") │ SECTION("result of empty")
{ │ {
CHECK(j.empty() == true); │ CHECK(j.empty() == true);
CHECK(j_const.empty() == true); │ CHECK(j_const.empty() == true);
} │ }
│
SECTION("definition of empty") │ SECTION("definition of empty")
{ │ {
CHECK(j.empty() == (j.begin() == j.end())); │ CHECK(j.empty() == (j.begin() == j.end()));
CHECK(j_const.empty() == (j_const.begin() == j_const.end())); │ CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
} │ }
} │ }
│
SECTION("filled array") │ SECTION("filled object")
{ │ {
json j = {1, 2, 3}; │ json j = {{"one", 1}, {"two", 2}, {"three", 3}};
const json j_const(j); │ const json j_const(j);
│
SECTION("result of empty") │ SECTION("result of empty")
{ │ {
CHECK(j.empty() == false); │ CHECK(j.empty() == false);
CHECK(j_const.empty() == false); │ CHECK(j_const.empty() == false);
} │ }
│
SECTION("definition of empty") │ SECTION("definition of empty")
{ │ {
CHECK(j.empty() == (j.begin() == j.end())); │ CHECK(j.empty() == (j.begin() == j.end()));
CHECK(j_const.empty() == (j_const.begin() == j_const.end())); │ CHECK(j_const.empty() == (j_const.begin() == j_const.end()));
} │ }
} │ }
} │
next prev up json/include/nlohmann/detail/iterators/iter_impl.hpp:314 │ json/include/nlohmann/detail/iterators/iter_impl.hpp:270
│
JSON_ASSERT(m_object != nullptr); │ JSON_ASSERT(m_object != nullptr);
│
switch (m_object->m_type) │ switch (m_object->m_type)
{ │ {
case value_t::object: │ case value_t::object:
{ │ {
JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); │ JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
return &(m_it.object_iterator->second); │ return m_it.object_iterator->second;
} │ }
│
case value_t::array: │ case value_t::array:
{ │ {
JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); │ JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
return &*m_it.array_iterator; │ return *m_it.array_iterator;
} │ }
│
case value_t::null: │ case value_t::null:
│ JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object));
│
case value_t::string: │ case value_t::string:
case value_t::boolean: │ case value_t::boolean:
case value_t::number_integer: │ case value_t::number_integer:
case value_t::number_unsigned: │ case value_t::number_unsigned:
case value_t::number_float: │ case value_t::number_float:
case value_t::binary: │ case value_t::binary:
case value_t::discarded: │ case value_t::discarded:
default: │ default:
{ │ {
if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) │ if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin()))
{ │ {
return m_object; │ return *m_object;
} │ }
│
JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); │ JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object));
} │ }
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:2253 │ json/tests/src/unit-ubjson.cpp:2206
│
json j = │ json j =
{ │ {
{ │ {
"post", { │ "post", {
{"id", 1137}, │ {"id", 1137},
{"author", "rkalla"}, │ {"author", "rkalla"},
{"timestamp", 1364482090592}, │ {"timestamp", 1364482090592},
{"body", "I totally agree!"} │ {"body", "I totally agree!"}
} │ }
} │ }
}; │ };
std::vector<uint8_t> v = {'{', '$', '{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', │ std::vector<uint8_t> v = {'{', 'i', 4, 'p', 'o', 's', 't', '{',
'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, │ 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6,
'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ' │ 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' '
'i', 2, 'i', 'd', 'I', 0x04, 0x71, │ 'i', 2, 'i', 'd', 'I', 0x04, 0x71,
'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p │ 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p
│ '}', '}'
}; │ };
CHECK(json::to_ubjson(j, true, true) == v); │ CHECK(json::to_ubjson(j) == v);
CHECK(json::from_ubjson(v) == j); │ CHECK(json::from_ubjson(v) == j);
} │
next prev up json/tests/src/unit-bjdata.cpp:3097 │ json/tests/src/unit-bjdata.cpp:3050
│
json j = │ json j =
{ │ {
{ │ {
"post", { │ "post", {
{"id", 1137}, │ {"id", 1137},
{"author", "rkalla"}, │ {"author", "rkalla"},
{"timestamp", 1364482090592}, │ {"timestamp", 1364482090592},
{"body", "I totally agree!"} │ {"body", "I totally agree!"}
} │ }
} │ }
}; │ };
std::vector<uint8_t> v = {'{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '{', │ std::vector<uint8_t> v = {'{', 'i', 4, 'p', 'o', 's', 't', '{',
'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, │ 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6,
'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ' │ 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' '
'i', 2, 'i', 'd', 'I', 0x71, 0x04, │ 'i', 2, 'i', 'd', 'I', 0x71, 0x04,
'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p │ 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p
│ '}', '}'
}; │ };
CHECK(json::to_bjdata(j, true, true) == v); │ CHECK(json::to_bjdata(j) == v);
CHECK(json::from_bjdata(v) == j); │ CHECK(json::from_bjdata(v) == j);
} │
next prev up json/tests/src/unit-conversions.cpp:170 │ json/tests/src/unit-conversions.cpp:122
│
json::object_t o_reference = {{"object", json::object()}, │ json::object_t o_reference = {{"object", json::object()},
{"array", {1, 2, 3, 4}}, │ {"array", {1, 2, 3, 4}},
{"number", 42}, │ {"number", 42},
{"boolean", false}, │ {"boolean", false},
{"null", nullptr}, │ {"null", nullptr},
{"string", "Hello world"} │ {"string", "Hello world"}
}; │ };
json j(o_reference); │ json j(o_reference);
│
SECTION("json::object_t") │ SECTION("json::object_t")
{ │ {
json::object_t o = j; │ json::object_t o = {{"previous", "value"}};
│ j.get_to(o);
CHECK(json(o) == j); │ CHECK(json(o) == j);
} │ }
│
SECTION("std::map<json::string_t, json>") │ SECTION("std::map<json::string_t, json>")
{ │ {
std::map<json::string_t, json> o = j; │ std::map<json::string_t, json> o{{"previous", "value"}};
│ j.get_to(o);
CHECK(json(o) == j); │ CHECK(json(o) == j);
} │ }
│
SECTION("std::multimap<json::string_t, json>") │ SECTION("std::multimap<json::string_t, json>")
{ │ {
std::multimap<json::string_t, json> o = j; │ std::multimap<json::string_t, json> o{{"previous", "value"}};
│ j.get_to(o);
CHECK(json(o) == j); │ CHECK(json(o) == j);
} │ }
│
SECTION("std::unordered_map<json::string_t, json>") │ SECTION("std::unordered_map<json::string_t, json>")
{ │ {
std::unordered_map<json::string_t, json> o = j; │ std::unordered_map<json::string_t, json> o{{"previous", "value"}};
│ j.get_to(o);
CHECK(json(o) == j); │ CHECK(json(o) == j);
} │ }
│
SECTION("std::unordered_multimap<json::string_t, json>") │ SECTION("std::unordered_multimap<json::string_t, json>")
{ │ {
std::unordered_multimap<json::string_t, json> o = j; │ std::unordered_multimap<json::string_t, json> o{{"previous", "value"}};
│ j.get_to(o);
CHECK(json(o) == j); │ CHECK(json(o) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:389 │ json/tests/src/unit-cbor.cpp:419
│
for (auto i = -24; i <= -1; ++i) │ for (size_t i = 0; i <= 23; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(0x20 - 1 - static_cast<u │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 1);
│
// check individual bytes │ // check individual bytes
CHECK(static_cast<int8_t>(0x20 - 1 - result[0]) == i); │ CHECK(result[0] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-bjdata.cpp:3074 │ json/tests/src/unit-bjdata.cpp:3050
│
json j = │ json j =
{ │ {
{ │ {
"post", { │ "post", {
{"id", 1137}, │ {"id", 1137},
{"author", "rkalla"}, │ {"author", "rkalla"},
{"timestamp", 1364482090592}, │ {"timestamp", 1364482090592},
{"body", "I totally agree!"} │ {"body", "I totally agree!"}
} │ }
} │ }
}; │ };
std::vector<uint8_t> v = {'{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '{', │ std::vector<uint8_t> v = {'{', 'i', 4, 'p', 'o', 's', 't', '{',
'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, │ 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6,
'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ' │ 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' '
'i', 2, 'i', 'd', 'I', 0x71, 0x04, │ 'i', 2, 'i', 'd', 'I', 0x71, 0x04,
'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p │ 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p
│ '}', '}'
}; │ };
CHECK(json::to_bjdata(j, true) == v); │ CHECK(json::to_bjdata(j) == v);
CHECK(json::from_bjdata(v) == j); │ CHECK(json::from_bjdata(v) == j);
} │
next prev up json/tests/src/unit-bjdata.cpp:3074 │ json/tests/src/unit-bjdata.cpp:3097
│
json j = │ json j =
{ │ {
{ │ {
"post", { │ "post", {
{"id", 1137}, │ {"id", 1137},
{"author", "rkalla"}, │ {"author", "rkalla"},
{"timestamp", 1364482090592}, │ {"timestamp", 1364482090592},
{"body", "I totally agree!"} │ {"body", "I totally agree!"}
} │ }
} │ }
}; │ };
std::vector<uint8_t> v = {'{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '{', │ std::vector<uint8_t> v = {'{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '{',
'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, │ 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6,
'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ' │ 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' '
'i', 2, 'i', 'd', 'I', 0x71, 0x04, │ 'i', 2, 'i', 'd', 'I', 0x71, 0x04,
'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p │ 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p
}; │ };
CHECK(json::to_bjdata(j, true) == v); │ CHECK(json::to_bjdata(j, true, true) == v);
CHECK(json::from_bjdata(v) == j); │ CHECK(json::from_bjdata(v) == j);
} │
next prev up json/tests/src/unit-ubjson.cpp:2230 │ json/tests/src/unit-ubjson.cpp:2206
│
json j = │ json j =
{ │ {
{ │ {
"post", { │ "post", {
{"id", 1137}, │ {"id", 1137},
{"author", "rkalla"}, │ {"author", "rkalla"},
{"timestamp", 1364482090592}, │ {"timestamp", 1364482090592},
{"body", "I totally agree!"} │ {"body", "I totally agree!"}
} │ }
} │ }
}; │ };
std::vector<uint8_t> v = {'{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '{', │ std::vector<uint8_t> v = {'{', 'i', 4, 'p', 'o', 's', 't', '{',
'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, │ 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6,
'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ' │ 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' '
'i', 2, 'i', 'd', 'I', 0x04, 0x71, │ 'i', 2, 'i', 'd', 'I', 0x04, 0x71,
'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p │ 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p
│ '}', '}'
}; │ };
CHECK(json::to_ubjson(j, true) == v); │ CHECK(json::to_ubjson(j) == v);
CHECK(json::from_ubjson(v) == j); │ CHECK(json::from_ubjson(v) == j);
} │
next prev up json/tests/src/unit-ubjson.cpp:2230 │ json/tests/src/unit-ubjson.cpp:2253
│
json j = │ json j =
{ │ {
{ │ {
"post", { │ "post", {
{"id", 1137}, │ {"id", 1137},
{"author", "rkalla"}, │ {"author", "rkalla"},
{"timestamp", 1364482090592}, │ {"timestamp", 1364482090592},
{"body", "I totally agree!"} │ {"body", "I totally agree!"}
} │ }
} │ }
}; │ };
std::vector<uint8_t> v = {'{', '#', 'i', 1, 'i', 4, 'p', 'o', 's', 't', '{', │ std::vector<uint8_t> v = {'{', '$', '{', '#', 'i', 1, 'i', 4, 'p', 'o', 's',
'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6, │ 'i', 6, 'a', 'u', 't', 'h', 'o', 'r', 'S', 'i', 6,
'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' ' │ 'i', 4, 'b', 'o', 'd', 'y', 'S', 'i', 16, 'I', ' '
'i', 2, 'i', 'd', 'I', 0x04, 0x71, │ 'i', 2, 'i', 'd', 'I', 0x04, 0x71,
'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p │ 'i', 9, 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p
}; │ };
CHECK(json::to_ubjson(j, true) == v); │ CHECK(json::to_ubjson(j, true, true) == v);
CHECK(json::from_ubjson(v) == j); │ CHECK(json::from_ubjson(v) == j);
} │
next prev up json/tests/src/unit-msgpack.cpp:875 │ json/tests/src/unit-msgpack.cpp:1314
│
CAPTURE(N) │ CAPTURE(N)
│
// create JSON value with string containing of N * 'x' │ // create JSON value with byte array containing of N * 'x'
const auto s = std::string(N, 'x'); │ const auto s = std::vector<uint8_t>(N, 'x');
json j = s; │ json j = json::binary(s);
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<std::uint8_t> expected;
expected.push_back(0xd9); │ expected.push_back(static_cast<std::uint8_t>(0xC4));
expected.push_back(static_cast<uint8_t>(N)); │ expected.push_back(static_cast<std::uint8_t>(N));
for (size_t i = 0; i < N; ++i) │ for (size_t i = 0; i < N; ++i)
{ │ {
expected.push_back('x'); │ expected.push_back(0x78);
} │ }
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 2); │ CHECK(result.size() == N + 2);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ if (N > 0)
│ {
│ CHECK(result.back() != '\x00');
│ }
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │
next prev up json/include/nlohmann/detail/output/binary_writer.hpp:575 │ json/include/nlohmann/detail/output/binary_writer.hpp:688
│
// step 1: write control byte and the array size │ // step 1: write control byte and the object size
const auto N = j.m_value.array->size(); │ const auto N = j.m_value.object->size();
if (N <= 15) │ if (N <= 15)
{ │ {
// fixarray │ // fixmap
write_number(static_cast<std::uint8_t>(0x90 | N)); │ write_number(static_cast<std::uint8_t>(0x80 | (N & 0xF)));
} │ }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint16_t>::max)())
{ │ {
// array 16 │ // map 16
oa->write_character(to_char_type(0xDC)); │ oa->write_character(to_char_type(0xDE));
write_number(static_cast<std::uint16_t>(N)); │ write_number(static_cast<std::uint16_t>(N));
} │ }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) │ else if (N <= (std::numeric_limits<std::uint32_t>::max)())
{ │ {
// array 32 │ // map 32
oa->write_character(to_char_type(0xDD)); │ oa->write_character(to_char_type(0xDF));
write_number(static_cast<std::uint32_t>(N)); │ write_number(static_cast<std::uint32_t>(N));
} │ }
│
// step 2: write each element │ // step 2: write each element
for (const auto& el : *j.m_value.array) │ for (const auto& el : *j.m_value.object)
{ │ {
write_msgpack(el); │ write_msgpack(el.first);
│ write_msgpack(el.second);
} │ }
break; │ break;
} │
next prev up json/tests/src/unit-msgpack.cpp:176 │ json/tests/src/unit-msgpack.cpp:206
│
for (auto i = -32; i <= -1; ++i) │ for (size_t i = 0; i <= 127; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_integer()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 1);
│
// check individual bytes │ // check individual bytes
CHECK(static_cast<int8_t>(result[0]) == i); │ CHECK(result[0] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1149 │ json/tests/src/unit-ubjson.cpp:1173
│
std::vector<uint8_t> expected; │ std::vector<std::uint8_t> expected;
expected.push_back(static_cast<std::uint8_t>('[')); │ expected.push_back(static_cast<std::uint8_t>('['));
for (std::size_t i = 0; i < N; ++i) │ expected.push_back(static_cast<std::uint8_t>('#'));
│ expected.push_back(static_cast<std::uint8_t>('i'));
│ expected.push_back(static_cast<std::uint8_t>(N));
│
│ for (size_t i = 0; i < N; ++i)
{ │ {
expected.push_back(static_cast<std::uint8_t>('U')); │ expected.push_back(static_cast<std::uint8_t>('U'));
expected.push_back(static_cast<std::uint8_t>(0x78)); │ expected.push_back(static_cast<std::uint8_t>(0x78));
} │ }
expected.push_back(static_cast<std::uint8_t>(']')); │
│
// compare result + size │ // compare result + size
const auto result = json::to_ubjson(j, false, false); │ const auto result = json::to_ubjson(j, true, false);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 12); │ CHECK(result.size() == N + 14);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip only works to an array of numbers │ // roundtrip only works to an array of numbers
json j_out = s; │ json j_out = s;
CHECK(json::from_ubjson(result) == j_out); │ CHECK(json::from_ubjson(result) == j_out);
CHECK(json::from_ubjson(result, true, false) == j_out); │ CHECK(json::from_ubjson(result, true, false) == j_out);
} │
next prev up json/tests/src/unit-bjdata.cpp:1579 │ json/tests/src/unit-bjdata.cpp:1603
│
std::vector<uint8_t> expected; │ std::vector<std::uint8_t> expected;
expected.push_back(static_cast<std::uint8_t>('[')); │ expected.push_back(static_cast<std::uint8_t>('['));
for (std::size_t i = 0; i < N; ++i) │ expected.push_back(static_cast<std::uint8_t>('#'));
│ expected.push_back(static_cast<std::uint8_t>('i'));
│ expected.push_back(static_cast<std::uint8_t>(N));
│
│ for (size_t i = 0; i < N; ++i)
{ │ {
expected.push_back(static_cast<std::uint8_t>('U')); │ expected.push_back(static_cast<std::uint8_t>('U'));
expected.push_back(static_cast<std::uint8_t>(0x78)); │ expected.push_back(static_cast<std::uint8_t>(0x78));
} │ }
expected.push_back(static_cast<std::uint8_t>(']')); │
│
// compare result + size │ // compare result + size
const auto result = json::to_bjdata(j, false, false); │ const auto result = json::to_bjdata(j, true, false);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == N + 12); │ CHECK(result.size() == N + 14);
// check that no null byte is appended │ // check that no null byte is appended
CHECK(result.back() != '\x00'); │ CHECK(result.back() != '\x00');
│
// roundtrip only works to an array of numbers │ // roundtrip only works to an array of numbers
json j_out = s; │ json j_out = s;
CHECK(json::from_bjdata(result) == j_out); │ CHECK(json::from_bjdata(result) == j_out);
CHECK(json::from_bjdata(result, true, false) == j_out); │ CHECK(json::from_bjdata(result, true, false) == j_out);
} │
next prev up json/tests/src/unit-msgpack.cpp:580 │ json/tests/src/unit-msgpack.cpp:206
│
for (size_t i = 0; i <= 127; ++i) │ for (size_t i = 0; i <= 127; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 1);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(result[0] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-msgpack.cpp:580 │ json/tests/src/unit-msgpack.cpp:176
│
for (size_t i = 0; i <= 127; ++i) │ for (auto i = -32; i <= -1; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_msgpack(j); │ const auto result = json::to_msgpack(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 1);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(static_cast<int8_t>(result[0]) == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_msgpack(result) == j); │ CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result, true, false) == j); │ CHECK(json::from_msgpack(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:648 │ json/tests/src/unit-cbor.cpp:711
│
for (size_t i = 0; i <= 23; ++i) │ for (size_t i = 256; i <= 65535; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(0x19);
│ expected.push_back(static_cast<uint8_t>((i >> 8) & 0xff));
│ expected.push_back(static_cast<uint8_t>(i & 0xff));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 3);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(result[0] == 0x19);
│ auto restored = static_cast<uint16_t>(static_cast<uint8_t>(resul
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:648 │ json/tests/src/unit-cbor.cpp:450
│
for (size_t i = 0; i <= 23; ++i) │ for (size_t i = 24; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
│ expected.push_back(static_cast<uint8_t>(0x18));
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(result[0] == 0x18);
│ CHECK(result[1] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:648 │ json/tests/src/unit-cbor.cpp:678
│
for (size_t i = 0; i <= 23; ++i) │ for (size_t i = 24; i <= 255; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with unsigned integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_unsigned());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
│ expected.push_back(0x18);
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(result[0] == 0x18);
│ auto restored = static_cast<uint8_t>(result[1]);
│ CHECK(restored == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:648 │ json/tests/src/unit-cbor.cpp:357
│
for (size_t i = 0; i <= 23; ++i) │ for (auto i = -256; i < -24; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(0x38);
│ expected.push_back(static_cast<uint8_t>(-1 - i));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 2);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(result[0] == 0x38);
│ CHECK(static_cast<int16_t>(-1 - result[1]) == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:648 │ json/tests/src/unit-cbor.cpp:419
│
for (size_t i = 0; i <= 23; ++i) │ for (size_t i = 0; i <= 23; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = -1;
│ j.get_ref<json::number_integer_t&>() = static_cast<json::number_
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(i));
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 1);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(result[0] == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-cbor.cpp:648 │ json/tests/src/unit-cbor.cpp:389
│
for (size_t i = 0; i <= 23; ++i) │ for (auto i = -24; i <= -1; ++i)
{ │ {
CAPTURE(i) │ CAPTURE(i)
│
// create JSON value with unsigned integer number │ // create JSON value with integer number
json j = i; │ json j = i;
│
// check type │ // check type
CHECK(j.is_number_unsigned()); │ CHECK(j.is_number_integer());
│
// create expected byte vector │ // create expected byte vector
std::vector<uint8_t> expected; │ std::vector<uint8_t> expected;
expected.push_back(static_cast<uint8_t>(i)); │ expected.push_back(static_cast<uint8_t>(0x20 - 1 - static_cast<u
│
// compare result + size │ // compare result + size
const auto result = json::to_cbor(j); │ const auto result = json::to_cbor(j);
CHECK(result == expected); │ CHECK(result == expected);
CHECK(result.size() == 1); │ CHECK(result.size() == 1);
│
// check individual bytes │ // check individual bytes
CHECK(result[0] == i); │ CHECK(static_cast<int8_t>(0x20 - 1 - result[0]) == i);
│
// roundtrip │ // roundtrip
CHECK(json::from_cbor(result) == j); │ CHECK(json::from_cbor(result) == j);
CHECK(json::from_cbor(result, true, false) == j); │ CHECK(json::from_cbor(result, true, false) == j);
} │ }
} │
next prev up json/tests/src/unit-ubjson.cpp:1913 │ json/tests/src/unit-ubjson.cpp:1929
│
std::vector<uint8_t> v0 = {'[', '$'}; │ std::vector<uint8_t> vST = {'[', '$', 'i', '#', 'i', 2, 1};
json _; │ json _;
CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v0), "[json.exception.parse_error │ CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vST), "[json.exception.parse_erro
CHECK(json::from_ubjson(v0, true, false).is_discarded()); │ CHECK(json::from_ubjson(vST, true, false).is_discarded());
│
std::vector<uint8_t> vi = {'[', '$', '#'}; │ std::vector<uint8_t> vS = {'[', '#', 'i', 2, 'i', 1};
CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vi), "[json.exception.parse_error │ CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vS), "[json.exception.parse_error
CHECK(json::from_ubjson(vi, true, false).is_discarded()); │ CHECK(json::from_ubjson(vS, true, false).is_discarded());
│
std::vector<uint8_t> vT = {'[', '$', 'T'}; │ std::vector<uint8_t> v = {'[', 'i', 2, 'i', 1};
CHECK_THROWS_WITH_AS(_ = json::from_ubjson(vT), "[json.exception.parse_error │ CHECK_THROWS_WITH_AS(_ = json::from_ubjson(v), "[json.exception.parse_error.
CHECK(json::from_ubjson(vT, true, false).is_discarded()); │ CHECK(json::from_ubjson(v, true, false).is_discarded());
} │
next prev up json/tests/src/fuzzer-parse_cbor.cpp:29 │ json/tests/src/fuzzer-parse_bson.cpp:29
│
try │ try
{ │ {
// step 1: parse input │ // step 1: parse input
std::vector<uint8_t> vec1(data, data + size); │ std::vector<uint8_t> vec1(data, data + size);
json j1 = json::from_cbor(vec1); │ json j1 = json::from_bson(vec1);
│
│ if (j1.is_discarded())
│ {
│ return 0;
│ }
│
try │ try
{ │ {
// step 2: round trip │ // step 2: round trip
std::vector<uint8_t> vec2 = json::to_cbor(j1); │ std::vector<uint8_t> vec2 = json::to_bson(j1);
│
// parse serialization │ // parse serialization
json j2 = json::from_cbor(vec2); │ json j2 = json::from_bson(vec2);
│
// serializations must match │ // serializations must match
assert(json::to_cbor(j2) == vec2); │ assert(json::to_bson(j2) == vec2);
} │ }
catch (const json::parse_error&) │ catch (const json::parse_error&)
{ │ {
// parsing a CBOR serialization must not fail │ // parsing a BSON serialization must not fail
assert(false); │ assert(false);
} │ }
} │ }
catch (const json::parse_error&) │ catch (const json::parse_error&)
{ │ {
// parse errors are ok, because input may be random bytes │ // parse errors are ok, because input may be random bytes
} │ }
catch (const json::type_error&) │ catch (const json::type_error&)
{ │ {
// type errors can occur during parsing, too │ // type errors can occur during parsing, too
} │ }
catch (const json::out_of_range&) │ catch (const json::out_of_range&)
{ │ {
// out of range errors can occur during parsing, too │ // out of range errors can occur during parsing, too
} │ }
│
// return 0 - non-zero return values are reserved for future use │ // return 0 - non-zero return values are reserved for future use
return 0; │ return 0;
} │