Lines Matching refs:json
33 using nlohmann::json;
61 bool number_integer(json::number_integer_t /*unused*/) in number_integer()
66 bool number_unsigned(json::number_unsigned_t /*unused*/) in number_unsigned()
71 bool number_float(json::number_float_t /*unused*/, const std::string& /*unused*/) in number_float()
111 …bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*u… in parse_error()
128 json j = json::value_t::discarded;
129 const auto result = json::to_cbor(j);
136 json j = std::numeric_limits<json::number_float_t>::quiet_NaN();
138 const auto result = json::to_cbor(j);
145 json j = std::numeric_limits<json::number_float_t>::infinity();
147 const auto result = json::to_cbor(j);
153 json j = nullptr;
155 const auto result = json::to_cbor(j);
159 CHECK(json::from_cbor(result) == j);
160 CHECK(json::from_cbor(result, true, false) == j);
167 json j = true;
169 const auto result = json::to_cbor(j);
173 CHECK(json::from_cbor(result) == j);
174 CHECK(json::from_cbor(result, true, false) == j);
179 json j = false;
181 const auto result = json::to_cbor(j);
185 CHECK(json::from_cbor(result) == j);
186 CHECK(json::from_cbor(result, true, false) == j);
213 json j = i;
232 const auto result = json::to_cbor(j);
250 CHECK(json::from_cbor(result) == j);
251 CHECK(json::from_cbor(result, true, false) == j);
270 json j = i;
285 const auto result = json::to_cbor(j);
299 CHECK(json::from_cbor(result) == j);
300 CHECK(json::from_cbor(result, true, false) == j);
311 json j = i;
324 const auto result = json::to_cbor(j);
335 CHECK(json::from_cbor(result) == j);
336 CHECK(json::from_cbor(result, true, false) == j);
342 json j = -9263;
345 const auto result = json::to_cbor(j);
352 CHECK(json::from_cbor(result) == j);
353 CHECK(json::from_cbor(result, true, false) == j);
363 json j = i;
374 const auto result = json::to_cbor(j);
383 CHECK(json::from_cbor(result) == j);
384 CHECK(json::from_cbor(result, true, false) == j);
395 json j = i;
405 const auto result = json::to_cbor(j);
413 CHECK(json::from_cbor(result) == j);
414 CHECK(json::from_cbor(result, true, false) == j);
425 json j = -1;
426 … j.get_ref<json::number_integer_t&>() = static_cast<json::number_integer_t>(i);
436 const auto result = json::to_cbor(j);
444 CHECK(json::from_cbor(result) == j);
445 CHECK(json::from_cbor(result, true, false) == j);
456 json j = -1;
457 … j.get_ref<json::number_integer_t&>() = static_cast<json::number_integer_t>(i);
468 const auto result = json::to_cbor(j);
477 CHECK(json::from_cbor(result) == j);
478 CHECK(json::from_cbor(result, true, false) == j);
489 json j = -1;
490 … j.get_ref<json::number_integer_t&>() = static_cast<json::number_integer_t>(i);
502 const auto result = json::to_cbor(j);
512 CHECK(json::from_cbor(result) == j);
513 CHECK(json::from_cbor(result, true, false) == j);
527 json j = -1;
528 … j.get_ref<json::number_integer_t&>() = static_cast<json::number_integer_t>(i);
542 const auto result = json::to_cbor(j);
555 CHECK(json::from_cbor(result) == j);
556 CHECK(json::from_cbor(result, true, false) == j);
570 json j = -1;
571 … j.get_ref<json::number_integer_t&>() = static_cast<json::number_integer_t>(i);
589 const auto result = json::to_cbor(j);
606 CHECK(json::from_cbor(result) == j);
607 CHECK(json::from_cbor(result, true, false) == j);
618 json j = i;
630 const auto result = json::to_msgpack(j);
640 CHECK(json::from_msgpack(result) == j);
654 json j = i;
664 const auto result = json::to_cbor(j);
672 CHECK(json::from_cbor(result) == j);
673 CHECK(json::from_cbor(result, true, false) == j);
684 json j = i;
695 const auto result = json::to_cbor(j);
705 CHECK(json::from_cbor(result) == j);
706 CHECK(json::from_cbor(result, true, false) == j);
717 json j = i;
729 const auto result = json::to_cbor(j);
739 CHECK(json::from_cbor(result) == j);
740 CHECK(json::from_cbor(result, true, false) == j);
754 json j = i;
768 const auto result = json::to_cbor(j);
781 CHECK(json::from_cbor(result) == j);
782 CHECK(json::from_cbor(result, true, false) == j);
796 json j = i;
814 const auto result = json::to_cbor(j);
831 CHECK(json::from_cbor(result) == j);
832 CHECK(json::from_cbor(result, true, false) == j);
842 json j = v;
847 const auto result = json::to_cbor(j);
851 CHECK(json::from_cbor(result) == j);
852 CHECK(json::from_cbor(result) == v);
854 CHECK(json::from_cbor(result, true, false) == j);
863 json j = v;
868 const auto result = json::to_cbor(j);
871 CHECK(json::from_cbor(result) == j);
872 CHECK(json::from_cbor(result) == v);
877 json j = v;
881 const auto result = json::to_cbor(j);
884 CHECK(json::from_cbor(result) == j);
885 CHECK(json::from_cbor(result) == v);
890 json j = v;
894 const auto result = json::to_cbor(j);
897 CHECK(json::from_cbor(result) == j);
898 CHECK(json::from_cbor(result) == v);
903 json j = v;
907 const auto result = json::to_cbor(j);
910 CHECK(json::from_cbor(result) == j);
911 CHECK(json::from_cbor(result) == v);
916 json j = v;
920 const auto result = json::to_cbor(j);
923 CHECK(json::from_cbor(result) == j);
924 CHECK(json::from_cbor(result) == v);
929 json j = v;
934 const auto result = json::to_cbor(j);
937 CHECK(json::from_cbor(result) == j);
938 CHECK(json::from_cbor(result) == v);
943 json j = v;
948 const auto result = json::to_cbor(j);
951 CHECK(json::from_cbor(result) == j);
952 CHECK(json::from_cbor(result) == v);
957 json j = v;
963 const auto result = json::to_cbor(j);
966 CHECK(json::from_cbor(result) == j);
967 CHECK(json::from_cbor(result) == v);
972 json j = v;
978 const auto result = json::to_cbor(j);
981 CHECK(json::from_cbor(result) == j);
982 CHECK(json::from_cbor(result) == v);
993 json _;
994 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0xf9})), json::parse_error&);
995 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0xf9})),
997 … CHECK(json::from_cbor(std::vector<uint8_t>({0xf9}), true, false).is_discarded());
1001 json _;
1002 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c})), json::parse_error&);
1003 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c})),
1005 … CHECK(json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c}), true, false).is_discarded());
1013 json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x00}));
1014 json::number_float_t d{j};
1020 json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x80, 0x00}));
1021 json::number_float_t d{j};
1027 json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x01}));
1028 json::number_float_t d{j};
1037 json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c, 0x00}));
1038 json::number_float_t d{j};
1039 CHECK(d == std::numeric_limits<json::number_float_t>::infinity());
1045 json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0xfc, 0x00}));
1046 json::number_float_t d{j};
1047 CHECK(d == -std::numeric_limits<json::number_float_t>::infinity());
1056 json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x3c, 0x00}));
1057 json::number_float_t d{j};
1063 json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0xc0, 0x00}));
1064 json::number_float_t d{j};
1070 json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7b, 0xff}));
1071 json::number_float_t d{j};
1078 json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c, 0x00}));
1079 json::number_float_t d{j};
1086 json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7e, 0x00}));
1087 json::number_float_t d{j};
1104 json j = s;
1115 const auto result = json::to_cbor(j);
1125 CHECK(json::from_cbor(result) == j);
1126 CHECK(json::from_cbor(result, true, false) == j);
1138 json j = s;
1150 const auto result = json::to_cbor(j);
1157 CHECK(json::from_cbor(result) == j);
1158 CHECK(json::from_cbor(result, true, false) == j);
1173 json j = s;
1183 const auto result = json::to_cbor(j);
1190 CHECK(json::from_cbor(result) == j);
1191 CHECK(json::from_cbor(result, true, false) == j);
1206 json j = s;
1218 const auto result = json::to_cbor(j);
1225 CHECK(json::from_cbor(result) == j);
1226 CHECK(json::from_cbor(result, true, false) == j);
1235 json j = json::array();
1237 const auto result = json::to_cbor(j);
1241 CHECK(json::from_cbor(result) == j);
1242 CHECK(json::from_cbor(result, true, false) == j);
1247 json j = {nullptr};
1249 const auto result = json::to_cbor(j);
1253 CHECK(json::from_cbor(result) == j);
1254 CHECK(json::from_cbor(result, true, false) == j);
1259 json j = json::parse("[1,2,3,4,5]");
1261 const auto result = json::to_cbor(j);
1265 CHECK(json::from_cbor(result) == j);
1266 CHECK(json::from_cbor(result, true, false) == j);
1271 json j = json::parse("[[[[]]]]");
1273 const auto result = json::to_cbor(j);
1277 CHECK(json::from_cbor(result) == j);
1278 CHECK(json::from_cbor(result, true, false) == j);
1283 json j(257, nullptr);
1288 const auto result = json::to_cbor(j);
1292 CHECK(json::from_cbor(result) == j);
1293 CHECK(json::from_cbor(result, true, false) == j);
1298 json j(65793, nullptr);
1305 const auto result = json::to_cbor(j);
1309 CHECK(json::from_cbor(result) == j);
1310 CHECK(json::from_cbor(result, true, false) == j);
1318 json j = json::object();
1320 const auto result = json::to_cbor(j);
1324 CHECK(json::from_cbor(result) == j);
1325 CHECK(json::from_cbor(result, true, false) == j);
1330 json j = {{"", nullptr}};
1332 const auto result = json::to_cbor(j);
1336 CHECK(json::from_cbor(result) == j);
1337 CHECK(json::from_cbor(result, true, false) == j);
1342 json j = json::parse(R"({"a": {"b": {"c": {}}}})");
1347 const auto result = json::to_cbor(j);
1351 CHECK(json::from_cbor(result) == j);
1352 CHECK(json::from_cbor(result, true, false) == j);
1357 json j;
1367 const auto result = json::to_cbor(j);
1378 CHECK(json::from_cbor(result) == j);
1379 CHECK(json::from_cbor(result, true, false) == j);
1384 json j;
1394 const auto result = json::to_cbor(j);
1407 CHECK(json::from_cbor(result) == j);
1408 CHECK(json::from_cbor(result, true, false) == j);
1413 json j;
1423 const auto result = json::to_cbor(j);
1438 CHECK(json::from_cbor(result) == j);
1439 CHECK(json::from_cbor(result, true, false) == j);
1453 json j = json::binary(s);
1464 const auto result = json::to_cbor(j);
1474 CHECK(json::from_cbor(result) == j);
1475 CHECK(json::from_cbor(result, true, false) == j);
1487 json j = json::binary(s);
1499 const auto result = json::to_cbor(j);
1506 CHECK(json::from_cbor(result) == j);
1507 CHECK(json::from_cbor(result, true, false) == j);
1522 json j = json::binary(s);
1532 const auto result = json::to_cbor(j);
1539 CHECK(json::from_cbor(result) == j);
1540 CHECK(json::from_cbor(result, true, false) == j);
1555 json j = json::binary(s);
1567 const auto result = json::to_cbor(j);
1574 CHECK(json::from_cbor(result) == j);
1575 CHECK(json::from_cbor(result, true, false) == j);
1582 auto j = json::from_cbor(input);
1584 auto k = json::binary({0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x99});
1585 CAPTURE(j.dump(0, ' ', false, json::error_handler_t::strict))
1593 json _;
1594 CHECK_NOTHROW(_ = json::from_cbor(input));
1601 json _;
1602 CHECK_NOTHROW(_ = json::from_cbor(input));
1612 … auto callback = [&binary_seen](int /*depth*/, json::parse_event_t /*event*/, json & parsed)
1621 json j;
1622 auto cbp = nlohmann::detail::json_sax_dom_callback_parser<json>(j, callback, true);
1623 CHECK(json::sax_parse(input, &cbp, json::input_format_t::cbor));
1637 json j = json::from_cbor(given);
1638 CHECK(j == json::binary(std::vector<uint8_t> {'a'}));
1646 json j = json::from_cbor(given);
1655 json j = json::from_cbor(given);
1656 CHECK(j == json::parse("[false]"));
1664 json j = json::from_cbor(given);
1665 CHECK(j == json::parse("{\"\": false}"));
1673 json _;
1674 CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>()), json::parse_error&);
1675 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>()),
1677 CHECK(json::from_cbor(std::vector<uint8_t>(), true, false).is_discarded());
1682 json _;
1683 CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x18})), json::parse_error&);
1684 CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x19})), json::parse_error&);
1685 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x19, 0x00})), json::parse_error&);
1686 CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1a})), json::parse_error&);
1687 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1a, 0x00})), json::parse_error&);
1688 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00})), json::parse_error&);
1689 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00, 0x00})), json::parse_e…
1690 CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1b})), json::parse_error&);
1691 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00})), json::parse_error&);
1692 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00})), json::parse_error&);
1693 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00})), json::parse_e…
1694 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00})), json::p…
1695 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})), j…
1696 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00…
1697 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00…
1698 CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x62})), json::parse_error&);
1699 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x62, 0x60})), json::parse_error&);
1700 CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x7F})), json::parse_error&);
1701 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x7F, 0x60})), json::parse_error&);
1702 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x82, 0x01})), json::parse_error&);
1703 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x9F, 0x01})), json::parse_error&);
1704 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0xBF, 0x61, 0x61, 0xF5})), json::parse_e…
1705 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0xA1, 0x61, 0X61})), json::parse_error&);
1706 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0xBF, 0x61, 0X61})), json::parse_error&);
1707 CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x5F})), json::parse_error&);
1708 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x5F, 0x00})), json::parse_error&);
1709 CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x41})), json::parse_error&);
1711 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x18})),
1713 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x19})),
1715 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x19, 0x00})),
1717 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1a})),
1719 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1a, 0x00})),
1721 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00})),
1723 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00, 0x00})),
1725 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1b})),
1727 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00})),
1729 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00})),
1731 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00})),
1733 … CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00})),
1735 … CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})),
1737 …CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x…
1739 …CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x…
1741 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x62})),
1743 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x62, 0x60})),
1745 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x7F})),
1747 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x7F, 0x60})),
1749 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x82, 0x01})),
1751 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x9F, 0x01})),
1753 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0xBF, 0x61, 0x61, 0xF5})),
1755 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0xA1, 0x61, 0x61})),
1757 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0xBF, 0x61, 0x61})),
1759 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x5F})),
1761 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x5F, 0x00})),
1763 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x41})),
1766 CHECK(json::from_cbor(std::vector<uint8_t>({0x18}), true, false).is_discarded());
1767 CHECK(json::from_cbor(std::vector<uint8_t>({0x19}), true, false).is_discarded());
1768 CHECK(json::from_cbor(std::vector<uint8_t>({0x19, 0x00}), true, false).is_discarded());
1769 CHECK(json::from_cbor(std::vector<uint8_t>({0x1a}), true, false).is_discarded());
1770 CHECK(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00}), true, false).is_discarded());
1771 … CHECK(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00}), true, false).is_discarded());
1772 …CHECK(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00, 0x00}), true, false).is_discarded());
1773 CHECK(json::from_cbor(std::vector<uint8_t>({0x1b}), true, false).is_discarded());
1774 CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00}), true, false).is_discarded());
1775 … CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00}), true, false).is_discarded());
1776 …CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00}), true, false).is_discarded());
1777 …CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00}), true, false).is_discar…
1778 …CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00}), true, false).is_…
1779 …CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), true, fals…
1780 …CHECK(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), true…
1781 CHECK(json::from_cbor(std::vector<uint8_t>({0x62}), true, false).is_discarded());
1782 CHECK(json::from_cbor(std::vector<uint8_t>({0x62, 0x60}), true, false).is_discarded());
1783 CHECK(json::from_cbor(std::vector<uint8_t>({0x7F}), true, false).is_discarded());
1784 CHECK(json::from_cbor(std::vector<uint8_t>({0x7F, 0x60}), true, false).is_discarded());
1785 CHECK(json::from_cbor(std::vector<uint8_t>({0x82, 0x01}), true, false).is_discarded());
1786 CHECK(json::from_cbor(std::vector<uint8_t>({0x9F, 0x01}), true, false).is_discarded());
1787 …CHECK(json::from_cbor(std::vector<uint8_t>({0xBF, 0x61, 0x61, 0xF5}), true, false).is_discarded());
1788 … CHECK(json::from_cbor(std::vector<uint8_t>({0xA1, 0x61, 0x61}), true, false).is_discarded());
1789 … CHECK(json::from_cbor(std::vector<uint8_t>({0xBF, 0x61, 0x61}), true, false).is_discarded());
1790 CHECK(json::from_cbor(std::vector<uint8_t>({0x5F}), true, false).is_discarded());
1791 CHECK(json::from_cbor(std::vector<uint8_t>({0x5F, 0x00}), true, false).is_discarded());
1792 CHECK(json::from_cbor(std::vector<uint8_t>({0x41}), true, false).is_discarded());
1799 json _;
1800 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0x1c})), json::parse_error&);
1801 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0x1c})),
1803 CHECK(json::from_cbor(std::vector<uint8_t>({0x1c}), true, false).is_discarded());
1805 … CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0xf8})), json::parse_error&);
1806 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0xf8})),
1808 CHECK(json::from_cbor(std::vector<uint8_t>({0xf8}), true, false).is_discarded());
1851 json _;
1852 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({static_cast<uint8_t>(byte)})), json::par…
1853 …CHECK(json::from_cbor(std::vector<uint8_t>({static_cast<uint8_t>(byte)}), true, false).is_discarde…
1860 json _;
1861 …CHECK_THROWS_AS(_ = json::from_cbor(std::vector<uint8_t>({0xa1, 0xff, 0x01})), json::parse_error&);
1862 CHECK_THROWS_WITH(_ = json::from_cbor(std::vector<uint8_t>({0xa1, 0xff, 0x01})),
1864 … CHECK(json::from_cbor(std::vector<uint8_t>({0xa1, 0xff, 0x01}), true, false).is_discarded());
1872 const auto result = json::from_cbor(vec, false);
1873 CHECK(result == json());
1874 CHECK(!json::from_cbor(vec, false, false).is_discarded());
1879 json _;
1880 CHECK_THROWS_AS(_ = json::from_cbor(vec), json::parse_error&);
1881 CHECK_THROWS_WITH(_ = json::from_cbor(vec),
1883 CHECK(json::from_cbor(vec, true, false).is_discarded());
1894 CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor));
1901 CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor));
1908 CHECK(!json::sax_parse(v, &scp, json::input_format_t::cbor));
1922 json j1 = json::parse(f_json);
1926 json j2;
1927 CHECK_NOTHROW(j2 = json::from_cbor(packed));
1937 json::to_cbor(j1, ss);
1938 json j3 = json::from_cbor(ss.str());
1945 json::to_cbor(j1, s);
1946 json j3 = json::from_cbor(s);
1953 CHECK(j1 == json::from_cbor(packed.begin() + 5, packed.end()));
1998 json j1 = json::from_cbor(vec1); in CAPTURE()
2003 std::vector<uint8_t> vec2 = json::to_cbor(j1); in CAPTURE()
2006 json j2 = json::from_cbor(vec2); in CAPTURE()
2011 catch (const json::parse_error&) in CAPTURE()
2017 catch (const json::parse_error&)
2199 json j1 = json::parse(f_json); in skip()
2203 json j2; in skip()
2204 CHECK_NOTHROW(j2 = json::from_cbor(packed)); in skip()
2214 json j1 = json::parse(f_json); in skip()
2218 json j2; in skip()
2219 CHECK_NOTHROW(j2 = json::from_cbor(f_cbor)); in skip()
2229 json j1 = json::parse(f_json); in skip()
2233 json j2; in skip()
2234 CHECK_NOTHROW(j2 = json::from_cbor({packed.data(), packed.size()})); in skip()
2244 json j1 = json::parse(f_json); in skip()
2254 json::to_cbor(j1, vec); in skip()
2316 auto res = json::from_cbor(std::vector<uint8_t>(1, byte));
2318 catch (const json::parse_error& e)
2340 CHECK(json::to_cbor(json::parse("0")) == std::vector<uint8_t>({0x00}));
2341 CHECK(json::parse("0") == json::from_cbor(std::vector<uint8_t>({0x00})));
2343 CHECK(json::to_cbor(json::parse("1")) == std::vector<uint8_t>({0x01}));
2344 CHECK(json::parse("1") == json::from_cbor(std::vector<uint8_t>({0x01})));
2346 CHECK(json::to_cbor(json::parse("10")) == std::vector<uint8_t>({0x0a}));
2347 CHECK(json::parse("10") == json::from_cbor(std::vector<uint8_t>({0x0a})));
2349 CHECK(json::to_cbor(json::parse("23")) == std::vector<uint8_t>({0x17}));
2350 CHECK(json::parse("23") == json::from_cbor(std::vector<uint8_t>({0x17})));
2352 CHECK(json::to_cbor(json::parse("24")) == std::vector<uint8_t>({0x18, 0x18}));
2353 CHECK(json::parse("24") == json::from_cbor(std::vector<uint8_t>({0x18, 0x18})));
2355 CHECK(json::to_cbor(json::parse("25")) == std::vector<uint8_t>({0x18, 0x19}));
2356 CHECK(json::parse("25") == json::from_cbor(std::vector<uint8_t>({0x18, 0x19})));
2358 CHECK(json::to_cbor(json::parse("100")) == std::vector<uint8_t>({0x18, 0x64}));
2359 CHECK(json::parse("100") == json::from_cbor(std::vector<uint8_t>({0x18, 0x64})));
2361 CHECK(json::to_cbor(json::parse("1000")) == std::vector<uint8_t>({0x19, 0x03, 0xe8}));
2362 CHECK(json::parse("1000") == json::from_cbor(std::vector<uint8_t>({0x19, 0x03, 0xe8})));
2364 …CHECK(json::to_cbor(json::parse("1000000")) == std::vector<uint8_t>({0x1a, 0x00, 0x0f, 0x42, 0x40}…
2365 …CHECK(json::parse("1000000") == json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x0f, 0x42, 0x40…
2367 …CHECK(json::to_cbor(json::parse("1000000000000")) == std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00,…
2368 …CHECK(json::parse("1000000000000") == json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00…
2370 …CHECK(json::to_cbor(json::parse("18446744073709551615")) == std::vector<uint8_t>({0x1b, 0xff, 0xff…
2371 …CHECK(json::parse("18446744073709551615") == json::from_cbor(std::vector<uint8_t>({0x1b, 0xff, 0xf…
2384 CHECK(json::to_cbor(json::parse("-1")) == std::vector<uint8_t>({0x20}));
2385 CHECK(json::parse("-1") == json::from_cbor(std::vector<uint8_t>({0x20})));
2387 CHECK(json::to_cbor(json::parse("-10")) == std::vector<uint8_t>({0x29}));
2388 CHECK(json::parse("-10") == json::from_cbor(std::vector<uint8_t>({0x29})));
2390 CHECK(json::to_cbor(json::parse("-100")) == std::vector<uint8_t>({0x38, 0x63}));
2391 CHECK(json::parse("-100") == json::from_cbor(std::vector<uint8_t>({0x38, 0x63})));
2393 CHECK(json::to_cbor(json::parse("-1000")) == std::vector<uint8_t>({0x39, 0x03, 0xe7}));
2394 CHECK(json::parse("-1000") == json::from_cbor(std::vector<uint8_t>({0x39, 0x03, 0xe7})));
2398 CHECK(json::parse("0.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x00})));
2402 CHECK(json::parse("-0.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0x80, 0x00})));
2406 CHECK(json::parse("1.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0x3c, 0x00})));
2408 …CHECK(json::to_cbor(json::parse("1.1")) == std::vector<uint8_t>({0xfb, 0x3f, 0xf1, 0x99, 0x99, 0x9…
2409 …CHECK(json::parse("1.1") == json::from_cbor(std::vector<uint8_t>({0xfb, 0x3f, 0xf1, 0x99, 0x99, 0x…
2413 CHECK(json::parse("1.5") == json::from_cbor(std::vector<uint8_t>({0xf9, 0x3e, 0x00})));
2417 CHECK(json::parse("65504.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0x7b, 0xff})));
2420 …CHECK(json::parse("100000.0") == json::from_cbor(std::vector<uint8_t>({0xfa, 0x47, 0xc3, 0x50, 0x0…
2423 …CHECK(json::parse("3.4028234663852886e+38") == json::from_cbor(std::vector<uint8_t>({0xfa, 0x7f, 0…
2425 …CHECK(json::to_cbor(json::parse("1.0e+300")) == std::vector<uint8_t>({0xfb, 0x7e, 0x37, 0xe4, 0x3c…
2426 …CHECK(json::parse("1.0e+300") == json::from_cbor(std::vector<uint8_t>({0xfb, 0x7e, 0x37, 0xe4, 0x3…
2430 CHECK(json::parse("-4.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0xc4, 0x00})));
2434 CHECK(json::parse("-4.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0xc4, 0x00})));
2438 CHECK(json::parse("-4.0") == json::from_cbor(std::vector<uint8_t>({0xf9, 0xc4, 0x00})));
2440 …CHECK(json::to_cbor(json::parse("-4.1")) == std::vector<uint8_t>({0xfb, 0xc0, 0x10, 0x66, 0x66, 0x…
2441 …CHECK(json::parse("-4.1") == json::from_cbor(std::vector<uint8_t>({0xfb, 0xc0, 0x10, 0x66, 0x66, 0…
2446 CHECK(json::to_cbor(json::parse("false")) == std::vector<uint8_t>({0xf4}));
2447 CHECK(json::parse("false") == json::from_cbor(std::vector<uint8_t>({0xf4})));
2449 CHECK(json::to_cbor(json::parse("true")) == std::vector<uint8_t>({0xf5}));
2450 CHECK(json::parse("true") == json::from_cbor(std::vector<uint8_t>({0xf5})));
2452 CHECK(json::to_cbor(json::parse("true")) == std::vector<uint8_t>({0xf5}));
2453 CHECK(json::parse("true") == json::from_cbor(std::vector<uint8_t>({0xf5})));
2458 CHECK(json::to_cbor(json::parse("\"\"")) == std::vector<uint8_t>({0x60}));
2459 CHECK(json::parse("\"\"") == json::from_cbor(std::vector<uint8_t>({0x60})));
2461 CHECK(json::to_cbor(json::parse("\"a\"")) == std::vector<uint8_t>({0x61, 0x61}));
2462 CHECK(json::parse("\"a\"") == json::from_cbor(std::vector<uint8_t>({0x61, 0x61})));
2464 …CHECK(json::to_cbor(json::parse("\"IETF\"")) == std::vector<uint8_t>({0x64, 0x49, 0x45, 0x54, 0x46…
2465 …CHECK(json::parse("\"IETF\"") == json::from_cbor(std::vector<uint8_t>({0x64, 0x49, 0x45, 0x54, 0x4…
2467 … CHECK(json::to_cbor(json::parse("\"\\u00fc\"")) == std::vector<uint8_t>({0x62, 0xc3, 0xbc}));
2468 … CHECK(json::parse("\"\\u00fc\"") == json::from_cbor(std::vector<uint8_t>({0x62, 0xc3, 0xbc})));
2470 …CHECK(json::to_cbor(json::parse("\"\\u6c34\"")) == std::vector<uint8_t>({0x63, 0xe6, 0xb0, 0xb4}));
2471 …CHECK(json::parse("\"\\u6c34\"") == json::from_cbor(std::vector<uint8_t>({0x63, 0xe6, 0xb0, 0xb4})…
2473 …CHECK(json::to_cbor(json::parse("\"\\ud800\\udd51\"")) == std::vector<uint8_t>({0x64, 0xf0, 0x90, …
2474 …CHECK(json::parse("\"\\ud800\\udd51\"") == json::from_cbor(std::vector<uint8_t>({0x64, 0xf0, 0x90,…
2477 …CHECK(json::parse("\"streaming\"") == json::from_cbor(std::vector<uint8_t>({0x7f, 0x65, 0x73, 0x74…
2483 json j;
2484 CHECK_NOTHROW(j = json::from_cbor(packed));
2487 CHECK(j == json::binary(expected));
2490 …CHECK(json::to_cbor(json::binary(std::vector<uint8_t> {}, 0x42)) == std::vector<uint8_t> {0xd8, 0x…
2491 …CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t> {}, 0x42)), true, true, jso…
2492 …CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t> {}, 0x42)), true, true, json…
2494 …CHECK(json::to_cbor(json::binary(std::vector<uint8_t> {}, 1000)) == std::vector<uint8_t> {0xd9, 0x…
2495 …CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t> {}, 1000)), true, true, jso…
2496 …CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t> {}, 1000)), true, true, json…
2498 …CHECK(json::to_cbor(json::binary(std::vector<uint8_t> {}, 394216)) == std::vector<uint8_t> {0xda, …
2499 …CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t> {}, 394216)), true, true, j…
2500 …CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t> {}, 394216)), true, true, js…
2502 …CHECK(json::to_cbor(json::binary(std::vector<uint8_t> {}, 8589934590)) == std::vector<uint8_t> {0x…
2503 …CHECK(!json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t> {}, 8589934590)), true, tru…
2504 …CHECK(json::from_cbor(json::to_cbor(json::binary(std::vector<uint8_t> {}, 8589934590)), true, true…
2509 CHECK(json::to_cbor(json::parse("[]")) == std::vector<uint8_t>({0x80}));
2510 CHECK(json::parse("[]") == json::from_cbor(std::vector<uint8_t>({0x80})));
2512 … CHECK(json::to_cbor(json::parse("[1, 2, 3]")) == std::vector<uint8_t>({0x83, 0x01, 0x02, 0x03}));
2513 …CHECK(json::parse("[1, 2, 3]") == json::from_cbor(std::vector<uint8_t>({0x83, 0x01, 0x02, 0x03})));
2515 …CHECK(json::to_cbor(json::parse("[1, [2, 3], [4, 5]]")) == std::vector<uint8_t>({0x83, 0x01, 0x82,…
2516 …CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({0x83, 0x01, 0x82…
2518 …CHECK(json::to_cbor(json::parse("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 1…
2519 …CHECK(json::parse("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,…
2522 CHECK(json::parse("[]") == json::from_cbor(std::vector<uint8_t>({0x9f, 0xff})));
2523 …CHECK(json::parse("[1, [2, 3], [4, 5]] ") == json::from_cbor(std::vector<uint8_t>({0x9f, 0x01, 0x8…
2524 …CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({0x9f, 0x01, 0x82…
2525 …CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({0x83, 0x01, 0x82…
2526 …CHECK(json::parse("[1, [2, 3], [4, 5]]") == json::from_cbor(std::vector<uint8_t>({0x83, 0x01, 0x9f…
2527 …CHECK(json::parse("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,…
2532 CHECK(json::to_cbor(json::parse("{}")) == std::vector<uint8_t>({0xa0}));
2533 CHECK(json::parse("{}") == json::from_cbor(std::vector<uint8_t>({0xa0})));
2535 …CHECK(json::to_cbor(json::parse("{\"a\": 1, \"b\": [2, 3]}")) == std::vector<uint8_t>({0xa2, 0x61,…
2536 …CHECK(json::parse("{\"a\": 1, \"b\": [2, 3]}") == json::from_cbor(std::vector<uint8_t>({0xa2, 0x61…
2538 …CHECK(json::to_cbor(json::parse("[\"a\", {\"b\": \"c\"}]")) == std::vector<uint8_t>({0x82, 0x61, 0…
2539 …CHECK(json::parse("[\"a\", {\"b\": \"c\"}]") == json::from_cbor(std::vector<uint8_t>({0x82, 0x61, …
2541 …CHECK(json::to_cbor(json::parse("{\"a\": \"A\", \"b\": \"B\", \"c\": \"C\", \"d\": \"D\", \"e\": \…
2542 …CHECK(json::parse("{\"a\": \"A\", \"b\": \"B\", \"c\": \"C\", \"d\": \"D\", \"e\": \"E\"}") == jso…
2545 …CHECK(json::parse("{\"a\": 1, \"b\": [2, 3]}") == json::from_cbor(std::vector<uint8_t>({0xbf, 0x61…
2546 …CHECK(json::parse("[\"a\", {\"b\": \"c\"}]") == json::from_cbor(std::vector<uint8_t>({0x82, 0x61, …
2547 …CHECK(json::parse("{\"Fun\": true, \"Amt\": -2}") == json::from_cbor(std::vector<uint8_t>({0xbf, 0…
2553 json j = "s";
2554 auto v = json::to_cbor(j);
2570 json _;
2571 CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
2572 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::…
2575 auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
2578 … auto j_tagged_stored = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::store);
2593 json _;
2594 CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
2595 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::…
2598 auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
2609 json _;
2610 CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
2611 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::…
2612 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json:…
2627 json _;
2628 CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
2629 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::…
2632 auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
2644 json _;
2645 CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
2646 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::…
2647 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json:…
2664 json _;
2665 CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
2666 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::…
2669 auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
2683 json _;
2684 CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
2685 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::…
2686 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json:…
2707 json _;
2708 CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
2709 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::…
2712 auto j_tagged = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore);
2730 json _;
2731 CHECK_THROWS_AS(_ = json::from_cbor(v_tagged), json::parse_error);
2732 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::error), json::…
2733 …CHECK_THROWS_AS(_ = json::from_cbor(v_tagged, true, true, json::cbor_tag_handler_t::ignore), json:…
2740 json j_binary;
2741 j_binary["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42);
2744 const auto vec = json::to_cbor(j_binary);
2748 json _;
2749 CHECK_THROWS_AS(_ = json::from_cbor(vec), json::parse_error);
2750 …CHECK_THROWS_WITH(_ = json::from_cbor(vec), "[json.exception.parse_error.112] parse error at byte …
2753 json jb = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore);