diff options
author | timurguryev <timurguryev@yandex-team.ru> | 2022-02-10 16:50:26 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:26 +0300 |
commit | 74b68813c7dbee6e7538883986e9657eb0593d86 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 | |
parent | 17c53d36e339526aed2b1251a9375e2d4a7e6ed5 (diff) | |
download | ydb-74b68813c7dbee6e7538883986e9657eb0593d86.tar.gz |
Restoring authorship annotation for <timurguryev@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | library/cpp/json/writer/json_value.h | 52 | ||||
-rw-r--r-- | library/cpp/json/writer/json_value_ut.cpp | 48 |
2 files changed, 50 insertions, 50 deletions
diff --git a/library/cpp/json/writer/json_value.h b/library/cpp/json/writer/json_value.h index 1af20b7088..3f0f50bc4c 100644 --- a/library/cpp/json/writer/json_value.h +++ b/library/cpp/json/writer/json_value.h @@ -265,30 +265,30 @@ namespace NJson { bool GetMapPointer(const TJsonValue& jv, const TStringBuf key, const TJsonValue::TMapType** value); bool GetArrayPointer(const TJsonValue& jv, const TStringBuf key, const TJsonValue::TArray** value); - - class TJsonMap: public TJsonValue { - public: - TJsonMap() - : TJsonValue(NJson::JSON_MAP) - {} - - TJsonMap(const std::initializer_list<std::pair<TString, TJsonValue>>& list) - : TJsonValue(NJson::JSON_MAP) - { - GetMapSafe() = THashMap<TString, TJsonValue>(list); - } - }; - - class TJsonArray: public TJsonValue { - public: - TJsonArray() - : TJsonValue(NJson::JSON_ARRAY) - {} - - TJsonArray(const std::initializer_list<TJsonValue>& list) - : TJsonValue(NJson::JSON_ARRAY) - { - GetArraySafe() = TJsonValue::TArray(list); - } - }; + + class TJsonMap: public TJsonValue { + public: + TJsonMap() + : TJsonValue(NJson::JSON_MAP) + {} + + TJsonMap(const std::initializer_list<std::pair<TString, TJsonValue>>& list) + : TJsonValue(NJson::JSON_MAP) + { + GetMapSafe() = THashMap<TString, TJsonValue>(list); + } + }; + + class TJsonArray: public TJsonValue { + public: + TJsonArray() + : TJsonValue(NJson::JSON_ARRAY) + {} + + TJsonArray(const std::initializer_list<TJsonValue>& list) + : TJsonValue(NJson::JSON_ARRAY) + { + GetArraySafe() = TJsonValue::TArray(list); + } + }; } diff --git a/library/cpp/json/writer/json_value_ut.cpp b/library/cpp/json/writer/json_value_ut.cpp index 9909ab96c3..dc7f6affdf 100644 --- a/library/cpp/json/writer/json_value_ut.cpp +++ b/library/cpp/json/writer/json_value_ut.cpp @@ -623,28 +623,28 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { json = std::move(json["hello"]); UNIT_ASSERT_VALUES_EQUAL(json.GetString(), longTestString); } - - Y_UNIT_TEST(TJsonArrayMapConstructor) { - TJsonMap emptyMap; - UNIT_ASSERT_VALUES_EQUAL(emptyMap.GetType(), JSON_MAP); - UNIT_ASSERT_VALUES_EQUAL(emptyMap.GetMapSafe().size(), 0); - - TJsonArray emptyArray; - UNIT_ASSERT_VALUES_EQUAL(emptyArray.GetType(), JSON_ARRAY); - UNIT_ASSERT_VALUES_EQUAL(emptyArray.GetArraySafe().size(), 0); - - TJsonMap filled = { - {"1", 1}, - {"2", "2"}, - {"3", TJsonArray{3}}, - {"4", TJsonMap{{"5", 5}}}, - }; - UNIT_ASSERT_VALUES_EQUAL(filled.GetType(), JSON_MAP); - UNIT_ASSERT_VALUES_EQUAL(filled["1"], TJsonValue{1}); - UNIT_ASSERT_VALUES_EQUAL(filled["2"], TJsonValue{"2"}); - UNIT_ASSERT_VALUES_EQUAL(filled["3"].GetArraySafe().size(), 1); - UNIT_ASSERT_VALUES_EQUAL(filled["3"][0], TJsonValue{3}); - UNIT_ASSERT_VALUES_EQUAL(filled["4"].GetMapSafe().size(), 1); - UNIT_ASSERT_VALUES_EQUAL(filled["4"]["5"], TJsonValue{5}); - } + + Y_UNIT_TEST(TJsonArrayMapConstructor) { + TJsonMap emptyMap; + UNIT_ASSERT_VALUES_EQUAL(emptyMap.GetType(), JSON_MAP); + UNIT_ASSERT_VALUES_EQUAL(emptyMap.GetMapSafe().size(), 0); + + TJsonArray emptyArray; + UNIT_ASSERT_VALUES_EQUAL(emptyArray.GetType(), JSON_ARRAY); + UNIT_ASSERT_VALUES_EQUAL(emptyArray.GetArraySafe().size(), 0); + + TJsonMap filled = { + {"1", 1}, + {"2", "2"}, + {"3", TJsonArray{3}}, + {"4", TJsonMap{{"5", 5}}}, + }; + UNIT_ASSERT_VALUES_EQUAL(filled.GetType(), JSON_MAP); + UNIT_ASSERT_VALUES_EQUAL(filled["1"], TJsonValue{1}); + UNIT_ASSERT_VALUES_EQUAL(filled["2"], TJsonValue{"2"}); + UNIT_ASSERT_VALUES_EQUAL(filled["3"].GetArraySafe().size(), 1); + UNIT_ASSERT_VALUES_EQUAL(filled["3"][0], TJsonValue{3}); + UNIT_ASSERT_VALUES_EQUAL(filled["4"].GetMapSafe().size(), 1); + UNIT_ASSERT_VALUES_EQUAL(filled["4"]["5"], TJsonValue{5}); + } } // TJsonValueTest |