@@ -3402,9 +3402,15 @@ TEST(Cast, StringToString) {
34023402
34033403TEST (Cast, StringToStringWithOffset) {
34043404 // GH-43660: Check casting String Arrays with nonzero offset
3405+ std::vector<int64_t > offsets = {3 , 8 , 10 , 12 };
3406+ std::vector<int64_t > lengths = {5 , 2 , 1 , 0 };
3407+
34053408 for (auto from_type : {utf8 (), large_utf8 ()}) {
34063409 for (auto to_type : {utf8 (), large_utf8 ()}) {
3407- for (int64_t offset : {3 , 8 , 10 , 12 }) {
3410+ for (size_t i = 0 ; i < offsets.size (); ++i) {
3411+ auto offset = offsets[i];
3412+ auto length = lengths[i];
3413+
34083414 auto input_with_nulls = R"( [
34093415 "foo", null, "bar", null, "quu", "foo", "baz", "bar",
34103416 null, "bar", "baz", null
@@ -3414,6 +3420,9 @@ TEST(Cast, StringToStringWithOffset) {
34143420 auto output_arr_with_nulls = ArrayFromJSON (to_type, input_with_nulls);
34153421 CheckCast (input_arr_with_nulls->Slice (offset),
34163422 output_arr_with_nulls->Slice (offset));
3423+ // Slice with length
3424+ CheckCast (input_arr_with_nulls->Slice (offset, length),
3425+ output_arr_with_nulls->Slice (offset, length));
34173426
34183427 auto input_no_nulls = R"( [
34193428 "foo", "aa", "bar", "bb", "quu", "foo", "baz", "bar",
@@ -3423,6 +3432,9 @@ TEST(Cast, StringToStringWithOffset) {
34233432 auto input_arr_no_nulls = ArrayFromJSON (from_type, input_no_nulls);
34243433 auto output_arr_no_nulls = ArrayFromJSON (to_type, input_no_nulls);
34253434 CheckCast (input_arr_no_nulls->Slice (offset), output_arr_no_nulls->Slice (offset));
3435+ // Slice with length
3436+ CheckCast (input_arr_no_nulls->Slice (offset, length),
3437+ output_arr_no_nulls->Slice (offset, length));
34263438 }
34273439 }
34283440 }
0 commit comments