diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:23 +0300 |
commit | 706b83ed7de5a473436620367af31fc0ceecde07 (patch) | |
tree | 103305d30dec77e8f6367753367f59b3cd68f9f1 /library/cpp/json/ut/json_writer_ut.cpp | |
parent | 918e8a1574070d0ec733f0b76cfad8f8892ad2e5 (diff) | |
download | ydb-706b83ed7de5a473436620367af31fc0ceecde07.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/json/ut/json_writer_ut.cpp')
-rw-r--r-- | library/cpp/json/ut/json_writer_ut.cpp | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/library/cpp/json/ut/json_writer_ut.cpp b/library/cpp/json/ut/json_writer_ut.cpp index ca11d34dad..ae60f208d4 100644 --- a/library/cpp/json/ut/json_writer_ut.cpp +++ b/library/cpp/json/ut/json_writer_ut.cpp @@ -7,9 +7,9 @@ using namespace NJson; Y_UNIT_TEST_SUITE(TJsonWriterTest) { Y_UNIT_TEST(SimpleWriteTest) { - TString expected1 = "{\"key1\":1,\"key2\":2,\"key3\":3"; + TString expected1 = "{\"key1\":1,\"key2\":2,\"key3\":3"; TString expected2 = expected1 + ",\"array\":[\"stroka\",false]"; - TString expected3 = expected2 + "}"; + TString expected3 = expected2 + "}"; TStringStream out; @@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } Y_UNIT_TEST(SimpleWriteValueTest) { - TString expected = "{\"key1\":null,\"key2\":{\"subkey1\":[1,{\"subsubkey\":\"test2\"},null,true],\"subkey2\":\"test\"}}"; + TString expected = "{\"key1\":null,\"key2\":{\"subkey1\":[1,{\"subsubkey\":\"test2\"},null,true],\"subkey2\":\"test\"}}"; TJsonValue v; v["key1"] = JSON_NULL; v["key2"]["subkey1"].AppendValue(1); @@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } Y_UNIT_TEST(FormatOutput) { - TString expected = "{\n \"key1\":null,\n \"key2\":\n {\n \"subkey1\":\n [\n 1,\n {\n \"subsubkey\":\"test2\"\n },\n null,\n true\n ],\n \"subkey2\":\"test\"\n }\n}"; + TString expected = "{\n \"key1\":null,\n \"key2\":\n {\n \"subkey1\":\n [\n 1,\n {\n \"subsubkey\":\"test2\"\n },\n null,\n true\n ],\n \"subkey2\":\"test\"\n }\n}"; TJsonValue v; v["key1"] = JSON_NULL; v["key2"]["subkey1"].AppendValue(1); @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } Y_UNIT_TEST(SortKeys) { - TString expected = "{\"a\":null,\"j\":null,\"n\":null,\"y\":null,\"z\":null}"; + TString expected = "{\"a\":null,\"j\":null,\"n\":null,\"y\":null,\"z\":null}"; TJsonValue v; v["z"] = JSON_NULL; v["n"] = JSON_NULL; @@ -84,7 +84,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { Y_UNIT_TEST(SimpleUnsignedIntegerWriteTest) { { - TString expected = "{\"test\":1}"; + TString expected = "{\"test\":1}"; TJsonValue v; v.InsertValue("test", 1ull); TStringStream out; @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } // 1 { - TString expected = "{\"test\":-1}"; + TString expected = "{\"test\":-1}"; TJsonValue v; v.InsertValue("test", -1); TStringStream out; @@ -102,7 +102,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } // -1 { - TString expected = "{\"test\":18446744073709551615}"; + TString expected = "{\"test\":18446744073709551615}"; TJsonValue v; v.InsertValue("test", 18446744073709551615ull); TStringStream out; @@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } // 18446744073709551615 { - TString expected = "{\"test\":[1,18446744073709551615]}"; + TString expected = "{\"test\":[1,18446744073709551615]}"; TJsonValue v; v.InsertValue("test", TJsonValue()); v["test"].AppendValue(1); @@ -123,62 +123,62 @@ Y_UNIT_TEST_SUITE(TJsonWriterTest) { } // SimpleUnsignedIntegerWriteTest Y_UNIT_TEST(WriteOptionalTest) { - { - TString expected = "{\"test\":1}"; - - TStringStream out; - - TJsonWriter json(&out, false); - json.OpenMap(); - json.WriteOptional("test", MakeMaybe<int>(1)); - json.CloseMap(); - json.Flush(); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); - } - - { - TString expected = "{}"; - - TStringStream out; - - TMaybe<int> nothing = Nothing(); - - TJsonWriter json(&out, false); - json.OpenMap(); - json.WriteOptional("test", nothing); - json.CloseMap(); - json.Flush(); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); - } - - { - TString expected = "{}"; - - TStringStream out; - - TMaybe<int> empty; - - TJsonWriter json(&out, false); - json.OpenMap(); - json.WriteOptional("test", empty); - json.CloseMap(); - json.Flush(); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); - } - - { - TString expected = "{}"; - - TStringStream out; - - TJsonWriter json(&out, false); - json.OpenMap(); - json.WriteOptional("test", Nothing()); - json.CloseMap(); - json.Flush(); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); - } - } + { + TString expected = "{\"test\":1}"; + + TStringStream out; + + TJsonWriter json(&out, false); + json.OpenMap(); + json.WriteOptional("test", MakeMaybe<int>(1)); + json.CloseMap(); + json.Flush(); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); + } + + { + TString expected = "{}"; + + TStringStream out; + + TMaybe<int> nothing = Nothing(); + + TJsonWriter json(&out, false); + json.OpenMap(); + json.WriteOptional("test", nothing); + json.CloseMap(); + json.Flush(); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); + } + + { + TString expected = "{}"; + + TStringStream out; + + TMaybe<int> empty; + + TJsonWriter json(&out, false); + json.OpenMap(); + json.WriteOptional("test", empty); + json.CloseMap(); + json.Flush(); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); + } + + { + TString expected = "{}"; + + TStringStream out; + + TJsonWriter json(&out, false); + json.OpenMap(); + json.WriteOptional("test", Nothing()); + json.CloseMap(); + json.Flush(); + UNIT_ASSERT_VALUES_EQUAL(out.Str(), expected); + } + } Y_UNIT_TEST(Callback) { NJsonWriter::TBuf json; |