Browse Source

Restoring authorship annotation for <tranvick@yandex-team.ru>. Commit 2 of 2.

tranvick 3 years ago
parent
commit
31f917630d

+ 2 - 2
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));
     }

+ 1 - 1
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;

+ 97 - 97
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;