Skip to content

Commit

Permalink
Fix build on MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
Neverlord committed Dec 17, 2023
1 parent cb6ac57 commit 7cc6d9a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/cpp/format/json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,16 @@ TEST(real) {
}

TEST(string) {
// Helper function that concatenates all arguments into one string.
auto concat = [](auto... args) {
std::string result;
(result += ... += args);
return result;
};
CHECK_EQUAL(to_v1("foo"sv), R"_({"@data-type":"string","data":"foo"})_");
CHECK_EQUAL(to_v1("foo\nbar"sv),
R"_({"@data-type":"string","data":"foo\nbar"})_");
CHECK_EQUAL(to_v1("foo\n\"bar"sv),
CHECK_EQUAL(to_v1(concat("foo\n", '"', "bar")), // concat: workaround for MSVC
R"_({"@data-type":"string","data":"foo\n\"bar"})_");
CHECK_EQUAL(to_v1(data{"foo"s}), R"_({"@data-type":"string","data":"foo"})_");
CHECK_EQUAL(to_v1(data{"foo\nbar"s}),
Expand Down

0 comments on commit 7cc6d9a

Please sign in to comment.