summaryrefslogtreecommitdiffstats
path: root/yql/essentials/minikql/jsonpath/ut/lax_ut.cpp
diff options
context:
space:
mode:
authorvvvv <[email protected]>2025-10-09 12:25:18 +0300
committervvvv <[email protected]>2025-10-09 12:57:17 +0300
commitcb77d014972b2cdb27d2e6d979fc3a2772b27ad4 (patch)
tree7f3bcd8ce71c6bd0f3ccc11e31b9f665475b819e /yql/essentials/minikql/jsonpath/ut/lax_ut.cpp
parentd58a8990d353b051c27e1069141117fdfde64358 (diff)
YQL-20086 minikql
commit_hash:e96f7390db5fcbe7e9f64f898141a263ad522daa
Diffstat (limited to 'yql/essentials/minikql/jsonpath/ut/lax_ut.cpp')
-rw-r--r--yql/essentials/minikql/jsonpath/ut/lax_ut.cpp131
1 files changed, 91 insertions, 40 deletions
diff --git a/yql/essentials/minikql/jsonpath/ut/lax_ut.cpp b/yql/essentials/minikql/jsonpath/ut/lax_ut.cpp
index 0fe3ed15a6c..a8a927f918e 100644
--- a/yql/essentials/minikql/jsonpath/ut/lax_ut.cpp
+++ b/yql/essentials/minikql/jsonpath/ut/lax_ut.cpp
@@ -1,6 +1,6 @@
#include "test_base.h"
-class TJsonPathLaxTest : public TJsonPathTestBase {
+class TJsonPathLaxTest: public TJsonPathTestBase {
public:
TJsonPathLaxTest()
: TJsonPathTestBase()
@@ -8,18 +8,18 @@ public:
}
UNIT_TEST_SUITE(TJsonPathLaxTest);
- UNIT_TEST(TestArrayUnwrap);
- UNIT_TEST(TestArrayWrap);
- UNIT_TEST(TestInvalidArrayIndices);
- UNIT_TEST(TestStructuralErrorsHandling);
- UNIT_TEST(TestCompareOperations);
- UNIT_TEST(TestFilter);
- UNIT_TEST(TestNumericMethods);
- UNIT_TEST(TestDoubleMethod);
- UNIT_TEST(TestKeyValueMethod);
- UNIT_TEST(TestExistsPredicate);
- UNIT_TEST(TestLikeRegexPredicate);
- UNIT_TEST(TestStartsWithPredicate);
+ UNIT_TEST(TestArrayUnwrap);
+ UNIT_TEST(TestArrayWrap);
+ UNIT_TEST(TestInvalidArrayIndices);
+ UNIT_TEST(TestStructuralErrorsHandling);
+ UNIT_TEST(TestCompareOperations);
+ UNIT_TEST(TestFilter);
+ UNIT_TEST(TestNumericMethods);
+ UNIT_TEST(TestDoubleMethod);
+ UNIT_TEST(TestKeyValueMethod);
+ UNIT_TEST(TestExistsPredicate);
+ UNIT_TEST(TestLikeRegexPredicate);
+ UNIT_TEST(TestStartsWithPredicate);
UNIT_TEST_SUITE_END();
void TestArrayUnwrap() {
@@ -27,28 +27,40 @@ public:
{R"([
{"key": 1},
{"key": 2}
- ])", "$.key", {"1", "2"}},
+ ])",
+ "$.key",
+ {"1", "2"}},
{R"([
{"key": 1},
{"key": 2}
- ])", "$.*", {"1", "2"}},
+ ])",
+ "$.*",
+ {"1", "2"}},
{R"({
"first": {"key": 1},
"second": []
- })", "$.*.key", {"1"}},
+ })",
+ "$.*.key",
+ {"1"}},
{R"({
"first": {"key": 1},
"second": []
- })", "$.*.*", {"1"}},
+ })",
+ "$.*.*",
+ {"1"}},
{R"({"another_key": 123})", "$.key", {}},
{R"([
{"key": [{"nested": 28}]},
{"key": [{"nested": 29}]}
- ])", "$.key.nested", {"28", "29"}},
+ ])",
+ "$.key.nested",
+ {"28", "29"}},
{R"([
{"key": [{"nested": 28}]},
{"key": [{"nested": 29}]}
- ])", "$.*.*", {"28", "29"}},
+ ])",
+ "$.*.*",
+ {"28", "29"}},
};
for (const auto& testCase : testCases) {
@@ -76,32 +88,44 @@ public:
{R"({
"idx": -1,
"array": [1, 2, 3]
- })", "$.array[$.idx]", {}},
+ })",
+ "$.array[$.idx]",
+ {}},
{R"({
"from": -1,
"to": 3,
"array": [1, 2, 3]
- })", "$.array[$.from to $.to]", {}},
+ })",
+ "$.array[$.from to $.to]",
+ {}},
{R"({
"from": 0,
"to": -1,
"array": [1, 2, 3]
- })", "$.array[$.from to $.to]", {}},
+ })",
+ "$.array[$.from to $.to]",
+ {}},
{R"([1, 2, 3, 4, 5])", "$[3 to 0]", {}},
{R"({
"idx": -1,
"array": [1, 2, 3]
- })", "$.array[$.idx, 1 to 2]", {"2", "3"}},
+ })",
+ "$.array[$.idx, 1 to 2]",
+ {"2", "3"}},
{R"({
"from": -1,
"to": 3,
"array": [1, 2, 3]
- })", "$.array[0, $.from to $.to, 2 to 2]", {"1", "3"}},
+ })",
+ "$.array[0, $.from to $.to, 2 to 2]",
+ {"1", "3"}},
{R"({
"from": 0,
"to": -1,
"array": [1, 2, 3]
- })", "$.array[0, $.from to $.to, 1 to 1]", {"1", "2"}},
+ })",
+ "$.array[0, $.from to $.to, 1 to 1]",
+ {"1", "2"}},
{R"([1, 2, 3, 4, 5])", "$[0, 3 to 0, 1]", {"1", "2"}},
{R"([[1, 2], [3, 4, 5], []])", "$[*][2]", {"5"}},
{"[]", "$[last]", {}},
@@ -123,7 +147,9 @@ public:
{"key": 1},
{"not_key": 2},
{"key": 3}
- ])", "$[*].key", {"1", "3"}},
+ ])",
+ "$[*].key",
+ {"1", "3"}},
};
for (const auto& testCase : testCases) {
@@ -139,20 +165,26 @@ public:
{R"({
"left": [1, 2, 3],
"right": [4, 5, 6]
- })", "$.left < $.right", {"true"}},
+ })",
+ "$.left < $.right",
+ {"true"}},
// Check incomparable types
// NOTE: Even though values of types string and number are incomparable,
- // pair 1 < 4 is true and was found first, so the overall result is true
+ // pair 1 < 4 is true and was found first, so the overall result is true
{R"({
"left": [1, 2, "string"],
"right": [4, 5, 6]
- })", "$.left < $.right", {"true"}},
+ })",
+ "$.left < $.right",
+ {"true"}},
// NOTE: In this example pair "string" < 4 results in error and was found first,
- // so overall result is null
+ // so overall result is null
{R"({
"left": ["string", 2, 3],
"right": [4, 5, 6]
- })", "$.left < $.right", {"null"}},
+ })",
+ "$.left < $.right",
+ {"null"}},
};
for (const auto& testCase : testCases) {
@@ -170,7 +202,9 @@ public:
{"age": 25},
{"age": 50},
{"age": 5}
- ])", "$ ? (@.age >= 18 && @.age <= 30) . age", {"18", "25"}},
+ ])",
+ "$ ? (@.age >= 18 && @.age <= 30) . age",
+ {"18", "25"}},
};
for (const auto& testCase : testCases) {
@@ -202,11 +236,25 @@ public:
"123", "123.4", "0.567", "1234e-1", "567e-3", "123.4e-1",
"123e3", "123e+3", "1.23e+1", "1.23e1",
"12e0", "12.3e0", "0", "0.0", "0.0e0"
- ])", "$.double()", {
- "123", "123.4", "0.567", "123.4", "0.567", "12.34",
- "123000", "123000", "12.3", "12.3",
- "12", "12.3", "0", "0", "0",
- }},
+ ])",
+ "$.double()",
+ {
+ "123",
+ "123.4",
+ "0.567",
+ "123.4",
+ "0.567",
+ "12.34",
+ "123000",
+ "123000",
+ "12.3",
+ "12.3",
+ "12",
+ "12.3",
+ "0",
+ "0",
+ "0",
+ }},
};
for (const auto& testCase : testCases) {
@@ -223,7 +271,9 @@ public:
"one": 1,
"two": 2,
"three": 3
- }])", "$.keyvalue().name", {"\"one\"", "\"three\"", "\"two\""}},
+ }])",
+ "$.keyvalue().name",
+ {"\"one\"", "\"three\"", "\"two\""}},
};
for (const auto& testCase : testCases) {
@@ -237,7 +287,9 @@ public:
const TVector<TMultiOutputTestCase> testCases = {
{R"({
"key": 123
- })", "exists ($.another_key)", {"false"}},
+ })",
+ "exists ($.another_key)",
+ {"false"}},
};
for (const auto& testCase : testCases) {
@@ -281,4 +333,3 @@ public:
};
UNIT_TEST_SUITE_REGISTRATION(TJsonPathLaxTest);
-