aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authortranvick <tranvick@yandex-team.ru>2022-02-10 16:50:26 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:26 +0300
commit6f09bec5f69ec7fcf5ce4084dc7d4b7c10b58656 (patch)
tree485632adfc3fcf8d034939d40381972a536ccc0f /library/cpp
parentb40cc40ac4588f461fa8dc466985465710d88689 (diff)
downloadydb-6f09bec5f69ec7fcf5ce4084dc7d4b7c10b58656.tar.gz
Restoring authorship annotation for <tranvick@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/json/writer/json_value.cpp4
-rw-r--r--library/cpp/json/writer/json_value.h2
-rw-r--r--library/cpp/json/writer/json_value_ut.cpp194
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 c61e8d1dc4..058cdd99ca 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 3f0f50bc4c..32e4d60230 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 dc7f6affdf..1e0f9f1eb2 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;