@@ -235,6 +235,38 @@ TYPED_TEST(TestReplaceNumeric, ReplaceWithMask) {
235235 this ->array (" [0, null, 10]" ));
236236}
237237
238+ TYPED_TEST (TestReplaceNumeric, ReplaceWithMaskForNullValuesAndMaskEnabled) {
239+ this ->Assert (ReplaceWithMask, this ->array (" [1, null, 1]" ),
240+ this ->mask (" [false, true, false]" ), this ->array (" [7]" ),
241+ this ->array (" [1, 7, 1]" ));
242+ this ->Assert (ReplaceWithMask, this ->array (" [1, null, 1, 7]" ),
243+ this ->mask (" [false, true, false, true]" ), this ->array (" [7, 20]" ),
244+ this ->array (" [1, 7, 1, 20]" ));
245+ this ->Assert (ReplaceWithMask, this ->array (" [1, 2, 3, 4]" ),
246+ this ->mask (" [false, true, false, true]" ), this ->array (" [null, null]" ),
247+ this ->array (" [1, null, 3, null]" ));
248+ this ->Assert (ReplaceWithMask, this ->array (" [null, 2, 3, 4]" ),
249+ this ->mask (" [true, true, false, true]" ), this ->array (" [1, null, null]" ),
250+ this ->array (" [1, null, 3, null]" ));
251+ this ->Assert (ReplaceWithMask, this ->array (" [1, null, 1]" ),
252+ this ->mask (" [false, true, false]" ), this ->scalar (" null" ),
253+ this ->array (" [1, null, 1]" ));
254+ this ->Assert (ReplaceWithMask, this ->array (" [1, null, 1]" ),
255+ this ->mask (" [true, true, true]" ), this ->array (" [7, 7, 7]" ),
256+ this ->array (" [7, 7, 7]" ));
257+ this ->Assert (ReplaceWithMask, this ->array (" [1, null, 1]" ),
258+ this ->mask (" [true, true, true]" ), this ->array (" [null, null, null]" ),
259+ this ->array (" [null, null, null]" ));
260+ this ->Assert (ReplaceWithMask, this ->array (" [1, null, 1]" ),
261+ this ->mask (" [false, true, false]" ), this ->scalar (" null" ),
262+ this ->array (" [1, null, 1]" ));
263+ this ->Assert (ReplaceWithMask, this ->array (" [1, null, 1]" ),
264+ this ->mask (" [true, true, true]" ), this ->scalar (" null" ),
265+ this ->array (" [null, null, null]" ));
266+ this ->Assert (ReplaceWithMask, this ->array (" [null, null]" ), this ->mask (" [true, true]" ),
267+ this ->array (" [1, 1]" ), this ->array (" [1, 1]" ));
268+ }
269+
238270TYPED_TEST (TestReplaceNumeric, ReplaceWithMaskRandom) {
239271 using ArrayType = typename TypeTraits<TypeParam>::ArrayType;
240272 using CType = typename TypeTraits<TypeParam>::CType;
@@ -340,16 +372,24 @@ TEST_F(TestReplaceBoolean, ReplaceWithMask) {
340372 this ->mask (" [false, false, null, null, true, true]" ),
341373 this ->array (" [false, null]" ),
342374 this ->array (" [null, null, null, null, false, null]" ));
375+ this ->Assert (ReplaceWithMask, this ->array (" [true, null, true]" ),
376+ this ->mask (" [false, true, false]" ), this ->array (" [true]" ),
377+ this ->array (" [true, true, true]" ));
343378
344379 this ->Assert (ReplaceWithMask, this ->array (" []" ), this ->mask (" []" ), this ->scalar (" true" ),
345380 this ->array (" []" ));
381+ this ->Assert (ReplaceWithMask, this ->array (" [null, false, true]" ),
382+ this ->mask (" [true, false, false]" ), this ->scalar (" false" ),
383+ this ->array (" [false, false, true]" ));
346384 this ->Assert (ReplaceWithMask, this ->array (" [false, false]" ), this ->mask (" [true, true]" ),
347385 this ->scalar (" true" ), this ->array (" [true, true]" ));
348386 this ->Assert (ReplaceWithMask, this ->array (" [false, false]" ), this ->mask (" [true, true]" ),
349387 this ->scalar (" null" ), this ->array (" [null, null]" ));
350388 this ->Assert (ReplaceWithMask, this ->array (" [false, false, false]" ),
351389 this ->mask (" [false, null, true]" ), this ->scalar (" true" ),
352390 this ->array (" [false, null, true]" ));
391+ this ->Assert (ReplaceWithMask, this ->array (" [null, null]" ), this ->mask (" [true, true]" ),
392+ this ->array (" [true, true]" ), this ->array (" [true, true]" ));
353393}
354394
355395TEST_F (TestReplaceBoolean, ReplaceWithMaskErrors) {
@@ -427,6 +467,9 @@ TEST_F(TestReplaceFixedSizeBinary, ReplaceWithMask) {
427467 this ->mask (" [false, false, null, null, true, true]" ),
428468 this ->array (R"( ["aaa", null])" ),
429469 this ->array (R"( [null, null, null, null, "aaa", null])" ));
470+ this ->Assert (ReplaceWithMask, this ->array (R"( ["aaa", null, "bbb"])" ),
471+ this ->mask (" [false, true, false]" ), this ->array (R"( ["aba"])" ),
472+ this ->array (R"( ["aaa", "aba", "bbb"])" ));
430473
431474 this ->Assert (ReplaceWithMask, this ->array (" []" ), this ->mask (" []" ),
432475 this ->scalar (R"( "zzz")" ), this ->array (" []" ));
0 commit comments