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 | 17c53d36e339526aed2b1251a9375e2d4a7e6ed5 (patch) | |
tree | 8b4f31d0d5007d2a12d31531e9d1fc8c15db1f41 | |
parent | 31f917630d1b92e1df0bad1a1e5a620721d51593 (diff) | |
download | ydb-17c53d36e339526aed2b1251a9375e2d4a7e6ed5.tar.gz |
Restoring authorship annotation for <timurguryev@yandex-team.ru>. Commit 1 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 3f0f50bc4c..1af20b7088 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 dc7f6affdf..9909ab96c3 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 |