aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/scheme/tests
diff options
context:
space:
mode:
authorOleg Sidorkin <osidorkin@gmail.com>2022-02-10 16:49:36 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:36 +0300
commit5ce74d4fee2d42a4b86efc02dfdc704d458760e1 (patch)
treef16a3558ca40d453a1c6a2ed764bd75d64cffade /library/cpp/scheme/tests
parentcd33f9aa8461f8e2b0b9e68efbb6bc9856197dc9 (diff)
downloadydb-5ce74d4fee2d42a4b86efc02dfdc704d458760e1.tar.gz
Restoring authorship annotation for Oleg Sidorkin <osidorkin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/scheme/tests')
-rw-r--r--library/cpp/scheme/tests/fuzz_json/lib/fuzz_json.cpp184
-rw-r--r--library/cpp/scheme/tests/fuzz_ops/lib/fuzz_ops.cpp6
-rw-r--r--library/cpp/scheme/tests/fuzz_ops/lib/vm_apply.cpp38
-rw-r--r--library/cpp/scheme/tests/ut/scheme_merge_ut.cpp2
-rw-r--r--library/cpp/scheme/tests/ut/scheme_path_ut.cpp30
-rw-r--r--library/cpp/scheme/tests/ut/scheme_proto_ut.cpp2
-rw-r--r--library/cpp/scheme/tests/ut/scheme_ut.cpp90
7 files changed, 176 insertions, 176 deletions
diff --git a/library/cpp/scheme/tests/fuzz_json/lib/fuzz_json.cpp b/library/cpp/scheme/tests/fuzz_json/lib/fuzz_json.cpp
index 7c16527c23..f34571d967 100644
--- a/library/cpp/scheme/tests/fuzz_json/lib/fuzz_json.cpp
+++ b/library/cpp/scheme/tests/fuzz_json/lib/fuzz_json.cpp
@@ -1,90 +1,90 @@
#include "fuzz_json.h"
-#include "util/generic/fwd.h"
+#include "util/generic/fwd.h"
#include <library/cpp/scheme/scheme.h>
#include <util/stream/null.h>
-namespace {
- static constexpr size_t MAX_DEPTH = 4;
- static constexpr size_t MAX_PATH_LEN = 256;
- static constexpr size_t MAX_ITERATIONS = 4;
-
- void SplitOnDepth(const TStringBuf src, const size_t depth, const size_t maxPathLen,
- TStringBuf& left, TStringBuf& right)
- {
- size_t pos = 0;
- size_t prevPos = 0;
- for(size_t i = 0; i < depth; ++i) {
- if (pos > maxPathLen) {
- break;
- }
- prevPos = pos;
- pos = src.find_first_of(TStringBuf("/]"), pos + 1);
- if (pos == TStringBuf::npos) {
- break;
- }
- }
- if (pos == TStringBuf::npos && prevPos > 0) {
- pos = prevPos;
- }
- if (src.length() > maxPathLen) {
- if (pos == TStringBuf::npos || pos > maxPathLen) {
- pos = maxPathLen;
- }
- }
- if (pos == TStringBuf::npos || pos == 0) {
- left = src;
- right = TStringBuf();
- } else {
- src.SplitAt(pos + 1, left, right);
- }
- }
-
- TString tmp;
- //Limit max array size in the path to 256
- TStringBuf ProcessPath(TStringBuf path) {
- size_t pos = 0;
- while(pos != TStringBuf::npos) {
- pos = path.find(']', pos + 1);
- if (pos == TStringBuf::npos) {
- continue;
- }
- size_t open = path.rfind('[', pos);
- if (open == TStringBuf::npos) {
- continue;
- }
- bool allDigit = true;
- for(size_t i = open + 1; i < pos; ++i) {
- if (path[i] < '0' || path[i] > '9') {
- allDigit = false;
- break;
- }
- }
- if (!allDigit) {
- continue;
- }
- if (pos - open > 4) {
- TString str = TString::Join(path.Head(open + 1), "256", path.Tail(pos));
- tmp = std::move(str);
- path = tmp;
- pos = (open + 1) + 3;
- continue;
- }
- }
- return path;
- }
-}
-
+namespace {
+ static constexpr size_t MAX_DEPTH = 4;
+ static constexpr size_t MAX_PATH_LEN = 256;
+ static constexpr size_t MAX_ITERATIONS = 4;
+
+ void SplitOnDepth(const TStringBuf src, const size_t depth, const size_t maxPathLen,
+ TStringBuf& left, TStringBuf& right)
+ {
+ size_t pos = 0;
+ size_t prevPos = 0;
+ for(size_t i = 0; i < depth; ++i) {
+ if (pos > maxPathLen) {
+ break;
+ }
+ prevPos = pos;
+ pos = src.find_first_of(TStringBuf("/]"), pos + 1);
+ if (pos == TStringBuf::npos) {
+ break;
+ }
+ }
+ if (pos == TStringBuf::npos && prevPos > 0) {
+ pos = prevPos;
+ }
+ if (src.length() > maxPathLen) {
+ if (pos == TStringBuf::npos || pos > maxPathLen) {
+ pos = maxPathLen;
+ }
+ }
+ if (pos == TStringBuf::npos || pos == 0) {
+ left = src;
+ right = TStringBuf();
+ } else {
+ src.SplitAt(pos + 1, left, right);
+ }
+ }
+
+ TString tmp;
+ //Limit max array size in the path to 256
+ TStringBuf ProcessPath(TStringBuf path) {
+ size_t pos = 0;
+ while(pos != TStringBuf::npos) {
+ pos = path.find(']', pos + 1);
+ if (pos == TStringBuf::npos) {
+ continue;
+ }
+ size_t open = path.rfind('[', pos);
+ if (open == TStringBuf::npos) {
+ continue;
+ }
+ bool allDigit = true;
+ for(size_t i = open + 1; i < pos; ++i) {
+ if (path[i] < '0' || path[i] > '9') {
+ allDigit = false;
+ break;
+ }
+ }
+ if (!allDigit) {
+ continue;
+ }
+ if (pos - open > 4) {
+ TString str = TString::Join(path.Head(open + 1), "256", path.Tail(pos));
+ tmp = std::move(str);
+ path = tmp;
+ pos = (open + 1) + 3;
+ continue;
+ }
+ }
+ return path;
+ }
+}
+
namespace NSc::NUt {
-
-
+
+
void FuzzJson(TStringBuf wire) {
if (wire.size() < 2) {
return;
}
-
- ProcessPath("[123][1234][12][2134][12312312][1][12]");
+
+ ProcessPath("[123][1234][12][2134][12312312][1][12]");
ui8 len1 = wire[0];
ui8 len2 = wire[1];
wire.Skip(2);
@@ -94,22 +94,22 @@ namespace NSc::NUt {
NSc::TValue val2 = NSc::TValue::FromJson(json2);
NSc::TValue val3;
val3.MergeUpdate(val1);
-
- size_t i = 0;
- while (!wire.empty()) {
- TStringBuf path;
- SplitOnDepth(wire, MAX_DEPTH, MAX_PATH_LEN, path, wire);
- path = ProcessPath(path);
- if (auto* target = val3.TrySelectOrAdd(path)) {
- target->MergeUpdate(val2);
- }
- ++i;
- // Release memory since there are up to MAX_DICT_SIZE * MAX_DEPTH elements
- if (i > MAX_ITERATIONS) {
- Cnull << val3.ToJson();
- val3 = NSc::TValue();
- }
- }
+
+ size_t i = 0;
+ while (!wire.empty()) {
+ TStringBuf path;
+ SplitOnDepth(wire, MAX_DEPTH, MAX_PATH_LEN, path, wire);
+ path = ProcessPath(path);
+ if (auto* target = val3.TrySelectOrAdd(path)) {
+ target->MergeUpdate(val2);
+ }
+ ++i;
+ // Release memory since there are up to MAX_DICT_SIZE * MAX_DEPTH elements
+ if (i > MAX_ITERATIONS) {
+ Cnull << val3.ToJson();
+ val3 = NSc::TValue();
+ }
+ }
Cnull << val3.ToJson();
}
}
diff --git a/library/cpp/scheme/tests/fuzz_ops/lib/fuzz_ops.cpp b/library/cpp/scheme/tests/fuzz_ops/lib/fuzz_ops.cpp
index 8a7facba24..a100d3a631 100644
--- a/library/cpp/scheme/tests/fuzz_ops/lib/fuzz_ops.cpp
+++ b/library/cpp/scheme/tests/fuzz_ops/lib/fuzz_ops.cpp
@@ -29,9 +29,9 @@ namespace NSc::NUt {
if (!ApplyNextAction(st, *act)) {
break;
}
- if (!NSc::TValue::DefaultValue().IsNull()) {
- std::terminate();
- }
+ if (!NSc::TValue::DefaultValue().IsNull()) {
+ std::terminate();
+ }
}
}
}
diff --git a/library/cpp/scheme/tests/fuzz_ops/lib/vm_apply.cpp b/library/cpp/scheme/tests/fuzz_ops/lib/vm_apply.cpp
index ada7b8854f..563187f9f4 100644
--- a/library/cpp/scheme/tests/fuzz_ops/lib/vm_apply.cpp
+++ b/library/cpp/scheme/tests/fuzz_ops/lib/vm_apply.cpp
@@ -77,22 +77,22 @@ namespace NSc::NUt {
Y_FAIL(); \
}
-#define Y_GEN_PTR_OP(op, arg, st, act) \
- if (auto* r = (op)) { \
- switch (act.GetRef(arg).Type) { \
- case TRef::T_CREATE_BACK: \
- Y_GEN_TRY_OP(st.TryPushBack(*r)) \
- break; \
- case TRef::T_CREATE_FRONT: \
- Y_GEN_TRY_OP(st.TryPushFront(*r)) \
- break; \
- case TRef::T_REF__POS: \
- st.LRef(act.GetRef(arg).Pos) = *r; \
- break; \
- default: \
- Y_FAIL(); \
- } \
- }
+#define Y_GEN_PTR_OP(op, arg, st, act) \
+ if (auto* r = (op)) { \
+ switch (act.GetRef(arg).Type) { \
+ case TRef::T_CREATE_BACK: \
+ Y_GEN_TRY_OP(st.TryPushBack(*r)) \
+ break; \
+ case TRef::T_CREATE_FRONT: \
+ Y_GEN_TRY_OP(st.TryPushFront(*r)) \
+ break; \
+ case TRef::T_REF__POS: \
+ st.LRef(act.GetRef(arg).Pos) = *r; \
+ break; \
+ default: \
+ Y_FAIL(); \
+ } \
+ }
bool ApplyNextAction(TVMState& st, TVMAction act) {
switch (act.Type) {
@@ -228,7 +228,7 @@ namespace NSc::NUt {
return true;
case VMA_ARRAY_GET_NO_ADD__IDX_REF:
- Y_GEN_PTR_OP(st.Current().GetNoAdd(act.GetIdx(0)), 1, st, act);
+ Y_GEN_PTR_OP(st.Current().GetNoAdd(act.GetIdx(0)), 1, st, act);
return true;
case VMA_DICT_CLEAR:
@@ -260,7 +260,7 @@ namespace NSc::NUt {
return true;
case VMA_DICT_GET_NO_ADD__IDX_REF:
- Y_GEN_PTR_OP(st.Current().GetNoAdd(act.GetKey(0)), 1, st, act);
+ Y_GEN_PTR_OP(st.Current().GetNoAdd(act.GetKey(0)), 1, st, act);
return true;
case VMA_MERGE_UPDATE__POS:
@@ -288,7 +288,7 @@ namespace NSc::NUt {
return true;
case VMA_SELECT_OR_ADD__PATH_REF:
- Y_GEN_PTR_OP(st.Current().TrySelectOrAdd(act.GetPath(0)), 1, st, act);
+ Y_GEN_PTR_OP(st.Current().TrySelectOrAdd(act.GetPath(0)), 1, st, act);
return true;
case VMA_SELECT_AND_DELETE__PATH_REF:
diff --git a/library/cpp/scheme/tests/ut/scheme_merge_ut.cpp b/library/cpp/scheme/tests/ut/scheme_merge_ut.cpp
index 2a06cf110d..5376456540 100644
--- a/library/cpp/scheme/tests/ut/scheme_merge_ut.cpp
+++ b/library/cpp/scheme/tests/ut/scheme_merge_ut.cpp
@@ -164,7 +164,7 @@ Y_UNIT_TEST_SUITE(TSchemeMergeTest) {
v["a"] = NSc::TValue::FromJson("[0.125,0.12,0.1,0.08,0.06]");
UNIT_ASSERT_JSON_EQ_JSON(v, "{a:[0.125,0.12,0.1,0.08,0.06]}");
- NSc::TValue a = v.TrySelectOrAdd("a")->MergeUpdateJson("[1,2,3]");
+ NSc::TValue a = v.TrySelectOrAdd("a")->MergeUpdateJson("[1,2,3]");
UNIT_ASSERT_JSON_EQ_JSON(a, "[1,2,3]");
UNIT_ASSERT_JSON_EQ_JSON(v, "{a:[1,2,3]}");
diff --git a/library/cpp/scheme/tests/ut/scheme_path_ut.cpp b/library/cpp/scheme/tests/ut/scheme_path_ut.cpp
index 0d4d79d483..9d9fd2cf63 100644
--- a/library/cpp/scheme/tests/ut/scheme_path_ut.cpp
+++ b/library/cpp/scheme/tests/ut/scheme_path_ut.cpp
@@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TSchemePathTest) {
UNIT_ASSERT(!v.PathExists(path));
UNIT_ASSERT(NSc::TValue::PathValid(path));
UNIT_ASSERT(NSc::TValue::Same(v.TrySelect(path), NSc::Null()));
- *v.TrySelectOrAdd(path) = 1;
+ *v.TrySelectOrAdd(path) = 1;
NSc::NUt::AssertSchemeJson(expected, v);
UNIT_ASSERT(v.PathExists(path));
UNIT_ASSERT(1 == v.TrySelectOrAdd(path)->GetNumber());
@@ -33,19 +33,19 @@ Y_UNIT_TEST_SUITE(TSchemePathTest) {
UNIT_ASSERT(v.PathExists(""));
UNIT_ASSERT(v.PathExists("//"));
- UNIT_ASSERT(NSc::TValue::Same(v, *v.TrySelectOrAdd("//")));
+ UNIT_ASSERT(NSc::TValue::Same(v, *v.TrySelectOrAdd("//")));
NSc::NUt::AssertSchemeJson("null", v);
UNIT_ASSERT(NSc::TValue::Same(v.TrySelectAndDelete("//"), NSc::Null()));
NSc::NUt::AssertSchemeJson("null", v);
v.SetDict();
- UNIT_ASSERT(NSc::TValue::Same(v, *v.TrySelectOrAdd("//")));
+ UNIT_ASSERT(NSc::TValue::Same(v, *v.TrySelectOrAdd("//")));
NSc::NUt::AssertSchemeJson("{}", v);
UNIT_ASSERT(NSc::TValue::Same(v.TrySelectAndDelete("//"), NSc::Null()));
NSc::NUt::AssertSchemeJson("{}", v);
v.SetArray();
- UNIT_ASSERT(NSc::TValue::Same(v, *v.TrySelectOrAdd("//")));
+ UNIT_ASSERT(NSc::TValue::Same(v, *v.TrySelectOrAdd("//")));
NSc::NUt::AssertSchemeJson("[]", v);
UNIT_ASSERT(NSc::TValue::Same(v.TrySelectAndDelete("//"), NSc::Null()));
NSc::NUt::AssertSchemeJson("[]", v);
@@ -63,7 +63,7 @@ Y_UNIT_TEST_SUITE(TSchemePathTest) {
Y_UNIT_TEST(TestSelectAndMerge) {
NSc::TValue v;
- v.TrySelectOrAdd("blender/enabled")->MergeUpdateJson("1");
+ v.TrySelectOrAdd("blender/enabled")->MergeUpdateJson("1");
UNIT_ASSERT_VALUES_EQUAL(NSc::TValue::FromJson("1").ToJson(), "1");
UNIT_ASSERT_VALUES_EQUAL(v.ToJson(), "{\"blender\":{\"enabled\":1}}");
}
@@ -97,61 +97,61 @@ Y_UNIT_TEST_SUITE(TSchemePathTest) {
{
NSc::TValue val;
- *val.TrySelectOrAdd("") = 100;
+ *val.TrySelectOrAdd("") = 100;
const TString res = R"=(100)=";
UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res);
}
{
NSc::TValue val;
- *val.TrySelectOrAdd("a") = 100;
+ *val.TrySelectOrAdd("a") = 100;
const TString res = R"=({"a":100})=";
UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res);
}
{
NSc::TValue val;
- *val.TrySelectOrAdd(R"=(////)=") = 100;
+ *val.TrySelectOrAdd(R"=(////)=") = 100;
const TString res = R"=(100)=";
UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res);
}
{
NSc::TValue val;
- *val.TrySelectOrAdd(R"=()=") = 100;
+ *val.TrySelectOrAdd(R"=()=") = 100;
const TString res = R"=(100)=";
UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res);
}
{
NSc::TValue val;
- *val.TrySelectOrAdd(R"=("")=") = 100;
+ *val.TrySelectOrAdd(R"=("")=") = 100;
const TString res = R"=({"":100})=";
UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res);
}
{
NSc::TValue val;
- *val.TrySelectOrAdd(R"=("[1]")=") = 100;
+ *val.TrySelectOrAdd(R"=("[1]")=") = 100;
const TString res = R"=({"[1]":100})=";
UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res);
}
{
NSc::TValue val;
- *val.TrySelectOrAdd(R"=("\"\"")=") = 100;
+ *val.TrySelectOrAdd(R"=("\"\"")=") = 100;
const TString res = R"=({"\"\"":100})=";
UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res);
}
{
NSc::TValue val;
- *val.TrySelectOrAdd(R"=("/10/")=") = 100;
+ *val.TrySelectOrAdd(R"=("/10/")=") = 100;
const TString res = R"=({"/10/":100})=";
UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res);
}
{
NSc::TValue val;
- *val.TrySelectOrAdd(R"=(/"[10]"//""/"\"/10/\""///)=") = 100;
+ *val.TrySelectOrAdd(R"=(/"[10]"//""/"\"/10/\""///)=") = 100;
const TString res = R"=({"[10]":{"":{"\"/10/\"":100}}})=";
UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res);
}
{
NSc::TValue val;
- *val.TrySelectOrAdd(R"=(/"[10]"//""/"\"/10/\""///)=") = 100;
+ *val.TrySelectOrAdd(R"=(/"[10]"//""/"\"/10/\""///)=") = 100;
const TString res = R"=({"[10]":{"":{"\"/10/\"":100}}})=";
UNIT_ASSERT_VALUES_EQUAL(val.ToJson(), res);
}
diff --git a/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp b/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp
index e711a0d092..5379ef6164 100644
--- a/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp
+++ b/library/cpp/scheme/tests/ut/scheme_proto_ut.cpp
@@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(TSchemeProtoTest) {
if (mapAsDict) {
v[key] = value;
} else {
- auto& newElement = v.Push();
+ auto& newElement = v.Push();
newElement["key"] = key;
newElement["value"] = value;
}
diff --git a/library/cpp/scheme/tests/ut/scheme_ut.cpp b/library/cpp/scheme/tests/ut/scheme_ut.cpp
index 1a5d07c31b..0ddefa7fea 100644
--- a/library/cpp/scheme/tests/ut/scheme_ut.cpp
+++ b/library/cpp/scheme/tests/ut/scheme_ut.cpp
@@ -317,12 +317,12 @@ Y_UNIT_TEST_SUITE(TSchemeTest) {
}
Y_UNIT_TEST(TestAssignmentDictChild) {
- {
- NSc::TValue v;
- {
- NSc::TValue b;
- v["a"] = b;
- }
+ {
+ NSc::TValue v;
+ {
+ NSc::TValue b;
+ v["a"] = b;
+ }
v = v["a"];
}
{
@@ -331,7 +331,7 @@ Y_UNIT_TEST_SUITE(TSchemeTest) {
NSc::TValue b;
v["a"] = b;
}
- v = v.Get("a");
+ v = v.Get("a");
}
{
NSc::TValue v;
@@ -341,8 +341,8 @@ Y_UNIT_TEST_SUITE(TSchemeTest) {
}
v = std::move(v["a"]);
}
- }
-
+ }
+
Y_UNIT_TEST(TestInsert) {
NSc::TValue v;
v.Insert(0, "b");
@@ -767,18 +767,18 @@ Y_UNIT_TEST_SUITE(TSchemeTest) {
UNIT_ASSERT(w.IsDict());
UNIT_ASSERT_VALUES_EQUAL(w.Get("foo").GetString(), "baz");
}
- UNIT_ASSERT(NSc::TValue::DefaultValue().IsNull());
- }
-
- //SPI-25156
- Y_UNIT_TEST(TestMoveNotCorruptingDefault) {
- using namespace NSc;
- TValue w = TValue::FromJson("{foo:bar}");
- TValue v = std::move(w);
- w["foo"] = "baz"; // no crash here
- UNIT_ASSERT(NSc::TValue::DefaultValue().IsNull());
+ UNIT_ASSERT(NSc::TValue::DefaultValue().IsNull());
}
+ //SPI-25156
+ Y_UNIT_TEST(TestMoveNotCorruptingDefault) {
+ using namespace NSc;
+ TValue w = TValue::FromJson("{foo:bar}");
+ TValue v = std::move(w);
+ w["foo"] = "baz"; // no crash here
+ UNIT_ASSERT(NSc::TValue::DefaultValue().IsNull());
+ }
+
Y_UNIT_TEST(TestCopyFrom) {
{
TString sa = "[1,2]";
@@ -845,34 +845,34 @@ Y_UNIT_TEST_SUITE(TSchemeTest) {
}
}
- Y_UNIT_TEST(TestCopyingDictIntoSelf) { //Found by fuzzing
- NSc::TValue a;
- NSc::TValue b = a.GetOrAdd("aa");
- b.CopyFrom(a);
- NSc::TValue target = NSc::TValue::FromJsonThrow("{\"aa\":null}");
- UNIT_ASSERT_VALUES_EQUAL(b, target);
- UNIT_ASSERT_VALUES_EQUAL(a, target);
- }
-
- Y_UNIT_TEST(TestCopyingDictIntoSelfByRef) { //Found by fuzzing
- NSc::TValue a;
- NSc::TValue& b = a.GetOrAdd("aa");
- b.CopyFrom(a);
- UNIT_ASSERT_VALUES_EQUAL(b, NSc::TValue::FromJsonThrow("{\"aa\":null}"));
- UNIT_ASSERT_VALUES_EQUAL(a, NSc::TValue::FromJsonThrow("{\"aa\": {\"aa\": null}}"));
- }
-
+ Y_UNIT_TEST(TestCopyingDictIntoSelf) { //Found by fuzzing
+ NSc::TValue a;
+ NSc::TValue b = a.GetOrAdd("aa");
+ b.CopyFrom(a);
+ NSc::TValue target = NSc::TValue::FromJsonThrow("{\"aa\":null}");
+ UNIT_ASSERT_VALUES_EQUAL(b, target);
+ UNIT_ASSERT_VALUES_EQUAL(a, target);
+ }
+
+ Y_UNIT_TEST(TestCopyingDictIntoSelfByRef) { //Found by fuzzing
+ NSc::TValue a;
+ NSc::TValue& b = a.GetOrAdd("aa");
+ b.CopyFrom(a);
+ UNIT_ASSERT_VALUES_EQUAL(b, NSc::TValue::FromJsonThrow("{\"aa\":null}"));
+ UNIT_ASSERT_VALUES_EQUAL(a, NSc::TValue::FromJsonThrow("{\"aa\": {\"aa\": null}}"));
+ }
+
Y_UNIT_TEST(TestGetNoAdd) {
NSc::TValue v = NSc::NUt::AssertFromJson("{a:[null,-1,2,3.4],b:3,c:{d:5}}");
- UNIT_ASSERT(v.GetNoAdd("a") != nullptr);
- UNIT_ASSERT(v.GetNoAdd("b") != nullptr);
- UNIT_ASSERT(v.GetNoAdd("c") != nullptr);
- UNIT_ASSERT(v.GetNoAdd("d") == nullptr);
- UNIT_ASSERT(v.GetNoAdd("value") == nullptr);
-
- NSc::TValue* child = v.GetNoAdd("c");
- UNIT_ASSERT(child != nullptr);
- (*child)["e"]["f"] = 42;
+ UNIT_ASSERT(v.GetNoAdd("a") != nullptr);
+ UNIT_ASSERT(v.GetNoAdd("b") != nullptr);
+ UNIT_ASSERT(v.GetNoAdd("c") != nullptr);
+ UNIT_ASSERT(v.GetNoAdd("d") == nullptr);
+ UNIT_ASSERT(v.GetNoAdd("value") == nullptr);
+
+ NSc::TValue* child = v.GetNoAdd("c");
+ UNIT_ASSERT(child != nullptr);
+ (*child)["e"]["f"] = 42;
const NSc::TValue expectedResult = NSc::NUt::AssertFromJson("{a:[null,-1,2,3.4],b:3,c:{d:5,e:{f:42}}}");
UNIT_ASSERT_VALUES_EQUAL(v, expectedResult);
}