summaryrefslogtreecommitdiffstats
path: root/test/th5s.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2015-04-01 14:22:16 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2015-04-01 14:22:16 (GMT)
commitb31a086f3ec5dce6ac995235864e3e1777066409 (patch)
tree96a27d8a0689f9393c07e79fd9e2cc876eed6429 /test/th5s.c
parentd28652dacf3d9f3703dc16f919049c452a2f5e09 (diff)
downloadhdf5-b31a086f3ec5dce6ac995235864e3e1777066409.zip
hdf5-b31a086f3ec5dce6ac995235864e3e1777066409.tar.gz
hdf5-b31a086f3ec5dce6ac995235864e3e1777066409.tar.bz2
[svn-r26690] Fix error in H5Sextent_copy
When the selection is set to all, H5Sextent_copy did not update the number of elements in the selection in the destination space. Fixed H5Sextent_copy to do this. Added tests for this functionality. Tested: jam, koala, ostrich (h5committest)
Diffstat (limited to 'test/th5s.c')
-rw-r--r--test/th5s.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/th5s.c b/test/th5s.c
index 9d51ec8..7c1c46e 100644
--- a/test/th5s.c
+++ b/test/th5s.c
@@ -2224,6 +2224,8 @@ test_h5s_extent_copy(void)
hsize_t d3_dims1[3] = {10, 10, 10}, /* 3-D dimensions */
d3_dims2[3] = {20, 20, 20},
d3_dims3[3] = {H5S_UNLIMITED, H5S_UNLIMITED, H5S_UNLIMITED};
+ hsize_t npoints[14]; /* Expected number of points in selection for each element in spaces */
+ hssize_t npoints_ret; /* Number of points returned by H5Sget_select_npoints() */
htri_t ext_equal; /* Whether two dataspace extents are equal */
const unsigned num_spaces = sizeof(spaces) / sizeof(spaces[0]);
unsigned i, j;
@@ -2232,36 +2234,50 @@ test_h5s_extent_copy(void)
/* Create dataspaces */
spaces[0] = H5Screate(H5S_NULL);
CHECK(spaces[0], FAIL, "H5Screate");
+ npoints[0] = (hsize_t)0;
spaces[1] = H5Screate(H5S_SCALAR);
CHECK(spaces[1], FAIL, "H5Screate");
+ npoints[1] = (hsize_t)1;
spaces[2] = H5Screate_simple(1, d1_dims1, NULL);
CHECK(spaces[2], FAIL, "H5Screate");
+ npoints[2] = d1_dims1[0];
spaces[3] = H5Screate_simple(1, d1_dims2, NULL);
CHECK(spaces[3], FAIL, "H5Screate");
+ npoints[3] = d1_dims2[0];
spaces[4] = H5Screate_simple(1, d1_dims1, d1_dims2);
CHECK(spaces[4], FAIL, "H5Screate");
+ npoints[4] = d1_dims1[0];
spaces[5] = H5Screate_simple(1, d1_dims1, d1_dims3);
CHECK(spaces[5], FAIL, "H5Screate");
+ npoints[5] = d1_dims1[0];
spaces[6] = H5Screate_simple(2, d2_dims1, NULL);
CHECK(spaces[6], FAIL, "H5Screate");
+ npoints[6] = d2_dims1[0] * d2_dims1[1];
spaces[7] = H5Screate_simple(2, d2_dims2, NULL);
CHECK(spaces[7], FAIL, "H5Screate");
+ npoints[7] = d2_dims2[0] * d2_dims2[1];
spaces[8] = H5Screate_simple(2, d2_dims1, d2_dims2);
CHECK(spaces[8], FAIL, "H5Screate");
+ npoints[8] = d2_dims1[0] * d2_dims1[1];
spaces[9] = H5Screate_simple(2, d2_dims1, d2_dims3);
CHECK(spaces[9], FAIL, "H5Screate");
+ npoints[9] = d2_dims1[0] * d2_dims1[1];
spaces[10] = H5Screate_simple(3, d3_dims1, NULL);
CHECK(spaces[10], FAIL, "H5Screate");
+ npoints[10] = d3_dims1[0] * d3_dims1[1] * d3_dims1[2];
spaces[11] = H5Screate_simple(3, d3_dims2, NULL);
CHECK(spaces[11], FAIL, "H5Screate");
+ npoints[11] = d3_dims2[0] * d3_dims2[1] * d3_dims2[2];
spaces[12] = H5Screate_simple(3, d3_dims1, d3_dims2);
CHECK(spaces[12], FAIL, "H5Screate");
+ npoints[12] = d3_dims1[0] * d3_dims1[1] * d3_dims1[2];
spaces[13] = H5Screate_simple(3, d3_dims1, d3_dims3);
CHECK(spaces[13], FAIL, "H5Screate");
+ npoints[13] = d3_dims1[0] * d3_dims1[1] * d3_dims1[2];
tmp_space = H5Screate(H5S_NULL);
CHECK(tmp_space, FAIL, "H5Screate");
@@ -2275,14 +2291,26 @@ test_h5s_extent_copy(void)
* will test copying from i/j to i/j */
ret = H5Sextent_copy(tmp_space, spaces[j]);
CHECK(ret, FAIL, "H5Sextent_copy");
+
+ /* Verify that the extents are equal */
ext_equal = H5Sextent_equal(tmp_space, spaces[j]);
VERIFY(ext_equal, TRUE, "H5Sextent_equal");
+ /* Verify that the correct number of elements is selected */
+ npoints_ret = H5Sget_select_npoints(tmp_space);
+ VERIFY((hsize_t)npoints_ret, npoints[j], "H5Sget_select_npoints");
+
/* Copy from j to i */
ret = H5Sextent_copy(tmp_space, spaces[i]);
CHECK(ret, FAIL, "H5Sextent_copy");
+
+ /* Verify that the extents are equal */
ext_equal = H5Sextent_equal(tmp_space, spaces[i]);
VERIFY(ext_equal, TRUE, "H5Sextent_equal");
+
+ /* Verify that the correct number of elements is selected */
+ npoints_ret = H5Sget_select_npoints(tmp_space);
+ VERIFY((hsize_t)npoints_ret, npoints[i], "H5Sget_select_npoints");
} /* end for */
/* Close dataspaces */