Lines Matching defs:key

72                 CHECK_THROWS_WITH_AS(j.at("foo"), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&);
73 CHECK_THROWS_WITH_AS(j_const.at("foo"), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&);
77 CHECK_THROWS_WITH_AS(j.at(std::string_view("foo")), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&);
78 CHECK_THROWS_WITH_AS(j_const.at(std::string_view("foo")), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&);
179 SECTION("given a key")
464 j_null["key"] = 1;
467 j_null["key"] = 2;
472 std::string_view key = "key";
475 j_null[key] = 1;
478 j_null[key] = 2;
488 // "integer" is the first key
491 // "array" is last key
497 // "array" is the smallest key
500 // "unsigned" is the largest key
742 SECTION("remove element by key")
786 SECTION("remove element by key (string_view)")
943 SECTION("remove element by key in non-object type")
1011 for (const auto* key :
1015 CHECK(j.find(key) != j.end());
1016 CHECK(*j.find(key) == j.at(key));
1017 CHECK(j_const.find(key) != j_const.end());
1018 CHECK(*j_const.find(key) == j_const.at(key));
1021 for (const std::string_view key :
1025 CHECK(j.find(key) != j.end());
1026 CHECK(*j.find(key) == j.at(key));
1027 CHECK(j_const.find(key) != j_const.end());
1028 CHECK(*j_const.find(key) == j_const.at(key));
1164 for (const auto* key :
1168 CHECK(j.count(key) == 1);
1169 CHECK(j_const.count(key) == 1);
1172 for (const std::string_view key :
1176 CHECK(j.count(key) == 1);
1177 CHECK(j_const.count(key) == 1);
1309 SECTION("check existence of key in an object")
1313 for (const auto* key :
1317 CHECK(j.contains(key) == true);
1318 CHECK(j_const.contains(key) == true);
1322 for (const std::string_view key :
1326 CHECK(j.contains(key) == true);
1327 CHECK(j_const.contains(key) == true);
1519 SECTION("literal key")
1543 SECTION("const char * key")
1545 const char* key = "foo";
1549 CHECK(j.value(key, "default") == "bar");
1550 CHECK(j.value(key, cpstr) == "bar");
1551 CHECK(j.value(key, castr) == "bar");
1552 CHECK(j.value(key, str) == "bar");
1564 CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1565 CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1568 SECTION("const char(&)[] key")
1570 const char key[] = "foo"; // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays)
1574 CHECK(j.value(key, "default") == "bar");
1575 CHECK(j.value(key, cpstr) == "bar");
1576 CHECK(j.value(key, castr) == "bar");
1577 CHECK(j.value(key, str) == "bar");
1589 CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1590 CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1593 SECTION("string_t/object_t::key_type key")
1595 string_t key = "foo";
1599 CHECK(j.value(key, "default") == "bar");
1600 CHECK(j.value(key, cpstr) == "bar");
1601 CHECK(j.value(key, castr) == "bar");
1602 CHECK(j.value(key, str) == "bar");
1614 CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1615 CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1619 SECTION("std::string_view key")
1621 std::string_view key = "foo";
1625 CHECK(j.value(key, "default") == "bar");
1626 CHECK(j.value(key, cpstr) == "bar");
1627 CHECK(j.value(key, castr) == "bar");
1628 CHECK(j.value(key, str) == "bar");
1640 CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1641 CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1648 SECTION("literal key")
1673 SECTION("const char * key")
1675 const char* key = "foo";
1679 CHECK(j.template value<string_t>(key, "default") == "bar");
1680 CHECK(j.template value<string_t>(key, cpstr) == "bar");
1681 CHECK(j.template value<string_t>(key, castr) == "bar");
1682 CHECK(j.template value<string_t>(key, str) == "bar");
1698 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1699 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1702 SECTION("const char(&)[] key")
1704 const char key[] = "foo"; // NOLINT(hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays)
1708 CHECK(j.template value<string_t>(key, "default") == "bar");
1709 CHECK(j.template value<string_t>(key, cpstr) == "bar");
1710 CHECK(j.template value<string_t>(key, castr) == "bar");
1711 CHECK(j.template value<string_t>(key, str) == "bar");
1727 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1728 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1731 SECTION("string_t/object_t::key_type key")
1733 string_t key = "foo";
1737 CHECK(j.template value<string_t>(key, "default") == "bar");
1738 CHECK(j.template value<string_t>(key, cpstr) == "bar");
1739 CHECK(j.template value<string_t>(key, castr) == "bar");
1740 CHECK(j.template value<string_t>(key, str) == "bar");
1752 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1753 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1757 SECTION("std::string_view key")
1759 std::string_view key = "foo";
1763 CHECK(j.template value<string_t>(key, "default") == "bar");
1764 CHECK(j.template value<string_t>(key, cpstr) == "bar");
1765 CHECK(j.template value<string_t>(key, castr) == "bar");
1766 CHECK(j.template value<string_t>(key, str) == "bar");
1782 CHECK(j.template value<std::string_view>(key, "default") == "bar");
1783 CHECK(j.template value<std::string_view>(key, cpstr) == "bar");
1784 CHECK(j.template value<std::string_view>(key, castr) == "bar");
1785 CHECK(j.template value<std::string_view>(key, str) == "bar");
1789 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1790 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);