aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/protobuf/json/ut/json2proto_ut.cpp
diff options
context:
space:
mode:
authorart-snake <art-snake@yandex-team.ru>2022-02-10 16:50:34 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:34 +0300
commit1700010e2088971894d12a7a16d6004866f986fd (patch)
treeac3b38289119375037d595858db9751013220a3f /library/cpp/protobuf/json/ut/json2proto_ut.cpp
parent785bc0acdf3b0c63f971ee17e845945d7381dcb7 (diff)
downloadydb-1700010e2088971894d12a7a16d6004866f986fd.tar.gz
Restoring authorship annotation for <art-snake@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/protobuf/json/ut/json2proto_ut.cpp')
-rw-r--r--library/cpp/protobuf/json/ut/json2proto_ut.cpp136
1 files changed, 68 insertions, 68 deletions
diff --git a/library/cpp/protobuf/json/ut/json2proto_ut.cpp b/library/cpp/protobuf/json/ut/json2proto_ut.cpp
index 0dfe57bc7a..081072971c 100644
--- a/library/cpp/protobuf/json/ut/json2proto_ut.cpp
+++ b/library/cpp/protobuf/json/ut/json2proto_ut.cpp
@@ -690,57 +690,57 @@ Y_UNIT_TEST(TestVectorizeScalars) {
#undef DEFINE_FIELD
}
-Y_UNIT_TEST(TestValueVectorizer) {
- {
- // No ValueVectorizer
- NJson::TJsonValue json;
- json["RepeatedString"] = "123";
- TJson2ProtoConfig config;
- TSingleRepeatedString expected;
- UNIT_ASSERT_EXCEPTION(Json2Proto(json, expected, config), yexception);
- }
- {
- // ValueVectorizer replace original value by array
- NJson::TJsonValue json;
- json["RepeatedString"] = "123";
- TJson2ProtoConfig config;
-
- TSingleRepeatedString expected;
- expected.AddRepeatedString("4");
- expected.AddRepeatedString("5");
- expected.AddRepeatedString("6");
-
- config.ValueVectorizer = [](const NJson::TJsonValue& val) -> NJson::TJsonValue::TArray {
- Y_UNUSED(val);
- return {NJson::TJsonValue("4"), NJson::TJsonValue("5"), NJson::TJsonValue("6")};
- };
- TSingleRepeatedString actual;
- Json2Proto(json, actual, config);
- UNIT_ASSERT_PROTOS_EQUAL(expected, actual);
- }
- {
- // ValueVectorizer replace original value by array and cast
- NJson::TJsonValue json;
- json["RepeatedInt"] = 123;
- TJson2ProtoConfig config;
-
- TSingleRepeatedInt expected;
- expected.AddRepeatedInt(4);
- expected.AddRepeatedInt(5);
- expected.AddRepeatedInt(6);
-
- config.ValueVectorizer = [](const NJson::TJsonValue& val) -> NJson::TJsonValue::TArray {
- Y_UNUSED(val);
- return {NJson::TJsonValue("4"), NJson::TJsonValue(5), NJson::TJsonValue("6")};
- };
- config.CastFromString = true;
-
- TSingleRepeatedInt actual;
- Json2Proto(json, actual, config);
- UNIT_ASSERT_PROTOS_EQUAL(expected, actual);
- }
-}
-
+Y_UNIT_TEST(TestValueVectorizer) {
+ {
+ // No ValueVectorizer
+ NJson::TJsonValue json;
+ json["RepeatedString"] = "123";
+ TJson2ProtoConfig config;
+ TSingleRepeatedString expected;
+ UNIT_ASSERT_EXCEPTION(Json2Proto(json, expected, config), yexception);
+ }
+ {
+ // ValueVectorizer replace original value by array
+ NJson::TJsonValue json;
+ json["RepeatedString"] = "123";
+ TJson2ProtoConfig config;
+
+ TSingleRepeatedString expected;
+ expected.AddRepeatedString("4");
+ expected.AddRepeatedString("5");
+ expected.AddRepeatedString("6");
+
+ config.ValueVectorizer = [](const NJson::TJsonValue& val) -> NJson::TJsonValue::TArray {
+ Y_UNUSED(val);
+ return {NJson::TJsonValue("4"), NJson::TJsonValue("5"), NJson::TJsonValue("6")};
+ };
+ TSingleRepeatedString actual;
+ Json2Proto(json, actual, config);
+ UNIT_ASSERT_PROTOS_EQUAL(expected, actual);
+ }
+ {
+ // ValueVectorizer replace original value by array and cast
+ NJson::TJsonValue json;
+ json["RepeatedInt"] = 123;
+ TJson2ProtoConfig config;
+
+ TSingleRepeatedInt expected;
+ expected.AddRepeatedInt(4);
+ expected.AddRepeatedInt(5);
+ expected.AddRepeatedInt(6);
+
+ config.ValueVectorizer = [](const NJson::TJsonValue& val) -> NJson::TJsonValue::TArray {
+ Y_UNUSED(val);
+ return {NJson::TJsonValue("4"), NJson::TJsonValue(5), NJson::TJsonValue("6")};
+ };
+ config.CastFromString = true;
+
+ TSingleRepeatedInt actual;
+ Json2Proto(json, actual, config);
+ UNIT_ASSERT_PROTOS_EQUAL(expected, actual);
+ }
+}
+
Y_UNIT_TEST(TestMapAsObject) {
TMapType modelProto;
@@ -1103,23 +1103,23 @@ Y_UNIT_TEST(TestMergeRepeatedAppend) {
UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto);
} // TestMergeRepeatedAppend
-Y_UNIT_TEST(TestEmptyStringForCastFromString) {
- NJson::TJsonValue json;
- json["I32"] = "";
- json["Bool"] = "";
- json["OneString"] = "";
-
- TJson2ProtoConfig config;
- config.SetCastFromString(true);
- config.SetDoNotCastEmptyStrings(true);
- TFlatOptional proto;
- UNIT_ASSERT_NO_EXCEPTION(Json2Proto(json, proto, config));
- UNIT_ASSERT(!proto.HasBool());
- UNIT_ASSERT(!proto.HasI32());
- UNIT_ASSERT(proto.HasOneString());
- UNIT_ASSERT_EQUAL("", proto.GetOneString());
-} // TestEmptyStringForCastFromString
-
+Y_UNIT_TEST(TestEmptyStringForCastFromString) {
+ NJson::TJsonValue json;
+ json["I32"] = "";
+ json["Bool"] = "";
+ json["OneString"] = "";
+
+ TJson2ProtoConfig config;
+ config.SetCastFromString(true);
+ config.SetDoNotCastEmptyStrings(true);
+ TFlatOptional proto;
+ UNIT_ASSERT_NO_EXCEPTION(Json2Proto(json, proto, config));
+ UNIT_ASSERT(!proto.HasBool());
+ UNIT_ASSERT(!proto.HasI32());
+ UNIT_ASSERT(proto.HasOneString());
+ UNIT_ASSERT_EQUAL("", proto.GetOneString());
+} // TestEmptyStringForCastFromString
+
Y_UNIT_TEST(TestAllowComments) {
constexpr TStringBuf json = R"(
{