From ef16f51674bdbf14045dcb2f319bea90872bbe89 Mon Sep 17 00:00:00 2001 From: Dominik Charousset Date: Sun, 17 Dec 2023 19:20:25 +0100 Subject: [PATCH] Fix build on MSVC --- tests/cpp/format/json.cc | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tests/cpp/format/json.cc b/tests/cpp/format/json.cc index 9c16261d..7adb19d8 100644 --- a/tests/cpp/format/json.cc +++ b/tests/cpp/format/json.cc @@ -122,16 +122,13 @@ TEST(real) { } TEST(string) { + // Note: putting these literals into CHECK_EQUAL confuses MSVC. + auto foobar = "foo\n\"bar"s; + auto foobar_res = R"_({"@data-type":"string","data":"foo\n\"bar"})_"; 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), - R"_({"@data-type":"string","data":"foo\n\"bar"})_"); + CHECK_EQUAL(to_v1(foobar), foobar_res); CHECK_EQUAL(to_v1(data{"foo"s}), R"_({"@data-type":"string","data":"foo"})_"); - CHECK_EQUAL(to_v1(data{"foo\nbar"s}), - R"_({"@data-type":"string","data":"foo\nbar"})_"); - CHECK_EQUAL(to_v1(data{"foo\n\"bar"s}), - R"_({"@data-type":"string","data":"foo\n\"bar"})_"); + CHECK_EQUAL(to_v1(data{foobar}), foobar_res); } TEST(address) { @@ -198,18 +195,15 @@ TEST(timestamp) { } TEST(enum_value) { + // Note: putting these literals into CHECK_EQUAL confuses MSVC. + auto foobar = "foo\n\"bar"s; + auto foobar_res = R"_({"@data-type":"enum-value","data":"foo\n\"bar"})_"; CHECK_EQUAL(to_v1(enum_value{"foo"}), R"_({"@data-type":"enum-value","data":"foo"})_"); - CHECK_EQUAL(to_v1(enum_value{"foo\nbar"}), - R"_({"@data-type":"enum-value","data":"foo\nbar"})_"); - CHECK_EQUAL(to_v1(enum_value{"foo\n\"bar"}), - R"_({"@data-type":"enum-value","data":"foo\n\"bar"})_"); + CHECK_EQUAL(to_v1(foobar), foobar_res); CHECK_EQUAL(to_v1(data{enum_value{"foo"}}), R"_({"@data-type":"enum-value","data":"foo"})_"); - CHECK_EQUAL(to_v1(data{enum_value{"foo\nbar"}}), - R"_({"@data-type":"enum-value","data":"foo\nbar"})_"); - CHECK_EQUAL(to_v1(data{enum_value{"foo\n\"bar"}}), - R"_({"@data-type":"enum-value","data":"foo\n\"bar"})_"); + CHECK_EQUAL(to_v1(data{enum_value{foobar}}), foobar_res); } TEST(vector) {