add test for indented output

This commit is contained in:
Axel Kohlmeyer
2025-04-17 16:26:03 -04:00
parent 6e2d7f48d7
commit 9a08f7b23b

View File

@ -48,7 +48,11 @@ TEST(JSON, serialize_deserialize)
j1["nothing"] = nullptr;
std::string expected = "{\"happy\":true,\"name\":\"Niels\",\"nothing\":null,\"pi\":3.141}";
std::string dumped = j1.dump();
std::string dumped = j1.dump(-1);
ASSERT_THAT(expected, Eq(dumped));
expected = "{\n \"happy\": true,\n \"name\": \"Niels\",\n \"nothing\": null,\n \"pi\": 3.141\n}";
dumped = j1.dump(2, ' ');
ASSERT_THAT(expected, Eq(dumped));
json j2 = json::parse(expected);