summaryrefslogtreecommitdiffstats
path: root/test/th5s.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/th5s.c')
-rw-r--r--test/th5s.c113
1 files changed, 82 insertions, 31 deletions
diff --git a/test/th5s.c b/test/th5s.c
index 901d0e3..97a6728 100644
--- a/test/th5s.c
+++ b/test/th5s.c
@@ -180,7 +180,10 @@ test_h5s_basic(void)
* Check to be sure we can't create a simple dataspace that has too many
* dimensions.
*/
- H5E_BEGIN_TRY { sid1 = H5Screate_simple(H5S_MAX_RANK + 1, dims3, NULL); }
+ H5E_BEGIN_TRY
+ {
+ sid1 = H5Screate_simple(H5S_MAX_RANK + 1, dims3, NULL);
+ }
H5E_END_TRY;
VERIFY(sid1, FAIL, "H5Screate_simple");
@@ -191,7 +194,7 @@ test_h5s_basic(void)
* If this test fails and the H5S_MAX_RANK variable has changed, follow
* the instructions in space_overflow.c for regenerating the th5s.h5 file.
*/
- {
+ if (!h5_driver_uses_modified_filename()) {
const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */
fid1 = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
@@ -247,43 +250,70 @@ test_h5s_basic(void)
CHECK(dset1, FAIL, "H5Dcreate2");
/* Try some writes with the bad dataspace (sid1) */
- H5E_BEGIN_TRY { ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, &n); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, &n);
+ }
H5E_END_TRY
VERIFY(ret, FAIL, "H5Dwrite");
- H5E_BEGIN_TRY { ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &n); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &n);
+ }
H5E_END_TRY
VERIFY(ret, FAIL, "H5Dwrite");
- H5E_BEGIN_TRY { ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, sid1, H5P_DEFAULT, &n); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, sid1, H5P_DEFAULT, &n);
+ }
H5E_END_TRY
VERIFY(ret, FAIL, "H5Dwrite");
/* Try to iterate using the bad dataspace */
- H5E_BEGIN_TRY { ret = H5Diterate(&n, H5T_NATIVE_INT, sid1, NULL, NULL); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Diterate(&n, H5T_NATIVE_INT, sid1, NULL, NULL);
+ }
H5E_END_TRY
VERIFY(ret, FAIL, "H5Diterate");
/* Try to fill using the bad dataspace */
- H5E_BEGIN_TRY { ret = H5Dfill(NULL, H5T_NATIVE_INT, &n, H5T_NATIVE_INT, sid1); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Dfill(NULL, H5T_NATIVE_INT, &n, H5T_NATIVE_INT, sid1);
+ }
H5E_END_TRY
VERIFY(ret, FAIL, "H5Dfill");
/* Now use the bad dataspace as the space for an attribute */
- H5E_BEGIN_TRY { aid1 = H5Acreate2(dset1, BASICATTR, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT); }
+ H5E_BEGIN_TRY
+ {
+ aid1 = H5Acreate2(dset1, BASICATTR, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT);
+ }
H5E_END_TRY
VERIFY(aid1, FAIL, "H5Acreate2");
/* Make sure that dataspace reads using the bad dataspace fail */
- H5E_BEGIN_TRY { ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, &n); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, &n);
+ }
H5E_END_TRY
VERIFY(ret, FAIL, "H5Dread");
- H5E_BEGIN_TRY { ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &n); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &n);
+ }
H5E_END_TRY
VERIFY(ret, FAIL, "H5Dread");
- H5E_BEGIN_TRY { ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, sid1, H5P_DEFAULT, &n); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, sid1, H5P_DEFAULT, &n);
+ }
H5E_END_TRY
VERIFY(ret, FAIL, "H5Dread");
@@ -700,7 +730,10 @@ test_h5s_zero_dim(void)
ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
- H5E_BEGIN_TRY { ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, wdata); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, wdata);
+ }
H5E_END_TRY;
VERIFY(ret, FAIL, "H5Dwrite");
@@ -716,7 +749,10 @@ test_h5s_zero_dim(void)
ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord);
CHECK(ret, FAIL, "H5Sselect_elements");
- H5E_BEGIN_TRY { ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &val); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &val);
+ }
H5E_END_TRY;
VERIFY(ret, FAIL, "H5Dwrite");
@@ -813,7 +849,10 @@ test_h5s_zero_dim(void)
/* Now extend the first dimension size of the dataset to SPACE1_DIM1*3 past the maximal size.
* It is supposed to fail. */
extend_dims[0] = SPACE1_DIM1 * 3;
- H5E_BEGIN_TRY { ret = H5Dset_extent(dset1, extend_dims); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Dset_extent(dset1, extend_dims);
+ }
H5E_END_TRY;
VERIFY(ret, FAIL, "H5Dset_extent");
@@ -1207,11 +1246,14 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high)
if (sbuf_size > 0) {
sbuf = (unsigned char *)HDcalloc((size_t)1, sbuf_size);
- CHECK(sbuf, NULL, "HDcalloc");
+ CHECK_PTR(sbuf, "HDcalloc");
}
/* Try decoding bogus buffer */
- H5E_BEGIN_TRY { ret_id = H5Sdecode(sbuf); }
+ H5E_BEGIN_TRY
+ {
+ ret_id = H5Sdecode(sbuf);
+ }
H5E_END_TRY;
VERIFY(ret_id, FAIL, "H5Sdecode");
@@ -1266,7 +1308,7 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high)
if (null_size > 0) {
null_sbuf = (unsigned char *)HDcalloc((size_t)1, null_size);
- CHECK(null_sbuf, NULL, "HDcalloc");
+ CHECK_PTR(null_sbuf, "HDcalloc");
}
/* Encode the null dataspace in the buffer */
@@ -1302,7 +1344,7 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high)
if (scalar_size > 0) {
scalar_buf = (unsigned char *)HDcalloc((size_t)1, scalar_size);
- CHECK(scalar_buf, NULL, "HDcalloc");
+ CHECK_PTR(scalar_buf, "HDcalloc");
}
/* Encode the scalar dataspace in the buffer */
@@ -1396,11 +1438,14 @@ test_h5s_encode1(void)
if (sbuf_size > 0) {
sbuf = (unsigned char *)HDcalloc((size_t)1, sbuf_size);
- CHECK(sbuf, NULL, "HDcalloc");
+ CHECK_PTR(sbuf, "HDcalloc");
}
/* Try decoding bogus buffer */
- H5E_BEGIN_TRY { ret_id = H5Sdecode(sbuf); }
+ H5E_BEGIN_TRY
+ {
+ ret_id = H5Sdecode(sbuf);
+ }
H5E_END_TRY;
VERIFY(ret_id, FAIL, "H5Sdecode");
@@ -1455,7 +1500,7 @@ test_h5s_encode1(void)
if (null_size > 0) {
null_sbuf = (unsigned char *)HDcalloc((size_t)1, null_size);
- CHECK(null_sbuf, NULL, "HDcalloc");
+ CHECK_PTR(null_sbuf, "HDcalloc");
}
/* Encode the null dataspace in the buffer */
@@ -1491,7 +1536,7 @@ test_h5s_encode1(void)
if (scalar_size > 0) {
scalar_buf = (unsigned char *)HDcalloc((size_t)1, scalar_size);
- CHECK(scalar_buf, NULL, "HDcalloc");
+ CHECK_PTR(scalar_buf, "HDcalloc");
}
/* Encode the scalar dataspace in the buffer */
@@ -1563,7 +1608,10 @@ test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid, uint32_t expected_version,
herr_t ret; /* Return value */
/* Get buffer size for encoding with the format setting in in_fapl */
- H5E_BEGIN_TRY { ret = H5Sencode2(in_sid, NULL, &buf_size, in_fapl); }
+ H5E_BEGIN_TRY
+ {
+ ret = H5Sencode2(in_sid, NULL, &buf_size, in_fapl);
+ }
H5E_END_TRY
if (expected_to_fail) {
@@ -1575,7 +1623,7 @@ test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid, uint32_t expected_version,
/* Allocate the buffer for encoding */
buf = (char *)HDmalloc(buf_size);
- CHECK(buf, NULL, "H5Dmalloc");
+ CHECK_PTR(buf, "H5Dmalloc");
/* Encode according to the setting in in_fapl */
ret = H5Sencode2(in_sid, buf, &buf_size, in_fapl);
@@ -2101,7 +2149,7 @@ test_h5s_encode_length(void)
/* Allocate the buffer */
if (sbuf_size > 0) {
sbuf = (unsigned char *)HDcalloc((size_t)1, sbuf_size);
- CHECK(sbuf, NULL, "H5Sencode2");
+ CHECK_PTR(sbuf, "H5Sencode2");
}
/* Encode the dataspace */
@@ -2158,7 +2206,10 @@ test_h5s_scalar_write(void)
CHECK(fid1, FAIL, "H5Fcreate");
/* Verify a non-zero rank fails with a NULL dimension. */
- H5E_BEGIN_TRY { sid1 = H5Screate_simple(SPACE1_RANK, NULL, NULL); }
+ H5E_BEGIN_TRY
+ {
+ sid1 = H5Screate_simple(SPACE1_RANK, NULL, NULL);
+ }
H5E_END_TRY
VERIFY(sid1, FAIL, "H5Screate_simple");
@@ -2398,7 +2449,7 @@ test_h5s_compound_scalar_read(void)
ret = H5Dread(dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata);
CHECK(ret, FAIL, "H5Dread");
- if (HDmemcmp(&space4_data, &rdata, sizeof(struct space4_struct))) {
+ if (HDmemcmp(&space4_data, &rdata, sizeof(struct space4_struct)) != 0) {
HDprintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", space4_data.c1, rdata.c1);
HDprintf("scalar data different: space4_data.u=%u, read_data4.u=%u\n", space4_data.u, rdata.u);
HDprintf("scalar data different: space4_data.f=%f, read_data4.f=%f\n", (double)space4_data.f,
@@ -2524,7 +2575,7 @@ test_h5s_chunk(void)
for (i = 0; i < CHUNK_DATA_NX; i++) {
for (j = 0; j < CHUNK_DATA_NY; j++) {
/* Check if the two values are within 0.001% range. */
- if (!H5_DBL_REL_EQUAL(chunk_data_dbl[i][j], (double)chunk_data_flt[i][j], (double)0.00001F))
+ if (!H5_DBL_REL_EQUAL(chunk_data_dbl[i][j], (double)chunk_data_flt[i][j], 0.00001))
TestErrPrintf("%u: chunk_data_dbl[%d][%d]=%e, chunk_data_flt[%d][%d]=%e\n",
(unsigned)__LINE__, i, j, chunk_data_dbl[i][j], i, j,
(double)chunk_data_flt[i][j]);
@@ -3253,7 +3304,7 @@ test_versionbounds(void)
/* Its version should be H5O_SDSPACE_VERSION_1 */
spacep = (H5S_t *)H5I_object(space);
- CHECK(spacep, NULL, "H5I_object");
+ CHECK_PTR(spacep, "H5I_object");
VERIFY(spacep->extent.version, H5O_SDSPACE_VERSION_1, "basic dataspace version bound");
/* Set high bound to V18 */
@@ -3274,7 +3325,7 @@ test_versionbounds(void)
dset_space = H5Dget_space(dset);
CHECK(dset_space, FAIL, "H5Dget_space");
spacep = (H5S_t *)H5I_object(dset_space);
- CHECK(spacep, NULL, "H5I_object");
+ CHECK_PTR(spacep, "H5I_object");
/* Dataspace version should remain as H5O_SDSPACE_VERSION_1 */
VERIFY(spacep->extent.version, H5O_SDSPACE_VERSION_1, "basic dataspace version bound");
@@ -3311,7 +3362,7 @@ test_versionbounds(void)
dset_space = H5Dget_space(dset);
CHECK(dset_space, FAIL, "H5Dget_space");
spacep = (H5S_t *)H5I_object(dset_space);
- CHECK(spacep, NULL, "H5I_object");
+ CHECK_PTR(spacep, "H5I_object");
/* Verify the dataspace version */
VERIFY(spacep->extent.version, H5O_sdspace_ver_bounds[low], "upgraded dataspace version");