summaryrefslogtreecommitdiffstats
path: root/test/th5o.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /test/th5o.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'test/th5o.c')
-rw-r--r--test/th5o.c400
1 files changed, 190 insertions, 210 deletions
diff --git a/test/th5o.c b/test/th5o.c
index 4bc2096..8885eb4 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -12,12 +12,12 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/***********************************************************
-*
-* Test program: th5o
-*
-* Test public H5O functions for accessing
-*
-*************************************************************/
+ *
+ * Test program: th5o
+ *
+ * Test public H5O functions for accessing
+ *
+ *************************************************************/
#include "testhdf5.h"
#include "H5Fprivate.h"
@@ -33,7 +33,6 @@
#define TEST6_DIM1 100
#define TEST6_DIM2 100
-
/****************************************************************
**
** test_h5o_open(): Test H5Oopen function.
@@ -42,13 +41,13 @@
static void
test_h5o_open(void)
{
- hid_t fid; /* HDF5 File ID */
- hid_t grp, dset, dtype, dspace; /* Object identifiers */
+ hid_t fid; /* HDF5 File ID */
+ hid_t grp, dset, dtype, dspace; /* Object identifiers */
hsize_t dims[RANK];
- H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
- H5G_info_t ginfo; /* Group info struct */
- H5T_class_t type_class; /* Class of the datatype */
- herr_t ret; /* Value returned from API calls */
+ H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
+ H5G_info_t ginfo; /* Group info struct */
+ H5T_class_t type_class; /* Class of the datatype */
+ herr_t ret; /* Value returned from API calls */
/* Create a new HDF5 file */
fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -72,7 +71,7 @@ test_h5o_open(void)
/* Create the data space for the dataset. */
dims[0] = DIM0;
dims[1] = DIM1;
- dspace = H5Screate_simple(RANK, dims, NULL);
+ dspace = H5Screate_simple(RANK, dims, NULL);
CHECK(dspace, FAIL, "H5Screate_simple");
/* Create the dataset. */
@@ -122,28 +121,30 @@ test_h5o_open(void)
CHECK(ret, FAIL, "H5Dclose");
/* Trying to open objects with bogus names should fail gracefully */
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
grp = H5Oopen(fid, "bogus_group", H5P_DEFAULT);
VERIFY(grp, FAIL, "H5Oopen");
dtype = H5Oopen(fid, "group/bogus_datatype", H5P_DEFAULT);
VERIFY(dtype, FAIL, "H5Oopen");
dset = H5Oopen(fid, "/bogus_dataset", H5P_DEFAULT);
VERIFY(dset, FAIL, "H5Oopen");
- } H5E_END_TRY
+ }
+ H5E_END_TRY
/* Close the file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
/* Trying to open an object with a bogus file ID should fail */
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
dset = H5Oopen(fid, "dataset", H5P_DEFAULT);
VERIFY(dset, FAIL, "H5Oopen");
- } H5E_END_TRY
+ }
+ H5E_END_TRY
} /* test_h5o_open() */
-
-
/****************************************************************
**
** test_h5o_close(): Test H5Oclose function.
@@ -152,10 +153,10 @@ test_h5o_open(void)
static void
test_h5o_close(void)
{
- hid_t fid; /* HDF5 File ID */
- hid_t grp, dset, dtype, dspace; /* Object identifiers */
- hsize_t dims[RANK];
- herr_t ret; /* Value returned from API calls */
+ hid_t fid; /* HDF5 File ID */
+ hid_t grp, dset, dtype, dspace; /* Object identifiers */
+ hsize_t dims[RANK];
+ herr_t ret; /* Value returned from API calls */
/* Create a new HDF5 file */
fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -180,7 +181,7 @@ test_h5o_close(void)
/* Create the data space for the dataset. */
dims[0] = DIM0;
dims[1] = DIM1;
- dspace = H5Screate_simple(RANK, dims, NULL);
+ dspace = H5Screate_simple(RANK, dims, NULL);
CHECK(dspace, FAIL, "H5Screate_simple");
/* Create the dataset. */
@@ -190,10 +191,12 @@ test_h5o_close(void)
CHECK(ret, FAIL, "H5Oclose");
/* Attempting to close the data space with H5Oclose should fail */
- H5E_BEGIN_TRY {
- ret = H5Oclose(dspace);
- VERIFY(ret, FAIL, "H5Oclose");
- } H5E_END_TRY
+ H5E_BEGIN_TRY
+ {
+ ret = H5Oclose(dspace);
+ VERIFY(ret, FAIL, "H5Oclose");
+ }
+ H5E_END_TRY
/* Close the dataspace for real */
ret = H5Sclose(dspace);
CHECK(ret, FAIL, "H5Sclose");
@@ -233,7 +236,6 @@ test_h5o_close(void)
CHECK(ret, FAIL, "H5Fclose");
}
-
#ifndef H5_NO_DEPRECATED_SYMBOLS
/****************************************************************
**
@@ -243,17 +245,17 @@ test_h5o_close(void)
static void
test_h5o_open_by_addr(void)
{
- hid_t fid; /* HDF5 File ID */
- hid_t grp, dset, dtype, dspace; /* Object identifiers */
- H5L_info2_t li; /* Buffer for H5Lget_info2 */
- haddr_t grp_addr; /* Addresses for objects */
+ hid_t fid; /* HDF5 File ID */
+ hid_t grp, dset, dtype, dspace; /* Object identifiers */
+ H5L_info2_t li; /* Buffer for H5Lget_info2 */
+ haddr_t grp_addr; /* Addresses for objects */
haddr_t dset_addr;
haddr_t dtype_addr;
hsize_t dims[RANK];
- H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
- H5G_info_t ginfo; /* Group info struct */
- H5T_class_t type_class; /* Class of the datatype */
- herr_t ret; /* Value returned from API calls */
+ H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
+ H5G_info_t ginfo; /* Group info struct */
+ H5T_class_t type_class; /* Class of the datatype */
+ herr_t ret; /* Value returned from API calls */
/* Create a new HDF5 file */
fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -277,7 +279,7 @@ test_h5o_open_by_addr(void)
/* Create the data space for the dataset. */
dims[0] = DIM0;
dims[1] = DIM1;
- dspace = H5Screate_simple(RANK, dims, NULL);
+ dspace = H5Screate_simple(RANK, dims, NULL);
CHECK(dspace, FAIL, "H5Screate_simple");
/* Create the dataset. */
@@ -345,39 +347,34 @@ test_h5o_open_by_addr(void)
/* Try giving some bogus values to H5O_open_by_addr. */
/* Try to open an object with a bad address */
grp_addr += 20;
- H5E_BEGIN_TRY{
- grp = H5Oopen_by_addr(fid, grp_addr);
- }H5E_END_TRY
+ H5E_BEGIN_TRY { grp = H5Oopen_by_addr(fid, grp_addr); }
+ H5E_END_TRY
VERIFY(grp, FAIL, "H5Oopen_by_addr");
/* For instance, an objectno smaller than the end of the file's superblock should
* trigger an error */
grp_addr = 10;
- H5E_BEGIN_TRY{
- grp = H5Oopen_by_addr(fid, grp_addr);
- }H5E_END_TRY
+ H5E_BEGIN_TRY { grp = H5Oopen_by_addr(fid, grp_addr); }
+ H5E_END_TRY
VERIFY(grp, FAIL, "H5Oopen_by_addr");
/* Likewise, an objectno larger than the size of the file should fail */
grp_addr = 0;
grp_addr = 1000000000;
- H5E_BEGIN_TRY{
- grp = H5Oopen_by_addr(fid, grp_addr);
- }H5E_END_TRY
+ H5E_BEGIN_TRY { grp = H5Oopen_by_addr(fid, grp_addr); }
+ H5E_END_TRY
VERIFY(grp, FAIL, "H5Oopen_by_addr");
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
/* Also, trying to open an object without a valid location should fail */
- H5E_BEGIN_TRY{
- dtype = H5Oopen_by_addr(fid, dtype_addr);
- }H5E_END_TRY
+ H5E_BEGIN_TRY { dtype = H5Oopen_by_addr(fid, dtype_addr); }
+ H5E_END_TRY
VERIFY(dtype, FAIL, "H5Oopen_by_addr");
} /* test_h5o_open_by_addr() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
/****************************************************************
**
** test_h5o_open_by_token(): Test H5Oopen_by_token function.
@@ -386,14 +383,14 @@ test_h5o_open_by_addr(void)
static void
test_h5o_open_by_token(void)
{
- hid_t fid; /* HDF5 File ID */
- hid_t grp, dset, dtype, dspace; /* Object identifiers */
- H5L_info2_t li; /* Buffer for H5Lget_info */
+ hid_t fid; /* HDF5 File ID */
+ hid_t grp, dset, dtype, dspace; /* Object identifiers */
+ H5L_info2_t li; /* Buffer for H5Lget_info */
hsize_t dims[RANK];
- H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
- H5G_info_t ginfo; /* Group info struct */
- H5T_class_t type_class; /* Class of the datatype */
- herr_t ret; /* Value returned from API calls */
+ H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
+ H5G_info_t ginfo; /* Group info struct */
+ H5T_class_t type_class; /* Class of the datatype */
+ herr_t ret; /* Value returned from API calls */
/* Create a new HDF5 file */
fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -417,7 +414,7 @@ test_h5o_open_by_token(void)
/* Create the data space for the dataset. */
dims[0] = DIM0;
dims[1] = DIM1;
- dspace = H5Screate_simple(RANK, dims, NULL);
+ dspace = H5Screate_simple(RANK, dims, NULL);
CHECK(dspace, FAIL, "H5Screate_simple");
/* Create the dataset. */
@@ -476,18 +473,16 @@ test_h5o_open_by_token(void)
/* Try giving some bogus values to H5O_open_by_token */
/* Try opening an object using H5O_TOKEN_UNDEF (should fail) */
- H5E_BEGIN_TRY{
- dtype = H5Oopen_by_token(fid, H5O_TOKEN_UNDEF);
- }H5E_END_TRY
+ H5E_BEGIN_TRY { dtype = H5Oopen_by_token(fid, H5O_TOKEN_UNDEF); }
+ H5E_END_TRY
VERIFY(dtype, FAIL, "H5Oopen_by_token");
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
/* Also, trying to open an object without a valid location (should fail) */
- H5E_BEGIN_TRY{
- dtype = H5Oopen_by_token(fid, li.u.token);
- }H5E_END_TRY
+ H5E_BEGIN_TRY { dtype = H5Oopen_by_token(fid, li.u.token); }
+ H5E_END_TRY
VERIFY(dtype, FAIL, "H5Oopen_by_token");
} /* test_h5o_open_by_token() */
@@ -500,11 +495,11 @@ test_h5o_open_by_token(void)
static void
test_h5o_refcount(void)
{
- hid_t fid; /* HDF5 File ID */
- hid_t grp, dset, dtype, dspace; /* Object identifiers */
- H5O_info2_t oinfo; /* Object info struct */
+ hid_t fid; /* HDF5 File ID */
+ hid_t grp, dset, dtype, dspace; /* Object identifiers */
+ H5O_info2_t oinfo; /* Object info struct */
hsize_t dims[RANK];
- herr_t ret; /* Value returned from API calls */
+ herr_t ret; /* Value returned from API calls */
/* Create a new HDF5 file */
fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -524,7 +519,7 @@ test_h5o_refcount(void)
/* Create the data space for the dataset. */
dims[0] = DIM0;
dims[1] = DIM1;
- dspace = H5Screate_simple(RANK, dims, NULL);
+ dspace = H5Screate_simple(RANK, dims, NULL);
CHECK(dspace, FAIL, "H5Screate_simple");
/* Create the dataset. */
@@ -666,7 +661,8 @@ test_h5o_refcount(void)
CHECK(ret, FAIL, "H5Dclose");
/* Make sure that bogus IDs return errors properly */
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
ret = H5Oincr_refcount(grp);
VERIFY(ret, FAIL, "H5Oincr_refcount");
ret = H5Oincr_refcount(dtype);
@@ -679,14 +675,14 @@ test_h5o_refcount(void)
VERIFY(ret, FAIL, "H5Odecr_refcount");
ret = H5Odecr_refcount(dset);
VERIFY(ret, FAIL, "H5Odecr_refcount");
- } H5E_END_TRY
+ }
+ H5E_END_TRY
/* Close the file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
} /* test_h5o_refcount() */
-
/****************************************************************
**
** test_h5o_plist(): Test object creation properties
@@ -695,13 +691,13 @@ test_h5o_refcount(void)
static void
test_h5o_plist(void)
{
- hid_t fid; /* HDF5 File ID */
- hid_t grp, dset, dtype, dspace; /* Object identifiers */
- hid_t fapl; /* File access property list */
- hid_t gcpl, dcpl, tcpl; /* Object creation properties */
- unsigned def_max_compact, def_min_dense; /* Default phase change parameters */
- unsigned max_compact, min_dense; /* Actual phase change parameters */
- herr_t ret; /* Value returned from API calls */
+ hid_t fid; /* HDF5 File ID */
+ hid_t grp, dset, dtype, dspace; /* Object identifiers */
+ hid_t fapl; /* File access property list */
+ hid_t gcpl, dcpl, tcpl; /* Object creation properties */
+ unsigned def_max_compact, def_min_dense; /* Default phase change parameters */
+ unsigned max_compact, min_dense; /* Actual phase change parameters */
+ herr_t ret; /* Value returned from API calls */
/* Make a FAPL that uses the "use the latest version of the format" flag */
fapl = H5Pcreate(H5P_FILE_ACCESS);
@@ -880,7 +876,6 @@ test_h5o_plist(void)
CHECK(ret, FAIL, "H5Pclose");
} /* test_h5o_plist() */
-
/****************************************************************
**
** test_h5o_link(): Test creating link to object
@@ -889,20 +884,20 @@ test_h5o_plist(void)
static void
test_h5o_link(void)
{
- hid_t file_id=-1;
- hid_t group_id=-1;
- hid_t space_id=-1;
- hid_t dset_id=-1;
- hid_t type_id=-1;
- hid_t fapl_id=-1;
- hid_t lcpl_id=-1;
- hsize_t dims[2] = {TEST6_DIM1, TEST6_DIM2};
- htri_t committed; /* Whether the named datatype is committed */
+ hid_t file_id = -1;
+ hid_t group_id = -1;
+ hid_t space_id = -1;
+ hid_t dset_id = -1;
+ hid_t type_id = -1;
+ hid_t fapl_id = -1;
+ hid_t lcpl_id = -1;
+ hsize_t dims[2] = {TEST6_DIM1, TEST6_DIM2};
+ htri_t committed; /* Whether the named datatype is committed */
H5F_libver_t low, high; /* File format bounds */
- int *wdata;
- int *rdata;
- int i, n;
- herr_t ret; /* Value returned from API calls */
+ int * wdata;
+ int * rdata;
+ int i, n;
+ herr_t ret; /* Value returned from API calls */
/* Allocate memory buffers */
/* (These are treated as 2-D buffers) */
@@ -912,11 +907,11 @@ test_h5o_link(void)
CHECK_PTR(rdata, "HDmalloc");
/* Initialize the raw data */
- for(i = n = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++)
- wdata[i] = n++;
+ for (i = n = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++)
+ wdata[i] = n++;
/* Create the dataspace */
- space_id = H5Screate_simple(2 ,dims, NULL);
+ space_id = H5Screate_simple(2, dims, NULL);
CHECK(space_id, FAIL, "H5Screate_simple");
/* Create LCPL with intermediate group creation flag set */
@@ -930,13 +925,12 @@ test_h5o_link(void)
CHECK(fapl_id, FAIL, "H5Pcreate");
/* Loop through all the combinations of low/high library format bounds */
- for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
- for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
+ for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
/* Set version bounds */
- H5E_BEGIN_TRY {
- ret = H5Pset_libver_bounds(fapl_id, low, high);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { ret = H5Pset_libver_bounds(fapl_id, low, high); }
+ H5E_END_TRY;
if (ret < 0) /* Invalid low/high combinations */
continue;
@@ -972,7 +966,7 @@ test_h5o_link(void)
CHECK(ret, FAIL, "H5Dread");
/* Verify the data */
- for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++)
+ for (i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++)
VERIFY(wdata[i], rdata[i], "H5Dread");
/* Create a group with no name*/
@@ -1010,7 +1004,7 @@ test_h5o_link(void)
/* Read data from dataset */
ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
CHECK(ret, FAIL, "H5Dread");
- for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++)
+ for (i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++)
VERIFY(wdata[i], rdata[i], "H5Dread");
/* Close open IDs */
@@ -1021,7 +1015,7 @@ test_h5o_link(void)
ret = H5Fclose(file_id);
CHECK(ret, FAIL, "H5Fclose");
} /* for high */
- } /* for low */
+ } /* for low */
/* Close remaining IDs */
ret = H5Sclose(space_id);
@@ -1034,7 +1028,6 @@ test_h5o_link(void)
HDfree(rdata);
} /* end test_h5o_link() */
-
/****************************************************************
**
** test_h5o_comment(): Test H5Oset(get)_comment functions.
@@ -1043,20 +1036,20 @@ test_h5o_link(void)
static void
test_h5o_comment(void)
{
- hid_t fid; /* HDF5 File ID */
- hid_t grp, dset, dtype, dspace; /* Object identifiers */
+ hid_t fid; /* HDF5 File ID */
+ hid_t grp, dset, dtype, dspace; /* Object identifiers */
hid_t attr_space, attr_id;
hsize_t dims[RANK];
- hsize_t attr_dims = 1;
- int attr_value = 5;
- const char *file_comment = "file comment";
- const char *grp_comment = "group comment";
- const char *dset_comment = "dataset comment";
- const char *dtype_comment = "datatype comment";
+ hsize_t attr_dims = 1;
+ int attr_value = 5;
+ const char *file_comment = "file comment";
+ const char *grp_comment = "group comment";
+ const char *dset_comment = "dataset comment";
+ const char *dtype_comment = "datatype comment";
char check_comment[64];
ssize_t comment_len = 0;
ssize_t len;
- herr_t ret; /* Value returned from API calls */
+ herr_t ret; /* Value returned from API calls */
int ret_value;
/* Create a new HDF5 file */
@@ -1109,7 +1102,7 @@ test_h5o_comment(void)
/* Create the data space for the dataset. */
dims[0] = DIM0;
dims[1] = DIM1;
- dspace = H5Screate_simple(RANK, dims, NULL);
+ dspace = H5Screate_simple(RANK, dims, NULL);
CHECK(dspace, FAIL, "H5Screate_simple");
/* Create the dataset. */
@@ -1121,9 +1114,8 @@ test_h5o_comment(void)
CHECK(ret, FAIL, "H5Oset_comment");
/* Putting a comment on the dataspace. It's supposed to fail. */
- H5E_BEGIN_TRY {
- ret = H5Oset_comment(dspace, "dataspace comment");
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { ret = H5Oset_comment(dspace, "dataspace comment"); }
+ H5E_END_TRY;
VERIFY(ret, FAIL, "H5Oset_comment");
/* Close the file */
@@ -1134,7 +1126,6 @@ test_h5o_comment(void)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Now make sure that the comments are correct all 4 types of objects */
/* Open file */
fid = H5Fopen(TEST_FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
@@ -1144,7 +1135,7 @@ test_h5o_comment(void)
comment_len = H5Oget_comment(fid, NULL, (size_t)0);
CHECK(comment_len, FAIL, "H5Oget_comment");
- len = H5Oget_comment(fid, check_comment, (size_t)comment_len+1);
+ len = H5Oget_comment(fid, check_comment, (size_t)comment_len + 1);
CHECK(len, FAIL, "H5Oget_comment");
ret_value = HDstrcmp(file_comment, check_comment);
@@ -1158,7 +1149,7 @@ test_h5o_comment(void)
comment_len = H5Oget_comment(grp, NULL, (size_t)0);
CHECK(comment_len, FAIL, "H5Oget_comment");
- len = H5Oget_comment(grp, check_comment, (size_t)comment_len+1);
+ len = H5Oget_comment(grp, check_comment, (size_t)comment_len + 1);
CHECK(len, FAIL, "H5Oget_comment");
ret_value = HDstrcmp(grp_comment, check_comment);
@@ -1172,7 +1163,7 @@ test_h5o_comment(void)
comment_len = H5Oget_comment(dtype, NULL, (size_t)0);
CHECK(comment_len, FAIL, "H5Oget_comment");
- len = H5Oget_comment(dtype, check_comment, (size_t)comment_len+1);
+ len = H5Oget_comment(dtype, check_comment, (size_t)comment_len + 1);
CHECK(len, FAIL, "H5Oget_comment");
ret_value = HDstrcmp(dtype_comment, check_comment);
@@ -1186,13 +1177,12 @@ test_h5o_comment(void)
comment_len = H5Oget_comment(dset, NULL, (size_t)0);
CHECK(comment_len, FAIL, "H5Oget_comment");
- len = H5Oget_comment(dset, check_comment, (size_t)comment_len+1);
+ len = H5Oget_comment(dset, check_comment, (size_t)comment_len + 1);
CHECK(ret, len, "H5Oget_comment");
ret_value = HDstrcmp(dset_comment, check_comment);
VERIFY(ret_value, 0, "H5Oget_comment");
-
/* Close the IDs */
ret = H5Gclose(grp);
CHECK(ret, FAIL, "H5Gclose");
@@ -1207,7 +1197,6 @@ test_h5o_comment(void)
} /* test_h5o_comment() */
-
/****************************************************************
**
** test_h5o_comment_by_name(): Test H5Oset(get)_comment_by_name functions.
@@ -1216,20 +1205,20 @@ test_h5o_comment(void)
static void
test_h5o_comment_by_name(void)
{
- hid_t fid; /* HDF5 File ID */
- hid_t grp, dset, dtype, dspace; /* Object identifiers */
+ hid_t fid; /* HDF5 File ID */
+ hid_t grp, dset, dtype, dspace; /* Object identifiers */
hid_t attr_space, attr_id;
hsize_t dims[RANK];
- hsize_t attr_dims = 1;
- int attr_value = 5;
- const char *file_comment = "file comment by name";
- const char *grp_comment = "group comment by name";
- const char *dset_comment = "dataset comment by name";
- const char *dtype_comment = "datatype comment by name";
+ hsize_t attr_dims = 1;
+ int attr_value = 5;
+ const char *file_comment = "file comment by name";
+ const char *grp_comment = "group comment by name";
+ const char *dset_comment = "dataset comment by name";
+ const char *dtype_comment = "datatype comment by name";
char check_comment[64];
ssize_t comment_len = 0;
ssize_t len;
- herr_t ret; /* Value returned from API calls */
+ herr_t ret; /* Value returned from API calls */
int ret_value;
/* Create a new HDF5 file */
@@ -1282,7 +1271,7 @@ test_h5o_comment_by_name(void)
/* Create the data space for the dataset. */
dims[0] = DIM0;
dims[1] = DIM1;
- dspace = H5Screate_simple(RANK, dims, NULL);
+ dspace = H5Screate_simple(RANK, dims, NULL);
CHECK(dspace, FAIL, "H5Screate_simple");
/* Create the dataset. */
@@ -1294,9 +1283,8 @@ test_h5o_comment_by_name(void)
CHECK(ret, FAIL, "H5Oset_comment_by_name");
/* Putting a comment on the dataspace. It's supposed to fail. */
- H5E_BEGIN_TRY {
- ret = H5Oset_comment_by_name(dspace, ".", "dataspace comment", H5P_DEFAULT);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { ret = H5Oset_comment_by_name(dspace, ".", "dataspace comment", H5P_DEFAULT); }
+ H5E_END_TRY;
VERIFY(ret, FAIL, "H5Oset_comment");
/* Close the file */
@@ -1316,7 +1304,7 @@ test_h5o_comment_by_name(void)
comment_len = H5Oget_comment_by_name(fid, ".", NULL, (size_t)0, H5P_DEFAULT);
CHECK(comment_len, FAIL, "H5Oget_comment_by_name");
- len = H5Oget_comment_by_name(fid, ".", check_comment, (size_t)comment_len+1, H5P_DEFAULT);
+ len = H5Oget_comment_by_name(fid, ".", check_comment, (size_t)comment_len + 1, H5P_DEFAULT);
CHECK(len, FAIL, "H5Oget_comment_by_name");
ret_value = HDstrcmp(file_comment, check_comment);
@@ -1330,7 +1318,7 @@ test_h5o_comment_by_name(void)
comment_len = H5Oget_comment_by_name(fid, "group", NULL, (size_t)0, H5P_DEFAULT);
CHECK(comment_len, FAIL, "H5Oget_comment_by_name");
- len = H5Oget_comment_by_name(fid, "group", check_comment, (size_t)comment_len+1, H5P_DEFAULT);
+ len = H5Oget_comment_by_name(fid, "group", check_comment, (size_t)comment_len + 1, H5P_DEFAULT);
CHECK(len, FAIL, "H5Oget_comment_by_name");
ret_value = HDstrcmp(grp_comment, check_comment);
@@ -1340,7 +1328,7 @@ test_h5o_comment_by_name(void)
comment_len = H5Oget_comment_by_name(grp, "datatype", NULL, (size_t)0, H5P_DEFAULT);
CHECK(comment_len, FAIL, "H5Oget_comment_by_name");
- len = H5Oget_comment_by_name(grp, "datatype", check_comment, (size_t)comment_len+1, H5P_DEFAULT);
+ len = H5Oget_comment_by_name(grp, "datatype", check_comment, (size_t)comment_len + 1, H5P_DEFAULT);
CHECK(len, FAIL, "H5Oget_comment");
ret_value = HDstrcmp(dtype_comment, check_comment);
@@ -1350,7 +1338,7 @@ test_h5o_comment_by_name(void)
comment_len = H5Oget_comment_by_name(fid, "dataset", NULL, (size_t)0, H5P_DEFAULT);
CHECK(comment_len, FAIL, "H5Oget_comment_by_name");
- len = H5Oget_comment_by_name(fid, "dataset", check_comment, (size_t)comment_len+1, H5P_DEFAULT);
+ len = H5Oget_comment_by_name(fid, "dataset", check_comment, (size_t)comment_len + 1, H5P_DEFAULT);
CHECK(len, FAIL, "H5Oget_comment_by_name");
ret_value = HDstrcmp(dset_comment, check_comment);
@@ -1366,7 +1354,6 @@ test_h5o_comment_by_name(void)
} /* test_h5o_comment_by_name() */
-
/****************************************************************
**
** test_h5o_getinfo_same_file(): Test that querying the object info for
@@ -1376,10 +1363,10 @@ test_h5o_comment_by_name(void)
static void
test_h5o_getinfo_same_file(void)
{
- hid_t fid1, fid2; /* HDF5 File ID */
- hid_t gid1, gid2; /* Group IDs */
- H5O_info2_t oinfo1, oinfo2; /* Object info structs */
- herr_t ret; /* Value returned from API calls */
+ hid_t fid1, fid2; /* HDF5 File ID */
+ hid_t gid1, gid2; /* Group IDs */
+ H5O_info2_t oinfo1, oinfo2; /* Object info structs */
+ herr_t ret; /* Value returned from API calls */
/* Create a new HDF5 file */
fid1 = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -1423,7 +1410,6 @@ test_h5o_getinfo_same_file(void)
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-
/* Open file twice */
fid1 = H5Fopen(TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
CHECK(fid1, FAIL, "H5Fopen");
@@ -1482,17 +1468,17 @@ test_h5o_getinfo_same_file(void)
static void
test_h5o_open_by_addr_deprec(void)
{
- hid_t fid; /* HDF5 File ID */
- hid_t grp, dset, dtype, dspace; /* Object identifiers */
- H5L_info1_t li; /* Buffer for H5Lget_info1 */
- haddr_t grp_addr; /* Addresses for objects */
+ hid_t fid; /* HDF5 File ID */
+ hid_t grp, dset, dtype, dspace; /* Object identifiers */
+ H5L_info1_t li; /* Buffer for H5Lget_info1 */
+ haddr_t grp_addr; /* Addresses for objects */
haddr_t dset_addr;
haddr_t dtype_addr;
hsize_t dims[RANK];
- H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
- H5G_info_t ginfo; /* Group info struct */
- H5T_class_t type_class; /* Class of the datatype */
- herr_t ret; /* Value returned from API calls */
+ H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
+ H5G_info_t ginfo; /* Group info struct */
+ H5T_class_t type_class; /* Class of the datatype */
+ herr_t ret; /* Value returned from API calls */
/* Create a new HDF5 file */
fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -1516,7 +1502,7 @@ test_h5o_open_by_addr_deprec(void)
/* Create the data space for the dataset. */
dims[0] = DIM0;
dims[1] = DIM1;
- dspace = H5Screate_simple(RANK, dims, NULL);
+ dspace = H5Screate_simple(RANK, dims, NULL);
CHECK(dspace, FAIL, "H5Screate_simple");
/* Create the dataset. */
@@ -1531,10 +1517,10 @@ test_h5o_open_by_addr_deprec(void)
ret = H5Lget_info1(fid, "group", &li, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lget_info");
grp_addr = li.u.address;
- ret = H5Lget_info1(fid, "group/datatype", &li, H5P_DEFAULT);
+ ret = H5Lget_info1(fid, "group/datatype", &li, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lget_info");
dtype_addr = li.u.address;
- ret = H5Lget_info1(fid, "dataset", &li, H5P_DEFAULT);
+ ret = H5Lget_info1(fid, "dataset", &li, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lget_info");
dset_addr = li.u.address;
@@ -1579,38 +1565,33 @@ test_h5o_open_by_addr_deprec(void)
/* Try giving some bogus values to H5O_open_by_addr. */
/* Try to open an object with a bad address */
grp_addr += 20;
- H5E_BEGIN_TRY{
- grp = H5Oopen_by_addr(fid, grp_addr);
- }H5E_END_TRY
+ H5E_BEGIN_TRY { grp = H5Oopen_by_addr(fid, grp_addr); }
+ H5E_END_TRY
VERIFY(grp, FAIL, "H5Oopen_by_addr");
/* For instance, an objectno smaller than the end of the file's superblock should
* trigger an error */
grp_addr = 10;
- H5E_BEGIN_TRY{
- grp = H5Oopen_by_addr(fid, grp_addr);
- }H5E_END_TRY
+ H5E_BEGIN_TRY { grp = H5Oopen_by_addr(fid, grp_addr); }
+ H5E_END_TRY
VERIFY(grp, FAIL, "H5Oopen_by_addr");
/* Likewise, an objectno larger than the size of the file should fail */
grp_addr = 0;
grp_addr = 1000000000;
- H5E_BEGIN_TRY{
- grp = H5Oopen_by_addr(fid, grp_addr);
- }H5E_END_TRY
+ H5E_BEGIN_TRY { grp = H5Oopen_by_addr(fid, grp_addr); }
+ H5E_END_TRY
VERIFY(grp, FAIL, "H5Oopen_by_addr");
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
/* Also, trying to open an object without a valid location should fail */
- H5E_BEGIN_TRY{
- dtype = H5Oopen_by_addr(fid, dtype_addr);
- }H5E_END_TRY
+ H5E_BEGIN_TRY { dtype = H5Oopen_by_addr(fid, dtype_addr); }
+ H5E_END_TRY
VERIFY(dtype, FAIL, "H5Oopen_by_addr");
} /* test_h5o_open_by_addr_deprec() */
-
/****************************************************************
**
** visit_obj_cb():
@@ -1621,29 +1602,31 @@ test_h5o_open_by_addr_deprec(void)
**
****************************************************************/
static int
-visit_obj_cb(hid_t group_id, const char *name, const H5O_info1_t *oinfo1,
- void H5_ATTR_UNUSED *_op_data)
+visit_obj_cb(hid_t group_id, const char *name, const H5O_info1_t *oinfo1, void H5_ATTR_UNUSED *_op_data)
{
- H5O_info1_t oinfo2; /* Object info structs */
+ H5O_info1_t oinfo2; /* Object info structs */
/* Verify the object info for "group1", "group2" and the root group */
- if(!(HDstrcmp(name, "group1"))) {
+ if (!(HDstrcmp(name, "group1"))) {
H5Oget_info_by_name2(group_id, name, &oinfo2, H5O_INFO_NUM_ATTRS, H5P_DEFAULT);
VERIFY(oinfo1->num_attrs, oinfo2.num_attrs, "obj info from H5Ovisit1");
- } else if(!(HDstrcmp(name, "group2"))) {
+ }
+ else if (!(HDstrcmp(name, "group2"))) {
H5Oget_info_by_name2(group_id, name, &oinfo2, H5O_INFO_HDR, H5P_DEFAULT);
VERIFY(oinfo1->hdr.nmesgs, oinfo2.hdr.nmesgs, "obj info from H5Ovisit1/H5Oget_info2");
VERIFY(oinfo1->hdr.nchunks, oinfo2.hdr.nchunks, "obj info from H5Ovisit1/H5Oget_info2");
- } else if(!(HDstrcmp(name, "."))) {
+ }
+ else if (!(HDstrcmp(name, "."))) {
H5Oget_info_by_name2(group_id, name, &oinfo2, H5O_INFO_META_SIZE, H5P_DEFAULT);
- VERIFY(oinfo1->meta_size.obj.index_size, oinfo2.meta_size.obj.index_size, "obj info from H5Ovisit1/H5Oget_info2");
- VERIFY(oinfo1->meta_size.obj.heap_size, oinfo2.meta_size.obj.heap_size, "obj info from H5Ovisit1/H5Oget_info2");
+ VERIFY(oinfo1->meta_size.obj.index_size, oinfo2.meta_size.obj.index_size,
+ "obj info from H5Ovisit1/H5Oget_info2");
+ VERIFY(oinfo1->meta_size.obj.heap_size, oinfo2.meta_size.obj.heap_size,
+ "obj info from H5Ovisit1/H5Oget_info2");
}
- return(H5_ITER_CONT);
+ return (H5_ITER_CONT);
} /* end visit_obj_cb() */
-
/****************************************************************
**
** test_h5o_getinfo_visit():
@@ -1656,14 +1639,14 @@ visit_obj_cb(hid_t group_id, const char *name, const H5O_info1_t *oinfo1,
static void
test_h5o_getinfo_visit(void)
{
- hid_t fid = -1; /* HDF5 File ID */
- hid_t gid1 = -1, gid2 = -1; /* Group IDs */
- hid_t sid = -1; /* Dataspace ID */
- hid_t aid = -1; /* Attribute ID */
- H5O_info1_t oinfo1, oinfo2; /* Object info structs */
- char attrname[25]; /* Attribute name */
- int j; /* Local index variable */
- herr_t ret; /* Value returned from API calls */
+ hid_t fid = -1; /* HDF5 File ID */
+ hid_t gid1 = -1, gid2 = -1; /* Group IDs */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t aid = -1; /* Attribute ID */
+ H5O_info1_t oinfo1, oinfo2; /* Object info structs */
+ char attrname[25]; /* Attribute name */
+ int j; /* Local index variable */
+ herr_t ret; /* Value returned from API calls */
/* Create an HDF5 file */
fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -1678,7 +1661,7 @@ test_h5o_getinfo_visit(void)
CHECK(sid, FAIL, "H5Screate");
/* Attach 10 attributes to "group1" */
- for(j = 0; j <10; j++) {
+ for (j = 0; j < 10; j++) {
/* Create the attribute name */
HDsprintf(attrname, "attr%u", j);
/* Create the attribute */
@@ -1700,7 +1683,7 @@ test_h5o_getinfo_visit(void)
/* Query the object info for "group1" via H5Oget_info1 and H5Oget_info2 */
ret = H5Oget_info1(gid1, &oinfo1);
CHECK(ret, FAIL, "H5Oget_info1");
- ret = H5Oget_info2(gid1, &oinfo2, H5O_INFO_BASIC|H5O_INFO_NUM_ATTRS);
+ ret = H5Oget_info2(gid1, &oinfo2, H5O_INFO_BASIC | H5O_INFO_NUM_ATTRS);
CHECK(ret, FAIL, "H5Oget_info2");
/* Verify the object info for "group1" is correct */
@@ -1714,7 +1697,7 @@ test_h5o_getinfo_visit(void)
/* Query the object info for "group2" via H5Oget_info1 and H5Oget_info2 */
ret = H5Oget_info_by_name1(fid, "group2", &oinfo1, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_native_info_by_name");
- ret = H5Oget_info_by_name2(fid, "group2", &oinfo2, H5O_INFO_HDR|H5O_INFO_META_SIZE, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "group2", &oinfo2, H5O_INFO_HDR | H5O_INFO_META_SIZE, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_native_info_by_name");
/* Verify the object info for "group2" is correct */
@@ -1740,7 +1723,6 @@ test_h5o_getinfo_visit(void)
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
/****************************************************************
**
** test_h5o(): Main H5O (generic object) testing routine.
@@ -1752,25 +1734,24 @@ test_h5o(void)
/* Output message about test being performed */
MESSAGE(5, ("Testing Objects\n"));
- test_h5o_open(); /* Test generic open function */
+ test_h5o_open(); /* Test generic open function */
#ifndef H5_NO_DEPRECATED_SYMBOLS
- test_h5o_open_by_addr(); /* Test opening objects by address */
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
- test_h5o_open_by_token(); /* Test opening objects by token */
- test_h5o_close(); /* Test generic close function */
- test_h5o_refcount(); /* Test incrementing and decrementing reference count */
- test_h5o_plist(); /* Test object creation properties */
- test_h5o_link(); /* Test object link routine */
- test_h5o_comment(); /* Test routines for comment */
- test_h5o_comment_by_name(); /* Test routines for comment by name */
- test_h5o_getinfo_same_file(); /* Test info for objects in the same file */
+ test_h5o_open_by_addr(); /* Test opening objects by address */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+ test_h5o_open_by_token(); /* Test opening objects by token */
+ test_h5o_close(); /* Test generic close function */
+ test_h5o_refcount(); /* Test incrementing and decrementing reference count */
+ test_h5o_plist(); /* Test object creation properties */
+ test_h5o_link(); /* Test object link routine */
+ test_h5o_comment(); /* Test routines for comment */
+ test_h5o_comment_by_name(); /* Test routines for comment by name */
+ test_h5o_getinfo_same_file(); /* Test info for objects in the same file */
#ifndef H5_NO_DEPRECATED_SYMBOLS
test_h5o_open_by_addr_deprec(); /* Test opening objects by address with H5Lget_info1 */
test_h5o_getinfo_visit(); /* Test object info for H5Oget_info1/2 and H5Ovisit1 */
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
} /* test_h5o() */
-
/*-------------------------------------------------------------------------
* Function: cleanup_h5o
*
@@ -1788,4 +1769,3 @@ cleanup_h5o(void)
{
remove(TEST_FILENAME);
}
-