Skip to content

Commit

Permalink
Restore json to alt_json conversion in unit test
Browse files Browse the repository at this point in the history
A unit test in unit-alt_string.cpp converts a json object to an alt_json
object. During the json_pointer refactor this failed to compile and was
commented out.
The failure can no longer be reproduced with the current code.

This commit restores the test to its originally proposed form.

Closes nlohmann#3425.
  • Loading branch information
falbrechtskirchinger committed Apr 12, 2022
1 parent a944306 commit ea64a6e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions test/src/unit-alt-string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,11 @@ TEST_CASE("alternative string type")

SECTION("JSON pointer")
{
// conversion from json to alt_json fails to compile (see #3425);
// attempted fix(*) produces: [[['b','a','r'],['b','a','z']]] (with each char being an integer)
// (*) disable implicit conversion for json_refs of any basic_json type
// alt_json j = R"(
// {
// "foo": ["bar", "baz"]
// }
// )"_json;
auto j = alt_json::parse(R"({"foo": ["bar", "baz"]})");
alt_json j = R"(
{
"foo": ["bar", "baz"]
}
)"_json;

CHECK(j.at(alt_json::json_pointer("/foo/0")) == j["foo"][0]);
CHECK(j.at(alt_json::json_pointer("/foo/1")) == j["foo"][1]);
Expand Down

0 comments on commit ea64a6e

Please sign in to comment.