blob: dbc4686ed8b457637d43cb48b0e6d3d8838612af (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#pragma once
#include <yql/essentials/core/issue/protos/issue_id.pb.h>
#include <yql/essentials/minikql/jsonpath/jsonpath.h>
#include <yql/essentials/minikql/dom/json.h>
#include <yql/essentials/minikql/computation/mkql_value_builder.h>
#include <yql/essentials/minikql/computation/mkql_computation_node_holders.h>
#include <yql/essentials/minikql/invoke_builtins/mkql_builtins.h>
#include <yql/essentials/minikql/mkql_mem_info.h>
#include <yql/essentials/minikql/mkql_function_registry.h>
#include <yql/essentials/minikql/mkql_alloc.h>
#include <yql/essentials/minikql/mkql_node.h>
#include <library/cpp/json/json_reader.h>
#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/yexception.h>
using namespace NYql;
using namespace NYql::NDom;
using namespace NYql::NUdf;
using namespace NYql::NJsonPath;
using namespace NJson;
using namespace NKikimr::NMiniKQL;
class TJsonPathTestBase: public TTestBase {
public:
TJsonPathTestBase();
protected:
const TVector<TStringBuf> LAX_MODES = {"", "lax "};
const TVector<TStringBuf> STRICT_MODES = {"strict "};
const TVector<TStringBuf> ALL_MODES = {"", "lax ", "strict "};
TIntrusivePtr<IFunctionRegistry> FunctionRegistry;
TScopedAlloc Alloc;
TTypeEnvironment Env;
TMemoryUsageInfo MemInfo;
THolderFactory HolderFactory;
TDefaultValueBuilder ValueBuilder;
const int MAX_PARSE_ERRORS = 100;
TIssueCode C(TIssuesIds::EIssueCode code);
TUnboxedValue ParseJson(TStringBuf raw);
struct TMultiOutputTestCase {
TString Json;
TString JsonPath;
TVector<TString> Result;
};
void RunTestCase(const TString& rawJson, const TString& rawJsonPath, const TVector<TString>& expectedResult);
void RunParseErrorTestCase(const TString& rawJsonPath);
struct TRuntimeErrorTestCase {
TString Json;
TString JsonPath;
TIssueCode Error;
};
void RunRuntimeErrorTestCase(const TString& rawJson, const TString& rawJsonPath, TIssueCode error);
struct TVariablesTestCase {
TString Json;
THashMap<TStringBuf, TStringBuf> Variables;
TString JsonPath;
TVector<TString> Result;
};
void RunVariablesTestCase(const TString& rawJson, const THashMap<TStringBuf, TStringBuf>& variables, const TString& rawJsonPath, const TVector<TString>& expectedResult);
};
|