Add checks to unit test readme
This commit is contained in:
parent
d354ac42c2
commit
58cef11a28
@ -106,12 +106,10 @@ TEST_CASE("README" * doctest::skip())
|
|||||||
json j = "{ \"happy\": true, \"pi\": 3.141 }"_json; // NOLINT(modernize-raw-string-literal)
|
json j = "{ \"happy\": true, \"pi\": 3.141 }"_json; // NOLINT(modernize-raw-string-literal)
|
||||||
|
|
||||||
// or even nicer with a raw string literal
|
// or even nicer with a raw string literal
|
||||||
auto j2 = R"(
|
auto j2 = R"({
|
||||||
{
|
|
||||||
"happy": true,
|
"happy": true,
|
||||||
"pi": 3.141
|
"pi": 3.141
|
||||||
}
|
})"_json;
|
||||||
)"_json;
|
|
||||||
|
|
||||||
// or explicitly
|
// or explicitly
|
||||||
auto j3 = json::parse(R"({"happy": true, "pi": 3.141})");
|
auto j3 = json::parse(R"({"happy": true, "pi": 3.141})");
|
||||||
@ -160,9 +158,9 @@ TEST_CASE("README" * doctest::skip())
|
|||||||
CHECK(foo == true);
|
CHECK(foo == true);
|
||||||
|
|
||||||
// other stuff
|
// other stuff
|
||||||
j.size(); // 3 entries
|
CHECK(j.size() == 3); // 3 entries
|
||||||
j.empty(); // false
|
CHECK_FALSE(j.empty()); // false
|
||||||
j.type(); // json::value_t::array
|
CHECK(j.type() == json::value_t::array); // json::value_t::array
|
||||||
j.clear(); // the array is empty again
|
j.clear(); // the array is empty again
|
||||||
|
|
||||||
// create an object
|
// create an object
|
||||||
@ -172,6 +170,7 @@ TEST_CASE("README" * doctest::skip())
|
|||||||
o["baz"] = 3.141;
|
o["baz"] = 3.141;
|
||||||
|
|
||||||
// find an entry
|
// find an entry
|
||||||
|
CHECK(o.find("foo") != o.end());
|
||||||
if (o.find("foo") != o.end())
|
if (o.find("foo") != o.end())
|
||||||
{
|
{
|
||||||
// there is an entry with key "foo"
|
// there is an entry with key "foo"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user