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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
#include <yql/essentials/minikql/comp_nodes/mkql_block_just.h>
#include <yql/essentials/minikql/comp_nodes/ut/mkql_block_test_helper.h>
#include <yql/essentials/minikql/comp_nodes/ut/mkql_computation_node_ut.h>
namespace NKikimr::NMiniKQL {
namespace {
template <typename T, typename V>
void TestJustKernelFuzzied(T input, V expected) {
TBlockHelper().TestKernelFuzzied(input, expected,
[&](TSetup<false>& setup, TRuntimeNode input) {
return setup.PgmBuilder->BlockJust(input);
});
}
} // namespace
Y_UNIT_TEST_SUITE(TMiniKQLBlockJustTest) {
// Tests for non-optional input
Y_UNIT_TEST(NotOptIntTest) {
// For non-optional types, BlockJust should add one level of optionality
std::vector<ui32> input{1, 2, 3, 4};
std::vector<TMaybe<ui32>> expected{1, 2, 3, 4};
TestJustKernelFuzzied(input, expected);
}
Y_UNIT_TEST(NotOptSingularNullTest) {
// Test with non-optional TSingularNull
std::vector<TSingularNull> input{TSingularNull(), TSingularNull(), TSingularNull(), TSingularNull()};
std::vector<TMaybe<TSingularNull>> expected{TSingularNull(), TSingularNull(), TSingularNull(), TSingularNull()};
TestJustKernelFuzzied(input, expected);
}
Y_UNIT_TEST(NotOptTaggedTest) {
// Test with non-optional tagged values
auto input = TagVector<TTag::A>(std::vector<ui32>{1, 2, 3, 4});
std::vector<TMaybe<TTagged<ui32, TTag::A>>> expected{
TTagged<ui32, TTag::A>(1),
TTagged<ui32, TTag::A>(2),
TTagged<ui32, TTag::A>(3),
TTagged<ui32, TTag::A>(4)};
TestJustKernelFuzzied(input, expected);
}
// Tests for already optional input
Y_UNIT_TEST(OptIntTest) {
// For optional types, BlockJust should add another level of optionality
std::vector<TMaybe<ui32>> input{1, 2, Nothing(), 4};
// The top level TMaybe should always be defined when BlockJust adds a level of optionality
std::vector<TMaybe<TMaybe<ui32>>> expected{
TMaybe<TMaybe<ui32>>{TMaybe<ui32>{1}},
TMaybe<TMaybe<ui32>>{TMaybe<ui32>{2}},
TMaybe<TMaybe<ui32>>{TMaybe<ui32>()},
TMaybe<TMaybe<ui32>>{TMaybe<ui32>{4}}};
TestJustKernelFuzzied(input, expected);
}
Y_UNIT_TEST(OptSingularVoidTest) {
// Test with optional TSingularVoid
std::vector<TMaybe<TSingularVoid>> input{TSingularVoid(), TSingularVoid(), Nothing(), TSingularVoid()};
// The top level TMaybe should always be defined when BlockJust adds a level of optionality
std::vector<TMaybe<TMaybe<TSingularVoid>>> expected{
TMaybe<TMaybe<TSingularVoid>>{TMaybe<TSingularVoid>{TSingularVoid()}},
TMaybe<TMaybe<TSingularVoid>>{TMaybe<TSingularVoid>{TSingularVoid()}},
TMaybe<TMaybe<TSingularVoid>>{TMaybe<TSingularVoid>()},
TMaybe<TMaybe<TSingularVoid>>{TMaybe<TSingularVoid>{TSingularVoid()}}};
TestJustKernelFuzzied(input, expected);
}
Y_UNIT_TEST(OptSingularNullTest) {
// Test with optional TSingularNull
std::vector<TMaybe<TSingularNull>> input{TSingularNull(), TSingularNull(), Nothing(), TSingularNull()};
// The top level TMaybe should always be defined when BlockJust adds a level of optionality
std::vector<TMaybe<TMaybe<TSingularNull>>> expected{
TMaybe<TMaybe<TSingularNull>>{TMaybe<TSingularNull>{TSingularNull()}},
TMaybe<TMaybe<TSingularNull>>{TMaybe<TSingularNull>{TSingularNull()}},
TMaybe<TMaybe<TSingularNull>>{TMaybe<TSingularNull>()},
TMaybe<TMaybe<TSingularNull>>{TMaybe<TSingularNull>{TSingularNull()}}};
TestJustKernelFuzzied(input, expected);
}
Y_UNIT_TEST(OptTaggedTest) {
// Test with optional tagged values
std::vector<TMaybe<TTagged<ui32, TTag::A>>> input{
TMaybe<TTagged<ui32, TTag::A>>{TTagged<ui32, TTag::A>(1)},
TMaybe<TTagged<ui32, TTag::A>>{TTagged<ui32, TTag::A>(2)},
Nothing(),
TMaybe<TTagged<ui32, TTag::A>>{TTagged<ui32, TTag::A>(4)}};
// The top level TMaybe should always be defined when BlockJust adds a level of optionality
std::vector<TMaybe<TMaybe<TTagged<ui32, TTag::A>>>> expected{
TMaybe<TMaybe<TTagged<ui32, TTag::A>>>{TMaybe<TTagged<ui32, TTag::A>>{TTagged<ui32, TTag::A>(1)}},
TMaybe<TMaybe<TTagged<ui32, TTag::A>>>{TMaybe<TTagged<ui32, TTag::A>>{TTagged<ui32, TTag::A>(2)}},
TMaybe<TMaybe<TTagged<ui32, TTag::A>>>{TMaybe<TTagged<ui32, TTag::A>>()},
TMaybe<TMaybe<TTagged<ui32, TTag::A>>>{TMaybe<TTagged<ui32, TTag::A>>{TTagged<ui32, TTag::A>(4)}}};
TestJustKernelFuzzied(input, expected);
}
Y_UNIT_TEST(PgIntTest) {
// Test with TPgInt (which is internally optional)
std::vector<TPgInt> input{TPgInt(1), TPgInt(2), TPgInt(), TPgInt(4)};
std::vector<TMaybe<TPgInt>> expected{TPgInt(1), TPgInt(2), TPgInt(), TPgInt(4)};
TestJustKernelFuzzied(input, expected);
}
Y_UNIT_TEST(TaggedOptTest) {
// Test with tagged optional values (TTagged<TMaybe<ui32>, TTag::A>)
auto input = TagVector<TTag::A>(std::vector<TMaybe<ui32>>{1, 2, Nothing(), 4});
// Expected: tagged optional values wrapped in Maybe
std::vector<TMaybe<TTagged<TMaybe<ui32>, TTag::A>>> expected;
for (const auto& item : input) {
expected.push_back(TMaybe<TTagged<TMaybe<ui32>, TTag::A>>(item));
}
TestJustKernelFuzzied(input, expected);
}
} // Y_UNIT_TEST_SUITE(TMiniKQLBlockJustTest)
} // namespace NKikimr::NMiniKQL
|