| 178 | |
| 179 | template <typename RunEndType> |
| 180 | void TestBasicsWithREEs() { |
| 181 | auto run_end_type = std::make_shared<RunEndType>(); |
| 182 | auto value_type = utf8(); |
| 183 | auto ree_type = run_end_encoded(run_end_type, value_type); |
| 184 | |
| 185 | // empty REEs |
| 186 | base_ = RunEndEncodedArrayFromJSON(0, ree_type, "[]", "[]"); |
| 187 | target_ = RunEndEncodedArrayFromJSON(0, ree_type, "[]", "[]"); |
| 188 | DoDiff(); |
| 189 | AssertInsertIs("[false]"); |
| 190 | AssertRunLengthIs("[0]"); |
| 191 | |
| 192 | // null REE arrays of different lengths |
| 193 | base_ = RunEndEncodedArrayFromJSON(2, ree_type, "[2]", "[null]"); |
| 194 | target_ = RunEndEncodedArrayFromJSON(4, ree_type, "[4]", "[null]"); |
| 195 | DoDiff(); |
| 196 | AssertInsertIs("[false, true, true]"); |
| 197 | AssertRunLengthIs("[2, 0, 0]"); |
| 198 | |
| 199 | // identical REE arrays w/ offsets |
| 200 | base_ = |
| 201 | RunEndEncodedArrayFromJSON(110, ree_type, R"([20, 120])", R"(["a", "b"])", 10); |
| 202 | target_ = |
| 203 | RunEndEncodedArrayFromJSON(110, ree_type, R"([20, 120])", R"(["a", "b"])", 10); |
| 204 | DoDiff(); |
| 205 | AssertInsertIs("[false]"); |
| 206 | AssertRunLengthIs("[110]"); |
| 207 | |
| 208 | // equivalent REE arrays |
| 209 | base_ = RunEndEncodedArrayFromJSON(120, ree_type, R"([10, 20, 120])", |
| 210 | R"(["a", "a", "b"])"); |
| 211 | target_ = RunEndEncodedArrayFromJSON(120, ree_type, R"([20, 30, 120])", |
| 212 | R"(["a", "b", "b"])"); |
| 213 | DoDiff(); |
| 214 | AssertInsertIs("[false]"); |
| 215 | AssertRunLengthIs("[120]"); |
| 216 | |
| 217 | // slice so last run-end goes beyond length |
| 218 | base_ = base_->Slice(5, 105); |
| 219 | target_ = target_->Slice(5, 105); |
| 220 | DoDiff(); |
| 221 | AssertInsertIs("[false]"); |
| 222 | AssertRunLengthIs("[105]"); |
| 223 | |
| 224 | // insert one |
| 225 | base_ = RunEndEncodedArrayFromJSON(12, ree_type, R"([2, 12])", R"(["a", "b"])"); |
| 226 | target_ = RunEndEncodedArrayFromJSON(13, ree_type, R"([3, 13])", R"(["a", "b"])"); |
| 227 | DoDiff(); |
| 228 | AssertInsertIs("[false, true]"); |
| 229 | AssertRunLengthIs("[2, 10]"); |
| 230 | |
| 231 | // delete one |
| 232 | base_ = |
| 233 | RunEndEncodedArrayFromJSON(13, ree_type, R"([2, 5, 13])", R"(["a", "b", "c"])"); |
| 234 | target_ = |
| 235 | RunEndEncodedArrayFromJSON(12, ree_type, R"([2, 4, 12])", R"(["a", "b", "c"])"); |
| 236 | DoDiff(); |
| 237 | AssertInsertIs("[false, false]"); |
nothing calls this directly
no test coverage detected