summaryrefslogtreecommitdiffstats
path: root/test/tselect.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2001-12-11 18:26:40 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2001-12-11 18:26:40 (GMT)
commit3baaa562ee650b7c5062c747cab425cd80ab53e0 (patch)
treed90e869acae6fb2cf001bf3a50d224dd50e7f7ef /test/tselect.c
parent43c1f21316556ae6ac898061a49194270d7e9d8b (diff)
downloadhdf5-3baaa562ee650b7c5062c747cab425cd80ab53e0.zip
hdf5-3baaa562ee650b7c5062c747cab425cd80ab53e0.tar.gz
hdf5-3baaa562ee650b7c5062c747cab425cd80ab53e0.tar.bz2
[svn-r4693] Purpose:
Bug Fix Description: The code in H5Sselect_hyperslab_valid contained an fencepost error and is allowing selections which overlap the extent by exactly one element in any dimension to pass as valid instead of flagging the selection as invalid. This bug only affects hyperslabs which have been OR'ed together, not the selection from a single H5Sselect_hyperslab. This fixes bug #550. Solution: Changed an '>' to an '>=' and added new regression test to check for error. Platforms tested: FreeBSD 4.4 (sleipnir)
Diffstat (limited to 'test/tselect.c')
-rw-r--r--test/tselect.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/test/tselect.c b/test/tselect.c
index c5aa682..6a413bd 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -3703,6 +3703,101 @@ test_select_hyper_chunk(hid_t fapl_plist, hid_t xfer_plist)
/****************************************************************
**
+** test_select_valid(): Test basic H5S (dataspace) selection code.
+** Tests selection validity
+**
+****************************************************************/
+static void
+test_select_valid(void)
+{
+ herr_t error;
+ htri_t valid;
+ hid_t main_space, sub_space;
+ hssize_t safe_start[2]={1,1};
+ hsize_t safe_count[2]={1,1};
+ hssize_t start[2];
+ hsize_t dims[2],maxdims[2],size[2],count[2];
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Selection Validity\n"));
+
+ count[0] = count[1] = 1;
+ dims[0] = dims[1] = maxdims[0] = maxdims[1] = 10;
+
+ main_space = H5Screate_simple(2,dims,maxdims);
+ CHECK(main_space, FAIL, "H5Screate_simple");
+
+ MESSAGE(8, ( "Case 1 : in the dimensions\nTry offset (4,4) and size(6,6), the original space is of size (10,10)\n"));
+ start[0] = start[1] = 4;
+ size[0] = size[1] = 6;
+
+ sub_space = H5Scopy(main_space);
+ CHECK(sub_space, FAIL, "H5Scopy");
+
+ error=H5Sselect_hyperslab(sub_space,H5S_SELECT_SET,start,size,count,size);
+ CHECK(error, FAIL, "H5Sselect_hyperslab");
+
+ valid=H5Sselect_valid(sub_space);
+ VERIFY(valid, TRUE, "H5Sselect_valid");
+
+ error=H5Sselect_hyperslab(sub_space,H5S_SELECT_OR,safe_start,NULL,safe_count,NULL);
+ CHECK(error, FAIL, "H5Sselect_hyperslab");
+
+ valid=H5Sselect_valid(sub_space);
+ VERIFY(valid, TRUE, "H5Sselect_valid");
+
+ error=H5Sclose(sub_space);
+ CHECK(error, FAIL, "H5Sclose");
+
+ MESSAGE(8, ( "Case 2 : exceed dimensions by 1\nTry offset (5,5) and size(6,6), the original space is of size (10,10)\n"));
+ start[0] = start[1] = 5;
+ size[0] = size[1] = 6;
+
+ sub_space = H5Scopy(main_space);
+ CHECK(sub_space, FAIL, "H5Scopy");
+
+ error=H5Sselect_hyperslab(sub_space,H5S_SELECT_SET,start,size,count,size);
+ CHECK(error, FAIL, "H5Sselect_hyperslab");
+
+ valid=H5Sselect_valid(sub_space);
+ VERIFY(valid, FALSE, "H5Sselect_valid");
+
+ error=H5Sselect_hyperslab(sub_space,H5S_SELECT_OR,safe_start,NULL,safe_count,NULL);
+ CHECK(error, FAIL, "H5Sselect_hyperslab");
+
+ valid=H5Sselect_valid(sub_space);
+ VERIFY(valid, FALSE, "H5Sselect_valid");
+
+ error=H5Sclose(sub_space);
+ CHECK(error, FAIL, "H5Sclose");
+
+ MESSAGE(8, ( "Case 3 : exceed dimensions by 2\nTry offset (6,6) and size(6,6), the original space is of size (10,10)\n"));
+ start[0] = start[1] = 6;
+ size[0] = size[1] = 6;
+
+ sub_space = H5Scopy(main_space);
+ CHECK(sub_space, FAIL, "H5Scopy");
+
+ error=H5Sselect_hyperslab(sub_space,H5S_SELECT_SET,start,size,count,size);
+ CHECK(error, FAIL, "H5Sselect_hyperslab");
+
+ valid=H5Sselect_valid(sub_space);
+ VERIFY(valid, FALSE, "H5Sselect_valid");
+
+ error=H5Sselect_hyperslab(sub_space,H5S_SELECT_OR,safe_start,NULL,safe_count,NULL);
+ CHECK(error, FAIL, "H5Sselect_hyperslab");
+
+ valid=H5Sselect_valid(sub_space);
+ VERIFY(valid, FALSE, "H5Sselect_valid");
+
+ error=H5Sclose(sub_space);
+ CHECK(error, FAIL, "H5Sclose");
+ error=H5Sclose(main_space);
+ CHECK(error, FAIL, "H5Sclose");
+} /* test_select_hyper_chunk() */
+
+/****************************************************************
+**
** test_select(): Main H5S selection testing routine.
**
****************************************************************/
@@ -3795,6 +3890,8 @@ test_select(void)
ret=H5Pclose(plist_id);
CHECK(ret, FAIL, "H5Pclose");
+ /* More tests for checking validity of selections */
+ test_select_valid();
} /* test_select() */