summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2015-02-25 17:05:16 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2015-02-25 17:05:16 (GMT)
commit2dae07556928721290360fb2393bb928e2367527 (patch)
tree8da7868532c7eb09f9869fb8f03c0ba95662a93a /test
parent48d9c30923a5d298670cf1f8e930c9a9624f80b9 (diff)
downloadhdf5-2dae07556928721290360fb2393bb928e2367527.zip
hdf5-2dae07556928721290360fb2393bb928e2367527.tar.gz
hdf5-2dae07556928721290360fb2393bb928e2367527.tar.bz2
[svn-r26300] Description:
Add H5Sis_regular_hyperslab() and H5Sget_regular_hyperslab() API routines, along with tests. Tested on: Mac OSX/64 10.10.2 (amazon) w/serial (h5committest forthcoming)
Diffstat (limited to 'test')
-rw-r--r--test/tselect.c164
1 files changed, 164 insertions, 0 deletions
diff --git a/test/tselect.c b/test/tselect.c
index d5a1f4c..b34d095 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -162,6 +162,12 @@
/* #defines for shape same / different rank tests */
#define SS_DR_MAX_RANK 5
+/* Information for regular hyperslab query test */
+#define SPACE13_RANK 3
+#define SPACE13_DIM1 50
+#define SPACE13_DIM2 50
+#define SPACE13_DIM3 50
+#define SPACE13_NPOINTS 4
/* Location comparison function */
@@ -13069,6 +13075,161 @@ test_select_bounds(void)
/****************************************************************
**
+** test_hyper_regular(): Tests query operations on regular hyperslabs
+**
+****************************************************************/
+static void
+test_hyper_regular(void)
+{
+ hid_t sid; /* Dataspace ID */
+ const hsize_t dims[SPACE13_RANK] = {SPACE13_DIM1, SPACE13_DIM2, SPACE13_DIM3}; /* Dataspace dimensions */
+ hsize_t coord[SPACE13_NPOINTS][SPACE13_RANK]; /* Coordinates for point selection */
+ hsize_t start[SPACE13_RANK]; /* The start of the hyperslab */
+ hsize_t stride[SPACE13_RANK]; /* The stride between block starts for the hyperslab */
+ hsize_t count[SPACE13_RANK]; /* The number of blocks for the hyperslab */
+ hsize_t block[SPACE13_RANK]; /* The size of each block for the hyperslab */
+ hsize_t t_start[SPACE13_RANK]; /* Temporary start of the hyperslab */
+ hsize_t t_count[SPACE13_RANK]; /* Temporary number of blocks for the hyperslab */
+ hsize_t q_start[SPACE13_RANK]; /* The queried start of the hyperslab */
+ hsize_t q_stride[SPACE13_RANK]; /* The queried stride between block starts for the hyperslab */
+ hsize_t q_count[SPACE13_RANK]; /* The queried number of blocks for the hyperslab */
+ hsize_t q_block[SPACE13_RANK]; /* The queried size of each block for the hyperslab */
+ htri_t is_regular; /* Whether a hyperslab selection is regular */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(6, ("Testing queries on regular hyperslabs\n"));
+
+ /* Create dataspace */
+ sid = H5Screate_simple(SPACE13_RANK, dims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Query if 'all' selection is regular hyperslab (should fail) */
+ H5E_BEGIN_TRY {
+ is_regular = H5Sis_regular_hyperslab(sid);
+ } H5E_END_TRY;
+ VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab");
+
+ /* Query regular hyperslab selection info (should fail) */
+ H5E_BEGIN_TRY {
+ ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Sget_regular_hyperslab");
+
+ /* Set 'none' selection */
+ ret = H5Sselect_none(sid);
+ CHECK(ret, FAIL, "H5Sselect_none");
+
+ /* Query if 'none' selection is regular hyperslab (should fail) */
+ H5E_BEGIN_TRY {
+ is_regular = H5Sis_regular_hyperslab(sid);
+ } H5E_END_TRY;
+ VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab");
+
+ /* Query regular hyperslab selection info (should fail) */
+ H5E_BEGIN_TRY {
+ ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Sget_regular_hyperslab");
+
+ /* Set point selection */
+ coord[0][0] = 3; coord[0][1] = 3; coord[0][2] = 3;
+ coord[1][0] = 3; coord[1][1] = 48; coord[1][2] = 48;
+ coord[2][0] = 48; coord[2][1] = 3; coord[2][2] = 3;
+ coord[3][0] = 48; coord[3][1] = 48; coord[3][2] = 48;
+ ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)SPACE13_NPOINTS, (const hsize_t *)coord);
+ CHECK(ret, FAIL, "H5Sselect_elements");
+
+ /* Query if 'point' selection is regular hyperslab (should fail) */
+ H5E_BEGIN_TRY {
+ is_regular = H5Sis_regular_hyperslab(sid);
+ } H5E_END_TRY;
+ VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab");
+
+ /* Query regular hyperslab selection info (should fail) */
+ H5E_BEGIN_TRY {
+ ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Sget_regular_hyperslab");
+
+ /* Set "regular" hyperslab selection */
+ start[0] = 2; start[1] = 2; start[2] = 2;
+ stride[0] = 5; stride[1] = 5; stride[2] = 5;
+ count[0] = 3; count[1] = 3; count[2] = 3;
+ block[0] = 4; block[1] = 4; block[2] = 4;
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Query if 'hyperslab' selection is regular hyperslab (should be TRUE) */
+ is_regular = H5Sis_regular_hyperslab(sid);
+ VERIFY(is_regular, TRUE, "H5Sis_regular_hyperslab");
+
+ /* Retrieve the hyperslab parameters */
+ ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block);
+ CHECK(ret, FAIL, "H5Sget_regular_hyperslab");
+
+ /* Verify the hyperslab parameters */
+ for(u = 0; u < SPACE13_RANK; u++) {
+ if(start[u] != q_start[u])
+ ERROR("H5Sget_regular_hyperslab, start");
+ if(stride[u] != q_stride[u])
+ ERROR("H5Sget_regular_hyperslab, stride");
+ if(count[u] != q_count[u])
+ ERROR("H5Sget_regular_hyperslab, count");
+ if(block[u] != q_block[u])
+ ERROR("H5Sget_regular_hyperslab, block");
+ } /* end for */
+
+ /* 'OR' in another point */
+ t_start[0] = 0; t_start[1] = 0; t_start[2] = 0;
+ t_count[0] = 1; t_count[1] = 1; t_count[2] = 1;
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, t_start, NULL, t_count, NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Query if 'hyperslab' selection is regular hyperslab (should be FALSE) */
+ is_regular = H5Sis_regular_hyperslab(sid);
+ VERIFY(is_regular, FALSE, "H5Sis_regular_hyperslab");
+
+ /* Query regular hyperslab selection info (should fail) */
+ H5E_BEGIN_TRY {
+ ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Sget_regular_hyperslab");
+
+ /* 'XOR' in the point again, to remove it, which should make it regular again */
+ t_start[0] = 0; t_start[1] = 0; t_start[2] = 0;
+ t_count[0] = 1; t_count[1] = 1; t_count[2] = 1;
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_XOR, t_start, NULL, t_count, NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Query if 'hyperslab' selection is regular hyperslab (should be TRUE) */
+ is_regular = H5Sis_regular_hyperslab(sid);
+ VERIFY(is_regular, TRUE, "H5Sis_regular_hyperslab");
+
+ /* Retrieve the hyperslab parameters */
+ ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block);
+ CHECK(ret, FAIL, "H5Sget_regular_hyperslab");
+
+ /* Verify the hyperslab parameters */
+ for(u = 0; u < SPACE13_RANK; u++) {
+ if(start[u] != q_start[u])
+ ERROR("H5Sget_regular_hyperslab, start");
+ if(stride[u] != q_stride[u])
+ ERROR("H5Sget_regular_hyperslab, stride");
+ if(count[u] != q_count[u])
+ ERROR("H5Sget_regular_hyperslab, count");
+ if(block[u] != q_block[u])
+ ERROR("H5Sget_regular_hyperslab, block");
+ } /* end for */
+
+ /* Close the dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+} /* test_hyper_regular() */
+
+/****************************************************************
+**
** test_select(): Main H5S selection testing routine.
**
****************************************************************/
@@ -13228,6 +13389,9 @@ test_select(void)
/* Test selection bounds with & without offsets */
test_select_bounds();
+ /* Test 'regular' hyperslab query routines */
+ test_hyper_regular();
+
} /* test_select() */