aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/scheme/tests/ut
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
commitf8f6804a3e352897afabc93afcb32081e3fca601 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/scheme/tests/ut
parent5ce74d4fee2d42a4b86efc02dfdc704d458760e1 (diff)
downloadydb-f8f6804a3e352897afabc93afcb32081e3fca601.tar.gz
Restoring authorship annotation for Oleg Sidorkin <osidorkin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/scheme/tests/ut')
-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
4 files changed, 62 insertions, 62 deletions
diff --git a/library/cpp/scheme/tests/ut/scheme_merge_ut.cpp b/library/cpp/scheme/tests/ut/scheme_merge_ut.cpp
index 5376456540..2a06cf110d 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 9d9fd2cf63..0d4d79d483 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 5379ef6164..e711a0d092 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 0ddefa7fea..1a5d07c31b 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());
+ 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());
}
- //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);
}