Skip to content

Commit 9fa1bc2

Browse files
committed
Add a test for a reshape of 0-sized object.
1 parent 71a883c commit 9fa1bc2

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/check_array.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,28 @@ START_TEST(test_take1_offset) {
270270
}
271271
END_TEST
272272

273+
START_TEST(test_reshape_0) {
274+
/* This tests that we don't segfault when reshaping 0-sized arrays */
275+
const size_t odims[3] = {24, 0, 33};
276+
const size_t ndims1[3] = {0, 24, 33};
277+
const size_t ndims2[3] = {24, 33, 0};
278+
279+
GpuArray v;
280+
ga_assert_ok(GpuArray_empty(&v, ctx, GA_FLOAT, 3, odims, GA_C_ORDER));
281+
ga_assert_ok(GpuArray_reshape_inplace(&v, 3, ndims1, GA_ANY_ORDER));
282+
ga_assert_ok(GpuArray_reshape_inplace(&v, 3, odims, GA_ANY_ORDER));
283+
ga_assert_ok(GpuArray_reshape_inplace(&v, 3, ndims2, GA_ANY_ORDER));
284+
}
285+
END_TEST
286+
273287
Suite *get_suite(void) {
274288
Suite *s = suite_create("array");
275289
TCase *tc = tcase_create("take1");
276290
tcase_add_checked_fixture(tc, setup, teardown);
277291
tcase_set_timeout(tc, 8.0);
278292
tcase_add_test(tc, test_take1_ok);
279293
tcase_add_test(tc, test_take1_offset);
294+
tcase_add_test(tc, test_reshape_0);
280295
suite_add_tcase(s, tc);
281296
return s;
282297
}

0 commit comments

Comments
 (0)