diff options
| author | tranvick <[email protected]> | 2022-02-10 16:50:26 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:50:26 +0300 | 
| commit | 31f917630d1b92e1df0bad1a1e5a620721d51593 (patch) | |
| tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp | |
| parent | 6f09bec5f69ec7fcf5ce4084dc7d4b7c10b58656 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
| -rw-r--r-- | library/cpp/json/writer/json_value.cpp | 4 | ||||
| -rw-r--r-- | library/cpp/json/writer/json_value.h | 2 | ||||
| -rw-r--r-- | library/cpp/json/writer/json_value_ut.cpp | 194 | 
3 files changed, 100 insertions, 100 deletions
diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index 058cdd99ca9..c61e8d1dc43 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -515,7 +515,7 @@ namespace NJson {      TJsonValue::TArray& TJsonValue::GetArraySafe() {          return const_cast<TJsonValue::TArray&>(const_cast<const TJsonValue*>(this)->GetArraySafe());      } -  +      bool TJsonValue::GetBooleanRobust() const noexcept {          switch (Type) {              case JSON_ARRAY: @@ -753,7 +753,7 @@ namespace NJson {          }          return false;      } -  +      bool TJsonValue::GetValuePointer(const TStringBuf key, TJsonValue** value) noexcept {          return static_cast<const TJsonValue*>(this)->GetValuePointer(key, const_cast<const TJsonValue**>(value));      } diff --git a/library/cpp/json/writer/json_value.h b/library/cpp/json/writer/json_value.h index 32e4d60230a..3f0f50bc4c8 100644 --- a/library/cpp/json/writer/json_value.h +++ b/library/cpp/json/writer/json_value.h @@ -92,7 +92,7 @@ namespace NJson {          bool GetValueByPath(TStringBuf path, TJsonValue& result, char delimiter = '.') const;          bool SetValueByPath(TStringBuf path, const TJsonValue& value, char delimiter = '.');          bool SetValueByPath(TStringBuf path, TJsonValue&& value, char delimiter = '.'); -  +          // returns NULL on failure          const TJsonValue* GetValueByPath(TStringBuf path, char delimiter = '.') const noexcept;          TJsonValue* GetValueByPath(TStringBuf path, char delimiter = '.') noexcept; diff --git a/library/cpp/json/writer/json_value_ut.cpp b/library/cpp/json/writer/json_value_ut.cpp index 1e0f9f1eb20..dc7f6affdff 100644 --- a/library/cpp/json/writer/json_value_ut.cpp +++ b/library/cpp/json/writer/json_value_ut.cpp @@ -379,103 +379,103 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) {      }      Y_UNIT_TEST(NonConstMethodsTest) { -        {  -            TJsonValue src;  -            TJsonValue value1;  -            value1.AppendValue(1);  -            value1.AppendValue(2);  -            src.InsertValue("key", value1);  +        { +            TJsonValue src; +            TJsonValue value1; +            value1.AppendValue(1); +            value1.AppendValue(2); +            src.InsertValue("key", value1);              src.InsertValue("key1", "HI!"); -  -            TJsonValue dst;  -            TJsonValue value2;  -            value2.AppendValue(1);  -            value2.AppendValue(2);  -            value2.AppendValue(3);  -            dst.InsertValue("key", value2);  -  -            src.GetValueByPath("key", '.')->AppendValue(3);  -            src.EraseValue("key1");  -            UNIT_ASSERT(src == dst);  -  -            dst.GetValueByPath("key", '.')->EraseValue(0);  -            UNIT_ASSERT(src != dst);  -            src.GetValueByPath("key", '.')->EraseValue(0);  -            UNIT_ASSERT(src == dst);  -        }  -  -        {  -            TJsonValue src;  -            TJsonValue value1;  -            TJsonValue arr1;  -            value1.InsertValue("key", "value");  -            arr1.AppendValue(value1);  -            arr1.AppendValue(value1);  -            arr1.AppendValue(value1);  -            src.InsertValue("arr", arr1);  -  -            TJsonValue dst;  -            TJsonValue value2;  -            TJsonValue arr2;  -            value2.InsertValue("key", "value");  -            value2.InsertValue("yek", "eulav");  -            arr2.AppendValue(value2);  -            arr2.AppendValue(value2);  -            arr2.AppendValue(value2);  -            arr2.AppendValue(value2);  -            dst.InsertValue("arr", arr2);  -  -            src["arr"].AppendValue(value1);  + +            TJsonValue dst; +            TJsonValue value2; +            value2.AppendValue(1); +            value2.AppendValue(2); +            value2.AppendValue(3); +            dst.InsertValue("key", value2); + +            src.GetValueByPath("key", '.')->AppendValue(3); +            src.EraseValue("key1"); +            UNIT_ASSERT(src == dst); + +            dst.GetValueByPath("key", '.')->EraseValue(0); +            UNIT_ASSERT(src != dst); +            src.GetValueByPath("key", '.')->EraseValue(0); +            UNIT_ASSERT(src == dst); +        } + +        { +            TJsonValue src; +            TJsonValue value1; +            TJsonValue arr1; +            value1.InsertValue("key", "value"); +            arr1.AppendValue(value1); +            arr1.AppendValue(value1); +            arr1.AppendValue(value1); +            src.InsertValue("arr", arr1); + +            TJsonValue dst; +            TJsonValue value2; +            TJsonValue arr2; +            value2.InsertValue("key", "value"); +            value2.InsertValue("yek", "eulav"); +            arr2.AppendValue(value2); +            arr2.AppendValue(value2); +            arr2.AppendValue(value2); +            arr2.AppendValue(value2); +            dst.InsertValue("arr", arr2); + +            src["arr"].AppendValue(value1);              for (auto& node : src["arr"].GetArraySafe()) { -                node.InsertValue("yek", "eulav");  -            }  -            UNIT_ASSERT(src == dst);  -        }  -  -        {  -            TJsonValue src;  -            TJsonValue value1;  -            TJsonValue arr1;  -            value1.InsertValue("key", "value");  -            arr1.AppendValue(value1);  -            arr1.AppendValue(value1);  -            arr1.AppendValue(value1);  -            src.InsertValue("arr", arr1);  -  -            TJsonValue dst;  -            TJsonValue value2;  -            TJsonValue arr2;  -            value2.InsertValue("key", "value");  -            value2.InsertValue("yek", "eulav");  -            arr2.AppendValue(value2);  -            arr2.AppendValue(value2);  -            arr2.AppendValue(value2);  -            arr2.AppendValue(value2);  -            dst.InsertValue("arr", arr2);  -  -            src["arr"].AppendValue(value1);  -            for (auto& node : src.GetValueByPath("arr", '.')->GetArraySafe()) {  -                node.InsertValue("yek", "eulav");  -            }  -            UNIT_ASSERT(src == dst);  -        }  -  -        {  -            TJsonValue json;  -            json.InsertValue("key", "value");  -            try {  -                json.GetArraySafe();  -                UNIT_ASSERT(false);  -            } catch (const TJsonException&) {  -            }  -  -            const TJsonValue constJson(json);  -            try {  -                constJson.GetArray();  -            } catch (...) {  -                UNIT_ASSERT(false);  -            }  -        }  +                node.InsertValue("yek", "eulav"); +            } +            UNIT_ASSERT(src == dst); +        } + +        { +            TJsonValue src; +            TJsonValue value1; +            TJsonValue arr1; +            value1.InsertValue("key", "value"); +            arr1.AppendValue(value1); +            arr1.AppendValue(value1); +            arr1.AppendValue(value1); +            src.InsertValue("arr", arr1); + +            TJsonValue dst; +            TJsonValue value2; +            TJsonValue arr2; +            value2.InsertValue("key", "value"); +            value2.InsertValue("yek", "eulav"); +            arr2.AppendValue(value2); +            arr2.AppendValue(value2); +            arr2.AppendValue(value2); +            arr2.AppendValue(value2); +            dst.InsertValue("arr", arr2); + +            src["arr"].AppendValue(value1); +            for (auto& node : src.GetValueByPath("arr", '.')->GetArraySafe()) { +                node.InsertValue("yek", "eulav"); +            } +            UNIT_ASSERT(src == dst); +        } + +        { +            TJsonValue json; +            json.InsertValue("key", "value"); +            try { +                json.GetArraySafe(); +                UNIT_ASSERT(false); +            } catch (const TJsonException&) { +            } + +            const TJsonValue constJson(json); +            try { +                constJson.GetArray(); +            } catch (...) { +                UNIT_ASSERT(false); +            } +        }          {              // Check non-const GetArraySafe() @@ -504,8 +504,8 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) {              TJsonValue::TMapType expectedMap = {{"foo", TJsonValue{"bar"}}};              UNIT_ASSERT(jsonMap == expectedMap);          } -    }  -  +    } +      Y_UNIT_TEST(NonexistentFieldAccessTest) {          {              TJsonValue json;  | 
