diff options
author | Neil Fortner <fortnern@gmail.com> | 2022-10-05 14:13:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-05 14:13:17 (GMT) |
commit | 84ecd826876f9d1e3fdac5dcd8fc681466a1b1ea (patch) | |
tree | 4891afabf14ac9bfad553169f79e2811825cfb8f /test | |
parent | 389e80dab6a586339044cb83f57216c5ed0fff3d (diff) | |
download | hdf5-84ecd826876f9d1e3fdac5dcd8fc681466a1b1ea.zip hdf5-84ecd826876f9d1e3fdac5dcd8fc681466a1b1ea.tar.gz hdf5-84ecd826876f9d1e3fdac5dcd8fc681466a1b1ea.tar.bz2 |
Fixed an issue that could occur when combining hyperslab selections (#2122) (#2138) (#2142)
Diffstat (limited to 'test')
-rw-r--r-- | test/th5s.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/th5s.c b/test/th5s.c index 9a9e3cb..8144504 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -2449,6 +2449,57 @@ test_h5s_bug1(void) CHECK(ret, FAIL, "H5Sclose"); } /* test_h5s_bug1() */ +/**************************************************************** +** +** test_h5s_bug2(): Test combining hyperslabs in a way that used +** to trip up H5S__hyper_update_diminfo() +** +****************************************************************/ +static void +test_h5s_bug2(void) +{ + hid_t space; /* Dataspace to copy extent to */ + hsize_t dims[2] = {1, 5}; /* Dimensions */ + hsize_t start[2] = {0, 0}; /* Hyperslab start */ + hsize_t count[2] = {1, 1}; /* Hyperslab start */ + htri_t select_valid; /* Whether the dataspace selection is valid */ + hssize_t elements_selected; /* Number of elements selected */ + herr_t ret; /* Generic error return */ + + /* Create dataspace */ + space = H5Screate_simple(2, dims, NULL); + CHECK(space, FAIL, "H5Screate"); + + /* Select hyperslab in space containing first element */ + ret = H5Sselect_hyperslab(space, H5S_SELECT_SET, start, NULL, count, NULL); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Add hyperslab in space containing last element */ + start[1] = 4; + ret = H5Sselect_hyperslab(space, H5S_SELECT_OR, start, NULL, count, NULL); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Add hyperslab in space containing the first 3 elements */ + start[1] = 0; + count[1] = 3; + ret = H5Sselect_hyperslab(space, H5S_SELECT_OR, start, NULL, count, NULL); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Check that space's selection is valid */ + select_valid = H5Sselect_valid(space); + CHECK(select_valid, FAIL, "H5Sselect_valid"); + VERIFY(select_valid, TRUE, "H5Sselect_valid result"); + + /* Check that 4 elements are selected */ + elements_selected = H5Sget_select_npoints(space); + CHECK(elements_selected, FAIL, "H5Sselect_valid"); + VERIFY(elements_selected, 4, "H5Sselect_valid result"); + + /* Close dataspaces */ + ret = H5Sclose(space); + CHECK(ret, FAIL, "H5Sclose"); +} /* test_h5s_bug2() */ + /*------------------------------------------------------------------------- * Function: test_versionbounds * @@ -2864,6 +2915,7 @@ test_h5s(void) test_h5s_extent_equal(); /* Test extent comparison code */ test_h5s_extent_copy(); /* Test extent copy code */ test_h5s_bug1(); /* Test bug in offset initialization */ + test_h5s_bug2(); /* Test bug found in H5S__hyper_update_diminfo() */ test_versionbounds(); /* Test version bounds with dataspace */ } /* test_h5s() */ |