MCPcopy Create free account
hub / github.com/bytedance/bolt / intArrayTest

Method intArrayTest

bolt/expression/tests/ArrayViewTest.cpp:81–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 };
80
81 void intArrayTest(
82 std::function<void(
83 int,
84 int,
85 typename exec::ArrayView<returnsOptionalValues, int64_t>::Element)>
86 testItem) {
87 auto arrayVector = makeNullableArrayVector(arrayDataBigInt);
88 DecodedVector decoded;
89 exec::VectorReader<Array<int64_t>> reader(
90 decode(decoded, *arrayVector.get()));
91
92 for (auto i = 0; i < arrayVector->size(); i++) {
93 auto arrayView = read(reader, i);
94 auto j = 0;
95
96 // Test iterate loop.
97 for (auto item : arrayView) {
98 testItem(i, j, item);
99 j++;
100 }
101 ASSERT_EQ(j, arrayDataBigInt[i].size());
102
103 // Test iterate loop 2.
104 auto it = arrayView.begin();
105 j = 0;
106 while (it != arrayView.end()) {
107 testItem(i, j, *it);
108 j++;
109 ++it;
110 }
111 ASSERT_EQ(j, arrayDataBigInt[i].size());
112
113 // Test index based loop.
114 for (j = 0; j < arrayView.size(); j++) {
115 testItem(i, j, arrayView[j]);
116 }
117 ASSERT_EQ(j, arrayDataBigInt[i].size());
118
119 // Test loop iterator with <.
120 j = 0;
121 for (it = arrayView.begin(); it < arrayView.end(); it++) {
122 testItem(i, j, *it);
123 j++;
124 }
125 ASSERT_EQ(j, arrayDataBigInt[i].size());
126
127 // Test loop iteration in reverse with post decrement
128 j = arrayDataBigInt[i].size() - 1;
129 for (it = arrayView.end() - 1; it >= arrayView.begin(); it--) {
130 testItem(i, j, *it);
131 j--;
132 }
133 // This is unintuitive but because we decrement after accessing each
134 // element, since j starts as one less than the size of the array, it
135 // should finish at -1.
136 ASSERT_EQ(j, -1);
137
138 // Test iterate with pre decrement

Callers

nothing calls this directly

Calls 6

decodeFunction · 0.70
readFunction · 0.50
getMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected