Commit 5820a182 authored by Dominik Charousset's avatar Dominik Charousset

Fix build on MSVC

parent 5b4905fb
...@@ -44,11 +44,12 @@ SCENARIO("the JSON writer converts builtin types to strings") { ...@@ -44,11 +44,12 @@ SCENARIO("the JSON writer converts builtin types to strings") {
} }
} }
GIVEN("a string") { GIVEN("a string") {
auto x = R"_(hello "world"!)_"s; std::string x = R"_(hello "world"!)_";
WHEN("converting it to JSON with any indentation factor") { WHEN("converting it to JSON with any indentation factor") {
THEN("the JSON output is the escaped string") { THEN("the JSON output is the escaped string") {
CHECK_EQ(to_json_string(x, 0), R"_("hello \"world\"!")_"s); std::string out = R"_("hello \"world\"!")_";
CHECK_EQ(to_json_string(x, 2), R"_("hello \"world\"!")_"s); CHECK_EQ(to_json_string(x, 0), out);
CHECK_EQ(to_json_string(x, 2), out);
} }
} }
} }
...@@ -56,16 +57,17 @@ SCENARIO("the JSON writer converts builtin types to strings") { ...@@ -56,16 +57,17 @@ SCENARIO("the JSON writer converts builtin types to strings") {
auto x = std::vector<int>{1, 2, 3}; auto x = std::vector<int>{1, 2, 3};
WHEN("converting it to JSON with indentation factor 0") { WHEN("converting it to JSON with indentation factor 0") {
THEN("the JSON output is a single line") { THEN("the JSON output is a single line") {
CHECK_EQ(to_json_string(x, 0), "[1, 2, 3]"s); std::string out = "[1, 2, 3]";
CHECK_EQ(to_json_string(x, 0), out);
} }
} }
WHEN("converting it to JSON with indentation factor 2") { WHEN("converting it to JSON with indentation factor 2") {
THEN("the JSON output uses multiple lines") { THEN("the JSON output uses multiple lines") {
auto out = R"_([ std::string out = R"_([
1, 1,
2, 2,
3 3
])_"s; ])_";
CHECK_EQ(to_json_string(x, 2), out); CHECK_EQ(to_json_string(x, 2), out);
} }
} }
...@@ -82,11 +84,11 @@ SCENARIO("the JSON writer converts builtin types to strings") { ...@@ -82,11 +84,11 @@ SCENARIO("the JSON writer converts builtin types to strings") {
} }
WHEN("converting it to JSON with indentation factor 2") { WHEN("converting it to JSON with indentation factor 2") {
THEN("the JSON output uses multiple lines") { THEN("the JSON output uses multiple lines") {
auto out = R"_({ std::string out = R"_({
"a": "A", "a": "A",
"b": "B", "b": "B",
"c": "C" "c": "C"
})_"s; })_";
CHECK_EQ(to_json_string(x, 2), out); CHECK_EQ(to_json_string(x, 2), out);
} }
} }
...@@ -95,19 +97,19 @@ SCENARIO("the JSON writer converts builtin types to strings") { ...@@ -95,19 +97,19 @@ SCENARIO("the JSON writer converts builtin types to strings") {
auto x = make_message(put_atom_v, "foo", 42); auto x = make_message(put_atom_v, "foo", 42);
WHEN("converting it to JSON with indentation factor 0") { WHEN("converting it to JSON with indentation factor 0") {
THEN("the JSON output is a single line") { THEN("the JSON output is a single line") {
CHECK_EQ(to_json_string(x, 0), std::string out = R"_([{"@type": "caf::put_atom"}, "foo", 42])_";
R"_([{"@type": "caf::put_atom"}, "foo", 42])_"s); CHECK_EQ(to_json_string(x, 0), out);
} }
} }
WHEN("converting it to JSON with indentation factor 2") { WHEN("converting it to JSON with indentation factor 2") {
THEN("the JSON output uses multiple lines") { THEN("the JSON output uses multiple lines") {
auto out = R"_([ std::string out = R"_([
{ {
"@type": "caf::put_atom" "@type": "caf::put_atom"
}, },
"foo", "foo",
42 42
])_"s; ])_";
CHECK_EQ(to_json_string(x, 2), out); CHECK_EQ(to_json_string(x, 2), out);
} }
} }
...@@ -119,17 +121,17 @@ SCENARIO("the JSON writer converts simple structs to strings") { ...@@ -119,17 +121,17 @@ SCENARIO("the JSON writer converts simple structs to strings") {
dummy_struct x{10, "foo"}; dummy_struct x{10, "foo"};
WHEN("converting it to JSON with indentation factor 0") { WHEN("converting it to JSON with indentation factor 0") {
THEN("the JSON output is a single line") { THEN("the JSON output is a single line") {
auto out = R"_({"@type": "dummy_struct", "a": 10, "b": "foo"})_"s; std::string out = R"_({"@type": "dummy_struct", "a": 10, "b": "foo"})_";
CHECK_EQ(to_json_string(x, 0), out); CHECK_EQ(to_json_string(x, 0), out);
} }
} }
WHEN("converting it to JSON with indentation factor 2") { WHEN("converting it to JSON with indentation factor 2") {
THEN("the JSON output uses multiple lines") { THEN("the JSON output uses multiple lines") {
auto out = R"_({ std::string out = R"_({
"@type": "dummy_struct", "@type": "dummy_struct",
"a": 10, "a": 10,
"b": "foo" "b": "foo"
})_"s; })_";
CHECK_EQ(to_json_string(x, 2), out); CHECK_EQ(to_json_string(x, 2), out);
} }
} }
......
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