Commit 392c0338 authored by Vitaliy Manushkin's avatar Vitaliy Manushkin

test refactoring

parent 51349537
...@@ -142,24 +142,54 @@ using alt_json = nlohmann::basic_json < ...@@ -142,24 +142,54 @@ using alt_json = nlohmann::basic_json <
TEST_CASE("alternative string type") TEST_CASE("alternative string type")
{ {
SECTION("dump") SECTION("dump")
{
{ {
alt_json doc; alt_json doc;
doc["pi"] = 3.141; doc["pi"] = 3.141;
alt_string dump = doc.dump();
CHECK(dump == R"({"pi":3.141})");
}
{
alt_json doc;
doc["happy"] = true; doc["happy"] = true;
alt_string dump = doc.dump();
CHECK(dump == R"({"happy":true})");
}
{
alt_json doc;
doc["name"] = "I'm Batman"; doc["name"] = "I'm Batman";
alt_string dump = doc.dump();
CHECK(dump == R"({"name":"I'm Batman"})");
}
{
alt_json doc;
doc["nothing"] = nullptr; doc["nothing"] = nullptr;
alt_string dump = doc.dump();
CHECK(dump == R"({"nothing":null})");
}
{
alt_json doc;
doc["answer"]["everything"] = 42; doc["answer"]["everything"] = 42;
doc["list"] = { 1, 0, 2 }; alt_string dump = doc.dump();
doc["object"] = { {"currency", "USD"}, {"value", 42.99} }; CHECK(dump == R"({"answer":{"everything":42}})");
}
{
alt_json doc;
doc["list"] = { 1, 0, 2 };
alt_string dump = doc.dump(); alt_string dump = doc.dump();
CHECK(dump == R"({"list":[1,0,2]})");
}
const char* const expect_str = {
R"({"answer":{"everything":42},)" alt_json doc;
R"("happy":true,"list":[1,0,2],)" doc["list"] = { 1, 0, 2 };
R"("name":"I'm Batman","nothing":null,)" alt_string dump = doc.dump();
R"("object":{"currency":"USD","value":42.99},)" CHECK(dump == R"({"list":[1,0,2]})");
R"("pi":3.141})"; }
CHECK(dump == expect_str);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment