summaryrefslogtreecommitdiffstats
path: root/c++/test
diff options
context:
space:
mode:
Diffstat (limited to 'c++/test')
-rw-r--r--c++/test/dsets.cpp728
-rw-r--r--c++/test/h5cpputil.cpp108
-rw-r--r--c++/test/h5cpputil.h106
-rw-r--r--c++/test/tarray.cpp212
-rw-r--r--c++/test/tattr.cpp856
-rw-r--r--c++/test/tcompound.cpp470
-rw-r--r--c++/test/tdspl.cpp68
-rw-r--r--c++/test/testhdf5.cpp65
-rw-r--r--c++/test/tfile.cpp550
-rw-r--r--c++/test/tfilter.cpp102
-rw-r--r--c++/test/th5s.cpp268
-rw-r--r--c++/test/titerate.cpp246
-rw-r--r--c++/test/tlinks.cpp327
-rw-r--r--c++/test/tobject.cpp186
-rw-r--r--c++/test/trefer.cpp385
-rw-r--r--c++/test/ttypes.cpp339
-rw-r--r--c++/test/tvlstr.cpp265
17 files changed, 2592 insertions, 2689 deletions
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp
index 76e4424..0116d6c 100644
--- a/c++/test/dsets.cpp
+++ b/c++/test/dsets.cpp
@@ -32,29 +32,28 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
-const H5std_string FILE1("dataset.h5");
-const H5std_string DSET_DEFAULT_NAME("default");
-const H5std_string DSET_DEFAULT_NAME_PATH("/default");
-const H5std_string DSET_CHUNKED_NAME("chunked");
-const H5std_string DSET_SIMPLE_IO_NAME("simple_io");
-const H5std_string DSET_TCONV_NAME("tconv");
-const H5std_string DSET_COMPRESS_NAME("compressed");
-const H5std_string DSET_BOGUS_NAME("bogus");
+const H5std_string FILE1("dataset.h5");
+const H5std_string DSET_DEFAULT_NAME("default");
+const H5std_string DSET_DEFAULT_NAME_PATH("/default");
+const H5std_string DSET_CHUNKED_NAME("chunked");
+const H5std_string DSET_SIMPLE_IO_NAME("simple_io");
+const H5std_string DSET_TCONV_NAME("tconv");
+const H5std_string DSET_COMPRESS_NAME("compressed");
+const H5std_string DSET_BOGUS_NAME("bogus");
/* Temporary filter IDs used for testing */
const int H5Z_FILTER_BOGUS = 305;
-static size_t filter_bogus(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
+static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes,
+ size_t *buf_size, void **buf);
// H5_ATTR_UNUSED variables caused warning, but taking them out caused failure.
-
/*-------------------------------------------------------------------------
* Function: test_create
*
@@ -68,7 +67,8 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts,
* Friday, January 5, 2001
*-------------------------------------------------------------------------
*/
-static herr_t test_create( H5File& file)
+static herr_t
+test_create(H5File &file)
{
SUBTEST("Create, open, close");
@@ -76,19 +76,17 @@ static herr_t test_create( H5File& file)
DataSet *dataset = NULL;
try {
// Create a data space
- hsize_t dims[2];
+ hsize_t dims[2];
dims[0] = 256;
dims[1] = 512;
- DataSpace space (2, dims, NULL);
+ DataSpace space(2, dims, NULL);
// Create a dataset using the default dataset creation properties.
// We're not sure what they are, so we won't check.
- dataset = new DataSet (file.createDataSet
- (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space));
-
+ dataset = new DataSet(file.createDataSet(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space));
// Add a comment to the dataset
- file.setComment (DSET_DEFAULT_NAME, "This is a dataset");
+ file.setComment(DSET_DEFAULT_NAME, "This is a dataset");
// Close the dataset
delete dataset;
@@ -98,18 +96,19 @@ static herr_t test_create( H5File& file)
// dataset can only be created once. If an exception is not thrown for
// this action by createDataSet, then throw an invalid action exception.
try {
- dataset = new DataSet (file.createDataSet
- (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space));
+ dataset = new DataSet(file.createDataSet(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space));
// continuation here, that means no exception has been thrown
- throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset");
+ throw InvalidActionException("H5File::createDataSet",
+ "Library allowed overwrite of existing dataset");
}
- catch (FileIException& E) // catching invalid creating dataset
- {} // do nothing, exception expected
+ catch (FileIException &E) // catching invalid creating dataset
+ {
+ } // do nothing, exception expected
// Open the dataset we created above and then close it. This is one
// way to open an existing dataset for accessing.
- dataset = new DataSet (file.openDataSet (DSET_DEFAULT_NAME));
+ dataset = new DataSet(file.openDataSet(DSET_DEFAULT_NAME));
// Get and verify the name of this dataset, using
// H5std_string getObjName()
@@ -125,30 +124,31 @@ static herr_t test_create( H5File& file)
delete dataset;
// This is another way to open an existing dataset for accessing.
- DataSet another_dataset(file.openDataSet (DSET_DEFAULT_NAME));
+ DataSet another_dataset(file.openDataSet(DSET_DEFAULT_NAME));
// Try opening a non-existent dataset. This should fail so if an
// exception is not thrown for this action by openDataSet, then
// display failure information and throw an exception.
try {
- dataset = new DataSet (file.openDataSet( "does_not_exist" ));
+ dataset = new DataSet(file.openDataSet("does_not_exist"));
// continuation here, that means no exception has been thrown
throw InvalidActionException("H5File::openDataSet", "Attempted to open a non-existent dataset");
}
- catch (FileIException& E ) // catching creating non-existent dataset
- {} // do nothing, exception expected
+ catch (FileIException &E) // catching creating non-existent dataset
+ {
+ } // do nothing, exception expected
// Create a new dataset that uses chunked storage instead of the default
// layout.
DSetCreatPropList create_parms;
- hsize_t csize[2];
+ hsize_t csize[2];
csize[0] = 5;
csize[1] = 100;
- create_parms.setChunk( 2, csize );
+ create_parms.setChunk(2, csize);
- dataset = new DataSet (file.createDataSet(DSET_CHUNKED_NAME,
- PredType::NATIVE_DOUBLE, space, create_parms));
+ dataset =
+ new DataSet(file.createDataSet(DSET_CHUNKED_NAME, PredType::NATIVE_DOUBLE, space, create_parms));
// Note: this one has no error message in C when failure occurs?
// clean up and return with success
@@ -156,10 +156,9 @@ static herr_t test_create( H5File& file)
PASSED();
return 0;
- } // outer most try block
+ } // outer most try block
- catch (InvalidActionException& E)
- {
+ catch (InvalidActionException &E) {
cerr << " FAILED" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
@@ -169,8 +168,7 @@ static herr_t test_create( H5File& file)
return -1;
}
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_create", __LINE__, __FILE__);
// clean up and return with failure
@@ -178,9 +176,8 @@ static herr_t test_create( H5File& file)
delete dataset;
return -1;
}
-} // test_create
+} // test_create
-
/*-------------------------------------------------------------------------
* Function: test_simple_io
*
@@ -196,75 +193,72 @@ static herr_t test_create( H5File& file)
* Friday, January 5, 2001
*-------------------------------------------------------------------------
*/
-static herr_t test_simple_io( H5File& file)
+static herr_t
+test_simple_io(H5File &file)
{
SUBTEST("Simple I/O");
- int points[100][200];
- int check[100][200];
+ int points[100][200];
+ int check[100][200];
int i, j, n;
// Initialize the dataset
- for (i = n = 0; i < 100; i++)
- {
+ for (i = n = 0; i < 100; i++) {
for (j = 0; j < 200; j++) {
points[i][j] = n++;
}
}
- char* tconv_buf = new char [1000];
- try
- {
+ char *tconv_buf = new char[1000];
+ try {
// Create the data space
hsize_t dims[2];
dims[0] = 100;
dims[1] = 200;
- DataSpace space (2, dims, NULL);
+ DataSpace space(2, dims, NULL);
// Create a small conversion buffer to test strip mining
DSetMemXferPropList xfer;
- xfer.setBuffer (1000, tconv_buf, NULL);
+ xfer.setBuffer(1000, tconv_buf, NULL);
// Create the dataset
- DataSet dataset (file.createDataSet (DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space));
+ DataSet dataset(file.createDataSet(DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space));
// Write the data to the dataset
- dataset.write(static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL,
+ xfer);
// Read the dataset back
- dataset.read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < 100; i++)
- for (j = 0; j < 200; j++)
- {
- int status = check_values (i, j, points[i][j], check[i][j]);
+ for (j = 0; j < 200; j++) {
+ int status = check_values(i, j, points[i][j], check[i][j]);
if (status == -1)
throw Exception("DataSet::read");
}
// clean up and return with success
- delete [] tconv_buf;
+ delete[] tconv_buf;
PASSED();
return 0;
- } // end try
+ } // end try
// catch all dataset, space, plist exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " FAILED" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
// clean up and return with failure
if (tconv_buf)
- delete [] tconv_buf;
+ delete[] tconv_buf;
return -1;
}
-} // test_simple_io
+} // test_simple_io
-
/*-------------------------------------------------------------------------
* Function: test_datasize
*
@@ -278,25 +272,24 @@ static herr_t test_simple_io( H5File& file)
* Thursday, March 22, 2012
*-------------------------------------------------------------------------
*/
-static herr_t test_datasize(FileAccPropList &fapl)
+static herr_t
+test_datasize(FileAccPropList &fapl)
{
SUBTEST("DataSet::getInMemDataSize()");
- try
- {
+ try {
// Open FILE1.
H5File file(FILE1, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl);
// Open dataset DSET_SIMPLE_IO_NAME.
- DataSet dset = file.openDataSet (DSET_SIMPLE_IO_NAME);
+ DataSet dset = file.openDataSet(DSET_SIMPLE_IO_NAME);
// Get the dataset's dataspace to calculate the size for verification.
DataSpace space(dset.getSpace());
// Get the dimension sizes.
hsize_t dims[2];
- int n_dims = space.getSimpleExtentDims(dims);
- if (n_dims < 0)
- {
+ int n_dims = space.getSimpleExtentDims(dims);
+ if (n_dims < 0) {
throw Exception("test_compression", "DataSpace::getSimpleExtentDims() failed");
}
@@ -308,8 +301,7 @@ static herr_t test_datasize(FileAccPropList &fapl)
size_t ds_size = dset.getInMemDataSize();
// Verify the data size.
- if (ds_size != expected_size)
- {
+ if (ds_size != expected_size) {
H5_FAILED();
cerr << " Expected data size = " << expected_size;
cerr << " but dset.getInMemDataSize() returned " << ds_size << endl;
@@ -318,19 +310,17 @@ static herr_t test_datasize(FileAccPropList &fapl)
PASSED();
return 0;
- } // end try
+ } // end try
// catch all dataset, space, plist exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " FAILED" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
return -1;
}
-} // test_datasize
+} // test_datasize
-
/*-------------------------------------------------------------------------
* Function: test_tconv
*
@@ -344,84 +334,79 @@ static herr_t test_datasize(FileAccPropList &fapl)
* Friday, January 5, 2001
*-------------------------------------------------------------------------
*/
-static herr_t test_tconv(H5File& file)
+static herr_t
+test_tconv(H5File &file)
{
// Prepare buffers for input/output
- char *out=NULL, *in=NULL;
- out = new char [4*1000000];
+ char *out = NULL, *in = NULL;
+ out = new char[4 * 1000000];
// assert (out); - should use exception handler for new - BMR
- in = new char [4*1000000];
- //assert (in);
+ in = new char[4 * 1000000];
+ // assert (in);
SUBTEST("Data type conversion");
// Initialize the dataset
for (int i = 0; i < 1000000; i++) {
- out[i*4+0] = 0x11;
- out[i*4+1] = 0x22;
- out[i*4+2] = 0x33;
- out[i*4+3] = 0x44;
+ out[i * 4 + 0] = 0x11;
+ out[i * 4 + 1] = 0x22;
+ out[i * 4 + 2] = 0x33;
+ out[i * 4 + 3] = 0x44;
}
- try
- {
+ try {
// Create the data space
hsize_t dims[1];
dims[0] = 1000000;
- DataSpace space (1, dims, NULL);
+ DataSpace space(1, dims, NULL);
// Create the data set
- DataSet dataset (file.createDataSet (DSET_TCONV_NAME, PredType::STD_I32LE, space));
+ DataSet dataset(file.createDataSet(DSET_TCONV_NAME, PredType::STD_I32LE, space));
// Write the data to the dataset
- dataset.write (static_cast<void*>(out), PredType::STD_I32LE);
+ dataset.write(static_cast<void *>(out), PredType::STD_I32LE);
// Read data with byte order conversion
- dataset.read (static_cast<void*>(in), PredType::STD_I32BE);
+ dataset.read(static_cast<void *>(in), PredType::STD_I32BE);
// Check
for (int i = 0; i < 1000000; i++) {
- if (in[4*i+0]!=out[4*i+3] ||
- in[4*i+1]!=out[4*i+2] ||
- in[4*i+2]!=out[4*i+1] ||
- in[4*i+3]!=out[4*i+0])
- {
+ if (in[4 * i + 0] != out[4 * i + 3] || in[4 * i + 1] != out[4 * i + 2] ||
+ in[4 * i + 2] != out[4 * i + 1] || in[4 * i + 3] != out[4 * i + 0]) {
throw Exception("DataSet::read", "Read with byte order conversion failed");
}
}
// clean up and return with success
- delete [] out;
- delete [] in;
+ delete[] out;
+ delete[] in;
PASSED();
return 0;
- } // end try
+ } // end try
// catch all dataset and space exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " FAILED" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
// clean up and return with failure
- delete [] out;
- delete [] in;
+ delete[] out;
+ delete[] in;
return -1;
}
-} // test_tconv
+} // test_tconv
/* This message derives from H5Z */
const H5Z_class2_t H5Z_BOGUS[1] = {{
- H5Z_CLASS_T_VERS, /* H5Z_class_t version number */
- H5Z_FILTER_BOGUS, /* Filter id number */
- 1, 1, /* Encode and decode enabled */
- "bogus", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
- (H5Z_func_t)filter_bogus, /* The actual filter function */
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version number */
+ H5Z_FILTER_BOGUS, /* Filter id number */
+ 1, 1, /* Encode and decode enabled */
+ "bogus", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ (H5Z_func_t)filter_bogus, /* The actual filter function */
}};
-
/*-------------------------------------------------------------------------
* Function: bogus
*
@@ -435,15 +420,14 @@ const H5Z_class2_t H5Z_BOGUS[1] = {{
* Tuesday, April 21, 1998
*-------------------------------------------------------------------------
*/
-static size_t filter_bogus(unsigned int flags, size_t cd_nelmts,
- const unsigned int cd_values[], size_t nbytes,
- size_t *buf_size, void **buf)
+static size_t
+filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], size_t nbytes,
+ size_t *buf_size, void **buf)
// H5_ATTR_UNUSED variables caused warning, but taking them out caused failure.
{
return nbytes;
}
-
/*-------------------------------------------------------------------------
* Function: test_compression
*
@@ -460,28 +444,27 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts,
* Friday, January 5, 2001
*-------------------------------------------------------------------------
*/
-static herr_t test_compression(H5File& file)
+static herr_t
+test_compression(H5File &file)
{
#ifndef H5_HAVE_FILTER_DEFLATE
const char *not_supported;
not_supported = " Deflate compression is not enabled.";
#endif /* H5_HAVE_FILTER_DEFLATE */
- int points[100][200];
- int check[100][200];
- hsize_t i, j, n;
+ int points[100][200];
+ int check[100][200];
+ hsize_t i, j, n;
// Initialize the dataset
- for (i = n = 0; i < 100; i++)
- {
+ for (i = n = 0; i < 100; i++) {
for (j = 0; j < 200; j++) {
points[i][j] = static_cast<int>(n++);
}
}
- char* tconv_buf = new char [1000];
- DataSet* dataset = NULL;
- try
- {
+ char * tconv_buf = new char[1000];
+ DataSet *dataset = NULL;
+ try {
const hsize_t size[2] = {100, 200};
// Create the data space
DataSpace space1(2, size, NULL);
@@ -489,39 +472,39 @@ static herr_t test_compression(H5File& file)
// Create a small conversion buffer to test strip mining
DSetMemXferPropList xfer;
- xfer.setBuffer (1000, tconv_buf, NULL);
+ xfer.setBuffer(1000, tconv_buf, NULL);
// Use chunked storage with compression
DSetCreatPropList dscreatplist;
const hsize_t chunk_size[2] = {2, 25};
- dscreatplist.setChunk (2, chunk_size);
- dscreatplist.setDeflate (6);
+ dscreatplist.setChunk(2, chunk_size);
+ dscreatplist.setDeflate(6);
#ifdef H5_HAVE_FILTER_DEFLATE
SUBTEST("Compression (setup)");
// Create the dataset
- dataset = new DataSet (file.createDataSet
- (DSET_COMPRESS_NAME, PredType::NATIVE_INT, space1, dscreatplist));
+ dataset =
+ new DataSet(file.createDataSet(DSET_COMPRESS_NAME, PredType::NATIVE_INT, space1, dscreatplist));
PASSED();
/*----------------------------------------------------------------------
- * STEP 1: Read uninitialized data. It should be zero.
- *----------------------------------------------------------------------
- */
+ * STEP 1: Read uninitialized data. It should be zero.
+ *----------------------------------------------------------------------
+ */
SUBTEST("Compression (uninitialized read)");
- dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
- for (i=0; i<size[0]; i++) {
- for (j=0; j<size[1]; j++) {
- if (0!=check[i][j]) {
+ for (i = 0; i < size[0]; i++) {
+ for (j = 0; j < size[1]; j++) {
+ if (0 != check[i][j]) {
H5_FAILED();
cerr << " Read a non-zero value." << endl;
- cerr << " At index " << static_cast<unsigned long>(i)
- << "," << static_cast<unsigned long>(j) << endl;
+ cerr << " At index " << static_cast<unsigned long>(i) << ","
+ << static_cast<unsigned long>(j) << endl;
throw Exception("test_compression", "Failed in uninitialized read");
}
}
@@ -529,38 +512,36 @@ static herr_t test_compression(H5File& file)
PASSED();
/*----------------------------------------------------------------------
- * STEP 2: Test compression by setting up a chunked dataset and writing
- * to it.
- *----------------------------------------------------------------------
- */
+ * STEP 2: Test compression by setting up a chunked dataset and writing
+ * to it.
+ *----------------------------------------------------------------------
+ */
SUBTEST("Compression (write)");
- for (i=n=0; i<size[0]; i++)
- {
- for (j=0; j<size[1]; j++)
- {
+ for (i = n = 0; i < size[0]; i++) {
+ for (j = 0; j < size[1]; j++) {
points[i][j] = static_cast<int>(n++);
}
}
- dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL,
+ xfer);
PASSED();
/*----------------------------------------------------------------------
- * STEP 3: Try to read the data we just wrote.
- *----------------------------------------------------------------------
- */
+ * STEP 3: Try to read the data we just wrote.
+ *----------------------------------------------------------------------
+ */
SUBTEST("Compression (read)");
// Read the dataset back
- dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < size[0]; i++)
- for (j = 0; j < size[1]; j++)
- {
- int status = check_values (i, j, points[i][j], check[i][j]);
+ for (j = 0; j < size[1]; j++) {
+ int status = check_values(i, j, points[i][j], check[i][j]);
if (status == -1)
throw Exception("test_compression", "Failed in read");
}
@@ -568,31 +549,29 @@ static herr_t test_compression(H5File& file)
PASSED();
/*----------------------------------------------------------------------
- * STEP 4: Write new data over the top of the old data. The new data is
- * random thus not very compressible, and will cause the chunks to move
- * around as they grow. We only change values for the left half of the
- * dataset although we rewrite the whole thing.
- *----------------------------------------------------------------------
- */
+ * STEP 4: Write new data over the top of the old data. The new data is
+ * random thus not very compressible, and will cause the chunks to move
+ * around as they grow. We only change values for the left half of the
+ * dataset although we rewrite the whole thing.
+ *----------------------------------------------------------------------
+ */
SUBTEST("Compression (modify)");
- for (i=0; i<size[0]; i++)
- {
- for (j=0; j<size[1]/2; j++)
- {
- points[i][j] = rand ();
+ for (i = 0; i < size[0]; i++) {
+ for (j = 0; j < size[1] / 2; j++) {
+ points[i][j] = rand();
}
}
- dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL,
+ xfer);
// Read the dataset back and check it
- dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < size[0]; i++)
- for (j = 0; j < size[1]; j++)
- {
- int status = check_values (i, j, points[i][j], check[i][j]);
+ for (j = 0; j < size[1]; j++) {
+ int status = check_values(i, j, points[i][j], check[i][j]);
if (status == -1)
throw Exception("test_compression", "Failed in modify");
}
@@ -600,66 +579,65 @@ static herr_t test_compression(H5File& file)
PASSED();
/*----------------------------------------------------------------------
- * STEP 5: Close the dataset and then open it and read it again. This
- * insures that the compression message is picked up properly from the
- * object header.
- *----------------------------------------------------------------------
- */
+ * STEP 5: Close the dataset and then open it and read it again. This
+ * insures that the compression message is picked up properly from the
+ * object header.
+ *----------------------------------------------------------------------
+ */
SUBTEST("Compression (re-open)");
// close this dataset to reuse the var
delete dataset;
- dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME));
- dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset = new DataSet(file.openDataSet(DSET_COMPRESS_NAME));
+ dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < size[0]; i++)
- for (j = 0; j < size[1]; j++)
- {
- int status = check_values (i, j, points[i][j], check[i][j]);
+ for (j = 0; j < size[1]; j++) {
+ int status = check_values(i, j, points[i][j], check[i][j]);
if (status == -1)
throw Exception("test_compression", "Failed in re-open");
}
PASSED();
-
/*----------------------------------------------------------------------
- * STEP 6: Test partial I/O by writing to and then reading from a
- * hyperslab of the dataset. The hyperslab does not line up on chunk
- * boundaries (we know that case already works from above tests).
- *----------------------------------------------------------------------
- */
+ * STEP 6: Test partial I/O by writing to and then reading from a
+ * hyperslab of the dataset. The hyperslab does not line up on chunk
+ * boundaries (we know that case already works from above tests).
+ *----------------------------------------------------------------------
+ */
SUBTEST("Compression (partial I/O)");
- const hsize_t hs_size[2] = {4, 50};
+ const hsize_t hs_size[2] = {4, 50};
const hsize_t hs_offset[2] = {7, 30};
for (i = 0; i < hs_size[0]; i++) {
for (j = 0; j < hs_size[1]; j++) {
- points[hs_offset[0]+i][hs_offset[1]+j] = rand ();
+ points[hs_offset[0] + i][hs_offset[1] + j] = rand();
}
}
- space1.selectHyperslab( H5S_SELECT_SET, hs_size, hs_offset );
- dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, space1, space1, xfer);
- dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, space1, space1, xfer);
+ space1.selectHyperslab(H5S_SELECT_SET, hs_size, hs_offset);
+ dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, space1, space1, xfer);
+ dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, space1, space1, xfer);
// Check that the values read are the same as the values written
- for (i=0; i<hs_size[0]; i++) {
- for (j=0; j<hs_size[1]; j++) {
- if (points[hs_offset[0]+i][hs_offset[1]+j] !=
- check[hs_offset[0]+i][hs_offset[1]+j]) {
- H5_FAILED();
- cerr << " Read different values than written.\n" << endl;
- cerr << " At index " << static_cast<unsigned long>((hs_offset[0]+i)) <<
- "," << static_cast<unsigned long>((hs_offset[1]+j)) << endl;
-
- cerr << " At original: " << static_cast<int>(points[hs_offset[0]+i][hs_offset[1]+j]) << endl;
- cerr << " At returned: " << static_cast<int>(check[hs_offset[0]+i][hs_offset[1]+j]) << endl;
- throw Exception("test_compression", "Failed in partial I/O");
- }
- } // for j
- } // for i
+ for (i = 0; i < hs_size[0]; i++) {
+ for (j = 0; j < hs_size[1]; j++) {
+ if (points[hs_offset[0] + i][hs_offset[1] + j] != check[hs_offset[0] + i][hs_offset[1] + j]) {
+ H5_FAILED();
+ cerr << " Read different values than written.\n" << endl;
+ cerr << " At index " << static_cast<unsigned long>((hs_offset[0] + i)) << ","
+ << static_cast<unsigned long>((hs_offset[1] + j)) << endl;
+
+ cerr << " At original: "
+ << static_cast<int>(points[hs_offset[0] + i][hs_offset[1] + j]) << endl;
+ cerr << " At returned: " << static_cast<int>(check[hs_offset[0] + i][hs_offset[1] + j])
+ << endl;
+ throw Exception("test_compression", "Failed in partial I/O");
+ }
+ } // for j
+ } // for i
delete dataset;
dataset = NULL;
@@ -673,29 +651,30 @@ static herr_t test_compression(H5File& file)
#endif
/*----------------------------------------------------------------------
- * STEP 7: Register an application-defined compression method and use it
- * to write and then read the dataset.
- *----------------------------------------------------------------------
- */
+ * STEP 7: Register an application-defined compression method and use it
+ * to write and then read the dataset.
+ *----------------------------------------------------------------------
+ */
SUBTEST("Compression (app-defined method)");
- if (H5Zregister (H5Z_BOGUS)<0)
- throw Exception("test_compression", "Failed in app-defined method");
- if (H5Pset_filter (dscreatplist.getId(), H5Z_FILTER_BOGUS, 0, 0, NULL)<0)
+ if (H5Zregister(H5Z_BOGUS) < 0)
+ throw Exception("test_compression", "Failed in app-defined method");
+ if (H5Pset_filter(dscreatplist.getId(), H5Z_FILTER_BOGUS, 0, 0, NULL) < 0)
throw Exception("test_compression", "Failed in app-defined method");
- dscreatplist.setFilter (H5Z_FILTER_BOGUS, 0, 0, NULL);
+ dscreatplist.setFilter(H5Z_FILTER_BOGUS, 0, 0, NULL);
- DataSpace space2 (2, size, NULL);
- dataset = new DataSet (file.createDataSet (DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist));
+ DataSpace space2(2, size, NULL);
+ dataset =
+ new DataSet(file.createDataSet(DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist));
- dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
- dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL,
+ xfer);
+ dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < size[0]; i++)
- for (j = 0; j < size[1]; j++)
- {
- int status = check_values (i, j, points[i][j], check[i][j]);
+ for (j = 0; j < size[1]; j++) {
+ int status = check_values(i, j, points[i][j], check[i][j]);
if (status == -1)
throw Exception("test_compression", "Failed in app-defined method");
}
@@ -703,17 +682,16 @@ static herr_t test_compression(H5File& file)
PASSED();
/*----------------------------------------------------------------------
- * Cleanup
- *----------------------------------------------------------------------
- */
+ * Cleanup
+ *----------------------------------------------------------------------
+ */
delete dataset;
- delete [] tconv_buf;
+ delete[] tconv_buf;
return 0;
} // end try
// catch all dataset, file, space, and plist exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " FAILED" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
@@ -721,12 +699,11 @@ static herr_t test_compression(H5File& file)
if (dataset != NULL)
delete dataset;
if (tconv_buf)
- delete [] tconv_buf;
+ delete[] tconv_buf;
return -1;
}
-} // test_compression
+} // test_compression
-
/*-------------------------------------------------------------------------
* Function: test_nbit_methods
*
@@ -742,18 +719,19 @@ static herr_t test_compression(H5File& file)
*-------------------------------------------------------------------------
*/
const H5std_string DSET_NBIT_NAME("nbit_dataset");
-const hsize_t DIM1 = 2;
-const hsize_t DIM2 = 5;
+const hsize_t DIM1 = 2;
+const hsize_t DIM2 = 5;
-static herr_t test_nbit_compression(H5File& file)
+static herr_t
+test_nbit_compression(H5File &file)
{
typedef struct {
- int i;
- char c;
+ int i;
+ char c;
short s;
} s1_t;
- const hsize_t size[2] = {DIM1, DIM2};
+ const hsize_t size[2] = {DIM1, DIM2};
const hsize_t chunk_size[2] = {DIM1, DIM2};
s1_t orig_data[DIM1][DIM2];
s1_t new_data[DIM1][DIM2];
@@ -761,8 +739,7 @@ static herr_t test_nbit_compression(H5File& file)
SUBTEST("N-bit compression (setup)");
- try
- {
+ try {
// Define datatypes of members of compound datatype
IntType i_type(PredType::NATIVE_INT);
IntType c_type(PredType::NATIVE_CHAR);
@@ -781,7 +758,7 @@ static herr_t test_nbit_compression(H5File& file)
mem_cmpd.insertMember("s", HOFFSET(s1_t, s), s_type);
// Set order of dataset compound datatype
- //cmpd.setOrder(H5T_ORDER_BE); only for atomic type?
+ // cmpd.setOrder(H5T_ORDER_BE); only for atomic type?
// Create the data space
DataSpace space(2, size);
@@ -796,36 +773,33 @@ static herr_t test_nbit_compression(H5File& file)
// Initialize data, assuming size of long long >= size of member datatypes
for (i = 0; i < size[0]; i++)
- for (j = 0; j < size[1]; j++)
- {
+ for (j = 0; j < size[1]; j++) {
orig_data[i][j].i = static_cast<int>(i * j);
orig_data[i][j].c = static_cast<char>('a' + i);
orig_data[i][j].s = static_cast<short>(i + j);
// Some even-numbered integer values are negative
- if ((i*size[1]+j+1)%2 == 0) {
+ if ((i * size[1] + j + 1) % 2 == 0) {
orig_data[i][j].i = -orig_data[i][j].i;
orig_data[i][j].s = static_cast<short>(-orig_data[i][j].s);
}
}
// Write to the dataset
- dataset.write(static_cast<void*>(orig_data), mem_cmpd);
+ dataset.write(static_cast<void *>(orig_data), mem_cmpd);
// Read the dataset back */
- dataset.read(static_cast<void*>(new_data), mem_cmpd);
+ dataset.read(static_cast<void *>(new_data), mem_cmpd);
// Check that the values read are the same as the values written.
for (i = 0; i < size[0]; i++)
- for (j = 0; j < size[1]; j++)
- {
- if((new_data[i][j].i != orig_data[i][j].i) ||
- (new_data[i][j].c != orig_data[i][j].c) ||
- (new_data[i][j].s != orig_data[i][j].s))
- {
+ for (j = 0; j < size[1]; j++) {
+ if ((new_data[i][j].i != orig_data[i][j].i) || (new_data[i][j].c != orig_data[i][j].c) ||
+ (new_data[i][j].s != orig_data[i][j].s)) {
H5_FAILED();
printf(" Read different values than written.\n");
- printf(" At index %lu,%lu\n", static_cast<unsigned long>(i), static_cast<unsigned long>(j));
+ printf(" At index %lu,%lu\n", static_cast<unsigned long>(i),
+ static_cast<unsigned long>(j));
}
}
@@ -834,8 +808,7 @@ static herr_t test_nbit_compression(H5File& file)
} // end try block
// catch all dataset, file, space, and plist exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " FAILED" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
@@ -843,7 +816,6 @@ static herr_t test_nbit_compression(H5File& file)
}
} // test_nbit_compression
-
/*-------------------------------------------------------------------------
* Function: test_multiopen
*
@@ -860,12 +832,13 @@ static herr_t test_nbit_compression(H5File& file)
* Saturday, February 17, 2001
*-------------------------------------------------------------------------
*/
-static herr_t test_multiopen (H5File& file)
+static herr_t
+test_multiopen(H5File &file)
{
SUBTEST("Multi-open with extending");
- DataSpace* space = NULL;
+ DataSpace *space = NULL;
try {
// Create a dataset creation property list
@@ -873,17 +846,17 @@ static herr_t test_multiopen (H5File& file)
// Set chunk size to given size
hsize_t cur_size[1] = {10};
- dcpl.setChunk (1, cur_size);
+ dcpl.setChunk(1, cur_size);
// Create a simple data space with unlimited size
hsize_t max_size[1] = {H5S_UNLIMITED};
- space = new DataSpace (1, cur_size, max_size);
+ space = new DataSpace(1, cur_size, max_size);
// Create first dataset
- DataSet dset1 = file.createDataSet ("multiopen", PredType::NATIVE_INT, *space, dcpl);
+ DataSet dset1 = file.createDataSet("multiopen", PredType::NATIVE_INT, *space, dcpl);
// Open again the first dataset from the file to another DataSet object.
- DataSet dset2 = file.openDataSet ("multiopen");
+ DataSet dset2 = file.openDataSet("multiopen");
// Relieve the dataspace
delete space;
@@ -891,18 +864,16 @@ static herr_t test_multiopen (H5File& file)
// Extend the dimensionality of the first dataset
cur_size[0] = 20;
- dset1.extend (cur_size);
+ dset1.extend(cur_size);
// Get the size from the second handle
- space = new DataSpace (dset2.getSpace());
+ space = new DataSpace(dset2.getSpace());
hsize_t tmp_size[1];
- space->getSimpleExtentDims (tmp_size);
- if (cur_size[0]!=tmp_size[0])
- {
- cerr << " Got " << static_cast<int>(tmp_size[0])
- << " instead of " << static_cast<int>(cur_size[0])
- << "!" << endl;
+ space->getSimpleExtentDims(tmp_size);
+ if (cur_size[0] != tmp_size[0]) {
+ cerr << " Got " << static_cast<int>(tmp_size[0]) << " instead of "
+ << static_cast<int>(cur_size[0]) << "!" << endl;
throw Exception("test_multiopen", "Failed in multi-open with extending");
}
@@ -913,8 +884,7 @@ static herr_t test_multiopen (H5File& file)
} // end try block
// catch all dataset, file, space, and plist exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " FAILED" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
@@ -923,9 +893,8 @@ static herr_t test_multiopen (H5File& file)
delete space;
return -1;
}
-} // test_multiopen
+} // test_multiopen
-
/*-------------------------------------------------------------------------
* Function: test_types
*
@@ -939,24 +908,25 @@ static herr_t test_multiopen (H5File& file)
* February 17, 2001
*-------------------------------------------------------------------------
*/
-static herr_t test_types(H5File& file)
+static herr_t
+test_types(H5File &file)
{
SUBTEST("Various datatypes");
- size_t i;
- DataSet* dset = NULL;
+ size_t i;
+ DataSet *dset = NULL;
try {
// Create a group in the file that was passed in from the caller
- Group grp = file.createGroup ("typetests");
+ Group grp = file.createGroup("typetests");
/* bitfield_1 */
unsigned char buf[32];
- hsize_t nelmts = sizeof(buf);
- DataType type;
+ hsize_t nelmts = sizeof(buf);
+ DataType type;
try { // block of bitfield_1
// test copying a predefined type
- type.copy (PredType::STD_B8LE);
+ type.copy(PredType::STD_B8LE);
// Test copying a user-defined type using DataType::copy
DataType copied_type;
@@ -967,7 +937,7 @@ static herr_t test_types(H5File& file)
another_copied_type = type;
// Test copying a user-defined int type using DataType::operator=
- IntType orig_int(PredType::STD_B8LE);
+ IntType orig_int(PredType::STD_B8LE);
DataType generic_type;
generic_type = orig_int;
@@ -978,45 +948,45 @@ static herr_t test_types(H5File& file)
IntType another_int_type;
another_int_type = new_int_type;
- DataSpace space (1, &nelmts);
+ DataSpace space(1, &nelmts);
dset = new DataSet(grp.createDataSet("bitfield_1", type, space));
// Fill buffer
- for (i=0; i<sizeof buf; i++)
- buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i);
+ for (i = 0; i < sizeof buf; i++)
+ buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i);
// Write data from buf using all default dataspaces and property list
- dset->write (buf, type);
+ dset->write(buf, type);
// no failure in bitfield_1, close this dataset
delete dset;
} // end try block of bitfield_1
// catch exceptions thrown in try block of bitfield_1
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " FAILED" << endl;
- cerr << " <<< " << "bitfield_1: " << E.getFuncName()
- << " - " << E.getDetailMsg() << " >>>" << endl << endl;
+ cerr << " <<< "
+ << "bitfield_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl
+ << endl;
if (dset != NULL)
delete dset;
return -1;
}
/* bitfield_2 */
- nelmts = sizeof(buf)/2;
+ nelmts = sizeof(buf) / 2;
try { // bitfield_2 block
- type.copy (PredType::STD_B16LE);
- DataSpace space (1, &nelmts);
+ type.copy(PredType::STD_B16LE);
+ DataSpace space(1, &nelmts);
dset = new DataSet(grp.createDataSet("bitfield_2", type, space));
// Fill buffer
- for (i=0; i<sizeof(buf); i++)
+ for (i = 0; i < sizeof(buf); i++)
buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i);
// Write data from buf using all default dataspaces and property
// list; if writing fails, deallocate dset and return.
- dset->write (buf, type);
+ dset->write(buf, type);
// no failure in bitfield_2, close this dataset and reset for
// variable reuse
@@ -1025,44 +995,46 @@ static herr_t test_types(H5File& file)
} // end try block of bitfield_2
// catch exceptions thrown in try block of bitfield_2
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " FAILED" << endl;
- cerr << " <<< " << "bitfield_2: " << E.getFuncName()
- << " - " << E.getDetailMsg() << " >>>" << endl << endl;
+ cerr << " <<< "
+ << "bitfield_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl
+ << endl;
if (dset != NULL)
delete dset;
throw E; // propagate the exception
}
/* opaque_1 */
- DataType* optype = NULL;
+ DataType *optype = NULL;
try { // opaque_1 block
optype = new DataType(H5T_OPAQUE, 1);
nelmts = sizeof(buf);
- DataSpace space (1, &nelmts);
- optype->setTag ("testing 1-byte opaque type");
+ DataSpace space(1, &nelmts);
+ optype->setTag("testing 1-byte opaque type");
dset = new DataSet(grp.createDataSet("opaque_1", *optype, space));
// Fill buffer
- for (i=0; i<sizeof buf; i++)
+ for (i = 0; i < sizeof buf; i++)
buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i);
// Write data from buf using all default dataspaces and property
// list; if writing fails, deallocate dset and return.
- dset->write (buf, *optype);
+ dset->write(buf, *optype);
// no failure in opaque_1
- delete dset; dset = NULL;
- delete optype; optype = NULL;
+ delete dset;
+ dset = NULL;
+ delete optype;
+ optype = NULL;
} // end try block of opaque_1
// catch exceptions thrown in try block of opaque_1
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " FAILED" << endl;
- cerr << " <<< " << "opaque_1: " << E.getFuncName()
- << " - " << E.getDetailMsg() << " >>>" << endl << endl;
+ cerr << " <<< "
+ << "opaque_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl
+ << endl;
if (dset != NULL)
delete dset;
if (optype != NULL)
@@ -1072,31 +1044,33 @@ static herr_t test_types(H5File& file)
/* opaque_2 */
try { // block opaque_2
- nelmts = sizeof(buf)/4;
- DataSpace space (1, &nelmts);
+ nelmts = sizeof(buf) / 4;
+ DataSpace space(1, &nelmts);
optype = new DataType(H5T_OPAQUE, 4);
- optype->setTag ("testing 4-byte opaque type");
+ optype->setTag("testing 4-byte opaque type");
dset = new DataSet(grp.createDataSet("opaque_2", *optype, space));
// Fill buffer
- for (i=0; i<sizeof(buf); i++)
+ for (i = 0; i < sizeof(buf); i++)
buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i);
// Write data from buf using all default dataspaces and property
// list; if writing fails, deallocate dset and return.
- dset->write (buf, *optype);
+ dset->write(buf, *optype);
// no failure in opaque_1
- delete dset; dset = NULL;
- delete optype; optype = NULL;
- } //end try block of opaque_2
+ delete dset;
+ dset = NULL;
+ delete optype;
+ optype = NULL;
+ } // end try block of opaque_2
// catch exceptions thrown in try block of opaque_2
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " FAILED" << endl;
- cerr << " <<< " << "opaque_2: " << E.getFuncName()
- << " - " << E.getDetailMsg() << " >>>" << endl << endl;
+ cerr << " <<< "
+ << "opaque_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl
+ << endl;
if (dset != NULL)
delete dset;
if (optype != NULL)
@@ -1108,13 +1082,11 @@ static herr_t test_types(H5File& file)
return 0;
} // end top try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
return -1;
}
-} // test_types
+} // test_types
-
/*-------------------------------------------------------------------------
* Function: test_getNativeObjinfo
*
@@ -1126,16 +1098,17 @@ static herr_t test_types(H5File& file)
* July, 2018
*-------------------------------------------------------------------------
*/
-static herr_t test_getnativeinfo(H5File& file)
+static herr_t
+test_getnativeinfo(H5File &file)
{
SUBTEST("Getting object information");
try {
// Create a data space
- hsize_t dims[2];
+ hsize_t dims[2];
dims[0] = 256;
dims[1] = 512;
- DataSpace space (2, dims, NULL);
+ DataSpace space(2, dims, NULL);
// Create a dataset using the default dataset creation properties.
// We're not sure what they are, so we won't check.
@@ -1158,23 +1131,20 @@ static herr_t test_getnativeinfo(H5File& file)
PASSED();
return 0;
- } // outer most try block
+ } // outer most try block
- catch (InvalidActionException& E)
- {
+ catch (InvalidActionException &E) {
cerr << " FAILED" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
return -1;
}
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_getnativeinfo", __LINE__, __FILE__);
return -1;
}
-} // test_getnativeinfo
+} // test_getnativeinfo
-
/*-------------------------------------------------------------------------
* Function: test_chunk_cache
*
@@ -1187,10 +1157,11 @@ static herr_t test_getnativeinfo(H5File& file)
* July 2018
*-------------------------------------------------------------------------
*/
-const int RANK1 = 1;
+const int RANK1 = 1;
const H5std_string FILE_ACCPLIST("test_accplist.h5");
-static herr_t test_chunk_cache(FileAccPropList fapl)
+static herr_t
+test_chunk_cache(FileAccPropList fapl)
{
SUBTEST("DSetAccPropList::set/getChunkCache");
@@ -1200,14 +1171,14 @@ static herr_t test_chunk_cache(FileAccPropList fapl)
DSetAccPropList dapl;
// Verify that chunk cache parameters are the same
- int mdc_nelmts = 0;
+ int mdc_nelmts = 0;
size_t nslots_1 = 0, nslots_4 = 0, nbytes_1 = 0, nbytes_4 = 0;
double w0_1 = 0.0F, w0_4 = 0.0F;
fapl_def.getCache(mdc_nelmts, nslots_1, nbytes_1, w0_1);
dapl.getChunkCache(nslots_4, nbytes_4, w0_4);
- verify_val(nslots_1, nslots_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__);
- verify_val(nbytes_1, nbytes_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__);
- verify_val(w0_1, w0_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__);
+ verify_val(nslots_1, nslots_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__);
+ verify_val(nbytes_1, nbytes_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__);
+ verify_val(w0_1, w0_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__);
// Set a link access property on dapl to verify property list inheritance
dapl.setNumLinks((size_t)134);
@@ -1220,7 +1191,7 @@ static herr_t test_chunk_cache(FileAccPropList fapl)
// Set new rdcc settings on fapl local
size_t nslots_2 = nslots_1 * 2;
size_t nbytes_2 = nbytes_1 * 2;
- double w0_2 = w0_1 / (double)2.0F;
+ double w0_2 = w0_1 / (double)2.0F;
fapl_local.getCache(mdc_nelmts, nslots_2, nbytes_2, w0_2);
// Create a new file using default fcpl and the passed-in fapl
@@ -1247,17 +1218,16 @@ static herr_t test_chunk_cache(FileAccPropList fapl)
// Retrieve and verify the raw data chunk cache parameters
nslots_4 = nbytes_4 = 0;
- w0_4 = 0.0F;
+ w0_4 = 0.0F;
dapl2.getChunkCache(nslots_4, nbytes_4, w0_4);
verify_val(nslots_2, nslots_4, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__);
verify_val(nbytes_2, nbytes_4, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__);
verify_val(H5_DBL_ABS_EQUAL(w0_2, w0_4), 1, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__);
-
// Set new values on original dapl
size_t nslots_3 = nslots_1 * 2;
size_t nbytes_3 = H5D_CHUNK_CACHE_NBYTES_DEFAULT;
- double w0_3 = w0_2 / 2;
+ double w0_3 = w0_2 / 2;
dapl.getChunkCache(nslots_3, nbytes_3, w0_3);
// Close dataset
@@ -1275,18 +1245,15 @@ static herr_t test_chunk_cache(FileAccPropList fapl)
verify_val(nbytes_3, nbytes_4, "DSetCreatPropList::getLayout", __LINE__, __FILE__);
verify_val(H5_DBL_ABS_EQUAL(w0_3, w0_4), 1, "DSetCreatPropList::getLayout", __LINE__, __FILE__);
-
PASSED();
return 0;
} // end top try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
return -1;
}
} // test_chunk_cache
-
/*-------------------------------------------------------------------------
* Function: test_virtual
*
@@ -1303,7 +1270,8 @@ static herr_t test_chunk_cache(FileAccPropList fapl)
*/
const int RANK = 2;
-static herr_t test_virtual()
+static herr_t
+test_virtual()
{
SUBTEST("DSetCreatPropList::setVirtual");
@@ -1338,8 +1306,8 @@ static herr_t test_virtual()
dims[1] = 6;
DataSpace vspace(RANK, dims, mdims);
- hsize_t start[RANK]; // Hyperslab start
- hsize_t count[RANK]; // Hyperslab count
+ hsize_t start[RANK]; // Hyperslab start
+ hsize_t count[RANK]; // Hyperslab count
start[0] = start[1] = 3;
count[0] = count[1] = 3;
vspace.selectHyperslab(H5S_SELECT_SET, count, start);
@@ -1358,13 +1326,11 @@ static herr_t test_virtual()
return 0;
} // end top try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
return -1;
}
} // test_virtual
-
/*-------------------------------------------------------------------------
* Function: test_dset
*
@@ -1387,15 +1353,14 @@ static herr_t test_virtual()
*
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_dset()
+extern "C" void
+test_dset()
{
hid_t fapl_id;
- fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template
- int nerrors=0; // keep track of number of failures occur
+ fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template
+ int nerrors = 0; // keep track of number of failures occur
- try
- {
+ try {
// Use the file access template id to create a file access prop.
// list object to pass in H5File::H5File
FileAccPropList fapl(fapl_id);
@@ -1403,19 +1368,19 @@ void test_dset()
H5File file(FILE1, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
// Cause the library to emit initial messages
- Group grp = file.createGroup( "emit diagnostics", 0);
+ Group grp = file.createGroup("emit diagnostics", 0);
grp.setComment("Causes diagnostic messages to be emitted");
- nerrors += test_create(file) < 0 ? 1:0;
- nerrors += test_simple_io(file) < 0 ? 1:0;
- nerrors += test_getnativeinfo(file) < 0 ? 1:0;
- nerrors += test_tconv(file) < 0 ? 1:0;
- nerrors += test_compression(file) < 0 ? 1:0;
- nerrors += test_nbit_compression(file) < 0 ? 1:0;
- nerrors += test_multiopen (file) < 0 ? 1:0;
- nerrors += test_types(file) < 0 ? 1:0;
- nerrors += test_virtual() < 0 ? 1:0;
- nerrors += test_chunk_cache(fapl) < 0 ? 1:0;
+ nerrors += test_create(file) < 0 ? 1 : 0;
+ nerrors += test_simple_io(file) < 0 ? 1 : 0;
+ nerrors += test_getnativeinfo(file) < 0 ? 1 : 0;
+ nerrors += test_tconv(file) < 0 ? 1 : 0;
+ nerrors += test_compression(file) < 0 ? 1 : 0;
+ nerrors += test_nbit_compression(file) < 0 ? 1 : 0;
+ nerrors += test_multiopen(file) < 0 ? 1 : 0;
+ nerrors += test_types(file) < 0 ? 1 : 0;
+ nerrors += test_virtual() < 0 ? 1 : 0;
+ nerrors += test_chunk_cache(fapl) < 0 ? 1 : 0;
// Close group "emit diagnostics".
grp.close();
@@ -1423,18 +1388,16 @@ void test_dset()
// Close the file before testing data size.
file.close();
- nerrors += test_datasize(fapl) <0 ? 1:0;
+ nerrors += test_datasize(fapl) < 0 ? 1 : 0;
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
test_report(nerrors, H5std_string(" Dataset"));
}
// Clean up data file
cleanup_dsets();
-} // test_dset
+} // test_dset
-
/*-------------------------------------------------------------------------
* Function: cleanup_dsets
*
@@ -1445,9 +1408,8 @@ void test_dset()
* Programmer (use C version)
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_dsets()
+extern "C" void
+cleanup_dsets()
{
HDremove(FILE1.c_str());
} // cleanup_dsets
-
diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp
index f271eed..b93f136 100644
--- a/c++/test/h5cpputil.cpp
+++ b/c++/test/h5cpputil.cpp
@@ -28,11 +28,11 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
/*-------------------------------------------------------------------------
* Function: test_report
@@ -49,24 +49,21 @@ using namespace H5;
* Friday, February 6, 2001
*-------------------------------------------------------------------------
*/
-int test_report( int nerrors, const H5std_string& testname )
+int
+test_report(int nerrors, const H5std_string &testname)
{
- if (nerrors)
- {
- nerrors = MAX(1, nerrors);
+ if (nerrors) {
+ nerrors = MAX(1, nerrors);
if (1 == nerrors)
- cerr << "***** " << nerrors << testname
- << " TEST FAILED! *****" << endl;
+ cerr << "***** " << nerrors << testname << " TEST FAILED! *****" << endl;
else
- cerr << "***** " << nerrors << testname
- << " TESTS FAILED! *****" << endl;
- return 1;
- }
- else
- {
- cerr << "All" << testname << " tests passed." << endl;
- return 0;
- }
+ cerr << "***** " << nerrors << testname << " TESTS FAILED! *****" << endl;
+ return 1;
+ }
+ else {
+ cerr << "All" << testname << " tests passed." << endl;
+ return 0;
+ }
}
/*-------------------------------------------------------------------------
@@ -81,14 +78,14 @@ int test_report( int nerrors, const H5std_string& testname )
*
*-------------------------------------------------------------------------
*/
-void issue_fail_msg(const char* where, int line, const char* file_name,
- const char* message)
+void
+issue_fail_msg(const char *where, int line, const char *file_name, const char *message)
{
- if (GetTestVerbosity()>=VERBO_HI)
- {
+ if (GetTestVerbosity() >= VERBO_HI) {
cerr << endl;
- cerr << ">>> FAILED in " << where << " at line " << line
- << " in " << file_name << " - " << message << endl << endl;
+ cerr << ">>> FAILED in " << where << " at line " << line << " in " << file_name << " - " << message
+ << endl
+ << endl;
}
}
@@ -104,15 +101,15 @@ void issue_fail_msg(const char* where, int line, const char* file_name,
*
*-------------------------------------------------------------------------
*/
-void issue_fail_msg(const char* where, int line, const char* file_name,
- const char* func_name, const char* message)
+void
+issue_fail_msg(const char *where, int line, const char *file_name, const char *func_name, const char *message)
{
- if (GetTestVerbosity()>=VERBO_HI)
- {
+ if (GetTestVerbosity() >= VERBO_HI) {
cerr << endl;
- cerr << ">>> FAILED in " << where << ": " << func_name << endl <<
- " at line " << line << " in " << file_name << endl <<
- " C library detail: " << message << endl << endl;
+ cerr << ">>> FAILED in " << where << ": " << func_name << endl
+ << " at line " << line << " in " << file_name << endl
+ << " C library detail: " << message << endl
+ << endl;
}
}
@@ -134,13 +131,13 @@ void issue_fail_msg(const char* where, int line, const char* file_name,
* Friday, February 6, 2001
*-------------------------------------------------------------------------
*/
-int check_values (hsize_t i, hsize_t j, int apoint, int acheck)
+int
+check_values(hsize_t i, hsize_t j, int apoint, int acheck)
{
- if (apoint != acheck)
- {
+ if (apoint != acheck) {
cerr << " Read different values than written.\n" << endl;
- cerr << " At index " << static_cast<unsigned long>(i) << "," <<
- static_cast<unsigned long>(j) << endl;
+ cerr << " At index " << static_cast<unsigned long>(i) << "," << static_cast<unsigned long>(j)
+ << endl;
return -1;
}
return 0;
@@ -161,10 +158,10 @@ int check_values (hsize_t i, hsize_t j, int apoint, int acheck)
*
*-------------------------------------------------------------------------
*/
-void check_values(const char *value, const char* msg, int line, const char* file_name)
+void
+check_values(const char *value, const char *msg, int line, const char *file_name)
{
- if (value == NULL)
- {
+ if (value == NULL) {
cerr << endl;
cerr << "*** ERROR: " << msg << ", at line " << line << endl;
IncTestNumErrs();
@@ -187,21 +184,19 @@ void check_values(const char *value, const char* msg, int line, const char* file
* May 2, 2010
*-------------------------------------------------------------------------
*/
-void verify_val(const char* x, const char* value, const char* where, int line, const char* file_name)
+void
+verify_val(const char *x, const char *value, const char *where, int line, const char *file_name)
{
- if (GetTestVerbosity()>=VERBO_HI)
- {
+ if (GetTestVerbosity() >= VERBO_HI) {
cerr << endl;
- cerr << " Call to routine: " << where << " at line " << line
- << " in " << file_name << " had value " << x << endl;
+ cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value "
+ << x << endl;
}
- if (strcmp(x, value) != 0)
- {
+ if (strcmp(x, value) != 0) {
cerr << endl;
- cerr << "*** UNEXPECTED VALUE from " << where << " should be "
- << value << ", but is " << x << " at line " << line
- << " in " << file_name << endl;
- //IncTestNumErrs();
+ cerr << "*** UNEXPECTED VALUE from " << where << " should be " << value << ", but is " << x
+ << " at line " << line << " in " << file_name << endl;
+ // IncTestNumErrs();
throw TestFailedException(where, "");
}
}
@@ -209,7 +204,7 @@ void verify_val(const char* x, const char* value, const char* where, int line, c
//--------------------------------------------------------------------------
// Function: InvalidActionException default constructor
//--------------------------------------------------------------------------
-InvalidActionException::InvalidActionException():Exception(){}
+InvalidActionException::InvalidActionException() : Exception() {}
//--------------------------------------------------------------------------
// Function: InvalidActionException overloaded constructor
@@ -221,7 +216,10 @@ InvalidActionException::InvalidActionException():Exception(){}
// func - IN: Name of the function where failure should occur
// message - IN: Message
//--------------------------------------------------------------------------
-InvalidActionException::InvalidActionException(const H5std_string func, const H5std_string message) : Exception(func, message) {}
+InvalidActionException::InvalidActionException(const H5std_string func, const H5std_string message)
+ : Exception(func, message)
+{
+}
//--------------------------------------------------------------------------
// Function: InvalidActionException destructor
@@ -231,7 +229,7 @@ InvalidActionException::~InvalidActionException() throw() {}
//--------------------------------------------------------------------------
// Function: TestFailedException default constructor
//--------------------------------------------------------------------------
-TestFailedException::TestFailedException():Exception(){}
+TestFailedException::TestFailedException() : Exception() {}
//--------------------------------------------------------------------------
// Function: TestFailedException overloaded constructor
@@ -243,10 +241,12 @@ TestFailedException::TestFailedException():Exception(){}
// func - IN: Name of the function where failure should occur
// message - IN: Message
//--------------------------------------------------------------------------
-TestFailedException::TestFailedException(const H5std_string func, const H5std_string message) : Exception(func, message) {}
+TestFailedException::TestFailedException(const H5std_string func, const H5std_string message)
+ : Exception(func, message)
+{
+}
//--------------------------------------------------------------------------
// Function: TestFailedException destructor
//--------------------------------------------------------------------------
TestFailedException::~TestFailedException() throw() {}
-
diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h
index 6664d0c..97ed00b 100644
--- a/c++/test/h5cpputil.h
+++ b/c++/test/h5cpputil.h
@@ -28,94 +28,97 @@ using namespace H5;
using std::cerr;
using std::endl;
-#define MESSAGE(V,A) {if (HDGetTestVerbosity()>(V)) print_func A;}
-#define SUBTEST(TEST) {printf(" Subtest: %-52s",TEST); fflush(stdout);}
+#define MESSAGE(V, A) \
+ { \
+ if (HDGetTestVerbosity() > (V)) \
+ print_func A; \
+ }
+#define SUBTEST(TEST) \
+ { \
+ printf(" Subtest: %-52s", TEST); \
+ fflush(stdout); \
+ }
-int check_values (hsize_t i, hsize_t j, int apoint, int acheck);
-void check_values(const char *value, const char* msg, int line, const char* file_name);
-int test_report (int, const H5std_string&);
-void issue_fail_msg(const char* where, int line, const char* file_name,
- const char* message="");
-void issue_fail_msg(const char* where, int line, const char* file_name,
- const char* func_name, const char* message);
+int check_values(hsize_t i, hsize_t j, int apoint, int acheck);
+void check_values(const char *value, const char *msg, int line, const char *file_name);
+int test_report(int, const H5std_string &);
+void issue_fail_msg(const char *where, int line, const char *file_name, const char *message = "");
+void issue_fail_msg(const char *where, int line, const char *file_name, const char *func_name,
+ const char *message);
class InvalidActionException : public Exception {
- public:
- InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG);
- InvalidActionException();
- virtual ~InvalidActionException() throw();
+ public:
+ InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG);
+ InvalidActionException();
+ virtual ~InvalidActionException() throw();
};
class TestFailedException : public Exception {
- public:
- TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG);
- TestFailedException();
- virtual ~TestFailedException() throw();
+ public:
+ TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG);
+ TestFailedException();
+ virtual ~TestFailedException() throw();
};
// Overloaded/Template functions to verify values and display proper info
// Verifies
-void verify_val(const char* x, const char* value, const char* where, int line, const char* file_name);
+void verify_val(const char *x, const char *value, const char *where, int line, const char *file_name);
template <class Type1, class Type2>
- void verify_val(Type1 x, Type2 value, const char* where, int line, const char* file_name)
+void
+verify_val(Type1 x, Type2 value, const char *where, int line, const char *file_name)
{
- if (GetTestVerbosity()>=VERBO_HI)
- {
+ if (GetTestVerbosity() >= VERBO_HI) {
cerr << endl;
- cerr << " Call to routine: " << where << " at line " << line
- << " in " << file_name << " had value " << x << endl;
+ cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value "
+ << x << endl;
}
- if (x != value)
- {
+ if (x != value) {
cerr << endl;
- cerr << "*** UNEXPECTED VALUE from " << where << " should be "
- << value << ", but is " << x << " at line " << line
- << " in " << file_name << endl;
+ cerr << "*** UNEXPECTED VALUE from " << where << " should be " << value << ", but is " << x
+ << " at line " << line << " in " << file_name << endl;
IncTestNumErrs();
throw TestFailedException(where, "");
}
}
template <class Type1, class Type2>
- void verify_val(Type1 x, Type2 value, const char* msg, const char* file_name, int line)
+void
+verify_val(Type1 x, Type2 value, const char *msg, const char *file_name, int line)
{
- if (x != value)
- {
+ if (x != value) {
cerr << endl;
- cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line
- << ": " << msg << " different: " << x << ", should be " << value
- << endl;
+ cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line << ": " << msg
+ << " different: " << x << ", should be " << value << endl;
IncTestNumErrs();
throw TestFailedException(file_name, msg);
}
}
template <class Type1, class Type2>
- void verify_val_noteq(Type1 x, Type2 value, const char* where, int line, const char* file_name)
+void
+verify_val_noteq(Type1 x, Type2 value, const char *where, int line, const char *file_name)
{
- if (GetTestVerbosity()>=VERBO_HI)
- {
+ if (GetTestVerbosity() >= VERBO_HI) {
cerr << endl;
- cerr << " Call to routine: " << where << " at line " << line
- << " in " << file_name << " had value " << x << endl;
+ cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value "
+ << x << endl;
}
- if (x == value)
- {
+ if (x == value) {
cerr << endl;
- cerr << "*** UNEXPECTED VALUE from " << where << " should not be "
- << value << " at line " << line << " in " << file_name << endl;
+ cerr << "*** UNEXPECTED VALUE from " << where << " should not be " << value << " at line " << line
+ << " in " << file_name << endl;
IncTestNumErrs();
throw TestFailedException(where, "");
}
}
template <class Type1, class Type2>
- void CHECK(Type1 x, Type2 value, const char* msg, int line, const char* file_name)
+void
+CHECK(Type1 x, Type2 value, const char *msg, int line, const char *file_name)
{
- if (x == value)
- {
+ if (x == value) {
cerr << endl;
cerr << "*** Function " << msg << " FAILED at line " << line << endl;
IncTestNumErrs();
@@ -124,14 +127,13 @@ template <class Type1, class Type2>
}
template <class Type1, class Type2>
- void verify_val(Type1 x, Type2 value, float epsilon, const char* msg, int line, const char* file_name)
+void
+verify_val(Type1 x, Type2 value, float epsilon, const char *msg, int line, const char *file_name)
{
- if (x == value)
- {
+ if (x == value) {
cerr << endl;
- cerr << "*** UNEXPECTED FLOAT VALUE: " << file_name << ":line " << line
- << ": " << msg << " different: " << x << ", should be " << value
- << " (epsilon=" << epsilon << ")" << endl;
+ cerr << "*** UNEXPECTED FLOAT VALUE: " << file_name << ":line " << line << ": " << msg
+ << " different: " << x << ", should be " << value << " (epsilon=" << epsilon << ")" << endl;
IncTestNumErrs();
throw TestFailedException(file_name, msg);
}
diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp
index d80de16..dc7ea71 100644
--- a/c++/test/tarray.cpp
+++ b/c++/test/tarray.cpp
@@ -25,29 +25,35 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
-const H5std_string FILENAME("tarray.h5");
-const H5std_string ARRAYTYPE_NAME("/Array type 1");
-const int SPACE1_RANK = 1;
-const hsize_t SPACE1_DIM1 = 4;
-const int ARRAY1_RANK = 1;
-const hsize_t ARRAY1_DIM1 = 4;
+const H5std_string FILENAME("tarray.h5");
+const H5std_string ARRAYTYPE_NAME("/Array type 1");
+const int SPACE1_RANK = 1;
+const hsize_t SPACE1_DIM1 = 4;
+const int ARRAY1_RANK = 1;
+const hsize_t ARRAY1_DIM1 = 4;
-typedef enum flt_t {
- FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER
-} flt_t;
+typedef enum flt_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER } flt_t;
typedef enum int_t {
- INT_CHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT,
- INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, INT_OTHER
+ INT_CHAR,
+ INT_UCHAR,
+ INT_SHORT,
+ INT_USHORT,
+ INT_INT,
+ INT_UINT,
+ INT_LONG,
+ INT_ULONG,
+ INT_LLONG,
+ INT_ULLONG,
+ INT_OTHER
} int_t;
-
/*-------------------------------------------------------------------------
* Function: test_array_compound_array
*
@@ -59,29 +65,29 @@ typedef enum int_t {
* January, 2016
*-------------------------------------------------------------------------
*/
-static void test_array_compound_array()
+static void
+test_array_compound_array()
{
SUBTEST("ArrayType::getArrayNDims & ArrayType::getArrayDims");
- typedef struct { // Typedef for compound datatype */
- int i;
+ typedef struct { // Typedef for compound datatype */
+ int i;
float f[ARRAY1_DIM1];
} s1_t;
- s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write
- s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information read in
- hsize_t sdims1[] = {SPACE1_DIM1};
- hsize_t tdims1[] = {ARRAY1_DIM1};
- int nmemb; // Number of compound members
- int ii; // counting variables
- hsize_t idxi, idxj, idxk; // dimension indicing variables
- H5T_class_t mclass; // Datatype class for field
+ s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write
+ s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information read in
+ hsize_t sdims1[] = {SPACE1_DIM1};
+ hsize_t tdims1[] = {ARRAY1_DIM1};
+ int nmemb; // Number of compound members
+ int ii; // counting variables
+ hsize_t idxi, idxj, idxk; // dimension indicing variables
+ H5T_class_t mclass; // Datatype class for field
// Initialize array data to write
- for (idxi =0; idxi < SPACE1_DIM1; idxi++)
+ for (idxi = 0; idxi < SPACE1_DIM1; idxi++)
for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) {
wdata[idxi][idxj].i = idxi * 10 + idxj;
- for(idxk = 0; idxk < ARRAY1_DIM1; idxk++)
- {
- float temp = idxi * 10.0 + idxj * 2.5 + idxk;
+ for (idxk = 0; idxk < ARRAY1_DIM1; idxk++) {
+ float temp = idxi * 10.0 + idxj * 2.5 + idxk;
wdata[idxi][idxj].f[idxk] = temp;
}
} // end for
@@ -157,8 +163,8 @@ static void test_array_compound_array()
// Verify that it is an array of compounds
DataType dstype = dataset.getDataType();
- mclass = dstype.getClass();
- verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__);
+ mclass = dstype.getClass();
+ verify_val(mclass == H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__);
dstype.close();
@@ -174,11 +180,12 @@ static void test_array_compound_array()
atype_check.getArrayDims(rdims1);
// Check the array dimensions
- for (ii =0; ii <ndims; ii++)
- if (rdims1[ii]!=tdims1[ii]) {
- TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n", ii, rdims1[ii], ii, tdims1[ii]);
- continue;
- } // end if
+ for (ii = 0; ii < ndims; ii++)
+ if (rdims1[ii] != tdims1[ii]) {
+ TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n",
+ ii, rdims1[ii], ii, tdims1[ii]);
+ continue;
+ } // end if
// Test ArrayType::ArrayType(const hid_t existing_id)
ArrayType new_arrtype(atype_check.getId());
@@ -193,9 +200,10 @@ static void test_array_compound_array()
// Check the array dimensions
for (ii = 0; ii < ndims; ii++)
if (rdims1[ii] != tdims1[ii]) {
- TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n", ii, rdims1[ii], ii, tdims1[ii]);
- continue;
- } // end if
+ TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n",
+ ii, rdims1[ii], ii, tdims1[ii]);
+ continue;
+ } // end if
/*
* Check the compound datatype and the array of floats datatype
@@ -204,8 +212,8 @@ static void test_array_compound_array()
// Get the compound datatype, which is the base datatype of the
// array datatype atype_check.
DataType base_type = atype_check.getSuper();
- mclass = base_type.getClass();
- verify_val(mclass==H5T_COMPOUND, true, "atype_check.getClass", __LINE__, __FILE__);
+ mclass = base_type.getClass();
+ verify_val(mclass == H5T_COMPOUND, true, "atype_check.getClass", __LINE__, __FILE__);
// Verify the compound datatype info
CompType ctype_check(base_type.getId());
@@ -217,15 +225,15 @@ static void test_array_compound_array()
// Check the 2nd field's name
H5std_string field2_name = ctype_check.getMemberName(1);
- if (HDstrcmp(field2_name.c_str(),"f") != 0)
- TestErrPrintf("Compound field name doesn't match!, field2_name=%s\n",field2_name.c_str());
+ if (HDstrcmp(field2_name.c_str(), "f") != 0)
+ TestErrPrintf("Compound field name doesn't match!, field2_name=%s\n", field2_name.c_str());
// Get the 2nd field's datatype
DataType f2_type = ctype_check.getMemberDataType(1);
// Get the 2nd field's class, this 2nd field should have an array type
mclass = f2_type.getClass();
- verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__);
+ verify_val(mclass == H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__);
f2_type.close();
// Get the 2nd field, array of floats datatype, to check
@@ -242,7 +250,8 @@ static void test_array_compound_array()
// Check the array dimensions
for (ii = 0; ii < ndims; ii++)
if (rdims1[ii] != tdims1[ii]) {
- TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n", ii, rdims1[ii], ii, tdims1[ii]);
+ TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n",
+ ii, rdims1[ii], ii, tdims1[ii]);
continue;
} // end if
@@ -257,33 +266,34 @@ static void test_array_compound_array()
for (idxi = 0; idxi < SPACE1_DIM1; idxi++) {
for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) {
if (wdata[idxi][idxj].i != rdata[idxi][idxj].i) {
- TestErrPrintf("Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n",idxi,idxj,wdata[idxi][idxj].i,idxi,idxj,rdata[idxi][idxj].i);
+ TestErrPrintf(
+ "Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n",
+ idxi, idxj, wdata[idxi][idxj].i, idxi, idxj, rdata[idxi][idxj].i);
continue;
} // end if
- } // end for
- } // end for
+ } // end for
+ } // end for
// Close all
atype_check.close();
dataset.close();
file1.close();
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_array_compound_array", __LINE__, __FILE__, E.getCDetailMsg());
}
} // end test_array_compound_array()
-
/*
* Helper routine to demonstrate the issue in HDFFV-9562
*/
-H5::DataType getArr()
+H5::DataType
+getArr()
{
hsize_t *dims = new hsize_t;
- *dims = 5;
+ *dims = 5;
H5::ArrayType ret;
ret = H5::ArrayType(H5::PredType::NATIVE_INT, 1, dims);
delete dims;
@@ -304,7 +314,8 @@ H5::DataType getArr()
* Used user's sample code in HDFFV-9562
*-------------------------------------------------------------------------
*/
-static void test_array_assignment()
+static void
+test_array_assignment()
{
hsize_t sdims1[] = {SPACE1_DIM1};
SUBTEST("ArrayType::operator=");
@@ -341,14 +352,12 @@ static void test_array_assignment()
file1.close();
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_array_assignment", __LINE__, __FILE__, E.getCDetailMsg());
}
} // end test_array_assignment()
-
/*-------------------------------------------------------------------------
* Function: test_array_info
*
@@ -360,27 +369,27 @@ static void test_array_assignment()
* April, 2016
*-------------------------------------------------------------------------
*/
-static void test_array_info()
+static void
+test_array_info()
{
SUBTEST("ArrayType Const Methods");
- typedef struct { // Typedef for compound datatype */
- int i;
+ typedef struct { // Typedef for compound datatype */
+ int i;
float f[ARRAY1_DIM1];
} s1_t;
- s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write
- hsize_t sdims1[] = {SPACE1_DIM1};
- hsize_t tdims1[] = {ARRAY1_DIM1};
- int ii; // counting variables
- hsize_t idxi, idxj, idxk; // dimension indicing variables
- H5T_class_t mclass; // Datatype class for field
+ s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write
+ hsize_t sdims1[] = {SPACE1_DIM1};
+ hsize_t tdims1[] = {ARRAY1_DIM1};
+ int ii; // counting variables
+ hsize_t idxi, idxj, idxk; // dimension indicing variables
+ H5T_class_t mclass; // Datatype class for field
// Initialize array data to write
- for (idxi =0; idxi < SPACE1_DIM1; idxi++)
+ for (idxi = 0; idxi < SPACE1_DIM1; idxi++)
for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) {
wdata[idxi][idxj].i = idxi * 10 + idxj;
- for(idxk = 0; idxk < ARRAY1_DIM1; idxk++)
- {
- float temp = idxi * 10.0 + idxj * 2.5 + idxk;
+ for (idxk = 0; idxk < ARRAY1_DIM1; idxk++) {
+ float temp = idxi * 10.0 + idxj * 2.5 + idxk;
wdata[idxi][idxj].f[idxk] = temp;
}
} // end for
@@ -429,44 +438,44 @@ static void test_array_info()
// Verify that it is an array of compounds
DataType dstype = dataset.getDataType();
- mclass = dstype.getClass();
- verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__);
+ mclass = dstype.getClass();
+ verify_val(mclass == H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__);
dstype.close();
{ // Let atype_check go out of scope
- // Get the array datatype, declared as const
- const ArrayType atype_check = dataset.getArrayType();
-
- // Check the array rank with the const method
- int ndims = atype_check.getArrayNDims();
- verify_val(ndims, ARRAY1_RANK, "atype_check.getArrayNDims", __LINE__, __FILE__);
-
- // Get the array dimensions with the const method
- hsize_t rdims1[H5S_MAX_RANK];
- atype_check.getArrayDims(rdims1);
-
- // Check the array dimensions
- for (ii =0; ii <ndims; ii++)
- if (rdims1[ii]!=tdims1[ii]) {
- TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n", ii, rdims1[ii], ii, tdims1[ii]);
- continue;
- } // end if
+ // Get the array datatype, declared as const
+ const ArrayType atype_check = dataset.getArrayType();
+
+ // Check the array rank with the const method
+ int ndims = atype_check.getArrayNDims();
+ verify_val(ndims, ARRAY1_RANK, "atype_check.getArrayNDims", __LINE__, __FILE__);
+
+ // Get the array dimensions with the const method
+ hsize_t rdims1[H5S_MAX_RANK];
+ atype_check.getArrayDims(rdims1);
+
+ // Check the array dimensions
+ for (ii = 0; ii < ndims; ii++)
+ if (rdims1[ii] != tdims1[ii]) {
+ TestErrPrintf(
+ "Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n", ii,
+ rdims1[ii], ii, tdims1[ii]);
+ continue;
+ } // end if
}
// Close all
dataset.close();
file1.close();
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_array_info", __LINE__, __FILE__, E.getCDetailMsg());
}
} // end test_array_info()
-
/*-------------------------------------------------------------------------
* Function: test_array
*
@@ -475,8 +484,8 @@ static void test_array_info()
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_array()
+extern "C" void
+test_array()
{
// Output message about test being performed
MESSAGE(5, ("Testing Array Datatypes\n"));
@@ -490,9 +499,8 @@ void test_array()
// Test const functions (HDFFV-9725)
test_array_info();
-} // test_array()
+} // test_array()
-
/*-------------------------------------------------------------------------
* Function: cleanup_array
*
@@ -504,8 +512,8 @@ void test_array()
* January, 2016
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_array()
+extern "C" void
+cleanup_array()
{
HDremove(FILENAME.c_str());
-} // cleanup_array
+} // cleanup_array
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp
index f432723..2290fff 100644
--- a/c++/test/tattr.cpp
+++ b/c++/test/tattr.cpp
@@ -26,11 +26,11 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
const H5std_string FILE_BASIC("tattr_basic.h5");
const H5std_string FILE_COMPOUND("tattr_compound.h5");
@@ -39,10 +39,10 @@ const H5std_string FILE_MULTI("tattr_multi.h5");
const H5std_string FILE_DTYPE("tattr_dtype.h5");
const H5std_string ATTR_TMP_NAME("temp_attr_name");
const H5std_string FATTR_TMP_NAME("temp_fattr_name");
-const size_t ATTR_MAX_DIMS = 7;
+const size_t ATTR_MAX_DIMS = 7;
/* 3-D dataset with fixed dimensions */
-const int SPACE1_RANK = 3;
+const int SPACE1_RANK = 3;
const hsize_t SPACE1_DIM1 = 3;
const hsize_t SPACE1_DIM2 = 15;
const hsize_t SPACE1_DIM3 = 13;
@@ -54,54 +54,55 @@ const H5std_string TYPE1_NAME("/Type");
/* Attribute Rank & Dimensions */
const H5std_string ATTR1_NAME("Attr1");
-const int ATTR1_RANK = 1;
-const hsize_t ATTR1_DIM1 = 3;
-int attr_data1[ATTR1_DIM1]={512,-234,98123}; /* Test data for 1st attribute */
+const int ATTR1_RANK = 1;
+const hsize_t ATTR1_DIM1 = 3;
+int attr_data1[ATTR1_DIM1] = {512, -234, 98123}; /* Test data for 1st attribute */
// File attribute, using the same rank and dimensions as ATTR1_NAME's
const H5std_string FATTR1_NAME("File Attr1");
const H5std_string FATTR2_NAME("File Attr2");
const H5std_string ATTR2_NAME("Attr2");
-const int ATTR2_RANK = 2;
-const hsize_t ATTR2_DIM1 = 2;
-const hsize_t ATTR2_DIM2 = 2;
-int attr_data2[ATTR2_DIM1][ATTR2_DIM2]={{7614,-416},{197814,-3}}; /* Test data for 2nd attribute */
+const int ATTR2_RANK = 2;
+const hsize_t ATTR2_DIM1 = 2;
+const hsize_t ATTR2_DIM2 = 2;
+int attr_data2[ATTR2_DIM1][ATTR2_DIM2] = {{7614, -416}, {197814, -3}}; /* Test data for 2nd attribute */
const H5std_string ATTR3_NAME("Attr3");
-const int ATTR3_RANK = 3;
-const hsize_t ATTR3_DIM1 = 2;
-const hsize_t ATTR3_DIM2 = 2;
-const hsize_t ATTR3_DIM3 = 2;
-double attr_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{2.3,-26.1},{0.123,-10.0}},{{981724.2,-0.91827},{2.0,23.0}}}; /* Test data for 3rd attribute */
+const int ATTR3_RANK = 3;
+const hsize_t ATTR3_DIM1 = 2;
+const hsize_t ATTR3_DIM2 = 2;
+const hsize_t ATTR3_DIM3 = 2;
+double attr_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = {
+ {{2.3, -26.1}, {0.123, -10.0}}, {{981724.2, -0.91827}, {2.0, 23.0}}}; /* Test data for 3rd attribute */
const H5std_string ATTR4_NAME("Attr4");
-const int ATTR4_RANK = 2;
-const hsize_t ATTR4_DIM1 = 2;
-const hsize_t ATTR4_DIM2 = 2;
+const int ATTR4_RANK = 2;
+const hsize_t ATTR4_DIM1 = 2;
+const hsize_t ATTR4_DIM2 = 2;
const H5std_string ATTR4_FIELDNAME1("i");
const H5std_string ATTR4_FIELDNAME2("d");
const H5std_string ATTR4_FIELDNAME3("c");
-size_t attr4_field1_off=0;
-size_t attr4_field2_off=0;
-size_t attr4_field3_off=0;
+size_t attr4_field1_off = 0;
+size_t attr4_field2_off = 0;
+size_t attr4_field3_off = 0;
struct attr4_struct {
- int i;
+ int i;
double d;
- char c;
- } attr_data4[ATTR4_DIM1][ATTR4_DIM2]={{{3,-26.1,'d'},{-100000, 0.123,'3'}},
- {{-23,981724.2,'Q'},{0,2.0,'\n'}}}; // Test data for 4th attribute
+ char c;
+} attr_data4[ATTR4_DIM1][ATTR4_DIM2] = {
+ {{3, -26.1, 'd'}, {-100000, 0.123, '3'}},
+ {{-23, 981724.2, 'Q'}, {0, 2.0, '\n'}}}; // Test data for 4th attribute
const H5std_string ATTR5_NAME("Attr5");
-const int ATTR5_RANK = 0;
-float attr_data5 = (float)-5.123; // Test data for 5th attribute
+const int ATTR5_RANK = 0;
+float attr_data5 = (float)-5.123; // Test data for 5th attribute
/* Info for another attribute */
const H5std_string ATTR1A_NAME("Attr1_a");
-int attr_data1a[ATTR1_DIM1]={256,11945,-22107};
+int attr_data1a[ATTR1_DIM1] = {256, 11945, -22107};
-
/*-------------------------------------------------------------------------
* Function: test_attr_basic_write
*
@@ -110,12 +111,13 @@ int attr_data1a[ATTR1_DIM1]={256,11945,-22107};
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_basic_write()
+static void
+test_attr_basic_write()
{
- hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
- hsize_t dims2[] = {ATTR1_DIM1};
- hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2};
- int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ hsize_t dims2[] = {ATTR1_DIM1};
+ hsize_t dims3[] = {ATTR2_DIM1, ATTR2_DIM2};
+ int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading 1st attribute
hsize_t i;
// Output message about test being performed
@@ -123,10 +125,10 @@ static void test_attr_basic_write()
try {
// Create file
- H5File fid1 (FILE_BASIC, H5F_ACC_TRUNC);
+ H5File fid1(FILE_BASIC, H5F_ACC_TRUNC);
// Create dataspace for dataset
- DataSpace ds_space (SPACE1_RANK, dims1);
+ DataSpace ds_space(SPACE1_RANK, dims1);
/*
* Test attribute with dataset
@@ -136,55 +138,59 @@ static void test_attr_basic_write()
DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space);
// Create dataspace for attribute
- DataSpace att_space (ATTR1_RANK, dims2);
+ DataSpace att_space(ATTR1_RANK, dims2);
// Create a file attribute
- Attribute file_attr2 = fid1.createAttribute (FATTR1_NAME, PredType::NATIVE_INT, att_space);
+ Attribute file_attr2 = fid1.createAttribute(FATTR1_NAME, PredType::NATIVE_INT, att_space);
// Create a file attribute
- Attribute file_attr1 = fid1.createAttribute (FATTR2_NAME, PredType::NATIVE_INT, att_space);
+ Attribute file_attr1 = fid1.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, att_space);
// Create an attribute for the dataset
- Attribute ds_attr1 = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space);
+ Attribute ds_attr1 = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space);
// Try creating an attribute that already exists. This should fail
// since two attributes cannot have the same name. If an exception
// is not thrown for this action by createAttribute, then throw an
// invalid action exception.
try {
- Attribute invalid_attr = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space);
+ Attribute invalid_attr = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space);
// continuation here, that means no exception has been thrown
- throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset");
+ throw InvalidActionException("H5File::createDataSet",
+ "Library allowed overwrite of existing dataset");
}
- catch (AttributeIException& E) // catching invalid creating attribute
- {} // do nothing, exception expected
+ catch (AttributeIException &E) // catching invalid creating attribute
+ {
+ } // do nothing, exception expected
// Write attribute information
- ds_attr1.write (PredType::NATIVE_INT, attr_data1);
+ ds_attr1.write(PredType::NATIVE_INT, attr_data1);
// Read attribute information immediately, without closing attribute
- ds_attr1.read (PredType::NATIVE_INT, read_data1);
+ ds_attr1.read(PredType::NATIVE_INT, read_data1);
// Verify values read in
- for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1[i]!=read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n", __LINE__,
+ i, attr_data1[i], i, read_data1[i]);
// Create two more attributes for this dataset, but only write to one.
- Attribute ds_attr2 = dataset.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, att_space);
- Attribute ds_attr3 = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_INT, att_space);
+ Attribute ds_attr2 = dataset.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, att_space);
+ Attribute ds_attr3 = dataset.createAttribute(ATTR3_NAME, PredType::NATIVE_INT, att_space);
// Write attribute information
- ds_attr2.write (PredType::NATIVE_INT, attr_data1a);
+ ds_attr2.write(PredType::NATIVE_INT, attr_data1a);
// Read attribute information immediately, without closing attribute
- ds_attr2.read (PredType::NATIVE_INT, read_data1);
+ ds_attr2.read(PredType::NATIVE_INT, read_data1);
// Verify values read in
- for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1a[i]!=read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1a[i],i,read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1a[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n",
+ __LINE__, i, attr_data1a[i], i, read_data1[i]);
// Close both attributes
ds_attr1.close();
@@ -196,47 +202,46 @@ static void test_attr_basic_write()
*/
// Create group in file fid1
- Group group = fid1.createGroup (GROUP1_NAME);
+ Group group = fid1.createGroup(GROUP1_NAME);
// Create dataspace for attribute
DataSpace sid3(ATTR2_RANK, dims3);
// Create an attribute for the group
- Attribute gr_attr = group.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, sid3);
+ Attribute gr_attr = group.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, sid3);
// Check storage size for attribute
hsize_t attr_size = gr_attr.getStorageSize();
- verify_val((long)attr_size, (long)(ATTR2_DIM1*ATTR2_DIM2*sizeof(int)),
- "Attribute::getStorageSize",__LINE__,__FILE__);
+ verify_val((long)attr_size, (long)(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)),
+ "Attribute::getStorageSize", __LINE__, __FILE__);
// Try to create the same attribute again (should fail)
try {
- Attribute invalid_attr = group.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, sid3);
+ Attribute invalid_attr = group.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, sid3);
// continuation here, that means no exception has been thrown
throw InvalidActionException("H5Group::createAttribute",
- "Attempting to create an existing attribute");
+ "Attempting to create an existing attribute");
}
- catch (AttributeIException& E) // catching invalid creating attribute
- {} // do nothing, exception expected
+ catch (AttributeIException &E) // catching invalid creating attribute
+ {
+ } // do nothing, exception expected
// Write attribute information
- gr_attr.write (PredType::NATIVE_INT, attr_data2);
+ gr_attr.write(PredType::NATIVE_INT, attr_data2);
// Check storage size for attribute
attr_size = gr_attr.getStorageSize();
- verify_val((long)attr_size, (long)(ATTR2_DIM1*ATTR2_DIM2*sizeof(int)),
- "Attribute::getStorageSize", __LINE__, __FILE__);
+ verify_val((long)attr_size, (long)(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)),
+ "Attribute::getStorageSize", __LINE__, __FILE__);
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_basic_write()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_basic_write()
+} // test_attr_basic_write()
-
/*-------------------------------------------------------------------------
* Function: test_attr_getname
*
@@ -264,7 +269,8 @@ static void test_attr_basic_write()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_getname()
+static void
+test_attr_getname()
{
// Output message about test being performed
SUBTEST("Testing all overloads of Attribute::getName");
@@ -290,36 +296,37 @@ static void test_attr_getname()
// using different buffer sizes and verify against FATTR1_NAME (3 cases)
// 1. With arbitrary buf_size that is larger than the name size
- size_t buf_size = FATTR1_NAME.length() + 10;
- char* fattr1_name = new char[buf_size+1];
- HDmemset(fattr1_name, 0, buf_size+1);
+ size_t buf_size = FATTR1_NAME.length() + 10;
+ char * fattr1_name = new char[buf_size + 1];
+ HDmemset(fattr1_name, 0, buf_size + 1);
ssize_t name_size = 0; // actual length of attribute name
- name_size = fattr1.getName(fattr1_name, buf_size+1);
+ name_size = fattr1.getName(fattr1_name, buf_size + 1);
CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__);
verify_val((size_t)name_size, FATTR1_NAME.length(), "Attribute::getName", __LINE__, __FILE__);
- verify_val((const char*)fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__);
- delete []fattr1_name;
+ verify_val((const char *)fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__);
+ delete[] fattr1_name;
// 2. With arbitrary buf_size that is smaller than the name's length.
// Let's try 4 first characters in the name.
- buf_size = 4;
+ buf_size = 4;
char short_name[5] = "File"; // to verify the read name
- fattr1_name = new char[buf_size+1];
- HDmemset(fattr1_name, 0, buf_size+1);
- name_size = fattr1.getName(fattr1_name, buf_size+1);
+ fattr1_name = new char[buf_size + 1];
+ HDmemset(fattr1_name, 0, buf_size + 1);
+ name_size = fattr1.getName(fattr1_name, buf_size + 1);
CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__);
verify_val((size_t)name_size, FATTR1_NAME.size(), "Attribute::getName", __LINE__, __FILE__);
- verify_val((const char*)fattr1_name, (const char*)short_name, "Attribute::getName", __LINE__, __FILE__);
- delete []fattr1_name;
+ verify_val((const char *)fattr1_name, (const char *)short_name, "Attribute::getName", __LINE__,
+ __FILE__);
+ delete[] fattr1_name;
// 3. With a buf_size that equals the name's length.
- buf_size = FATTR1_NAME.length();
- fattr1_name = new char[buf_size+1];
- HDmemset(fattr1_name, 0, buf_size+1);
- name_size = fattr1.getName(fattr1_name, buf_size+1);
+ buf_size = FATTR1_NAME.length();
+ fattr1_name = new char[buf_size + 1];
+ HDmemset(fattr1_name, 0, buf_size + 1);
+ name_size = fattr1.getName(fattr1_name, buf_size + 1);
CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__);
verify_val(fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__);
- delete []fattr1_name;
+ delete[] fattr1_name;
// B. Get attribute name with
// ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size)
@@ -357,7 +364,7 @@ static void test_attr_getname()
// Open attribute
Attribute attr1(dataset.openAttribute(ATTR1_NAME));
- size_t len = 4;
+ size_t len = 4;
H5std_string dattr_name1 = attr1.getName(len);
verify_val(dattr_name1, "Attr", "Attribute::getName", __LINE__, __FILE__);
@@ -370,13 +377,11 @@ static void test_attr_getname()
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_getname()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_getname()
+} // test_attr_getname()
-
/*-------------------------------------------------------------------------
* Function: test_attr_rename
*
@@ -385,9 +390,10 @@ static void test_attr_getname()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_rename()
+static void
+test_attr_rename()
{
- int read_data1[ATTR1_DIM1]={0}; // Buffer for reading the attribute
+ int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading the attribute
hsize_t i;
// Output message about test being performed
@@ -441,15 +447,16 @@ static void test_attr_rename()
verify_val(attr_name, ATTR_TMP_NAME, "Attribute::getName", __LINE__, __FILE__);
// Read attribute information immediately, without closing attribute
- attr1.read (PredType::NATIVE_INT, read_data1);
+ attr1.read(PredType::NATIVE_INT, read_data1);
// Verify values read in
- for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1[i]!=read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n", __LINE__,
+ i, attr_data1[i], i, read_data1[i]);
// Close attribute
- attr1.close();
+ attr1.close();
// Check for existence of second attribute
attr_exists = dataset.attrExists(ATTR2_NAME);
@@ -464,12 +471,13 @@ static void test_attr_rename()
verify_val(attr2_name, ATTR2_NAME, "Attribute::getName", __LINE__, __FILE__);
// Read attribute information immediately, without closing attribute
- attr2.read (PredType::NATIVE_INT, read_data1);
+ attr2.read(PredType::NATIVE_INT, read_data1);
// Verify values read in
- for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1a[i]!=read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1a[i],i,read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1a[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n",
+ __LINE__, i, attr_data1a[i], i, read_data1[i]);
// Close attribute
attr2.close();
@@ -485,13 +493,11 @@ static void test_attr_rename()
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_rename()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_rename()
+} // test_attr_rename()
-
/*-------------------------------------------------------------------------
* Function: test_attr_basic_read
*
@@ -500,7 +506,8 @@ static void test_attr_rename()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_basic_read()
+static void
+test_attr_basic_read()
{
hsize_t i, j;
@@ -525,16 +532,17 @@ static void test_attr_basic_read()
verify_val(oinfo.num_attrs, 3, "DataSet::getObjinfo", __LINE__, __FILE__);
// Open an attribute for the dataset
- Attribute ds_attr=dataset.openAttribute(ATTR1_NAME);
+ Attribute ds_attr = dataset.openAttribute(ATTR1_NAME);
// Read attribute information
- int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute
+ int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading 1st attribute
ds_attr.read(PredType::NATIVE_INT, &read_data1);
// Verify values read in
- for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1[i]!=read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",
+ __LINE__, i, attr_data1[i], i, read_data1[i]);
/*
* Test attribute with group
@@ -555,27 +563,27 @@ static void test_attr_basic_read()
Attribute gr_attr = group.openAttribute(ATTR2_NAME);
// Buffer for reading 2nd attribute
- int read_data2[ATTR2_DIM1][ATTR2_DIM2]={{0}};
+ int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}};
// Read attribute information
gr_attr.read(PredType::NATIVE_INT, read_data2);
// Verify values read in
- for(i=0; i<ATTR2_DIM1; i++)
- for(j=0; j<ATTR2_DIM2; j++)
- if(attr_data2[i][j]!=read_data2[i][j]) {
- TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__, i,j,attr_data2[i][j],i,j,read_data2[i][j]);
+ for (i = 0; i < ATTR2_DIM1; i++)
+ for (j = 0; j < ATTR2_DIM2; j++)
+ if (attr_data2[i][j] != read_data2[i][j]) {
+ TestErrPrintf(
+ "%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",
+ __LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]);
}
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_basic_read()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_basic_read()
+} // test_attr_basic_read()
-
/*-------------------------------------------------------------------------
* Function: test_attr_compound_write
*
@@ -584,10 +592,11 @@ static void test_attr_basic_read()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_compound_write()
+static void
+test_attr_compound_write()
{
- // Output message about test being performed
+ // Output message about test being performed
SUBTEST("Multiple Attribute Functions");
try {
@@ -595,11 +604,11 @@ static void test_attr_compound_write()
H5File fid1(FILE_COMPOUND.c_str(), H5F_ACC_TRUNC);
// Create dataspace for dataset
- hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
DataSpace sid1(SPACE1_RANK, dims1);
// Create a dataset
- DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR,sid1);
+ DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, sid1);
// Create the attribute datatype.
CompType comp_type(sizeof(struct attr4_struct));
@@ -614,7 +623,7 @@ static void test_attr_compound_write()
comp_type.insertMember(ATTR4_FIELDNAME3, attr4_field3_off, PredType::NATIVE_SCHAR);
// Create dataspace for 1st attribute
- hsize_t dims2[] = {ATTR4_DIM1,ATTR4_DIM2};
+ hsize_t dims2[] = {ATTR4_DIM1, ATTR4_DIM2};
DataSpace sid2(ATTR4_RANK, dims2);
// Create complex attribute for the dataset
@@ -622,10 +631,11 @@ static void test_attr_compound_write()
// Try to create the same attribute again (should fail)
try {
- Attribute invalid_attr = dataset.createAttribute (ATTR4_NAME, comp_type, sid2);
+ Attribute invalid_attr = dataset.createAttribute(ATTR4_NAME, comp_type, sid2);
}
- catch (AttributeIException& E) // catching invalid creating attribute
- {} // do nothing, exception expected
+ catch (AttributeIException &E) // catching invalid creating attribute
+ {
+ } // do nothing, exception expected
// Write complex attribute data
attr.write(comp_type, attr_data4);
@@ -633,13 +643,11 @@ static void test_attr_compound_write()
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_compound_write()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_compound_write()
+} // test_attr_compound_write()
-
/*-------------------------------------------------------------------------
* Function: test_attr_compound_read
*
@@ -648,11 +656,12 @@ static void test_attr_compound_write()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_compound_read()
+static void
+test_attr_compound_read()
{
- hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions
- size_t size; // Attribute datatype size as stored in file
- size_t offset; // Attribute datatype field offset
+ hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions
+ size_t size; // Attribute datatype size as stored in file
+ size_t offset; // Attribute datatype field offset
struct attr4_struct read_data4[ATTR4_DIM1][ATTR4_DIM2]; // Buffer for reading 4th attribute
// Output message about test being performed
@@ -690,8 +699,8 @@ static void test_attr_compound_read()
// Get the dims of the dataspace and verify them
int ndims = space.getSimpleExtentDims(dims);
verify_val(ndims, ATTR4_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
- verify_val((long)dims[0], (long)ATTR4_DIM1, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__);
- verify_val((long)dims[1], (long)ATTR4_DIM2, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__);
+ verify_val((long)dims[0], (long)ATTR4_DIM1, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
+ verify_val((long)dims[1], (long)ATTR4_DIM2, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
// Get the class of the datatype that is used by attr
H5T_class_t type_class = attr.getTypeClass();
@@ -709,13 +718,11 @@ static void test_attr_compound_read()
// Verify that the fields have the same names as when the type
// was created
int j;
- for(j=0; j<fields; j++)
- {
+ for (j = 0; j < fields; j++) {
H5std_string fieldname = datatype.getMemberName(j);
- if(!((fieldname == ATTR4_FIELDNAME1) ||
- (fieldname == ATTR4_FIELDNAME2) ||
- (fieldname == ATTR4_FIELDNAME3)))
- TestErrPrintf("%d:invalid field name for field #%d: %s\n",__LINE__,j,fieldname.c_str());
+ if (!((fieldname == ATTR4_FIELDNAME1) || (fieldname == ATTR4_FIELDNAME2) ||
+ (fieldname == ATTR4_FIELDNAME3)))
+ TestErrPrintf("%d:invalid field name for field #%d: %s\n", __LINE__, j, fieldname.c_str());
} /* end for */
offset = datatype.getMemberOffset(0);
@@ -733,8 +740,8 @@ static void test_attr_compound_read()
type_class = datatype.getMemberClass(0);
verify_val(type_class, H5T_INTEGER, "DataType::getMemberClass", __LINE__, __FILE__);
// Get and verify the order of this member's type
- IntType i_type = datatype.getMemberIntType(0);
- H5T_order_t order = i_type.getOrder();
+ IntType i_type = datatype.getMemberIntType(0);
+ H5T_order_t order = i_type.getOrder();
verify_val(order, PredType::NATIVE_INT.getOrder(), "DataType::getOrder", __LINE__, __FILE__);
// Get and verify the size of this member's type
@@ -745,7 +752,7 @@ static void test_attr_compound_read()
type_class = datatype.getMemberClass(1);
verify_val(type_class, H5T_FLOAT, "DataType::getMemberClass", __LINE__, __FILE__);
FloatType f_type = datatype.getMemberFloatType(1);
- order = f_type.getOrder();
+ order = f_type.getOrder();
verify_val(order, PredType::NATIVE_DOUBLE.getOrder(), "DataType::getOrder", __LINE__, __FILE__);
size = f_type.getSize();
verify_val(size, PredType::NATIVE_DOUBLE.getSize(), "DataType::getSize", __LINE__, __FILE__);
@@ -756,7 +763,7 @@ static void test_attr_compound_read()
// Note: H5T_INTEGER is correct here!
StrType s_type = datatype.getMemberStrType(2);
- order = s_type.getOrder();
+ order = s_type.getOrder();
verify_val(order, PredType::NATIVE_SCHAR.getOrder(), "DataType::getOrder", __LINE__, __FILE__);
size = s_type.getSize();
verify_val(size, PredType::NATIVE_SCHAR.getSize(), "DataType::getSize", __LINE__, __FILE__);
@@ -766,26 +773,30 @@ static void test_attr_compound_read()
// Verify values read in
hsize_t ii, jj;
- for(ii=0; ii<ATTR4_DIM1; ii++)
- for(jj=0; jj<ATTR4_DIM2; jj++)
- if(HDmemcmp(&attr_data4[ii][jj],&read_data4[ii][jj],sizeof(struct attr4_struct))) {
- TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n",__LINE__,ii,jj,attr_data4[ii][jj].i,ii,jj,read_data4[ii][jj].i);
- TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n",__LINE__,ii,jj,attr_data4[ii][jj].d,ii,jj,read_data4[ii][jj].d);
- TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",__LINE__,ii,jj,attr_data4[ii][jj].c,ii,jj,read_data4[ii][jj].c);
- } /* end if */
+ for (ii = 0; ii < ATTR4_DIM1; ii++)
+ for (jj = 0; jj < ATTR4_DIM2; jj++)
+ if (HDmemcmp(&attr_data4[ii][jj], &read_data4[ii][jj], sizeof(struct attr4_struct))) {
+ TestErrPrintf(
+ "%d:attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n",
+ __LINE__, ii, jj, attr_data4[ii][jj].i, ii, jj, read_data4[ii][jj].i);
+ TestErrPrintf(
+ "%d:attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n",
+ __LINE__, ii, jj, attr_data4[ii][jj].d, ii, jj, read_data4[ii][jj].d);
+ TestErrPrintf(
+ "%d:attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",
+ __LINE__, ii, jj, attr_data4[ii][jj].c, ii, jj, read_data4[ii][jj].c);
+ } /* end if */
// Verify name
H5std_string attr_name = attr.getName();
verify_val(attr_name, ATTR4_NAME, "Attribute::getName", __LINE__, __FILE__);
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, E.getCDetailMsg());
}
- try
- {
+ try {
// Now, try truncating the file to make sure reference counting is good.
// If any references to ids in the previous block are left unterminated,
// the truncating will fail, because the file will not be closed in
@@ -795,13 +806,12 @@ static void test_attr_compound_read()
PASSED();
} // end try block
- catch (FileIException& E)
- {
- issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, "Unable to truncate file, possibly because some objects are left opened");
+ catch (FileIException &E) {
+ issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__,
+ "Unable to truncate file, possibly because some objects are left opened");
}
-} // test_attr_compound_read()
+} // test_attr_compound_read()
-
/*-------------------------------------------------------------------------
* Function: test_attr_scalar_write
*
@@ -810,7 +820,8 @@ static void test_attr_compound_read()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_scalar_write()
+static void
+test_attr_scalar_write()
{
// Output message about test being performed
SUBTEST("Basic Scalar Attribute Writing Functions");
@@ -820,11 +831,11 @@ static void test_attr_scalar_write()
H5File fid1(FILE_SCALAR, H5F_ACC_TRUNC);
// Create dataspace for dataset
- hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
DataSpace sid1(SPACE1_RANK, dims1);
// Create a dataset
- DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR,sid1);
+ DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, sid1);
// Close dataset's dataspace
sid1.close();
@@ -833,34 +844,34 @@ static void test_attr_scalar_write()
DataSpace att_space(ATTR5_RANK, NULL);
// Create an attribute for the dataset
- Attribute ds_attr = dataset.createAttribute (ATTR5_NAME, PredType::NATIVE_FLOAT, att_space);
+ Attribute ds_attr = dataset.createAttribute(ATTR5_NAME, PredType::NATIVE_FLOAT, att_space);
// Try creating an attribute that already exists. This should fail
// since two attributes cannot have the same name. If an exception
// is not thrown for this action by createAttribute, then throw an
// invalid action exception.
try {
- Attribute invalid_attr = dataset.createAttribute (ATTR5_NAME, PredType::NATIVE_FLOAT, att_space);
+ Attribute invalid_attr = dataset.createAttribute(ATTR5_NAME, PredType::NATIVE_FLOAT, att_space);
// continuation here, that means no exception has been thrown
- throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset");
+ throw InvalidActionException("H5File::createDataSet",
+ "Library allowed overwrite of existing dataset");
}
- catch (AttributeIException& E) // catching invalid creating attribute
- {} // do nothing, exception expected
+ catch (AttributeIException &E) // catching invalid creating attribute
+ {
+ } // do nothing, exception expected
// Write attribute information
- ds_attr.write (PredType::NATIVE_FLOAT, &attr_data5);
+ ds_attr.write(PredType::NATIVE_FLOAT, &attr_data5);
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_scalar_write()
+} // test_attr_scalar_write()
-
/*-------------------------------------------------------------------------
* Function: test_attr_scalar_read
*
@@ -872,7 +883,8 @@ static void test_attr_scalar_write()
/* Epsilon for floating-point comparisons */
#define FP_EPSILON 0.000001F
-static void test_attr_scalar_read()
+static void
+test_attr_scalar_read()
{
// Output message about test being performed
SUBTEST("Basic Scalar Attribute Reading Functions");
@@ -889,11 +901,11 @@ static void test_attr_scalar_read()
verify_val(num_attrs, 1, "DataSet::getNumAttrs", __LINE__, __FILE__);
// Open an attribute for the dataset
- Attribute ds_attr=dataset.openAttribute(ATTR5_NAME);
+ Attribute ds_attr = dataset.openAttribute(ATTR5_NAME);
// Read attribute information
- float read_data2=0.0; // Buffer for reading 1st attribute
- ds_attr.read(PredType::NATIVE_FLOAT,&read_data2);
+ float read_data2 = 0.0; // Buffer for reading 1st attribute
+ ds_attr.read(PredType::NATIVE_FLOAT, &read_data2);
if (HDfabs(read_data2 - attr_data5) > FP_EPSILON)
verify_val(read_data2, attr_data5, FP_EPSILON, "Attribute::read", __LINE__, __FILE__);
@@ -907,13 +919,11 @@ static void test_attr_scalar_read()
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_scalar_read()
+} // test_attr_scalar_read()
-
/*-------------------------------------------------------------------------
* Function: test_attr_mult_write
*
@@ -922,75 +932,76 @@ static void test_attr_scalar_read()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_mult_write()
+static void
+test_attr_mult_write()
{
// Output message about test being performed
SUBTEST("Multiple Attribute Writing Functions");
try {
// Create file
- H5File fid1 (FILE_MULTI, H5F_ACC_TRUNC);
+ H5File fid1(FILE_MULTI, H5F_ACC_TRUNC);
// Create dataspace for dataset
- hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
- DataSpace ds_space (SPACE1_RANK, dims1);
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ DataSpace ds_space(SPACE1_RANK, dims1);
// Create a dataset
DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space);
// Create dataspace for 1st attribute
- hsize_t dims2[] = {ATTR1_DIM1};
- DataSpace att_space (ATTR1_RANK, dims2);
+ hsize_t dims2[] = {ATTR1_DIM1};
+ DataSpace att_space(ATTR1_RANK, dims2);
// Create 1st attribute for the dataset
- Attribute ds_attr = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space);
+ Attribute ds_attr = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space);
// Write attribute information
- ds_attr.write (PredType::NATIVE_INT, attr_data1);
+ ds_attr.write(PredType::NATIVE_INT, attr_data1);
// Create dataspace for 2nd attribute
- hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2};
- DataSpace att2_space (ATTR2_RANK, dims3);
+ hsize_t dims3[] = {ATTR2_DIM1, ATTR2_DIM2};
+ DataSpace att2_space(ATTR2_RANK, dims3);
// Create 2nd attribute for the dataset
- Attribute ds_attr2 = dataset.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, att2_space);
+ Attribute ds_attr2 = dataset.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, att2_space);
// Write 2nd attribute information
- ds_attr2.write (PredType::NATIVE_INT, attr_data2);
+ ds_attr2.write(PredType::NATIVE_INT, attr_data2);
// Create dataspace for 3rd attribute
- hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3};
- DataSpace att3_space (ATTR3_RANK, dims4);
+ hsize_t dims4[] = {ATTR3_DIM1, ATTR3_DIM2, ATTR3_DIM3};
+ DataSpace att3_space(ATTR3_RANK, dims4);
// Create 3rd attribute for the dataset
- Attribute ds_attr3 = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space);
+ Attribute ds_attr3 = dataset.createAttribute(ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space);
// Try creating an attribute that already exists. This should fail
// since two attributes cannot have the same name. If an exception
// is not thrown for this action by createAttribute, then throw an
// invalid action exception.
try {
- Attribute invalid_attr = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space);
+ Attribute invalid_attr = dataset.createAttribute(ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space);
// continuation here, that means no exception has been thrown
- throw InvalidActionException("DataSet::createAttribute", "Attempting to create a duplicate attribute");
+ throw InvalidActionException("DataSet::createAttribute",
+ "Attempting to create a duplicate attribute");
}
- catch (AttributeIException& E) // catching invalid creating attribute
- {} // do nothing, exception expected
+ catch (AttributeIException &E) // catching invalid creating attribute
+ {
+ } // do nothing, exception expected
// Write 3rd attribute information
- ds_attr3.write (PredType::NATIVE_DOUBLE, attr_data3);
+ ds_attr3.write(PredType::NATIVE_DOUBLE, attr_data3);
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_mult_write()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_mult_write()
+} // test_attr_mult_write()
-
/*-------------------------------------------------------------------------
* Function: test_attr_mult_read
*
@@ -999,14 +1010,15 @@ static void test_attr_mult_write()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_mult_read()
+static void
+test_attr_mult_read()
{
- int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute
- int read_data2[ATTR2_DIM1][ATTR2_DIM2]={{0}}; // Buffer for reading 2nd attribute
- double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{0}}}; // Buffer for reading 3rd attribute
- hsize_t i,j,k;
+ int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading 1st attribute
+ int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; // Buffer for reading 2nd attribute
+ double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = {{{0}}}; // Buffer for reading 3rd attribute
+ hsize_t i, j, k;
- // Output message about test being performed
+ // Output message about test being performed
SUBTEST("Multiple Attribute Reading Functions");
try {
@@ -1033,10 +1045,11 @@ static void test_attr_mult_read()
verify_val(rank, ATTR1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
// Get the dims of the dataspace and verify them
- hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions
- int ndims = space.getSimpleExtentDims(dims);
+ hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions
+ int ndims = space.getSimpleExtentDims(dims);
if ((long)dims[0] != (long)ATTR1_DIM1)
- TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n",__LINE__,(int)dims[0],ATTR1_DIM1);
+ TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n", __LINE__,
+ (int)dims[0], ATTR1_DIM1);
/* Verify Datatype */
@@ -1046,7 +1059,7 @@ static void test_attr_mult_read()
// Verify that the type is of integer datatype
verify_val(type_class, H5T_INTEGER, "Attribute::getTypeClass", __LINE__, __FILE__);
- // Get the integer datatype
+ // Get the integer datatype
IntType i_type1 = attr.getIntType();
// Get and verify the order of this type
@@ -1061,9 +1074,10 @@ static void test_attr_mult_read()
attr.read(PredType::NATIVE_INT, read_data1);
// Verify values read in
- for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1[i]!=read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n", __LINE__,
+ i, attr_data1[i], i, read_data1[i]);
// Verify Name
H5std_string attr_name = attr.getName();
@@ -1087,8 +1101,8 @@ static void test_attr_mult_read()
// Get the dims of the dataspace and verify them
ndims = space.getSimpleExtentDims(dims);
- verify_val((long)dims[0], (long)ATTR2_DIM1, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__);
- verify_val((long)dims[1], (long)ATTR2_DIM2, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__);
+ verify_val((long)dims[0], (long)ATTR2_DIM1, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
+ verify_val((long)dims[1], (long)ATTR2_DIM2, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
/* Verify Datatype */
@@ -1098,7 +1112,7 @@ static void test_attr_mult_read()
// Verify that the type is of integer datatype
verify_val(type_class, H5T_INTEGER, "Attribute::getTypeClass", __LINE__, __FILE__);
- // Get the integer datatype
+ // Get the integer datatype
IntType i_type2 = attr.getIntType();
// Get and verify the order of this type
@@ -1111,13 +1125,15 @@ static void test_attr_mult_read()
// Read attribute information
attr.read(PredType::NATIVE_INT, read_data2);
- //attr.read(i_type, read_data2);
+ // attr.read(i_type, read_data2);
// Verify values read in
- for(i=0; i<ATTR2_DIM1; i++)
- for(j=0; j<ATTR2_DIM2; j++)
- if(attr_data2[i][j]!=read_data2[i][j])
- TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__,i,j,attr_data2[i][j],i,j,read_data2[i][j]);
+ for (i = 0; i < ATTR2_DIM1; i++)
+ for (j = 0; j < ATTR2_DIM2; j++)
+ if (attr_data2[i][j] != read_data2[i][j])
+ TestErrPrintf(
+ "%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",
+ __LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]);
// Verify Name
attr_name = attr.getName();
@@ -1139,9 +1155,9 @@ static void test_attr_mult_read()
// Get the dims of the dataspace and verify them
ndims = space.getSimpleExtentDims(dims);
- verify_val((long)dims[0],(long)ATTR3_DIM1,"attribute dimensions",__FILE__,__LINE__);
- verify_val((long)dims[1],(long)ATTR3_DIM2,"attribute dimensions",__FILE__,__LINE__);
- verify_val((long)dims[2],(long)ATTR3_DIM3,"attribute dimensions",__FILE__,__LINE__);
+ verify_val((long)dims[0], (long)ATTR3_DIM1, "attribute dimensions", __FILE__, __LINE__);
+ verify_val((long)dims[1], (long)ATTR3_DIM2, "attribute dimensions", __FILE__, __LINE__);
+ verify_val((long)dims[2], (long)ATTR3_DIM3, "attribute dimensions", __FILE__, __LINE__);
/* Verify Datatype */
@@ -1151,7 +1167,7 @@ static void test_attr_mult_read()
// Verify that the type is of compound datatype
verify_val(type_class, H5T_FLOAT, "Attribute::getTypeClass", __LINE__, __FILE__);
- // Get the double datatype
+ // Get the double datatype
FloatType f_type = attr.getFloatType();
// Get and verify the order of this type
@@ -1166,11 +1182,13 @@ static void test_attr_mult_read()
attr.read(PredType::NATIVE_DOUBLE, read_data3);
// Verify values read in
- for(i=0; i<ATTR3_DIM1; i++)
- for(j=0; j<ATTR3_DIM2; j++)
- for(k=0; k<ATTR3_DIM3; k++)
- if(attr_data3[i][j][k]!=read_data3[i][j][k])
- TestErrPrintf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, read_data3[%d][%d][%d]=%f\n",__LINE__,i,j,k,attr_data3[i][j][k],i,j,k,read_data3[i][j][k]);
+ for (i = 0; i < ATTR3_DIM1; i++)
+ for (j = 0; j < ATTR3_DIM2; j++)
+ for (k = 0; k < ATTR3_DIM3; k++)
+ if (attr_data3[i][j][k] != read_data3[i][j][k])
+ TestErrPrintf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, "
+ "read_data3[%d][%d][%d]=%f\n",
+ __LINE__, i, j, k, attr_data3[i][j][k], i, j, k, read_data3[i][j][k]);
// Verify Name
attr_name = attr.getName();
@@ -1179,13 +1197,11 @@ static void test_attr_mult_read()
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_mult_read()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_mult_read()
+} // test_attr_mult_read()
-
/*-------------------------------------------------------------------------
* Function: test_attr_delete
*
@@ -1194,9 +1210,10 @@ static void test_attr_mult_read()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_delete()
+static void
+test_attr_delete()
{
- H5std_string attr_name; // Buffer for attribute names
+ H5std_string attr_name; // Buffer for attribute names
// Output message about test being performed
SUBTEST("Removing Attribute Function");
@@ -1218,7 +1235,7 @@ static void test_attr_delete()
// Verify the name of the only file attribute left
Attribute fattr = fid1.openAttribute((unsigned)0);
- attr_name = fattr.getName();
+ attr_name = fattr.getName();
verify_val(attr_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__);
fattr.close();
@@ -1236,10 +1253,12 @@ static void test_attr_delete()
dataset.removeAttr("Bogus");
// continuation here, that means no exception has been thrown
- throw InvalidActionException("DataSet::removeAttr", "Attempting to remove non-existing attribute");
+ throw InvalidActionException("DataSet::removeAttr",
+ "Attempting to remove non-existing attribute");
}
- catch (AttributeIException& E) // catching invalid removing attribute
- {} // do nothing, exception expected
+ catch (AttributeIException &E) // catching invalid removing attribute
+ {
+ } // do nothing, exception expected
// Test deleting dataset's attributes
@@ -1299,13 +1318,11 @@ static void test_attr_delete()
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_delete()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_delete()
+} // test_attr_delete()
-
/*-------------------------------------------------------------------------
* Function: test_attr_dtype_shared
*
@@ -1314,14 +1331,15 @@ static void test_attr_delete()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_dtype_shared()
+static void
+test_attr_dtype_shared()
{
- int data=8; // Data to write
- int rdata=0; // Data read in
+ int data = 8; // Data to write
+ int rdata = 0; // Data read in
#ifndef H5_NO_DEPRECATED_SYMBOLS
- H5G_stat_t statbuf; // Object's information
+ H5G_stat_t statbuf; // Object's information
#endif
- h5_stat_size_t filesize; // Size of file after modifications
+ h5_stat_size_t filesize; // Size of file after modifications
// Output message about test being performed
SUBTEST("Shared Datatypes with Attributes");
@@ -1334,7 +1352,7 @@ static void test_attr_dtype_shared()
fid1.close();
// Get size of file
- h5_stat_size_t empty_filesize; // Size of empty file
+ h5_stat_size_t empty_filesize; // Size of empty file
empty_filesize = h5_get_file_size(FILE_DTYPE.c_str(), H5P_DEFAULT);
if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -1347,67 +1365,68 @@ static void test_attr_dtype_shared()
// scope, causing incorrect number of ref counts.
{ // First enclosed block
- // Create a datatype to commit and use
- IntType dtype(PredType::NATIVE_INT);
+ // Create a datatype to commit and use
+ IntType dtype(PredType::NATIVE_INT);
- // Commit datatype to file
- dtype.commit(fid1, TYPE1_NAME);
+ // Commit datatype to file
+ dtype.commit(fid1, TYPE1_NAME);
#ifndef H5_NO_DEPRECATED_SYMBOLS
- // Check reference count on named datatype
- fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 1, "DataType::getObjinfo", __LINE__, __FILE__);
+ // Check reference count on named datatype
+ fid1.getObjinfo(TYPE1_NAME, statbuf);
+ verify_val((int)statbuf.nlink, 1, "DataType::getObjinfo", __LINE__, __FILE__);
#endif
- // Create dataspace for dataset
- DataSpace dspace;
+ // Create dataspace for dataset
+ DataSpace dspace;
- DataSet dset = fid1.createDataSet(DSET1_NAME, dtype, dspace);
+ DataSet dset = fid1.createDataSet(DSET1_NAME, dtype, dspace);
#ifndef H5_NO_DEPRECATED_SYMBOLS
- // Check reference count on named datatype
- fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 2, "H5File::getObjinfo", __LINE__, __FILE__);
+ // Check reference count on named datatype
+ fid1.getObjinfo(TYPE1_NAME, statbuf);
+ verify_val((int)statbuf.nlink, 2, "H5File::getObjinfo", __LINE__, __FILE__);
#endif
- // Create attribute on dataset
- Attribute attr = dset.createAttribute(ATTR1_NAME,dtype,dspace);
+ // Create attribute on dataset
+ Attribute attr = dset.createAttribute(ATTR1_NAME, dtype, dspace);
#ifndef H5_NO_DEPRECATED_SYMBOLS
- // Check reference count on named datatype
- fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 3, "DataSet::getObjinfo", __LINE__, __FILE__);
+ // Check reference count on named datatype
+ fid1.getObjinfo(TYPE1_NAME, statbuf);
+ verify_val((int)statbuf.nlink, 3, "DataSet::getObjinfo", __LINE__, __FILE__);
#endif
- // Close attribute
- attr.close();
+ // Close attribute
+ attr.close();
- // Delete attribute
- dset.removeAttr(ATTR1_NAME);
+ // Delete attribute
+ dset.removeAttr(ATTR1_NAME);
#ifndef H5_NO_DEPRECATED_SYMBOLS
- // Check reference count on named datatype
- fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 2, "DataSet::getObjinfo after DataSet::removeAttr", __LINE__, __FILE__);
+ // Check reference count on named datatype
+ fid1.getObjinfo(TYPE1_NAME, statbuf);
+ verify_val((int)statbuf.nlink, 2, "DataSet::getObjinfo after DataSet::removeAttr", __LINE__,
+ __FILE__);
#endif
- // Create attribute on dataset
- attr = dset.createAttribute(ATTR1_NAME,dtype,dspace);
+ // Create attribute on dataset
+ attr = dset.createAttribute(ATTR1_NAME, dtype, dspace);
#ifndef H5_NO_DEPRECATED_SYMBOLS
- // Check reference count on named datatype
- fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 3, "DataSet::createAttribute", __LINE__, __FILE__);
+ // Check reference count on named datatype
+ fid1.getObjinfo(TYPE1_NAME, statbuf);
+ verify_val((int)statbuf.nlink, 3, "DataSet::createAttribute", __LINE__, __FILE__);
#endif
- // Write data into the attribute
- attr.write(PredType::NATIVE_INT,&data);
+ // Write data into the attribute
+ attr.write(PredType::NATIVE_INT, &data);
- // Close attribute, dataset, dataspace, datatype, and file
- attr.close();
- dset.close();
- dspace.close();
- dtype.close();
+ // Close attribute, dataset, dataspace, datatype, and file
+ attr.close();
+ dset.close();
+ dspace.close();
+ dtype.close();
} // end of first enclosing
fid1.close();
@@ -1417,24 +1436,24 @@ static void test_attr_dtype_shared()
{ // Second enclosed block...
- // Open dataset
- DataSet *dset2 = new DataSet (fid1.openDataSet(DSET1_NAME));
+ // Open dataset
+ DataSet *dset2 = new DataSet(fid1.openDataSet(DSET1_NAME));
- // Open attribute
- Attribute *attr2 = new Attribute (dset2->openAttribute(ATTR1_NAME));
+ // Open attribute
+ Attribute *attr2 = new Attribute(dset2->openAttribute(ATTR1_NAME));
- // Read data from the attribute
- attr2->read(PredType::NATIVE_INT, &rdata);
- verify_val(data, rdata, "Attribute::read", __LINE__, __FILE__);
+ // Read data from the attribute
+ attr2->read(PredType::NATIVE_INT, &rdata);
+ verify_val(data, rdata, "Attribute::read", __LINE__, __FILE__);
- // Close attribute and dataset
- delete attr2;
- delete dset2;
+ // Close attribute and dataset
+ delete attr2;
+ delete dset2;
#ifndef H5_NO_DEPRECATED_SYMBOLS
- // Check reference count on named datatype
- fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__);
+ // Check reference count on named datatype
+ fid1.getObjinfo(TYPE1_NAME, statbuf);
+ verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__);
#endif
} // end of second enclosing
@@ -1458,15 +1477,13 @@ static void test_attr_dtype_shared()
verify_val((long)filesize, (long)empty_filesize, "Checking file size", __LINE__, __FILE__);
PASSED();
- } // end try block
+ } // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_dtype_shared()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_dtype_shared()
+} // test_attr_dtype_shared()
-
/*-------------------------------------------------------------------------
* Function: test_string_attr
*
@@ -1480,9 +1497,10 @@ const H5std_string ATTR1_FL_STR_NAME("String_attr 1");
const H5std_string ATTR2_FL_STR_NAME("String_attr 2");
const H5std_string ATTR_VL_STR_NAME("String_attr");
const H5std_string ATTRSTR_DATA("String Attribute");
-const int ATTR_LEN = 17;
+const int ATTR_LEN = 17;
-static void test_string_attr()
+static void
+test_string_attr()
{
// Output message about test being performed
SUBTEST("I/O on FL and VL String Attributes");
@@ -1501,7 +1519,7 @@ static void test_string_attr()
Group root = fid1.openGroup("/");
// Create dataspace for the attribute.
- DataSpace att_space (H5S_SCALAR);
+ DataSpace att_space(H5S_SCALAR);
/* Test Attribute::write(...,const void *buf) with Fixed len string */
@@ -1524,18 +1542,20 @@ static void test_string_attr()
// Read and verify the attribute string as a string of chars.
char flstring_att_check[ATTR_LEN];
gr_flattr1.read(fls_type, flstring_att_check);
- if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0)
- TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check);
+ if (HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str()) != 0)
+ TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",
+ __LINE__, ATTRSTR_DATA.c_str(), flstring_att_check);
// Read and verify the attribute string as a string of chars; buffer
// is dynamically allocated.
size_t attr_size = gr_flattr1.getInMemDataSize();
- char *fl_dyn_string_att_check;
- fl_dyn_string_att_check = new char[attr_size+1];
+ char * fl_dyn_string_att_check;
+ fl_dyn_string_att_check = new char[attr_size + 1];
gr_flattr1.read(fls_type, fl_dyn_string_att_check);
- if(HDstrcmp(fl_dyn_string_att_check, ATTRSTR_DATA.c_str())!=0)
- TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), fl_dyn_string_att_check);
- delete []fl_dyn_string_att_check;
+ if (HDstrcmp(fl_dyn_string_att_check, ATTRSTR_DATA.c_str()) != 0)
+ TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",
+ __LINE__, ATTRSTR_DATA.c_str(), fl_dyn_string_att_check);
+ delete[] fl_dyn_string_att_check;
/* Test Attribute::read(...,H5std_string& strg) with FL string */
@@ -1543,13 +1563,15 @@ static void test_string_attr()
H5std_string read_flstr1;
gr_flattr1.read(fls_type, read_flstr1);
if (read_flstr1 != ATTRSTR_DATA)
- TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr1=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr1.c_str());
+ TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr1=%s\n", __LINE__,
+ ATTRSTR_DATA.c_str(), read_flstr1.c_str());
// Read and verify the attribute string as a string of chars.
HDstrcpy(flstring_att_check, "");
gr_flattr2.read(fls_type, flstring_att_check);
- if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0)
- TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check);
+ if (HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str()) != 0)
+ TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",
+ __LINE__, ATTRSTR_DATA.c_str(), flstring_att_check);
/* Test Attribute::read(...,H5std_string& strg) with FL string */
@@ -1557,7 +1579,8 @@ static void test_string_attr()
H5std_string read_flstr2;
gr_flattr2.read(fls_type, read_flstr2);
if (read_flstr2 != ATTRSTR_DATA)
- TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr2=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr2.c_str());
+ TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr2=%s\n", __LINE__,
+ ATTRSTR_DATA.c_str(), read_flstr2.c_str());
//
// Variable-lenth string attributes
@@ -1575,8 +1598,9 @@ static void test_string_attr()
// Read and verify the attribute string as a string of chars.
char *string_att_check;
gr_vlattr.read(vls_type, &string_att_check);
- if(HDstrcmp(string_att_check, ATTRSTR_DATA.c_str())!=0)
- TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), string_att_check);
+ if (HDstrcmp(string_att_check, ATTRSTR_DATA.c_str()) != 0)
+ TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",
+ __LINE__, ATTRSTR_DATA.c_str(), string_att_check);
HDfree(string_att_check);
/* Test Attribute::read(...,H5std_string& strg) with VL string */
@@ -1584,17 +1608,16 @@ static void test_string_attr()
H5std_string read_str;
gr_vlattr.read(vls_type, read_str);
if (read_str != ATTRSTR_DATA)
- TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_str.c_str());
+ TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n", __LINE__,
+ ATTRSTR_DATA.c_str(), read_str.c_str());
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_string_attr()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_string_attr()
+} // test_string_attr()
-
/*-------------------------------------------------------------------------
* Function: test_attr_exists
*
@@ -1606,7 +1629,8 @@ static void test_string_attr()
* Additional attrExists tests are in test_attr_rename().
*-------------------------------------------------------------------------
*/
-static void test_attr_exists()
+static void
+test_attr_exists()
{
// Output message about test being performed
SUBTEST("Check Attribute Existence");
@@ -1621,12 +1645,14 @@ static void test_attr_exists()
// Check for existence of attribute
bool attr_exists = fid1.attrExists(ATTR1_FL_STR_NAME);
if (attr_exists == false)
- throw InvalidActionException("H5File::attrExists", "fid1, ATTR1_FL_STR_NAMEAttribute should exist but does not");
+ throw InvalidActionException("H5File::attrExists",
+ "fid1, ATTR1_FL_STR_NAMEAttribute should exist but does not");
// Check for existence of attribute
attr_exists = fid1.attrExists(FATTR1_NAME);
if (attr_exists == false)
- throw InvalidActionException("H5File::attrExists", "fid1,FATTR2_NAMEAttribute should exist but does not");
+ throw InvalidActionException("H5File::attrExists",
+ "fid1,FATTR2_NAMEAttribute should exist but does not");
// Open a group.
Group group = fid1.openGroup(GROUP1_NAME);
@@ -1634,22 +1660,20 @@ static void test_attr_exists()
// Check for existence of attribute
attr_exists = group.attrExists(ATTR2_NAME);
if (attr_exists == false)
- throw InvalidActionException("H5File::attrExists", "group, ATTR2_NAMEAttribute should exist but does not");
+ throw InvalidActionException("H5File::attrExists",
+ "group, ATTR2_NAMEAttribute should exist but does not");
PASSED();
} // end try block
- catch (InvalidActionException& E)
- {
+ catch (InvalidActionException &E) {
issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg());
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_exists()
+} // test_attr_exists()
-
/*-------------------------------------------------------------------------
* Function: test_attr_dense_create
*
@@ -1659,25 +1683,25 @@ static void test_attr_exists()
*-------------------------------------------------------------------------
*/
const H5std_string FILE_CRTPROPS("tattr_crt_properties.h5");
-const int NAME_BUF_SIZE = 1024;
-const unsigned MAX_COMPACT_DEF = 8;
-const unsigned MIN_DENSE_DEF = 6;
+const int NAME_BUF_SIZE = 1024;
+const unsigned MAX_COMPACT_DEF = 8;
+const unsigned MIN_DENSE_DEF = 6;
-static void test_attr_dense_create(FileCreatPropList& fcpl,
- FileAccPropList& fapl)
+static void
+test_attr_dense_create(FileCreatPropList &fcpl, FileAccPropList &fapl)
{
// Output message about test being performed
SUBTEST("Dense Attribute Storage Creation");
try {
// Create file
- H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl);
+ H5File fid1(FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl);
// Close file
fid1.close();
// Get size of file
- h5_stat_size_t empty_filesize; // Size of empty file
+ h5_stat_size_t empty_filesize; // Size of empty file
empty_filesize = h5_get_file_size(FILE_CRTPROPS.c_str(), fapl.getId());
if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
@@ -1698,16 +1722,18 @@ static void test_attr_dense_create(FileCreatPropList& fcpl,
// Retrieve limits for compact/dense attribute storage
dcpl.getAttrPhaseChange(max_compact, min_dense);
- verify_val(max_compact, MAX_COMPACT_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__);
- verify_val(min_dense, MIN_DENSE_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__);
+ verify_val(max_compact, MAX_COMPACT_DEF, "DSetCreatPropList::getAttrPhaseChange", __LINE__, __FILE__);
+ verify_val(min_dense, MIN_DENSE_DEF, "DSetCreatPropList::getAttrPhaseChange", __LINE__, __FILE__);
// Set new compact/dense attribute storage limits to some random numbers
dcpl.setAttrPhaseChange(7, 5);
// Retrieve limits for compact/dense attribute storage and verify them
dcpl.getAttrPhaseChange(max_compact, min_dense);
- verify_val(max_compact, static_cast<unsigned>(7), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__);
- verify_val(min_dense, static_cast<unsigned>(5), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__);
+ verify_val(max_compact, static_cast<unsigned>(7), "DSetCreatPropList::getAttrPhaseChange", __LINE__,
+ __FILE__);
+ verify_val(min_dense, static_cast<unsigned>(5), "DSetCreatPropList::getAttrPhaseChange", __LINE__,
+ __FILE__);
// Close property list
dcpl.close();
@@ -1715,10 +1741,9 @@ static void test_attr_dense_create(FileCreatPropList& fcpl,
// H5O__is_attr_dense_test - un-usable
// Add attributes, until just before converting to dense storage
- char attr_name[NAME_BUF_SIZE];
+ char attr_name[NAME_BUF_SIZE];
unsigned attr_num;
- for (attr_num = 0; attr_num < max_compact; attr_num++)
- {
+ for (attr_num = 0; attr_num < max_compact; attr_num++) {
// Create attribute
sprintf(attr_name, "attr %02u", attr_num);
Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space);
@@ -1740,28 +1765,27 @@ static void test_attr_dense_create(FileCreatPropList& fcpl,
}
// Attempt to add attribute again, which should fail
- try
- {
+ try {
// Create another attribute
sprintf(attr_name, "attr %02u", attr_num);
Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space);
// continuation here, that means no exception has been thrown
- throw InvalidActionException("DataSet::createAttribute", "Maximum number of attributes has been reached");
+ throw InvalidActionException("DataSet::createAttribute",
+ "Maximum number of attributes has been reached");
}
- catch (AttributeIException& E) // catching invalid action
- {} // do nothing, exception expected
+ catch (AttributeIException &E) // catching invalid action
+ {
+ } // do nothing, exception expected
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_dense_create()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_dense_create()
+} // test_attr_dense_create()
-
/*-------------------------------------------------------------------------
* Function: test_attr_corder_create_basic
*
@@ -1770,23 +1794,23 @@ static void test_attr_dense_create(FileCreatPropList& fcpl,
* Return None
*-------------------------------------------------------------------------
*/
-static void test_attr_corder_create_basic(FileCreatPropList& fcpl,
- FileAccPropList& fapl)
+static void
+test_attr_corder_create_basic(FileCreatPropList &fcpl, FileAccPropList &fapl)
{
// Output message about test being performed
SUBTEST("Basic Code for Attributes with Creation Order Info");
try {
// Create file
- H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl);
+ H5File fid1(FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl);
// Create dataset creation property list.
DSetCreatPropList dcpl;
// Get creation order indexing on object
unsigned crt_order_flags = 0;
- crt_order_flags = dcpl.getAttrCrtOrder();
- verify_val(crt_order_flags, (unsigned)0, "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__);
+ crt_order_flags = dcpl.getAttrCrtOrder();
+ verify_val(crt_order_flags, (unsigned)0, "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__);
// Setting invalid combination of a attribute order creation order
// indexing on should fail
@@ -1794,16 +1818,19 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl,
dcpl.setAttrCrtOrder(H5P_CRT_ORDER_INDEXED);
// continuation here, that means no exception has been thrown
- throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", "Indexing cannot be set alone, order tracking is required");
+ throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder",
+ "Indexing cannot be set alone, order tracking is required");
}
- catch (PropListIException& E) // catching invalid action
- {} // do nothing, exception expected
+ catch (PropListIException &E) // catching invalid action
+ {
+ } // do nothing, exception expected
// Set attribute creation order tracking & indexing for object then
// verify them
dcpl.setAttrCrtOrder(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED);
crt_order_flags = dcpl.getAttrCrtOrder();
- verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__);
+ verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED),
+ "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__);
// Create dataspace for dataset
DataSpace ds_space(H5S_SCALAR);
@@ -1838,18 +1865,17 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl,
// Query the attribute creation properties
crt_order_flags = dcpl.getAttrCrtOrder();
- verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__);
+ verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED),
+ "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__);
PASSED();
} // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr_corder_create_basic()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr_corder_create_basic()
+} // test_attr_corder_create_basic()
-
/*-------------------------------------------------------------------------
* Function: test_attr
*
@@ -1858,14 +1884,13 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl,
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_attr()
+extern "C" void
+test_attr()
{
// Output message about test being performed
MESSAGE(5, ("Testing Attributes\n"));
- try
- {
+ try {
// Create a default file access property list
FileAccPropList fapl;
@@ -1887,45 +1912,41 @@ void test_attr()
// Loop over using new group format
unsigned new_format;
- for (new_format = FALSE; new_format <= TRUE; new_format++)
- {
+ for (new_format = FALSE; new_format <= TRUE; new_format++) {
FileAccPropList curr_fapl;
// Set the file access proplist for the type of format
- if (new_format)
- {
+ if (new_format) {
MESSAGE(7, ("testing with new file format\n"));
curr_fapl = fapl_new;
}
- else
- {
+ else {
MESSAGE(7, ("testing with old file format\n"));
curr_fapl = fapl;
}
- test_attr_basic_write(); // Test basic H5A writing code
- test_attr_getname(); // Test overloads of Attribute::getName
- test_attr_rename(); // Test renaming attribute
- test_attr_basic_read(); // Test basic H5A reading code
+ test_attr_basic_write(); // Test basic H5A writing code
+ test_attr_getname(); // Test overloads of Attribute::getName
+ test_attr_rename(); // Test renaming attribute
+ test_attr_basic_read(); // Test basic H5A reading code
test_attr_compound_write(); // Test complex datatype H5A writing code
test_attr_compound_read(); // Test complex datatype H5A reading code
- test_attr_scalar_write(); // Test scalar dataspace H5A writing code
- test_attr_scalar_read(); // Test scalar dataspace H5A reading code
+ test_attr_scalar_write(); // Test scalar dataspace H5A writing code
+ test_attr_scalar_read(); // Test scalar dataspace H5A reading code
- test_attr_mult_write(); // Test writing multiple attributes
- test_attr_mult_read(); // Test reading multiple attributes
- test_attr_delete(); // Test deleting attributes
+ test_attr_mult_write(); // Test writing multiple attributes
+ test_attr_mult_read(); // Test reading multiple attributes
+ test_attr_delete(); // Test deleting attributes
- test_attr_dtype_shared(); // Test using shared datatypes in attributes
+ test_attr_dtype_shared(); // Test using shared datatypes in attributes
- test_string_attr(); // Test read/write string attribute
- test_attr_exists(); // Test H5Location::attrExists
+ test_string_attr(); // Test read/write string attribute
+ test_attr_exists(); // Test H5Location::attrExists
// Test with new format
- if (new_format)
- {
+ if (new_format) {
// Test dense attribute storage creation
test_attr_dense_create(fcpl, curr_fapl);
@@ -1933,15 +1954,13 @@ void test_attr()
test_attr_corder_create_basic(fcpl, curr_fapl);
}
} // end for
- } // end try block
+ } // end try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_attr()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_attr()
+} // test_attr()
-
/*-------------------------------------------------------------------------
* Function: cleanup_attr
*
@@ -1950,8 +1969,8 @@ void test_attr()
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_attr()
+extern "C" void
+cleanup_attr()
{
HDremove(FILE_BASIC.c_str());
HDremove(FILE_COMPOUND.c_str());
@@ -1960,4 +1979,3 @@ void cleanup_attr()
HDremove(FILE_DTYPE.c_str());
HDremove(FILE_CRTPROPS.c_str());
}
-
diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp
index ec8adf0..7b48a78 100644
--- a/c++/test/tcompound.cpp
+++ b/c++/test/tcompound.cpp
@@ -25,21 +25,20 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
/* Number of elements in each test */
#define NTESTELEM 100000
typedef struct complex_t {
- double re;
- double im;
+ double re;
+ double im;
} complex_t;
-
/*-------------------------------------------------------------------------
* Function: test_compound_1
*
@@ -51,7 +50,8 @@ typedef struct complex_t {
* January, 2007
*-------------------------------------------------------------------------
*/
-static void test_compound_1()
+static void
+test_compound_1()
{
// Output message about test being performed
SUBTEST("Compound Data Types");
@@ -63,15 +63,13 @@ static void test_compound_1()
complex_type.insertMember("real", HOFFSET(complex_t, re), PredType::NATIVE_DOUBLE);
complex_type.insertMember("imaginary", HOFFSET(complex_t, im), PredType::NATIVE_DOUBLE);
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_compound_1()
+} // test_compound_1()
-
/*-------------------------------------------------------------------------
* Function: test_compound_2
*
@@ -85,7 +83,8 @@ static void test_compound_1()
* January, 2007
*-------------------------------------------------------------------------
*/
-static void test_compound_2()
+static void
+test_compound_2()
{
typedef struct {
int a, b, c[4], d, e;
@@ -94,33 +93,33 @@ static void test_compound_2()
int e, d, c[4], b, a;
} dst_typ_t;
- src_typ_t *s_ptr;
- dst_typ_t *d_ptr;
- const int nelmts = NTESTELEM;
- const hsize_t four = 4;
- int i;
+ src_typ_t * s_ptr;
+ dst_typ_t * d_ptr;
+ const int nelmts = NTESTELEM;
+ const hsize_t four = 4;
+ int i;
unsigned char *buf = NULL, *orig = NULL, *bkg = NULL;
- ArrayType *array_dt = NULL;
+ ArrayType * array_dt = NULL;
// Output message about test being performed
SUBTEST("Compound Element Reordering");
try {
// Sizes should be the same, but be careful just in case
- buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
- bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t));
- orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t));
- for (i=0; i<nelmts; i++) {
- s_ptr = ((src_typ_t*)orig) + i;
- s_ptr->a = i*8+0;
- s_ptr->b = i*8+1;
- s_ptr->c[0] = i*8+2;
- s_ptr->c[1] = i*8+3;
- s_ptr->c[2] = i*8+4;
- s_ptr->c[3] = i*8+5;
- s_ptr->d = i*8+6;
- s_ptr->e = i*8+7;
+ buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
+ bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t));
+ orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t));
+ for (i = 0; i < nelmts; i++) {
+ s_ptr = ((src_typ_t *)orig) + i;
+ s_ptr->a = i * 8 + 0;
+ s_ptr->b = i * 8 + 1;
+ s_ptr->c[0] = i * 8 + 2;
+ s_ptr->c[1] = i * 8 + 3;
+ s_ptr->c[2] = i * 8 + 4;
+ s_ptr->c[3] = i * 8 + 5;
+ s_ptr->d = i * 8 + 6;
+ s_ptr->e = i * 8 + 7;
}
- memcpy(buf, orig, nelmts*sizeof(src_typ_t));
+ memcpy(buf, orig, nelmts * sizeof(src_typ_t));
// Build hdf5 datatypes
array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
@@ -150,29 +149,22 @@ static void test_compound_2()
st.convert(dt, (size_t)nelmts, buf, bkg);
// Compare results
- for (i=0; i<nelmts; i++) {
- s_ptr = ((src_typ_t*)orig) + i;
- d_ptr = ((dst_typ_t*)buf) + i;
- if (s_ptr->a != d_ptr->a ||
- s_ptr->b != d_ptr->b ||
- s_ptr->c[0] != d_ptr->c[0] ||
- s_ptr->c[1] != d_ptr->c[1] ||
- s_ptr->c[2] != d_ptr->c[2] ||
- s_ptr->c[3] != d_ptr->c[3] ||
- s_ptr->d != d_ptr->d ||
- s_ptr->e != d_ptr->e) {
+ for (i = 0; i < nelmts; i++) {
+ s_ptr = ((src_typ_t *)orig) + i;
+ d_ptr = ((dst_typ_t *)buf) + i;
+ if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] ||
+ s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] ||
+ s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) {
H5_FAILED();
cerr << " i=" << i << endl;
- cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b
- << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << ","
- << s_ptr->c[2] << "," << s_ptr->c[3] << ", d="
- << s_ptr->d << ", e=" << s_ptr->e << "}" << endl;
- cerr << " dst={a=" << s_ptr->a << ", b=" << s_ptr->b
- << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << ","
- << s_ptr->c[2] << "," << s_ptr->c[3] << ", d="
- << s_ptr->d << ", e=" << s_ptr->e << "}" << endl;
- }
+ cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << ","
+ << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d
+ << ", e=" << s_ptr->e << "}" << endl;
+ cerr << " dst={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << ","
+ << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d
+ << ", e=" << s_ptr->e << "}" << endl;
}
+ }
// Release resources
HDfree(buf);
HDfree(bkg);
@@ -182,18 +174,16 @@ static void test_compound_2()
st.close();
dt.close();
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
- if(array_dt)
+ if (array_dt)
delete array_dt;
-} // test_compound_2()
+} // test_compound_2()
-
/*-------------------------------------------------------------------------
* Function: test_compound_3
*
@@ -207,42 +197,43 @@ static void test_compound_2()
* January, 2007
*-------------------------------------------------------------------------
*/
-static void test_compound_3()
+static void
+test_compound_3()
{
typedef struct {
int a, b, c[4], d, e;
} src_typ_t;
typedef struct {
- int a, c[4], e;
+ int a, c[4], e;
} dst_typ_t;
- src_typ_t *s_ptr;
- dst_typ_t *d_ptr;
- int i;
- const int nelmts = NTESTELEM;
- const hsize_t four = 4;
+ src_typ_t * s_ptr;
+ dst_typ_t * d_ptr;
+ int i;
+ const int nelmts = NTESTELEM;
+ const hsize_t four = 4;
unsigned char *buf = NULL, *orig = NULL, *bkg = NULL;
- ArrayType* array_dt = NULL;
+ ArrayType * array_dt = NULL;
// Output message about test being performed
SUBTEST("Compound Datatype Subset Conversions");
try {
/* Initialize */
- buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
- bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t));
- orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t));
- for (i=0; i<nelmts; i++) {
- s_ptr = ((src_typ_t*)orig) + i;
- s_ptr->a = i*8+0;
- s_ptr->b = i*8+1;
- s_ptr->c[0] = i*8+2;
- s_ptr->c[1] = i*8+3;
- s_ptr->c[2] = i*8+4;
- s_ptr->c[3] = i*8+5;
- s_ptr->d = i*8+6;
- s_ptr->e = i*8+7;
+ buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
+ bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t));
+ orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t));
+ for (i = 0; i < nelmts; i++) {
+ s_ptr = ((src_typ_t *)orig) + i;
+ s_ptr->a = i * 8 + 0;
+ s_ptr->b = i * 8 + 1;
+ s_ptr->c[0] = i * 8 + 2;
+ s_ptr->c[1] = i * 8 + 3;
+ s_ptr->c[2] = i * 8 + 4;
+ s_ptr->c[3] = i * 8 + 5;
+ s_ptr->d = i * 8 + 6;
+ s_ptr->e = i * 8 + 7;
}
- memcpy(buf, orig, nelmts*sizeof(src_typ_t));
+ memcpy(buf, orig, nelmts * sizeof(src_typ_t));
/* Build hdf5 datatypes */
array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
@@ -270,27 +261,20 @@ static void test_compound_3()
st.convert(dt, (size_t)nelmts, buf, bkg);
/* Compare results */
- for (i=0; i<nelmts; i++) {
- s_ptr = ((src_typ_t*)orig) + i;
- d_ptr = ((dst_typ_t*)buf) + i;
- if (s_ptr->a != d_ptr->a ||
- s_ptr->c[0] != d_ptr->c[0] ||
- s_ptr->c[1] != d_ptr->c[1] ||
- s_ptr->c[2] != d_ptr->c[2] ||
- s_ptr->c[3] != d_ptr->c[3] ||
- s_ptr->e != d_ptr->e) {
+ for (i = 0; i < nelmts; i++) {
+ s_ptr = ((src_typ_t *)orig) + i;
+ d_ptr = ((dst_typ_t *)buf) + i;
+ if (s_ptr->a != d_ptr->a || s_ptr->c[0] != d_ptr->c[0] || s_ptr->c[1] != d_ptr->c[1] ||
+ s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || s_ptr->e != d_ptr->e) {
H5_FAILED();
cerr << " i=" << i << endl;
- cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b
- << ", c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << ","
- << s_ptr->c[2] << "," << s_ptr->c[3] << "], d="
- << s_ptr->d << ", e=" << s_ptr->e << "}" << endl;
- cerr << " dst={a=" << d_ptr->a
- << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << ","
- << d_ptr->c[2] << "," << d_ptr->c[3] << "], e="
- << d_ptr->e << "}" << endl;
+ cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << ", c=[" << s_ptr->c[0] << ","
+ << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << "], d=" << s_ptr->d
+ << ", e=" << s_ptr->e << "}" << endl;
+ cerr << " dst={a=" << d_ptr->a << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << ","
+ << d_ptr->c[2] << "," << d_ptr->c[3] << "], e=" << d_ptr->e << "}" << endl;
} // if
- } // for
+ } // for
/* Release resources */
HDfree(buf);
@@ -301,18 +285,16 @@ static void test_compound_3()
st.close();
dt.close();
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
- if(array_dt)
+ if (array_dt)
delete array_dt;
-} // test_compound_3()
+} // test_compound_3()
-
/*-------------------------------------------------------------------------
* Function: test_compound_4
*
@@ -326,7 +308,8 @@ static void test_compound_3()
* January, 2007
*-------------------------------------------------------------------------
*/
-static void test_compound_4()
+static void
+test_compound_4()
{
typedef struct {
@@ -335,38 +318,38 @@ static void test_compound_4()
typedef struct {
short b;
- int a, c[4];
+ int a, c[4];
short d;
- int e;
+ int e;
} dst_typ_t;
- src_typ_t *s_ptr;
- dst_typ_t *d_ptr;
- int i;
- const int nelmts = NTESTELEM;
- const hsize_t four = 4;
+ src_typ_t * s_ptr;
+ dst_typ_t * d_ptr;
+ int i;
+ const int nelmts = NTESTELEM;
+ const hsize_t four = 4;
unsigned char *buf = NULL, *orig = NULL, *bkg = NULL;
- ArrayType* array_dt = NULL;
+ ArrayType * array_dt = NULL;
// Output message about test being performed
SUBTEST("Compound Element Shrinking & Reordering");
try {
/* Sizes should be the same, but be careful just in case */
- buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
- bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t));
- orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t));
- for (i=0; i<nelmts; i++) {
- s_ptr = ((src_typ_t*)orig) + i;
- s_ptr->a = i*8+0;
- s_ptr->b = (i*8+1) & 0x7fff;
- s_ptr->c[0] = i*8+2;
- s_ptr->c[1] = i*8+3;
- s_ptr->c[2] = i*8+4;
- s_ptr->c[3] = i*8+5;
- s_ptr->d = (i*8+6) & 0x7fff;
- s_ptr->e = i*8+7;
+ buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
+ bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t));
+ orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t));
+ for (i = 0; i < nelmts; i++) {
+ s_ptr = ((src_typ_t *)orig) + i;
+ s_ptr->a = i * 8 + 0;
+ s_ptr->b = (i * 8 + 1) & 0x7fff;
+ s_ptr->c[0] = i * 8 + 2;
+ s_ptr->c[1] = i * 8 + 3;
+ s_ptr->c[2] = i * 8 + 4;
+ s_ptr->c[3] = i * 8 + 5;
+ s_ptr->d = (i * 8 + 6) & 0x7fff;
+ s_ptr->e = i * 8 + 7;
}
- memcpy(buf, orig, nelmts*sizeof(src_typ_t));
+ memcpy(buf, orig, nelmts * sizeof(src_typ_t));
/* Build hdf5 datatypes */
array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
@@ -396,30 +379,22 @@ static void test_compound_4()
st.convert(dt, (size_t)nelmts, buf, bkg);
/* Compare results */
- for (i=0; i<nelmts; i++) {
- s_ptr = ((src_typ_t*)orig) + i;
- d_ptr = ((dst_typ_t*)buf) + i;
- if (s_ptr->a != d_ptr->a ||
- s_ptr->b != d_ptr->b ||
- s_ptr->c[0] != d_ptr->c[0] ||
- s_ptr->c[1] != d_ptr->c[1] ||
- s_ptr->c[2] != d_ptr->c[2] ||
- s_ptr->c[3] != d_ptr->c[3] ||
- s_ptr->d != d_ptr->d ||
- s_ptr->e != d_ptr->e)
- {
+ for (i = 0; i < nelmts; i++) {
+ s_ptr = ((src_typ_t *)orig) + i;
+ d_ptr = ((dst_typ_t *)buf) + i;
+ if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] ||
+ s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] ||
+ s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) {
H5_FAILED();
cerr << " i=" << i << endl;
- cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b
- << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << ","
- << s_ptr->c[2] << "," << s_ptr->c[3] << ", d="
- << s_ptr->d << ", e=" << s_ptr->e << "}" << endl;
- cerr << " dst={a=" << d_ptr->a << ", b=" << d_ptr->b
- << "c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << ","
- << d_ptr->c[2] << "," << d_ptr->c[3] << ", d="
- << d_ptr->d << ", e=" << d_ptr->e << "}" << endl;
+ cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << ","
+ << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d
+ << ", e=" << s_ptr->e << "}" << endl;
+ cerr << " dst={a=" << d_ptr->a << ", b=" << d_ptr->b << "c=[" << d_ptr->c[0] << ","
+ << d_ptr->c[1] << "," << d_ptr->c[2] << "," << d_ptr->c[3] << ", d=" << d_ptr->d
+ << ", e=" << d_ptr->e << "}" << endl;
} // if
- } // for
+ } // for
/* Release resources */
HDfree(buf);
@@ -430,18 +405,16 @@ static void test_compound_4()
st.close();
dt.close();
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
- if(array_dt)
+ if (array_dt)
delete array_dt;
-} // test_compound_4()
+} // test_compound_4()
-
/*-------------------------------------------------------------------------
* Function: test_compound_5
*
@@ -456,27 +429,27 @@ static void test_compound_4()
* January, 2007
*-------------------------------------------------------------------------
*/
-static void test_compound_5()
+static void
+test_compound_5()
{
typedef struct {
- char name[16];
- short tdim;
- short coll_ids[4];
+ char name[16];
+ short tdim;
+ short coll_ids[4];
} src_typ_t;
typedef struct {
- char name[16];
- short tdim;
- int coll_ids[4];
+ char name[16];
+ short tdim;
+ int coll_ids[4];
} dst_typ_t;
- hsize_t dims[1] = {4};
- src_typ_t src[2] = {{"one", 102, {104, 105, 106, 107}},
- {"two", 202, {204, 205, 206, 207}}};
- dst_typ_t *dst;
- void *buf = HDcalloc(2, sizeof(dst_typ_t));
- void *bkg = HDcalloc(2, sizeof(dst_typ_t));
- ArrayType* array_dt = NULL;
+ hsize_t dims[1] = {4};
+ src_typ_t src[2] = {{"one", 102, {104, 105, 106, 107}}, {"two", 202, {204, 205, 206, 207}}};
+ dst_typ_t *dst;
+ void * buf = HDcalloc(2, sizeof(dst_typ_t));
+ void * bkg = HDcalloc(2, sizeof(dst_typ_t));
+ ArrayType *array_dt = NULL;
// Output message about test being performed
SUBTEST("Optimized Struct Converter");
@@ -484,17 +457,17 @@ static void test_compound_5()
/* Build datatypes */
array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims);
- CompType short_array(4*sizeof(short));
+ CompType short_array(4 * sizeof(short));
short_array.insertMember("_", 0, *array_dt);
array_dt->close();
delete array_dt;
- CompType int_array(4*sizeof(int));
+ CompType int_array(4 * sizeof(int));
array_dt = new ArrayType(PredType::NATIVE_INT, 1, dims);
int_array.insertMember("_", 0, *array_dt);
array_dt->close();
- StrType strg(PredType::C_S1, 16);
+ StrType strg(PredType::C_S1, 16);
CompType src_type(sizeof(src_typ_t));
src_type.insertMember("name", HOFFSET(src_typ_t, name), strg);
src_type.insertMember("tdim", HOFFSET(src_typ_t, tdim), PredType::NATIVE_SHORT);
@@ -508,7 +481,7 @@ static void test_compound_5()
/* Convert data */
memcpy(buf, src, sizeof(src));
src_type.convert(dst_type, (size_t)2, buf, bkg);
- dst = (dst_typ_t*)buf;
+ dst = (dst_typ_t *)buf;
/* Cleanup */
src_type.close();
@@ -518,31 +491,27 @@ static void test_compound_5()
int_array.close();
/* Check results */
- if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) ||
- src[1].tdim!=dst[1].tdim ||
- src[1].coll_ids[0]!=dst[1].coll_ids[0] ||
- src[1].coll_ids[1]!=dst[1].coll_ids[1] ||
- src[1].coll_ids[2]!=dst[1].coll_ids[2] ||
- src[1].coll_ids[3]!=dst[1].coll_ids[3])
- { H5_FAILED(); }
+ if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || src[1].tdim != dst[1].tdim ||
+ src[1].coll_ids[0] != dst[1].coll_ids[0] || src[1].coll_ids[1] != dst[1].coll_ids[1] ||
+ src[1].coll_ids[2] != dst[1].coll_ids[2] || src[1].coll_ids[3] != dst[1].coll_ids[3]) {
+ H5_FAILED();
+ }
/* Free memory buffers */
HDfree(buf);
HDfree(bkg);
dst = NULL;
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
- if(array_dt)
+ if (array_dt)
delete array_dt;
-} // test_compound_5()
+} // test_compound_5()
-
/*-------------------------------------------------------------------------
* Function: test_compound_6
*
@@ -556,7 +525,8 @@ static void test_compound_5()
* January, 2007
*-------------------------------------------------------------------------
*/
-static void test_compound_6()
+static void
+test_compound_6()
{
typedef struct {
short b;
@@ -568,25 +538,25 @@ static void test_compound_6()
long d;
} dst_typ_t;
- src_typ_t *s_ptr;
- dst_typ_t *d_ptr;
- int i;
- const int nelmts = NTESTELEM;
- unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;
+ src_typ_t * s_ptr;
+ dst_typ_t * d_ptr;
+ int i;
+ const int nelmts = NTESTELEM;
+ unsigned char *buf = NULL, *orig = NULL, *bkg = NULL;
// Output message about test being performed
SUBTEST("Compound Element Growing");
try {
/* Sizes should be the same, but be careful just in case */
- buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
- bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t));
- orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t));
- for (i=0; i<nelmts; i++) {
- s_ptr = ((src_typ_t*)orig) + i;
- s_ptr->b = (i*8+1) & 0x7fff;
- s_ptr->d = (i*8+6) & 0x7fff;
+ buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
+ bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t));
+ orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t));
+ for (i = 0; i < nelmts; i++) {
+ s_ptr = ((src_typ_t *)orig) + i;
+ s_ptr->b = (i * 8 + 1) & 0x7fff;
+ s_ptr->d = (i * 8 + 6) & 0x7fff;
}
- memcpy(buf, orig, nelmts*sizeof(src_typ_t));
+ memcpy(buf, orig, nelmts * sizeof(src_typ_t));
/* Build hdf5 datatypes */
CompType st(sizeof(src_typ_t));
@@ -601,20 +571,16 @@ static void test_compound_6()
st.convert(dt, (size_t)nelmts, buf, bkg);
/* Compare results */
- for (i=0; i<nelmts; i++) {
- s_ptr = ((src_typ_t*)orig) + i;
- d_ptr = ((dst_typ_t*)buf) + i;
- if (s_ptr->b != d_ptr->b ||
- s_ptr->d != d_ptr->d)
- {
+ for (i = 0; i < nelmts; i++) {
+ s_ptr = ((src_typ_t *)orig) + i;
+ d_ptr = ((dst_typ_t *)buf) + i;
+ if (s_ptr->b != d_ptr->b || s_ptr->d != d_ptr->d) {
H5_FAILED();
cerr << " i=" << i << endl;
- cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d
- << "}" << endl;
- cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d
- << "}" << endl;
+ cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d << "}" << endl;
+ cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d << "}" << endl;
} // if
- } // for
+ } // for
/* Release resources */
HDfree(buf);
@@ -625,15 +591,13 @@ static void test_compound_6()
st.close();
dt.close();
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_compound_6()
+} // test_compound_6()
-
/*-------------------------------------------------------------------------
* Function: test_compound_7
*
@@ -646,18 +610,19 @@ static void test_compound_6()
* January, 2007
*-------------------------------------------------------------------------
*/
-static void test_compound_7()
+static void
+test_compound_7()
{
typedef struct {
- int a;
+ int a;
float b;
- long c;
+ long c;
} s1_typ_t;
typedef struct {
- int a;
- float b;
- long c;
+ int a;
+ float b;
+ long c;
double d;
} s2_typ_t;
@@ -666,9 +631,9 @@ static void test_compound_7()
try {
CompType tid1(sizeof(s1_typ_t));
- tid1.insertMember("a", HOFFSET(s1_typ_t,a),PredType::NATIVE_INT);
- tid1.insertMember("b", HOFFSET(s1_typ_t,b),PredType::NATIVE_FLOAT);
- tid1.insertMember("c", HOFFSET(s1_typ_t,c),PredType::NATIVE_LONG);
+ tid1.insertMember("a", HOFFSET(s1_typ_t, a), PredType::NATIVE_INT);
+ tid1.insertMember("b", HOFFSET(s1_typ_t, b), PredType::NATIVE_FLOAT);
+ tid1.insertMember("c", HOFFSET(s1_typ_t, c), PredType::NATIVE_LONG);
size_t type_size = tid1.getSize();
verify_val(type_size, sizeof(s1_typ_t), "DataType::getSize", __LINE__, __FILE__);
@@ -683,22 +648,23 @@ static void test_compound_7()
try {
tid2.insertMember("d", HOFFSET(s2_typ_t, d), PredType::NATIVE_DOUBLE);
// Should FAIL but didn't, so throw an invalid action exception
- throw InvalidActionException("CompType::insertMember", "Attempted to insert field past end of compound data type.");
- } catch (DataTypeIException& err) {}
+ throw InvalidActionException("CompType::insertMember",
+ "Attempted to insert field past end of compound data type.");
+ }
+ catch (DataTypeIException &err) {
+ }
/* Release resources */
tid1.close();
tid2.close();
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_compound_7()
+} // test_compound_7()
-
/*-------------------------------------------------------------------------
* Function: test_compound_set_size
*
@@ -712,7 +678,8 @@ static void test_compound_7()
*/
const H5std_string COMPFILE("tcompound_types.h5");
-static void test_compound_set_size()
+static void
+test_compound_set_size()
{
typedef struct {
int a, b, c[4], d, e;
@@ -779,15 +746,13 @@ static void test_compound_set_size()
file.close();
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_compound_set_size()
+} // test_compound_set_size()
-
/*-------------------------------------------------------------------------
* Function: test_compound
*
@@ -799,23 +764,22 @@ static void test_compound_set_size()
* January 2007
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_compound()
+extern "C" void
+test_compound()
{
// Output message about test being performed
MESSAGE(5, ("Testing Compound Data Type operations\n"));
- test_compound_1(); // various things about compound data types
- test_compound_2(); // compound element reordering
- test_compound_3(); // compound datatype subset conversions
- test_compound_4(); // compound element shrinking & reordering
- test_compound_5(); // optimized struct converter
- test_compound_6(); // compound element growing
- test_compound_7(); // compound element insertion
- test_compound_set_size(); // set size on compound data types
-} // test_compound()
-
-
+ test_compound_1(); // various things about compound data types
+ test_compound_2(); // compound element reordering
+ test_compound_3(); // compound datatype subset conversions
+ test_compound_4(); // compound element shrinking & reordering
+ test_compound_5(); // optimized struct converter
+ test_compound_6(); // compound element growing
+ test_compound_7(); // compound element insertion
+ test_compound_set_size(); // set size on compound data types
+} // test_compound()
+
/*-------------------------------------------------------------------------
* Function: cleanup_compound
*
@@ -824,8 +788,8 @@ void test_compound()
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_compound()
+extern "C" void
+cleanup_compound()
{
HDremove(COMPFILE.c_str());
-} // cleanup_file
+} // cleanup_file
diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp
index 438f385..4cdf408 100644
--- a/c++/test/tdspl.cpp
+++ b/c++/test/tdspl.cpp
@@ -26,20 +26,21 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
const H5std_string FILENAME("tdatatransform.h5");
-static void test_transfplist()
+static void
+test_transfplist()
{
- const char* c_to_f = "(9/5.0)*x + 32";
- const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
+ const char *c_to_f = "(9/5.0)*x + 32";
+ const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
/* inverses the utrans transform in init_test to get back original array */
- const char* utrans_inv = "(x/3)*4 - 100";
+ const char *utrans_inv = "(x/3)*4 - 100";
SUBTEST("DSetMemXferPropList::set/getDataTransform()");
try {
@@ -63,12 +64,12 @@ static void test_transfplist()
// Find out the length of the transform expression, allocate the buffer
// for it, then read and verify the expression from the copied plist
- ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL);
- char *c_to_f_read = (char *)HDmalloc(tran_len+1);
- HDmemset(c_to_f_read, 0, tran_len+1);
- dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len+1);
- verify_val((const char*)c_to_f_read, (const char*)c_to_f,
- "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
+ ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL);
+ char * c_to_f_read = (char *)HDmalloc(tran_len + 1);
+ HDmemset(c_to_f_read, 0, tran_len + 1);
+ dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len + 1);
+ verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform",
+ __LINE__, __FILE__);
HDfree(c_to_f_read);
//
@@ -78,39 +79,37 @@ static void test_transfplist()
// Get and verify the expression with:
// ssize_t getDataTransform(char* exp, const size_t buf_size [default=0])
- tran_len = dxpl_c_to_f.getDataTransform(NULL);
- c_to_f_read = (char *)HDmalloc(tran_len+1);
- HDmemset(c_to_f_read, 0, tran_len+1);
- dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len+1);
- verify_val((const char*)c_to_f_read, (const char*)c_to_f,
- "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
+ tran_len = dxpl_c_to_f.getDataTransform(NULL);
+ c_to_f_read = (char *)HDmalloc(tran_len + 1);
+ HDmemset(c_to_f_read, 0, tran_len + 1);
+ dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len + 1);
+ verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform",
+ __LINE__, __FILE__);
HDfree(c_to_f_read);
// Get and verify the expression with:
// H5std_string DSetMemXferPropList::getDataTransform()
H5std_string simple_read = dxpl_simple.getDataTransform();
- verify_val((const char*)simple_read.c_str(), (const char*)simple,
- "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
+ verify_val((const char *)simple_read.c_str(), (const char *)simple,
+ "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
// Get and verify the expression with:
// ssize_t getDataTransform(char* exp, const size_t buf_size)
- tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0);
- char *utrans_inv_read = (char *)HDmalloc(tran_len+1);
- HDmemset(utrans_inv_read, 0, tran_len+1);
- dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len+1);
- verify_val((const char*)utrans_inv_read, (const char*)utrans_inv,
- "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
+ tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0);
+ char *utrans_inv_read = (char *)HDmalloc(tran_len + 1);
+ HDmemset(utrans_inv_read, 0, tran_len + 1);
+ dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len + 1);
+ verify_val((const char *)utrans_inv_read, (const char *)utrans_inv,
+ "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
HDfree(utrans_inv_read);
PASSED();
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_transfplist", __LINE__, __FILE__, E.getCDetailMsg());
}
}
-
/*-------------------------------------------------------------------------
* Function: test_dsproplist
*
@@ -119,17 +118,16 @@ static void test_transfplist()
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_dsproplist()
+extern "C" void
+test_dsproplist()
{
// Output message about test being performed
MESSAGE(5, ("Testing Generic Dataset Property Lists\n"));
test_transfplist(); // test set/getDataTransform()
-} // test_dsproplist()
+} // test_dsproplist()
-
/*-------------------------------------------------------------------------
* Function: cleanup_dsproplist
*
@@ -138,8 +136,8 @@ void test_dsproplist()
* Return none
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_dsproplist()
+extern "C" void
+cleanup_dsproplist()
{
HDremove(FILENAME.c_str());
}
diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp
index a2a0867..a38d36d 100644
--- a/c++/test/testhdf5.cpp
+++ b/c++/test/testhdf5.cpp
@@ -47,17 +47,16 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
int
main(int argc, char *argv[])
{
- try
- {
+ try {
// Turn of the auto-printing when failure occurs so that we can
// handle the errors appropriately since sometime failures are
// caused deliberately and expected.
@@ -70,39 +69,38 @@ main(int argc, char *argv[])
// testing dataset functionalities in dset.cpp
AddTest("dsets", test_dset, cleanup_dsets, "Dataset I/O Operations", NULL);
// testing dataspace functionalities in th5s.cpp
- AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL);
+ AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL);
// testing attribute functionalities in tattr.cpp
- AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL);
+ AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL);
// testing object functionalities in tobject.cpp
- AddTest("tobject", test_object, cleanup_object, "Objects", NULL);
+ AddTest("tobject", test_object, cleanup_object, "Objects", NULL);
// testing reference functionalities in trefer.cpp
- AddTest("trefer", test_reference, cleanup_reference, "References", NULL);
+ AddTest("trefer", test_reference, cleanup_reference, "References", NULL);
// testing variable-length strings in tvlstr.cpp
- AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL);
- AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL);
- AddTest("tarray", test_array, cleanup_array, "Array Datatypes", NULL);
- AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL);
- AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL);
- AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL);
- AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL);
-/* Comment out tests that are not done yet. - BMR, Feb 2001
- AddTest("select", test_select, cleanup_select, "Selections", NULL);
- AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL);
- AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL);
-*/
- AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL);
-/*
- AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL);
- AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL);
-
-Comment out tests that are not done yet */
-
-/* Tentative - BMR 2007/1/12
- AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL);
-*/
+ AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL);
+ AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL);
+ AddTest("tarray", test_array, cleanup_array, "Array Datatypes", NULL);
+ AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL);
+ AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL);
+ AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL);
+ AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL);
+ /* Comment out tests that are not done yet. - BMR, Feb 2001
+ AddTest("select", test_select, cleanup_select, "Selections", NULL);
+ AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL);
+ AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL);
+ */
+ AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL);
+ /*
+ AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL);
+ AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL);
+
+ Comment out tests that are not done yet */
+
+ /* Tentative - BMR 2007/1/12
+ AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL);
+ */
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("Tests failed", __LINE__, __FILE__, E.getCDetailMsg());
}
@@ -110,7 +108,7 @@ Comment out tests that are not done yet */
TestInfo(argv[0]);
/* Parse command line arguments */
- TestParseCmdLine(argc,argv);
+ TestParseCmdLine(argc, argv);
/* Perform requested testing */
PerformTests();
@@ -128,4 +126,3 @@ Comment out tests that are not done yet */
return (GetTestNumErrs());
}
-
diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp
index f5625a3..b4e5da5 100644
--- a/c++/test/tfile.cpp
+++ b/c++/test/tfile.cpp
@@ -29,38 +29,37 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
-
-const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0;
-const size_t F1_OFFSET_SIZE = sizeof(haddr_t);
-const size_t F1_LENGTH_SIZE = sizeof(hsize_t);
-const unsigned F1_SYM_LEAF_K = 4;
-const unsigned F1_SYM_INTERN_K = 16;
-const H5std_string FILE1("tfile1.h5");
-
-const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512;
-const size_t F2_OFFSET_SIZE = 8;
-const size_t F2_LENGTH_SIZE = 8;
-const unsigned F2_SYM_LEAF_K = 8;
-const unsigned F2_SYM_INTERN_K = 32;
-const unsigned F2_ISTORE = 64;
-const H5std_string FILE2("tfile2.h5");
-
-const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0;
-const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE;
-const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE;
-const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K;
-const unsigned F3_SYM_INTERN_K = F2_SYM_INTERN_K;
-const H5std_string FILE3("tfile3.h5");
-
-const int KB = 1024;
-const H5std_string FILE4("tfile4.h5");
-
-
+#include "h5cpputil.h" // C++ utilility header file
+
+const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0;
+const size_t F1_OFFSET_SIZE = sizeof(haddr_t);
+const size_t F1_LENGTH_SIZE = sizeof(hsize_t);
+const unsigned F1_SYM_LEAF_K = 4;
+const unsigned F1_SYM_INTERN_K = 16;
+const H5std_string FILE1("tfile1.h5");
+
+const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512;
+const size_t F2_OFFSET_SIZE = 8;
+const size_t F2_LENGTH_SIZE = 8;
+const unsigned F2_SYM_LEAF_K = 8;
+const unsigned F2_SYM_INTERN_K = 32;
+const unsigned F2_ISTORE = 64;
+const H5std_string FILE2("tfile2.h5");
+
+const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0;
+const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE;
+const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE;
+const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K;
+const unsigned F3_SYM_INTERN_K = F2_SYM_INTERN_K;
+const H5std_string FILE3("tfile3.h5");
+
+const int KB = 1024;
+const H5std_string FILE4("tfile4.h5");
+
/*-------------------------------------------------------------------------
* Function: test_file_create
*
@@ -80,7 +79,8 @@ const H5std_string FILE4("tfile4.h5");
* with a special routine.
*-------------------------------------------------------------------------
*/
-static void test_file_create()
+static void
+test_file_create()
{
// Output message about test being performed
SUBTEST("File Creation I/O");
@@ -93,21 +93,22 @@ static void test_file_create()
remove(FILE1.c_str());
// Setting this to NULL for cleaning up in failure situations
- H5File* file1 = NULL;
+ H5File *file1 = NULL;
try {
// Create file FILE1
- file1 = new H5File (FILE1, H5F_ACC_EXCL);
+ file1 = new H5File(FILE1, H5F_ACC_EXCL);
// Try to create the same file with H5F_ACC_TRUNC. This should fail
// because file1 is the same file and is currently open.
try {
- H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E
+ H5File file2(FILE1, H5F_ACC_TRUNC); // should throw E
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("H5File constructor", "Attempted to create an existing file.");
}
- catch (FileIException& E) // catch truncating existing file
- {} // do nothing, FAIL expected
+ catch (FileIException &E) // catch truncating existing file
+ {
+ } // do nothing, FAIL expected
// Close file1
delete file1;
@@ -116,52 +117,56 @@ static void test_file_create()
// Try again with H5F_ACC_EXCL. This should fail because the file
// already exists from the previous steps.
try {
- H5File file2(FILE1, H5F_ACC_EXCL); // should throw E
+ H5File file2(FILE1, H5F_ACC_EXCL); // should throw E
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("H5File constructor", "File already exists.");
}
- catch (FileIException& E) // catching creating existing file
- {} // do nothing, FAIL expected
+ catch (FileIException &E) // catching creating existing file
+ {
+ } // do nothing, FAIL expected
- // Test create with H5F_ACC_TRUNC. This will truncate the existing file.
- file1 = new H5File (FILE1, H5F_ACC_TRUNC);
+ // Test create with H5F_ACC_TRUNC. This will truncate the existing file.
+ file1 = new H5File(FILE1, H5F_ACC_TRUNC);
// Try to create first file again. This should fail because file1
// is the same file and is currently open.
- try {
- H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E
+ try {
+ H5File file2(FILE1, H5F_ACC_TRUNC); // should throw E
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("H5File constructor", "H5F_ACC_TRUNC attempt on an opened file.");
}
- catch (FileIException& E) // catching truncating opened file
- {} // do nothing, FAIL expected
+ catch (FileIException &E) // catching truncating opened file
+ {
+ } // do nothing, FAIL expected
- // Try with H5F_ACC_EXCL. This should fail too because the file already
- // exists.
- try {
- H5File file3 (FILE1, H5F_ACC_EXCL); // should throw E
+ // Try with H5F_ACC_EXCL. This should fail too because the file already
+ // exists.
+ try {
+ H5File file3(FILE1, H5F_ACC_EXCL); // should throw E
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("H5File constructor", "H5F_ACC_EXCL attempt on an existing file.");
- }
- catch (FileIException& E) // catching H5F_ACC_EXCL on existing file
- {} // do nothing, FAIL expected
+ }
+ catch (FileIException &E) // catching H5F_ACC_EXCL on existing file
+ {
+ } // do nothing, FAIL expected
- // Get the file-creation template
+ // Get the file-creation template
FileCreatPropList tmpl1 = file1->getCreatePlist();
hsize_t ublock = tmpl1.getUserblock();
- verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);
+ verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__,
+ __FILE__);
- size_t parm1, parm2; // file-creation parameters
- tmpl1.getSizes( parm1, parm2);
+ size_t parm1, parm2; // file-creation parameters
+ tmpl1.getSizes(parm1, parm2);
verify_val(parm1, F1_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
verify_val(parm2, F1_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
- unsigned iparm1,iparm2; // file-creation parameters
- tmpl1.getSymk( iparm1, iparm2);
+ unsigned iparm1, iparm2; // file-creation parameters
+ tmpl1.getSymk(iparm1, iparm2);
verify_val(iparm1, F1_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
verify_val(iparm2, F1_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
@@ -171,85 +176,84 @@ static void test_file_create()
// Close first file
delete file1;
}
- catch (InvalidActionException& E)
- {
+ catch (InvalidActionException &E) {
cerr << " *FAILED*" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
if (file1 != NULL) // clean up
delete file1;
}
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg());
if (file1 != NULL) // clean up
delete file1;
}
// Setting this to NULL for cleaning up in failure situations
- FileCreatPropList* tmpl1 = NULL;
- try
- {
- // Create a new file with a non-standard file-creation template
+ FileCreatPropList *tmpl1 = NULL;
+ try {
+ // Create a new file with a non-standard file-creation template
tmpl1 = new FileCreatPropList;
- // Set the new file-creation parameters
- tmpl1->setUserblock (F2_USERBLOCK_SIZE);
- tmpl1->setSizes( F2_OFFSET_SIZE, F2_LENGTH_SIZE );
- tmpl1->setSymk( F2_SYM_INTERN_K, F2_SYM_LEAF_K );
+ // Set the new file-creation parameters
+ tmpl1->setUserblock(F2_USERBLOCK_SIZE);
+ tmpl1->setSizes(F2_OFFSET_SIZE, F2_LENGTH_SIZE);
+ tmpl1->setSymk(F2_SYM_INTERN_K, F2_SYM_LEAF_K);
- // Try to create second file, with non-standard file-creation template
- // params.
- H5File file2( FILE2, H5F_ACC_TRUNC, *tmpl1 );
+ // Try to create second file, with non-standard file-creation template
+ // params.
+ H5File file2(FILE2, H5F_ACC_TRUNC, *tmpl1);
- // Release file-creation template
+ // Release file-creation template
delete tmpl1;
tmpl1 = NULL;
// Get the file-creation template
- tmpl1 = new FileCreatPropList (file2.getCreatePlist());
+ tmpl1 = new FileCreatPropList(file2.getCreatePlist());
// Get the file-creation parameters
hsize_t ublock = tmpl1->getUserblock();
- verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);
+ verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__,
+ __FILE__);
size_t parm1, parm2; // file-creation parameters
- tmpl1->getSizes( parm1, parm2);
+ tmpl1->getSizes(parm1, parm2);
verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
- unsigned iparm1,iparm2; // file-creation parameters
- tmpl1->getSymk( iparm1, iparm2);
+ unsigned iparm1, iparm2; // file-creation parameters
+ tmpl1->getSymk(iparm1, iparm2);
verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
// Clone the file-creation template
FileCreatPropList tmpl2;
- tmpl2.copy (*tmpl1);
+ tmpl2.copy(*tmpl1);
// Release file-creation template
delete tmpl1;
tmpl1 = NULL;
// Set the new file-creation parameter
- tmpl2.setUserblock( F3_USERBLOCK_SIZE );
+ tmpl2.setUserblock(F3_USERBLOCK_SIZE);
// Try to create second file, with non-standard file-creation template
// params
- H5File file3( FILE3, H5F_ACC_TRUNC, tmpl2 );
+ H5File file3(FILE3, H5F_ACC_TRUNC, tmpl2);
// Get the file-creation template
- tmpl1 = new FileCreatPropList (file3.getCreatePlist());
+ tmpl1 = new FileCreatPropList(file3.getCreatePlist());
// Get the file-creation parameters
ublock = tmpl1->getUserblock();
- verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);
+ verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__,
+ __FILE__);
- tmpl1->getSizes( parm1, parm2);
+ tmpl1->getSizes(parm1, parm2);
verify_val(parm1, F3_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
verify_val(parm2, F3_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
- tmpl1->getSymk( iparm1, iparm2);
+ tmpl1->getSymk(iparm1, iparm2);
verify_val(iparm1, F3_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
verify_val(iparm2, F3_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
@@ -258,15 +262,13 @@ static void test_file_create()
PASSED();
}
// catch all exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg());
- if (tmpl1 != NULL) // clean up
+ if (tmpl1 != NULL) // clean up
delete tmpl1;
}
-} // test_file_create()
+} // test_file_create()
-
/*-------------------------------------------------------------------------
* Function: test_file_open
*
@@ -286,7 +288,8 @@ static void test_file_create()
* with a special routine.
*-------------------------------------------------------------------------
*/
-static void test_file_open()
+static void
+test_file_open()
{
// Output message about test being performed
SUBTEST("File Opening I/O");
@@ -294,22 +297,23 @@ static void test_file_open()
try {
// Open first file
- H5File file1 (FILE2, H5F_ACC_RDWR );
+ H5File file1(FILE2, H5F_ACC_RDWR);
// Get the file-creation template
FileCreatPropList tmpl1 = file1.getCreatePlist();
// Get the file-creation parameters
hsize_t ublock = tmpl1.getUserblock();
- verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);
+ verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__,
+ __FILE__);
- size_t parm1, parm2; // file-creation parameters
- tmpl1.getSizes( parm1, parm2);
+ size_t parm1, parm2; // file-creation parameters
+ tmpl1.getSizes(parm1, parm2);
verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
- unsigned iparm1,iparm2; // file-creation parameters
- tmpl1.getSymk( iparm1, iparm2);
+ unsigned iparm1, iparm2; // file-creation parameters
+ tmpl1.getSymk(iparm1, iparm2);
verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
@@ -319,14 +323,15 @@ static void test_file_open()
// Try truncating the file, and it should fail because the file is
// still opened with file2.
- try {
- H5File file3 (FILE2, H5F_ACC_TRUNC); // should throw E
+ try {
+ H5File file3(FILE2, H5F_ACC_TRUNC); // should throw E
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("H5File constructor", "Attempt truncating an opened file.");
- }
- catch (FileIException& E) // catching H5F_ACC_TRUNC on opened file
- {} // do nothing, FAIL expected
+ }
+ catch (FileIException &E) // catching H5F_ACC_TRUNC on opened file
+ {
+ } // do nothing, FAIL expected
// Now, really close the file.
file2.close();
@@ -340,15 +345,13 @@ static void test_file_open()
H5File file4(FILE2, H5F_ACC_TRUNC);
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_file_open()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_file_open()
+} // test_file_open()
-
/*-------------------------------------------------------------------------
* Function: test_file_size
*
@@ -360,12 +363,13 @@ static void test_file_open()
* June, 2004
*-------------------------------------------------------------------------
*/
-static void test_file_size()
+static void
+test_file_size()
{
// Output message about test being performed
SUBTEST("File Size");
- hid_t fapl_id;
+ hid_t fapl_id;
fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template
try {
@@ -373,33 +377,34 @@ static void test_file_size()
// list object to pass in H5File::H5File
FileAccPropList fapl(fapl_id);
- // Set to sec2 driver. Do we want to test other file drivers?
+ // Set to sec2 driver. Do we want to test other file drivers?
// They're not tested in C++.
// File drivers seem not implemented.
// fapl.setSec2();
// Create a file
- H5File file4( FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
+ H5File file4(FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
// Get file size
hsize_t file_size = file4.getFileSize();
// Check if file size is reasonable. It's supposed to be 2KB now.
- if (file_size < 1*KB || file_size > 4*KB)
- issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFileSize() returned unreasonable value");
+ if (file_size < 1 * KB || file_size > 4 * KB)
+ issue_fail_msg("test_file_size()", __LINE__, __FILE__,
+ "getFileSize() returned unreasonable value");
// Get the amount of free space in the file
hssize_t free_space = file4.getFreeSpace();
// Check if it's reasonable. It's 0 now.
- if (free_space < 0 || free_space > 4*KB)
- issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFreeSpace returned unreasonable value");
+ if (free_space < 0 || free_space > 4 * KB)
+ issue_fail_msg("test_file_size()", __LINE__, __FILE__,
+ "getFreeSpace returned unreasonable value");
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_file_size()", __LINE__, __FILE__, E.getCDetailMsg());
}
@@ -408,9 +413,8 @@ static void test_file_size()
if (ret < 0)
issue_fail_msg("test_file_size()", __LINE__, __FILE__, "H5Pclose failed");
-} // test_file_size()
+} // test_file_size()
-
/*-------------------------------------------------------------------------
* Function: test_file_num
*
@@ -422,12 +426,13 @@ static void test_file_size()
* April, 2019
*-------------------------------------------------------------------------
*/
-static void test_file_num()
+static void
+test_file_num()
{
// Output message about test being performed
SUBTEST("File Number");
- hid_t fapl_id;
+ hid_t fapl_id;
fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template
try {
@@ -454,10 +459,9 @@ static void test_file_num()
issue_fail_msg("test_file_num()", __LINE__, __FILE__, "getFileNum() returned wrong value");
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_file_num()", __LINE__, __FILE__, E.getCDetailMsg());
}
@@ -466,9 +470,8 @@ static void test_file_num()
if (ret < 0)
issue_fail_msg("test_file_num()", __LINE__, __FILE__, "H5Pclose failed");
-} // test_file_num()
+} // test_file_num()
-
/*-------------------------------------------------------------------------
* Function: test_file_name
*
@@ -480,14 +483,14 @@ static void test_file_num()
* July, 2004
*-------------------------------------------------------------------------
*/
-const int RANK = 2;
-const int NX = 4;
-const int NY = 5;
-const H5std_string GROUPNAME ("group");
-const H5std_string DSETNAME ("dataset");
-const H5std_string DATTRNAME ("dataset attribute");
-const H5std_string FATTRNAME ("file attribute");
-const H5std_string DTYPENAME ("compound");
+const int RANK = 2;
+const int NX = 4;
+const int NY = 5;
+const H5std_string GROUPNAME("group");
+const H5std_string DSETNAME("dataset");
+const H5std_string DATTRNAME("dataset attribute");
+const H5std_string FATTRNAME("file attribute");
+const H5std_string DTYPENAME("compound");
// Compound datatype
typedef struct s1_t {
@@ -495,7 +498,8 @@ typedef struct s1_t {
float b;
} s1_t;
-static void test_file_name()
+static void
+test_file_name()
{
// Output message about test being performed.
SUBTEST("File Name");
@@ -517,11 +521,11 @@ static void test_file_name()
verify_val(file_name, FILE4, "Group::getFileName", __LINE__, __FILE__);
// Create the data space.
- hsize_t dims[RANK] = {NX, NY};
+ hsize_t dims[RANK] = {NX, NY};
DataSpace space(RANK, dims);
// Create a new dataset.
- DataSet dataset(file4.createDataSet (DSETNAME, PredType::NATIVE_INT, space));
+ DataSet dataset(file4.createDataSet(DSETNAME, PredType::NATIVE_INT, space));
// Get and verify file name via a dataset.
file_name = dataset.getFileName();
@@ -535,7 +539,7 @@ static void test_file_name()
verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__);
// Create a compound datatype.
- CompType comp_type (sizeof(s1_t));
+ CompType comp_type(sizeof(s1_t));
// Insert fields.
comp_type.insertMember("a", HOFFSET(s1_t, a), PredType::NATIVE_INT);
@@ -548,15 +552,13 @@ static void test_file_name()
comp_type.getFileName();
verify_val(file_name, FILE4, "CompType::getFileName", __LINE__, __FILE__);
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_file_name()
+} // test_file_name()
-
/*-------------------------------------------------------------------------
*
* Function: test_file_attribute
@@ -566,15 +568,16 @@ static void test_file_name()
* Return None
*-------------------------------------------------------------------------
*/
-const int RANK1 = 1;
-const int ATTR1_DIM1 = 3;
-const H5std_string FILE5("tfattrs.h5");
-const H5std_string FATTR1_NAME ("file attribute 1");
-const H5std_string FATTR2_NAME ("file attribute 2");
-int fattr_data[ATTR1_DIM1]={512,-234,98123}; // Test data for file attribute
-int dattr_data[ATTR1_DIM1]={256,-123,1000}; // Test data for dataset attribute
-
-static void test_file_attribute()
+const int RANK1 = 1;
+const int ATTR1_DIM1 = 3;
+const H5std_string FILE5("tfattrs.h5");
+const H5std_string FATTR1_NAME("file attribute 1");
+const H5std_string FATTR2_NAME("file attribute 2");
+int fattr_data[ATTR1_DIM1] = {512, -234, 98123}; // Test data for file attribute
+int dattr_data[ATTR1_DIM1] = {256, -123, 1000}; // Test data for dataset attribute
+
+static void
+test_file_attribute()
{
int rdata[ATTR1_DIM1];
int i;
@@ -588,7 +591,7 @@ static void test_file_attribute()
H5File file5(FILE5, H5F_ACC_TRUNC);
// Create the data space
- hsize_t dims[RANK1] = {ATTR1_DIM1};
+ hsize_t dims[RANK1] = {ATTR1_DIM1};
DataSpace space(RANK1, dims);
// Create two attributes for the file
@@ -601,13 +604,15 @@ static void test_file_attribute()
// Try to create the same attribute again (should fail)
Attribute fattr_dup(file5.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, space));
// Should FAIL but didn't, so throw an invalid action exception
- throw InvalidActionException("H5File createAttribute", "Attempted to create an existing attribute.");
+ throw InvalidActionException("H5File createAttribute",
+ "Attempted to create an existing attribute.");
}
- catch (AttributeIException& E) // catch creating existing attribute
- {} // do nothing, FAIL expected
+ catch (AttributeIException &E) // catch creating existing attribute
+ {
+ } // do nothing, FAIL expected
// Create a new dataset
- DataSet dataset(file5.createDataSet (DSETNAME, PredType::NATIVE_INT, space));
+ DataSet dataset(file5.createDataSet(DSETNAME, PredType::NATIVE_INT, space));
// Create an attribute for the dataset
Attribute dattr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space));
@@ -663,20 +668,18 @@ static void test_file_attribute()
if (rdata[i] != dattr_data[i]) {
H5_FAILED();
cerr << endl;
- cerr << "element [" << i << "] is " << rdata[i] <<
- "but should have been " << dattr_data[i] << endl;
- }
+ cerr << "element [" << i << "] is " << rdata[i] << "but should have been " << dattr_data[i]
+ << endl;
}
+ }
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_file_attribute()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_file_attribute()
+} // test_file_attribute()
-
/*-------------------------------------------------------------------------
* Function: test_libver_bounds_real
*
@@ -690,94 +693,92 @@ static void test_file_attribute()
* March, 2015
*-------------------------------------------------------------------------
*/
-const H5std_string FILE6("tfile5.h5");
-const H5std_string ROOTGROUP("/");
-const H5std_string GROUP1("/G1");
-const H5std_string SUBGROUP3("/G1/G3");
-
-static void test_libver_bounds_real(
- H5F_libver_t libver_create, unsigned oh_vers_create,
- H5F_libver_t libver_mod, unsigned oh_vers_mod)
+const H5std_string FILE6("tfile5.h5");
+const H5std_string ROOTGROUP("/");
+const H5std_string GROUP1("/G1");
+const H5std_string SUBGROUP3("/G1/G3");
+
+static void
+test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create, H5F_libver_t libver_mod,
+ unsigned oh_vers_mod)
{
try {
- /*
- * Create a new file using the default creation property and access property
- * with latest library version.
- */
- FileAccPropList fapl;
- fapl.setLibverBounds(libver_create, H5F_LIBVER_LATEST);
- H5File file(FILE6, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
+ /*
+ * Create a new file using the default creation property and access property
+ * with latest library version.
+ */
+ FileAccPropList fapl;
+ fapl.setLibverBounds(libver_create, H5F_LIBVER_LATEST);
+ H5File file(FILE6, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
- /*
- * Make sure the root group has the correct object header version
- */
- unsigned obj_version = file.childObjVersion(ROOTGROUP);
- verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);
-
- // Verify object header version another way
- H5O_native_info_t ninfo;
- HDmemset(&ninfo, 0, sizeof(ninfo));
- file.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_HDR);
- verify_val(ninfo.hdr.version, oh_vers_create, "H5File::getNativeObjinfo", __LINE__, __FILE__);
-
- /*
- * Reopen the file and make sure the root group still has the correct
- * version
- */
- file.close();
+ /*
+ * Make sure the root group has the correct object header version
+ */
+ unsigned obj_version = file.childObjVersion(ROOTGROUP);
+ verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);
- fapl.setLibverBounds(libver_mod, H5F_LIBVER_LATEST);
+ // Verify object header version another way
+ H5O_native_info_t ninfo;
+ HDmemset(&ninfo, 0, sizeof(ninfo));
+ file.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_HDR);
+ verify_val(ninfo.hdr.version, oh_vers_create, "H5File::getNativeObjinfo", __LINE__, __FILE__);
- file.openFile(FILE6, H5F_ACC_RDWR, fapl);
+ /*
+ * Reopen the file and make sure the root group still has the correct
+ * version
+ */
+ file.close();
- obj_version = file.childObjVersion(ROOTGROUP);
- verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);
+ fapl.setLibverBounds(libver_mod, H5F_LIBVER_LATEST);
- /*
- * Create a group named "/G1" in the file, and make sure it has the correct
- * object header version
- */
- Group group = file.createGroup(GROUP1);
+ file.openFile(FILE6, H5F_ACC_RDWR, fapl);
- obj_version = group.objVersion();
- verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__);
+ obj_version = file.childObjVersion(ROOTGROUP);
+ verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);
- // Verify object header version another way
- HDmemset(&ninfo, 0, sizeof(ninfo));
- group.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_HDR);
- verify_val(ninfo.hdr.version, oh_vers_mod, "Group::getNativeObjinfo", __LINE__, __FILE__);
+ /*
+ * Create a group named "/G1" in the file, and make sure it has the correct
+ * object header version
+ */
+ Group group = file.createGroup(GROUP1);
- group.close(); // close "/G1"
+ obj_version = group.objVersion();
+ verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__);
- /*
- * Create a group named "/G1/G3" in the file, and make sure it has the
- * correct object header version
- */
- group = file.createGroup(SUBGROUP3);
+ // Verify object header version another way
+ HDmemset(&ninfo, 0, sizeof(ninfo));
+ group.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_HDR);
+ verify_val(ninfo.hdr.version, oh_vers_mod, "Group::getNativeObjinfo", __LINE__, __FILE__);
- obj_version = group.objVersion();
- verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__);
+ group.close(); // close "/G1"
- group.close(); // close "/G1/G3"
+ /*
+ * Create a group named "/G1/G3" in the file, and make sure it has the
+ * correct object header version
+ */
+ group = file.createGroup(SUBGROUP3);
- /*
- * Make sure the root group still has the correct object header version
- */
- obj_version = file.childObjVersion(ROOTGROUP);
- verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);
+ obj_version = group.objVersion();
+ verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__);
- // Everything should be closed as they go out of scope
- } // end of try block
+ group.close(); // close "/G1/G3"
- catch (Exception& E)
- {
+ /*
+ * Make sure the root group still has the correct object header version
+ */
+ obj_version = file.childObjVersion(ROOTGROUP);
+ verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);
+
+ // Everything should be closed as they go out of scope
+ } // end of try block
+
+ catch (Exception &E) {
issue_fail_msg("test_libver_bounds_real()", __LINE__, __FILE__, E.getCDetailMsg());
}
} /* end test_libver_bounds_real() */
-
/*-------------------------------------------------------------------------
*
* Function: test_libver_bounds
@@ -791,7 +792,8 @@ static void test_libver_bounds_real(
* March 2015
*-------------------------------------------------------------------------
*/
-static void test_libver_bounds()
+static void
+test_libver_bounds()
{
// Output message about test being performed
SUBTEST("Setting library version bounds");
@@ -802,7 +804,6 @@ static void test_libver_bounds()
PASSED();
} /* end test_libver_bounds() */
-
/*-------------------------------------------------------------------------
* Function: test_commonfg
*
@@ -814,7 +815,8 @@ static void test_libver_bounds()
* March, 2015
*-------------------------------------------------------------------------
*/
-static void test_commonfg()
+static void
+test_commonfg()
{
// Output message about test being performed
SUBTEST("Root group");
@@ -830,11 +832,11 @@ static void test_commonfg()
Group group(rootgroup.createGroup(GROUPNAME, 0));
// Create the data space.
- hsize_t dims[RANK] = {NX, NY};
+ hsize_t dims[RANK] = {NX, NY};
DataSpace space(RANK, dims);
// Create a new dataset.
- DataSet dataset(group.createDataSet (DSETNAME, PredType::NATIVE_INT, space));
+ DataSet dataset(group.createDataSet(DSETNAME, PredType::NATIVE_INT, space));
// Get and verify file name via a dataset.
H5std_string file_name = dataset.getFileName();
@@ -855,16 +857,14 @@ static void test_commonfg()
verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__);
PASSED();
- } // end of try block
+ } // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_commonfg()", __LINE__, __FILE__, E.getCDetailMsg());
}
} /* end test_commonfg() */
-
/*-------------------------------------------------------------------------
* Function: test_file_info
*
@@ -879,16 +879,17 @@ static void test_commonfg()
*-------------------------------------------------------------------------
*/
const H5std_string FILE7("tfile7.h5");
-const hsize_t FSP_SIZE_DEF = 4096;
-const hsize_t FSP_SIZE512 = 512;
+const hsize_t FSP_SIZE_DEF = 4096;
+const hsize_t FSP_SIZE512 = 512;
-static void test_file_info()
+static void
+test_file_info()
{
// Output message about test being performed
SUBTEST("File general information");
- hsize_t out_threshold = 0; // Free space section threshold to get
- hbool_t out_persist = FALSE;// Persist free-space read
+ hsize_t out_threshold = 0; // Free space section threshold to get
+ hbool_t out_persist = FALSE; // Persist free-space read
// File space handling strategy
H5F_fspace_strategy_t out_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR;
@@ -919,7 +920,8 @@ static void test_file_info()
/* Retrieve file space page size */
hsize_t out_fsp_psize = fcpl.getFileSpacePagesize();
- verify_val(out_fsp_psize, FSP_SIZE_DEF, "FileCreatPropList::getFileSpacePagesize", __LINE__, __FILE__);
+ verify_val(out_fsp_psize, FSP_SIZE_DEF, "FileCreatPropList::getFileSpacePagesize", __LINE__,
+ __FILE__);
// Set various file information.
fcpl.setUserblock(F2_USERBLOCK_SIZE);
@@ -927,9 +929,9 @@ static void test_file_info()
fcpl.setSymk(F2_SYM_INTERN_K, F2_SYM_LEAF_K);
fcpl.setIstorek(F2_ISTORE);
- hsize_t threshold = 5; // Free space section threshold to set
- hbool_t persist = TRUE; // Persist free-space to set
- H5F_fspace_strategy_t strategy = H5F_FSPACE_STRATEGY_PAGE;
+ hsize_t threshold = 5; // Free space section threshold to set
+ hbool_t persist = TRUE; // Persist free-space to set
+ H5F_fspace_strategy_t strategy = H5F_FSPACE_STRATEGY_PAGE;
fcpl.setFileSpaceStrategy(strategy, persist, threshold);
fcpl.setFileSpacePagesize(FSP_SIZE512);
@@ -981,10 +983,10 @@ static void test_file_info()
unsigned istore_ik = fcpl2.getIstorek();
verify_val(istore_ik, F2_ISTORE, "FileCreatPropList::getIstorek", __LINE__, __FILE__);
- /* ret=H5Pget_shared_mesg_nindexes(fcpl2,&nindexes);
- CHECK(ret, FAIL, "H5Pget_shared_mesg_nindexes");
- VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes");
- */
+ /* ret=H5Pget_shared_mesg_nindexes(fcpl2,&nindexes);
+ CHECK(ret, FAIL, "H5Pget_shared_mesg_nindexes");
+ VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes");
+ */
// Get and verify the file space info from the creation property list */
fcpl2.getFileSpaceStrategy(out_strategy, out_persist, out_threshold);
@@ -996,14 +998,12 @@ static void test_file_info()
verify_val(out_fsp_psize, FSP_SIZE512, "FileCreatPropList::getFileSpacePagesize", __LINE__, __FILE__);
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_filespace_info()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} /* test_file_info() */
+} /* test_file_info() */
-
/*-------------------------------------------------------------------------
* Function: test_file
*
@@ -1015,24 +1015,23 @@ static void test_file_info()
* January 2001
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_file()
+extern "C" void
+test_file()
{
// Output message about test being performed
MESSAGE(5, ("Testing File I/O Operations\n"));
- test_file_create(); // Test file creation (also creation templates)
- test_file_open(); // Test file opening
- test_file_size(); // Test file size
- test_file_num(); // Test file number
- test_file_name(); // Test getting file's name
- test_file_attribute(); // Test file attribute feature
- test_libver_bounds(); // Test format version
- test_commonfg(); // Test H5File as a root group
- test_file_info(); // Test various file info
-} // test_file()
-
-
+ test_file_create(); // Test file creation (also creation templates)
+ test_file_open(); // Test file opening
+ test_file_size(); // Test file size
+ test_file_num(); // Test file number
+ test_file_name(); // Test getting file's name
+ test_file_attribute(); // Test file attribute feature
+ test_libver_bounds(); // Test format version
+ test_commonfg(); // Test H5File as a root group
+ test_file_info(); // Test various file info
+} // test_file()
+
/*-------------------------------------------------------------------------
* Function: cleanup_file
*
@@ -1044,7 +1043,8 @@ void test_file()
#ifdef __cplusplus
extern "C"
#endif
-void cleanup_file()
+ void
+ cleanup_file()
{
HDremove(FILE1.c_str());
HDremove(FILE2.c_str());
@@ -1053,4 +1053,4 @@ void cleanup_file()
HDremove(FILE5.c_str());
HDremove(FILE6.c_str());
HDremove(FILE7.c_str());
-} // cleanup_file
+} // cleanup_file
diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp
index 5a493ac..e7788e5 100644
--- a/c++/test/tfilter.cpp
+++ b/c++/test/tfilter.cpp
@@ -25,14 +25,14 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
-#define DSET_DIM1 100
-#define DSET_DIM2 200
+#define DSET_DIM1 100
+#define DSET_DIM2 200
#define FILTER_CHUNK_DIM1 2
#define FILTER_CHUNK_DIM2 25
@@ -56,16 +56,15 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts,
static size_t filter_bogus(size_t nbytes);
/* This message derives from H5Z */
const H5Z_class2_t H5Z_BOGUS[1] = {{
- H5Z_CLASS_T_VERS, /* H5Z_class_t version */
- H5Z_FILTER_BOGUS, /* Filter id number */
- 1, 1, /* Encoding and decoding enabled */
- "bogus", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
- (H5Z_func_t)filter_bogus, /* The actual filter function */
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ H5Z_FILTER_BOGUS, /* Filter id number */
+ 1, 1, /* Encoding and decoding enabled */
+ "bogus", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ (H5Z_func_t)filter_bogus, /* The actual filter function */
}};
-
/*-------------------------------------------------------------------------
* Function: filter_bogus
*
@@ -90,7 +89,6 @@ filter_bogus(size_t nbytes)
return nbytes;
}
-
/*-------------------------------------------------------------------------
* Function: test_null_filter
*
@@ -107,25 +105,26 @@ filter_bogus(size_t nbytes)
*/
const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2};
-static void test_null_filter()
+static void
+test_null_filter()
{
// Output message about test being performed
SUBTEST("'Null' filter");
try {
- //hsize_t null_size; // Size of dataset with null filter
+ // hsize_t null_size; // Size of dataset with null filter
// Prepare dataset create property list
DSetCreatPropList dsplist;
dsplist.setChunk(2, chunk_size);
- if (H5Zregister (H5Z_BOGUS)<0)
+ if (H5Zregister(H5Z_BOGUS) < 0)
throw Exception("test_null_filter", "H5Zregister failed");
// Set some pretent filter
dsplist.setFilter(H5Z_FILTER_BOGUS);
// this function is just a stub right now; will work on it later - BMR
- //if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0)
+ // if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0)
// throw Exception("test_null_filter", "test_filter_internal failed");
// Close objects.
@@ -134,13 +133,11 @@ static void test_null_filter()
} // end of try
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_null_filter()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_null_filter
+} // test_null_filter
-
/*-------------------------------------------------------------------------
* Function: test_szip_filter
*
@@ -157,28 +154,29 @@ static void test_null_filter()
*/
const H5std_string DSET_SZIP_NAME("szipped dataset");
-static void test_szip_filter(H5File& file1)
+static void
+test_szip_filter(H5File &file1)
{
#ifdef H5_HAVE_FILTER_SZIP
int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2];
- unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK;
- unsigned szip_pixels_per_block=4;
+ unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK;
+ unsigned szip_pixels_per_block = 4;
// Output message about test being performed
SUBTEST("szip filter (with encoder)");
- if ( h5_szip_can_encode() == 1) {
- char* tconv_buf = new char [1000];
+ if (h5_szip_can_encode() == 1) {
+ char *tconv_buf = new char[1000];
try {
- const hsize_t size[2] = {DSET_DIM1, DSET_DIM2};
+ const hsize_t size[2] = {DSET_DIM1, DSET_DIM2};
// Create the data space
DataSpace space1(2, size, NULL);
// Create a small conversion buffer to test strip mining (?)
DSetMemXferPropList xfer;
- xfer.setBuffer (1000, tconv_buf, NULL);
+ xfer.setBuffer(1000, tconv_buf, NULL);
// Prepare dataset create property list
DSetCreatPropList dsplist;
@@ -188,27 +186,24 @@ static void test_szip_filter(H5File& file1)
dsplist.setSzip(szip_options_mask, szip_pixels_per_block);
// Create a dataset with szip compression
- DataSpace space2 (2, size, NULL);
- DataSet dataset(file1.createDataSet (DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist));
+ DataSpace space2(2, size, NULL);
+ DataSet dataset(file1.createDataSet(DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist));
hsize_t i, j, n;
- for (i=n=0; i<size[0]; i++)
- {
- for (j=0; j<size[1]; j++)
- {
+ for (i = n = 0; i < size[0]; i++) {
+ for (j = 0; j < size[1]; j++) {
points[i][j] = (int)n++;
}
}
// Write to the dataset then read back the values
- dataset.write ((void*)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
- dataset.read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.write((void *)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.read((void *)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < size[0]; i++)
- for (j = 0; j < size[1]; j++)
- {
- int status = check_values (i, j, points[i][j], check[i][j]);
+ for (j = 0; j < size[1]; j++) {
+ int status = check_values(i, j, points[i][j], check[i][j]);
if (status == -1)
throw Exception("test_szip_filter", "Failed in testing szip method");
}
@@ -217,8 +212,7 @@ static void test_szip_filter(H5File& file1)
} // end of try
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_szip_filter()", __LINE__, __FILE__, E.getCDetailMsg());
}
@@ -228,15 +222,14 @@ static void test_szip_filter(H5File& file1)
SKIPPED();
}
-#else /* H5_HAVE_FILTER_SZIP */
+#else /* H5_HAVE_FILTER_SZIP */
SUBTEST("szip filter");
SKIPPED();
H5std_string fname = file1.getFileName();
cerr << " Szip filter not enabled for file '" << fname << "'" << endl;
#endif /* H5_HAVE_FILTER_SZIP */
-} // test_szip_filter
+} // test_szip_filter
-
/*-------------------------------------------------------------------------
* Function: test_filters
*
@@ -245,18 +238,17 @@ static void test_szip_filter(H5File& file1)
* Return None
*-------------------------------------------------------------------------
*/
-const H5std_string FILE1("tfilters.h5");
-extern "C"
-void test_filters()
+const H5std_string FILE1("tfilters.h5");
+extern "C" void
+test_filters()
{
// Output message about test being performed
MESSAGE(5, ("Testing Various Filters\n"));
- hid_t fapl_id;
+ hid_t fapl_id;
fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template
- try
- {
+ try {
// Use the file access template id to create a file access prop. list
FileAccPropList fapl(fapl_id);
@@ -266,13 +258,11 @@ void test_filters()
test_null_filter();
test_szip_filter(file1);
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_filters()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_filters()
+} // test_filters()
-
/*-------------------------------------------------------------------------
* Function: cleanup_filters
*
@@ -281,8 +271,8 @@ void test_filters()
* Return none
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_filters()
+extern "C" void
+cleanup_filters()
{
HDremove(FILE1.c_str());
}
diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp
index d4853da..8709c25 100644
--- a/c++/test/th5s.cpp
+++ b/c++/test/th5s.cpp
@@ -28,39 +28,39 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
-#include "H5srcdir.h" // srcdir querying header file
+#include "h5cpputil.h" // C++ utilility header file
+#include "H5srcdir.h" // srcdir querying header file
-const H5std_string TESTFILE("th5s.h5");
-const H5std_string DATAFILE("th5s1.h5");
+const H5std_string TESTFILE("th5s.h5");
+const H5std_string DATAFILE("th5s1.h5");
/* 3-D dataset with fixed dimensions */
const H5std_string SPACE1_NAME("Space1");
-const int SPACE1_RANK = 3;
-const int SPACE1_DIM1 = 3;
-const int SPACE1_DIM2 = 15;
-const int SPACE1_DIM3 = 13;
+const int SPACE1_RANK = 3;
+const int SPACE1_DIM1 = 3;
+const int SPACE1_DIM2 = 15;
+const int SPACE1_DIM3 = 13;
/* 4-D dataset with one unlimited dimension */
const H5std_string SPACE2_NAME("Space2");
-const int SPACE2_RANK = 4;
-const int SPACE2_DIM1 = 0;
-const int SPACE2_DIM2 = 15;
-const int SPACE2_DIM3 = 13;
-const int SPACE2_DIM4 = 23;
-const hsize_t SPACE2_MAX1 = H5S_UNLIMITED;
-const hsize_t SPACE2_MAX2 = 15;
-const hsize_t SPACE2_MAX3 = 13;
-const hsize_t SPACE2_MAX4 = 23;
+const int SPACE2_RANK = 4;
+const int SPACE2_DIM1 = 0;
+const int SPACE2_DIM2 = 15;
+const int SPACE2_DIM3 = 13;
+const int SPACE2_DIM4 = 23;
+const hsize_t SPACE2_MAX1 = H5S_UNLIMITED;
+const hsize_t SPACE2_MAX2 = 15;
+const hsize_t SPACE2_MAX3 = 13;
+const hsize_t SPACE2_MAX4 = 23;
/* Scalar dataset with simple datatype */
const H5std_string SPACE3_NAME("Scalar1");
-const int SPACE3_RANK = 0;
-unsigned space3_data=65;
+const int SPACE3_RANK = 0;
+unsigned space3_data = 65;
/* Scalar dataset with compound datatype */
const H5std_string SPACE4_NAME("Scalar2");
@@ -68,21 +68,20 @@ const H5std_string SPACE4_FIELDNAME1("c1");
const H5std_string SPACE4_FIELDNAME2("u");
const H5std_string SPACE4_FIELDNAME3("f");
const H5std_string SPACE4_FIELDNAME4("c2");
-size_t space4_field1_off=0;
-size_t space4_field2_off=0;
-size_t space4_field3_off=0;
-size_t space4_field4_off=0;
+size_t space4_field1_off = 0;
+size_t space4_field2_off = 0;
+size_t space4_field3_off = 0;
+size_t space4_field4_off = 0;
struct space4_struct {
- char c1;
+ char c1;
unsigned u;
- float f;
- char c2;
- } space4_data={'v',987123,(float)-3.14,'g'}; /* Test data for 4th dataspace */
+ float f;
+ char c2;
+} space4_data = {'v', 987123, (float)-3.14, 'g'}; /* Test data for 4th dataspace */
/* Null dataspace */
int space5_data = 7;
-
/*-------------------------------------------------------------------------
* Function: test_h5s_basic
*
@@ -105,11 +104,12 @@ int space5_data = 7;
* size to be zero. So I took out the test against it.
*-------------------------------------------------------------------------
*/
-static void test_h5s_basic()
+static void
+test_h5s_basic()
{
hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4};
- hsize_t dims3[H5S_MAX_RANK+1];
+ hsize_t dims3[H5S_MAX_RANK + 1];
hsize_t tmax[4];
// Output message about test being performed
@@ -117,13 +117,13 @@ static void test_h5s_basic()
try {
// Create simple dataspace sid1
- DataSpace sid1 (SPACE1_RANK, dims1 );
+ DataSpace sid1(SPACE1_RANK, dims1);
// Get simple extent npoints of the dataspace sid1 and verify it
hssize_t n; // Number of dataspace elements
n = sid1.getSimpleExtentNpoints();
verify_val((long)n, (long)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3),
- "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of dataspace sid1 and verify it
int rank; // Logical rank of dataspace
@@ -131,21 +131,21 @@ static void test_h5s_basic()
verify_val(rank, SPACE1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
// Retrieves dimension size of dataspace sid1 and verify it
- int ndims; // Number of dimensions
+ int ndims; // Number of dimensions
hsize_t tdims[4]; // Dimension array to test with
- ndims = sid1.getSimpleExtentDims( tdims );
+ ndims = sid1.getSimpleExtentDims(tdims);
verify_val(ndims, SPACE1_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
verify_val(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(unsigned)), 0,
- "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
+ "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
// Create simple dataspace sid2
- hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4};
- DataSpace sid2 (SPACE2_RANK, dims2, max2);
+ hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4};
+ DataSpace sid2(SPACE2_RANK, dims2, max2);
// Get simple extent npoints of dataspace sid2 and verify it
n = sid2.getSimpleExtentNpoints();
verify_val((long)n, (long)(SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4),
- "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of dataspace sid2 and verify it
rank = sid2.getSimpleExtentNdims();
@@ -153,34 +153,36 @@ static void test_h5s_basic()
// Retrieves dimension size and max size of dataspace sid2 and
// verify them
- ndims = sid2.getSimpleExtentDims( tdims, tmax );
+ ndims = sid2.getSimpleExtentDims(tdims, tmax);
verify_val(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(unsigned)), 0,
- "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
- verify_val(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0,
- "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
+ "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
+ verify_val(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0, "DataSpace::getSimpleExtentDims",
+ __LINE__, __FILE__);
// Check to be sure we can't create a simple data space that has too
// many dimensions.
try {
- DataSpace manydims_ds(H5S_MAX_RANK+1, dims3, NULL);
+ DataSpace manydims_ds(H5S_MAX_RANK + 1, dims3, NULL);
// Should FAIL but didn't, so throw an invalid action exception
- throw InvalidActionException("DataSpace constructor", "Library allowed overwrite of existing dataset");
+ throw InvalidActionException("DataSpace constructor",
+ "Library allowed overwrite of existing dataset");
}
- catch (DataSpaceIException& E) // Simple data space with too many dims
- {} // do nothing, exception expected
-
- /*
- * Try reading a file that has been prepared that has a dataset with a
- * higher dimensionality than what the library can handle.
- *
- * If this test fails and the H5S_MAX_RANK variable has changed, follow
- * the instructions in space_overflow.c for regenating the th5s.h5 file.
- */
- char *tmp_str = new char[TESTFILE.length()+1];
+ catch (DataSpaceIException &E) // Simple data space with too many dims
+ {
+ } // do nothing, exception expected
+
+ /*
+ * Try reading a file that has been prepared that has a dataset with a
+ * higher dimensionality than what the library can handle.
+ *
+ * If this test fails and the H5S_MAX_RANK variable has changed, follow
+ * the instructions in space_overflow.c for regenating the th5s.h5 file.
+ */
+ char *tmp_str = new char[TESTFILE.length() + 1];
strcpy(tmp_str, TESTFILE.c_str());
const char *testfile = H5_get_srcdir_filename(tmp_str);
- delete []tmp_str;
+ delete[] tmp_str;
// Create file
H5File fid1(testfile, H5F_ACC_RDONLY);
@@ -188,33 +190,33 @@ static void test_h5s_basic()
// Try to open the dataset that has higher dimensionality than
// what the library can handle and this operation should fail.
try {
- DataSet dset1 = fid1.openDataSet( "dset" );
+ DataSet dset1 = fid1.openDataSet("dset");
// Should FAIL but didn't, so throw an invalid action exception
- throw InvalidActionException("H5File::openDataSet", "Opening a dataset with higher dimensionality than what the library can handle");
+ throw InvalidActionException(
+ "H5File::openDataSet",
+ "Opening a dataset with higher dimensionality than what the library can handle");
}
- catch (FileIException& E) // catching higher dimensionality dataset
- {} // do nothing, exception expected
+ catch (FileIException &E) // catching higher dimensionality dataset
+ {
+ } // do nothing, exception expected
- // CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure
- // in the p_close see how this will handle it. - BMR
+ // CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure
+ // in the p_close see how this will handle it. - BMR
PASSED();
- } // end of try block
+ } // end of try block
- catch (InvalidActionException& E)
- {
+ catch (InvalidActionException &E) {
cerr << " FAILED" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
}
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_h5s_basic()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_h5s_basic()
+} // test_h5s_basic()
-
/*-------------------------------------------------------------------------
* Function: test_h5s_scalar_write
*
@@ -234,7 +236,8 @@ static void test_h5s_basic()
* with a special routine.
*-------------------------------------------------------------------------
*/
-static void test_h5s_scalar_write()
+static void
+test_h5s_scalar_write()
{
// Output message about test being performed
SUBTEST("Scalar Dataspace Writing");
@@ -246,7 +249,7 @@ static void test_h5s_scalar_write()
// Create scalar dataspace
DataSpace sid1(SPACE3_RANK, NULL);
- //n = H5Sget_simple_extent_npoints(sid1);
+ // n = H5Sget_simple_extent_npoints(sid1);
hssize_t n; // Number of dataspace elements
n = sid1.getSimpleExtentNpoints();
verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
@@ -256,9 +259,9 @@ static void test_h5s_scalar_write()
verify_val(rank, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
// Retrieves dimension size of dataspace sid1 and verify it
- int ndims; // Number of dimensions
+ int ndims; // Number of dimensions
hsize_t tdims[4]; // Dimension array to test with
- ndims = sid1.getSimpleExtentDims( tdims );
+ ndims = sid1.getSimpleExtentDims(tdims);
verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
// Verify extent type
@@ -267,18 +270,16 @@ static void test_h5s_scalar_write()
verify_val(ext_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__);
// Create and write a dataset
- DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1);
+ DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1);
dataset.write(&space3_data, PredType::NATIVE_UINT);
PASSED();
} // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_h5s_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_h5s_scalar_write()
+} // test_h5s_scalar_write()
-
/*-------------------------------------------------------------------------
* Function: test_h5s_scalar_read
*
@@ -298,7 +299,8 @@ static void test_h5s_scalar_write()
* with a special routine.
*-------------------------------------------------------------------------
*/
-static void test_h5s_scalar_read()
+static void
+test_h5s_scalar_read()
{
hsize_t tdims[4]; // Dimension array to test with
@@ -331,16 +333,14 @@ static void test_h5s_scalar_read()
verify_val(rdata, space3_data, "DataSet::read", __LINE__, __FILE__);
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
// all the exceptions caused by negative returned values by C APIs
issue_fail_msg("test_h5s_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_h5s_scalar_read()
+} // test_h5s_scalar_read()
-
/*-------------------------------------------------------------------------
* Function: test_h5s_null
*
@@ -360,7 +360,8 @@ static void test_h5s_scalar_read()
* with a special routine.
*-------------------------------------------------------------------------
*/
-static void test_h5s_null()
+static void
+test_h5s_null()
{
// Output message about test being performed
SUBTEST("Null Dataspace Writing");
@@ -377,7 +378,7 @@ static void test_h5s_null()
verify_val((long)n, 0, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Create a dataset
- DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1);
+ DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1);
// Try to write nothing to the dataset
dataset.write(&space5_data, PredType::NATIVE_INT);
@@ -388,13 +389,11 @@ static void test_h5s_null()
PASSED();
} // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_h5s_null()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_h5s_null()
+} // test_h5s_null()
-
/*-------------------------------------------------------------------------
* Function: test_h5s_compound_scalar_write
*
@@ -415,7 +414,8 @@ static void test_h5s_null()
* with a special routine.
*-------------------------------------------------------------------------
*/
-static void test_h5s_compound_scalar_write()
+static void
+test_h5s_compound_scalar_write()
{
// Output message about test being performed
SUBTEST("Compound Dataspace Writing");
@@ -426,18 +426,14 @@ static void test_h5s_compound_scalar_write()
// Create the compound datatype.
CompType tid1(sizeof(struct space4_struct));
- space4_field1_off=HOFFSET(struct space4_struct, c1);
- tid1.insertMember(SPACE4_FIELDNAME1, space4_field1_off,
- PredType::NATIVE_SCHAR);
- space4_field2_off=HOFFSET(struct space4_struct, u);
- tid1.insertMember(SPACE4_FIELDNAME2, space4_field2_off,
- PredType::NATIVE_UINT);
- space4_field3_off=HOFFSET(struct space4_struct, f);
- tid1.insertMember(SPACE4_FIELDNAME3, space4_field3_off,
- PredType::NATIVE_FLOAT);
- space4_field4_off=HOFFSET(struct space4_struct, c2);
- tid1.insertMember(SPACE4_FIELDNAME4, space4_field4_off,
- PredType::NATIVE_SCHAR);
+ space4_field1_off = HOFFSET(struct space4_struct, c1);
+ tid1.insertMember(SPACE4_FIELDNAME1, space4_field1_off, PredType::NATIVE_SCHAR);
+ space4_field2_off = HOFFSET(struct space4_struct, u);
+ tid1.insertMember(SPACE4_FIELDNAME2, space4_field2_off, PredType::NATIVE_UINT);
+ space4_field3_off = HOFFSET(struct space4_struct, f);
+ tid1.insertMember(SPACE4_FIELDNAME3, space4_field3_off, PredType::NATIVE_FLOAT);
+ space4_field4_off = HOFFSET(struct space4_struct, c2);
+ tid1.insertMember(SPACE4_FIELDNAME4, space4_field4_off, PredType::NATIVE_SCHAR);
// Create scalar dataspace
DataSpace sid1(SPACE3_RANK, NULL);
@@ -459,15 +455,13 @@ static void test_h5s_compound_scalar_write()
dataset.write(&space4_data, tid1);
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
// all the exceptions caused by negative returned values by C APIs
issue_fail_msg("test_h5s_compound_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_h5s_compound_scalar_write()
+} // test_h5s_compound_scalar_write()
-
/*-------------------------------------------------------------------------
* Function: test_h5s_compound_scalar_read
*
@@ -488,7 +482,8 @@ static void test_h5s_compound_scalar_write()
* with a special routine.
*-------------------------------------------------------------------------
*/
-static void test_h5s_compound_scalar_read()
+static void
+test_h5s_compound_scalar_read()
{
hsize_t tdims[4]; // Dimension array to test with
@@ -521,27 +516,24 @@ static void test_h5s_compound_scalar_read()
dataset.read(&rdata, type);
// Verify read data
- if(HDmemcmp(&space4_data,&rdata,sizeof(struct space4_struct)))
- {
- cerr << "scalar data different: space4_data.c1="
- << space4_data.c1 << ", read_data4.c1=" << rdata.c1 << endl;
- cerr << "scalar data different: space4_data.u="
- << space4_data.u << ", read_data4.u=" << rdata.u << endl;
- cerr << "scalar data different: space4_data.f="
- << space4_data.f << ", read_data4.f=" << rdata.f << endl;
- TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n",
- space4_data.c1, rdata.c2);
+ if (HDmemcmp(&space4_data, &rdata, sizeof(struct space4_struct))) {
+ cerr << "scalar data different: space4_data.c1=" << space4_data.c1
+ << ", read_data4.c1=" << rdata.c1 << endl;
+ cerr << "scalar data different: space4_data.u=" << space4_data.u << ", read_data4.u=" << rdata.u
+ << endl;
+ cerr << "scalar data different: space4_data.f=" << space4_data.f << ", read_data4.f=" << rdata.f
+ << endl;
+ TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", space4_data.c1,
+ rdata.c2);
} // end if
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
// all the exceptions caused by negative returned values by C APIs
issue_fail_msg("test_h5s_compound_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_h5s_compound_scalar_read()
+} // test_h5s_compound_scalar_read()
-
/*-------------------------------------------------------------------------
* Function: test_h5s
*
@@ -553,21 +545,20 @@ static void test_h5s_compound_scalar_read()
* Mar 2001
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_h5s()
+extern "C" void
+test_h5s()
{
// Output message about test being performed
MESSAGE(5, ("Testing Dataspaces\n"));
- test_h5s_basic(); // Test basic H5S code
- test_h5s_scalar_write(); // Test scalar H5S writing code
- test_h5s_scalar_read(); // Test scalar H5S reading code
- test_h5s_null(); // Test null H5S code
- test_h5s_compound_scalar_write(); // Test compound datatype scalar H5S writing code
- test_h5s_compound_scalar_read(); // Test compound datatype scalar H5S reading code
-} // test_h5s()
+ test_h5s_basic(); // Test basic H5S code
+ test_h5s_scalar_write(); // Test scalar H5S writing code
+ test_h5s_scalar_read(); // Test scalar H5S reading code
+ test_h5s_null(); // Test null H5S code
+ test_h5s_compound_scalar_write(); // Test compound datatype scalar H5S writing code
+ test_h5s_compound_scalar_read(); // Test compound datatype scalar H5S reading code
+} // test_h5s()
-
/*-------------------------------------------------------------------------
* Function: cleanup_h5s
*
@@ -576,9 +567,8 @@ void test_h5s()
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_h5s()
+extern "C" void
+cleanup_h5s()
{
HDremove(DATAFILE.c_str());
-} // cleanup_h5s
-
+} // cleanup_h5s
diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp
index d69e8d2..83229b9 100644
--- a/c++/test/titerate.cpp
+++ b/c++/test/titerate.cpp
@@ -25,11 +25,11 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
/* Number of datasets for group iteration test */
#define NDATASETS 50
@@ -41,53 +41,48 @@ using namespace H5;
//#define ITER_NGROUPS 150
/* General maximum length of names used */
-#define NAMELEN 80
+#define NAMELEN 80
/* 1-D dataset with fixed dimensions */
//#define SPACE1_RANK 1
//#define SPACE1_DIM1 4
-const H5std_string FILE_ITERATE("titerate.h5");
-const H5std_string GROUP1("Top Group");
-const H5std_string GROUP1_PATH("/Top Group");
-const H5std_string GROUP1_1("Sub-Group 1.1");
-const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1");
-const H5std_string GROUP1_2("Sub-Group 1.2");
-const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2");
-const H5std_string DSET_DEFAULT_NAME("default");
-const H5std_string DSET_IN_FILE("Dataset in File");
-const H5std_string DSET_IN_FILE_PATH("/Dataset in File");
-const H5std_string DSET_IN_GRP1("Dataset in Group 1");
-const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1");
-const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2");
-const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2");
-
-typedef enum {
- RET_ZERO,
- RET_TWO,
- RET_CHANGE,
- RET_CHANGE2
-} iter_enum;
+const H5std_string FILE_ITERATE("titerate.h5");
+const H5std_string GROUP1("Top Group");
+const H5std_string GROUP1_PATH("/Top Group");
+const H5std_string GROUP1_1("Sub-Group 1.1");
+const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1");
+const H5std_string GROUP1_2("Sub-Group 1.2");
+const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2");
+const H5std_string DSET_DEFAULT_NAME("default");
+const H5std_string DSET_IN_FILE("Dataset in File");
+const H5std_string DSET_IN_FILE_PATH("/Dataset in File");
+const H5std_string DSET_IN_GRP1("Dataset in Group 1");
+const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1");
+const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2");
+const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2");
+
+typedef enum { RET_ZERO, RET_TWO, RET_CHANGE, RET_CHANGE2 } iter_enum;
/* Custom group iteration callback data */
typedef struct {
- char name[NAMELEN]; /* The name of the object */
- H5O_type_t type; /* The type of the object */
- iter_enum command; /* The type of return value */
+ char name[NAMELEN]; /* The name of the object */
+ H5O_type_t type; /* The type of the object */
+ iter_enum command; /* The type of return value */
} iter_info;
int iter_strcmp(const void *s1, const void *s2);
-
/*-------------------------------------------------------------------------
* Function: iter_strcmp
*
* Purpose String comparison routine for qsort
*-------------------------------------------------------------------------
*/
-int iter_strcmp(const void *s1, const void *s2)
+int
+iter_strcmp(const void *s1, const void *s2)
{
- return(HDstrcmp(*(const char * const *)s1,*(const char * const *)s2));
+ return (HDstrcmp(*(const char *const *)s1, *(const char *const *)s2));
}
/*-------------------------------------------------------------------------
@@ -96,36 +91,37 @@ int iter_strcmp(const void *s1, const void *s2)
* Purpose Custom link iteration callback routine
*-------------------------------------------------------------------------
*/
-static herr_t liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link_info, void *op_data)
+static herr_t
+liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link_info,
+ void *op_data)
{
- iter_info *info = (iter_info *)op_data;
- static int count = 0;
+ iter_info *info = (iter_info *)op_data;
+ static int count = 0;
static int count2 = 0;
HDstrcpy(info->name, name);
- switch(info->command) {
+ switch (info->command) {
case RET_ZERO:
- return(0);
+ return (0);
case RET_TWO:
- return(2);
+ return (2);
case RET_CHANGE:
count++;
- return(count > 10 ? 1 : 0);
+ return (count > 10 ? 1 : 0);
case RET_CHANGE2:
count2++;
- return(count2 > 10 ? 1 : 0);
+ return (count2 > 10 ? 1 : 0);
default:
printf("invalid iteration command");
- return(-1);
+ return (-1);
} /* end switch */
} /* end liter_cb() */
-
/*-------------------------------------------------------------------------
* Function: test_iter_group
*
@@ -138,14 +134,15 @@ static herr_t liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_i
* Friday, September 9, 2016
*-------------------------------------------------------------------------
*/
-static void test_iter_group(FileAccPropList& fapl)
+static void
+test_iter_group(FileAccPropList &fapl)
{
- int i; /* counting variable */
- hsize_t idx; /* Index in the group */
- char name[NAMELEN]; /* temporary name buffer */
- char *lnames[NDATASETS + 2];/* Names of the links created */
- iter_info info; /* Custom iteration information */
- herr_t ret; /* Generic return value */
+ int i; /* counting variable */
+ hsize_t idx; /* Index in the group */
+ char name[NAMELEN]; /* temporary name buffer */
+ char * lnames[NDATASETS + 2]; /* Names of the links created */
+ iter_info info; /* Custom iteration information */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
SUBTEST("Group Iteration");
@@ -157,8 +154,8 @@ static void test_iter_group(FileAccPropList& fapl)
/* Test iterating over empty group */
info.command = RET_ZERO;
- idx = 0;
- ret = H5Literate2(file.getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info);
+ idx = 0;
+ ret = H5Literate2(file.getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info);
verify_val(ret, SUCCEED, "H5Literate", __LINE__, __FILE__);
DataType datatype(PredType::NATIVE_INT);
@@ -166,16 +163,15 @@ static void test_iter_group(FileAccPropList& fapl)
// Create a scalar file space
DataSpace filespace;
- for (i=0; i< NDATASETS; i++)
- {
- sprintf(name, "Dataset %d", i);
+ for (i = 0; i < NDATASETS; i++) {
+ sprintf(name, "Dataset %d", i);
- // Create a dataset in the file
- DataSet dataset = file.createDataSet(name, datatype, filespace);
+ // Create a dataset in the file
+ DataSet dataset = file.createDataSet(name, datatype, filespace);
- /* Keep a copy of the dataset names */
- lnames[i] = HDstrdup(name);
- check_values(lnames[i], "HDstrdup returns NULL", __LINE__, __FILE__);
+ /* Keep a copy of the dataset names */
+ lnames[i] = HDstrdup(name);
+ check_values(lnames[i], "HDstrdup returns NULL", __LINE__, __FILE__);
} /* end for */
@@ -191,7 +187,6 @@ static void test_iter_group(FileAccPropList& fapl)
/* Sort the dataset names */
HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
-
/* Iterate through the datasets in the root group in various ways */
// Open data file to read
@@ -205,15 +200,16 @@ static void test_iter_group(FileAccPropList& fapl)
verify_val(nobjs, (hsize_t)(NDATASETS + 2), "H5Gget_info", __LINE__, __FILE__);
H5std_string obj_name;
- for (i = 0; i < nobjs; i++)
- {
- //H5O_info2_t oinfo; /* Object info */
+ for (i = 0; i < nobjs; i++) {
+ // H5O_info2_t oinfo; /* Object info */
obj_name = root_group.getObjnameByIdx(i);
- //ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, (size_t)NAMELEN, H5P_DEFAULT);
+ // ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i,
+ // dataset_name, (size_t)NAMELEN, H5P_DEFAULT);
- //oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, ".");
- //ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT);
+ // oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, ".");
+ // ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo,
+ // H5P_DEFAULT);
} /* end for */
// Attempted to iterate with invalid index, should fail
@@ -223,63 +219,69 @@ static void test_iter_group(FileAccPropList& fapl)
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with invalid index");
}
- catch (GroupIException& invalid_action) // invalid index
- {} // do nothing, exception expected
+ catch (GroupIException &invalid_action) // invalid index
+ {
+ } // do nothing, exception expected
// Attempted to iterate with negative index, should fail
try {
info.command = RET_ZERO;
- idx = (hsize_t)-1;
- obj_name = root_group.getObjnameByIdx(idx);
+ idx = (hsize_t)-1;
+ obj_name = root_group.getObjnameByIdx(idx);
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index");
}
- catch (FileIException& invalid_action) // invalid index
- {} // do nothing, exception expected
- catch (GroupIException& invalid_action) // invalid index
- {} // do nothing, exception expected
+ catch (FileIException &invalid_action) // invalid index
+ {
+ } // do nothing, exception expected
+ catch (GroupIException &invalid_action) // invalid index
+ {
+ } // do nothing, exception expected
/* Test skipping exactly as many entries as in the group */
try {
info.command = RET_ZERO;
- idx = NDATASETS + 2;
- obj_name = root_group.getObjnameByIdx(idx);
+ idx = NDATASETS + 2;
+ obj_name = root_group.getObjnameByIdx(idx);
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index");
}
- catch (FileIException& invalid_action) // invalid index
- {} // do nothing, exception expected
- catch (GroupIException& invalid_action) // invalid index
- {} // do nothing, exception expected
+ catch (FileIException &invalid_action) // invalid index
+ {
+ } // do nothing, exception expected
+ catch (GroupIException &invalid_action) // invalid index
+ {
+ } // do nothing, exception expected
/* Test skipping more entries than are in the group */
try {
info.command = RET_ZERO;
- idx = NDATASETS + 3;
- obj_name = root_group.getObjnameByIdx(idx);
+ idx = NDATASETS + 3;
+ obj_name = root_group.getObjnameByIdx(idx);
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index");
}
- catch (FileIException& invalid_action) // invalid index
- {} // do nothing, exception expected
- catch (GroupIException& invalid_action) // invalid index
- {} // do nothing, exception expected
+ catch (FileIException &invalid_action) // invalid index
+ {
+ } // do nothing, exception expected
+ catch (GroupIException &invalid_action) // invalid index
+ {
+ } // do nothing, exception expected
/* Free the dataset names */
- for(i = 0; i< (NDATASETS + 2); i++)
+ for (i = 0; i < (NDATASETS + 2); i++)
HDfree(lnames[i]);
// Everything will be closed as they go out of scope
PASSED();
- } // try block
+ } // try block
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_iter_group", __LINE__, __FILE__);
}
@@ -348,7 +350,6 @@ static void test_iter_group(FileAccPropList& fapl)
#endif
} /* test_iter_group() */
-
/*-------------------------------------------------------------------------
* Function: printelems
*
@@ -362,31 +363,29 @@ const H5std_string GDATASET_NAME("group dset");
const H5std_string ATTR_NAME("Units");
const H5std_string FATTR_NAME("F attr");
const H5std_string GATTR_NAME("G attr");
-const int DIM1 = 2;
-void printelems(const Group& group, const H5std_string& dsname, const H5std_string& atname)
+const int DIM1 = 2;
+void
+printelems(const Group &group, const H5std_string &dsname, const H5std_string &atname)
{
- try
- {
- DataSet d1(group.openDataSet(dsname));
+ try {
+ DataSet d1(group.openDataSet(dsname));
DataSpace s1 = d1.getSpace();
s1.close();
d1.close();
- unsigned idx = 0;
- Attribute a1(group.openAttribute(idx));
+ unsigned idx = 0;
+ Attribute a1(group.openAttribute(idx));
H5std_string aname = a1.getName();
verify_val(aname, atname, "printelems", __LINE__, __FILE__);
a1.close();
- }
+ }
// Catch all exceptions and rethrow so caller can handle
- catch (Exception& E)
- {
+ catch (Exception &E) {
throw;
}
}
-
/*-------------------------------------------------------------------------
* Function: test_HDFFV_9920
*
@@ -396,33 +395,31 @@ void printelems(const Group& group, const H5std_string& dsname, const H5std_stri
* Friday, September 9, 2016
*-------------------------------------------------------------------------
*/
-static void test_HDFFV_9920()
+static void
+test_HDFFV_9920()
{
- int attr_data[2] = { 100, 200};
- hsize_t dims[1] = { DIM1 };
+ int attr_data[2] = {100, 200};
+ hsize_t dims[1] = {DIM1};
- try
- {
+ try {
// Create a new file and a group in it
- H5File file( FILE_NAME, H5F_ACC_TRUNC );
+ H5File file(FILE_NAME, H5F_ACC_TRUNC);
Group gr1(file.createGroup(GRP_NAME));
// Create the data space for the attribute.
- DataSpace dspace = DataSpace (1, dims );
+ DataSpace dspace = DataSpace(1, dims);
DataSet fds = file.createDataSet(FDATASET_NAME, PredType::STD_I32BE, dspace);
DataSet gds = gr1.createDataSet(GDATASET_NAME, PredType::STD_I32BE, dspace);
// Create a file attribute and a group attribute.
- Attribute fa1 = file.createAttribute(FATTR_NAME, PredType::STD_I32BE,
- dspace);
- Attribute ga1 = gr1.createAttribute(GATTR_NAME, PredType::STD_I32BE,
- dspace);
+ Attribute fa1 = file.createAttribute(FATTR_NAME, PredType::STD_I32BE, dspace);
+ Attribute ga1 = gr1.createAttribute(GATTR_NAME, PredType::STD_I32BE, dspace);
// Write the attribute data.
- fa1.write( PredType::NATIVE_INT, attr_data);
- ga1.write( PredType::NATIVE_INT, attr_data);
+ fa1.write(PredType::NATIVE_INT, attr_data);
+ ga1.write(PredType::NATIVE_INT, attr_data);
fa1.close();
ga1.close();
@@ -433,16 +430,14 @@ static void test_HDFFV_9920()
printelems(file, FDATASET_NAME, FATTR_NAME);
printelems(gr1, GDATASET_NAME, GATTR_NAME);
- } // end of try block
+ } // end of try block
// Catch all failures for handling in the same way
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_HDFFV_9920()", __LINE__, __FILE__, E.getCDetailMsg());
}
}
-
/*-------------------------------------------------------------------------
* Function: test_iterate
*
@@ -455,8 +450,8 @@ static void test_HDFFV_9920()
* Tuesday, September 6, 2016
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_iterate()
+extern "C" void
+test_iterate()
{
// Output message about test being performed
MESSAGE(5, ("Testing Iterate Feature\n"));
@@ -465,13 +460,12 @@ void test_iterate()
FileAccPropList fapl;
fapl.setLibverBounds(H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- test_iter_group(fapl); // Test iterating groups
- test_HDFFV_9920(); // Test the fix of HDFFV-9920
- //test_iter_attr(fapl); // Test iterating attributes
+ test_iter_group(fapl); // Test iterating groups
+ test_HDFFV_9920(); // Test the fix of HDFFV-9920
+ // test_iter_attr(fapl); // Test iterating attributes
-} // test_iterate
+} // test_iterate
-
/*-------------------------------------------------------------------------
* Function: cleanup_iterate
*
@@ -480,8 +474,8 @@ void test_iterate()
* Return none
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_iterate()
+extern "C" void
+cleanup_iterate()
{
HDremove(FILE_ITERATE.c_str());
} // cleanup_iterate
diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp
index 1bdd442..8690ac2 100644
--- a/c++/test/tlinks.cpp
+++ b/c++/test/tlinks.cpp
@@ -25,37 +25,30 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
-#define NAME_BUF_SIZE 1024
-#define H5L_DIM1 100
-#define H5L_DIM2 100
+#define NAME_BUF_SIZE 1024
+#define H5L_DIM1 100
+#define H5L_DIM2 100
// Object visit structs
typedef struct {
- const char *path; /* Path to object */
- H5O_type_t type; /* Type of object */
+ const char *path; /* Path to object */
+ H5O_type_t type; /* Type of object */
} obj_visit_t;
// User data for callback function
typedef struct {
- unsigned idx; /* Index in object visit structure */
- const obj_visit_t *info; /* Pointer to the object visit structure to use */
+ unsigned idx; /* Index in object visit structure */
+ const obj_visit_t *info; /* Pointer to the object visit structure to use */
} ovisit_ud_t;
-static const char *FILENAME[] = {
- "link0",
- "link1.h5",
- "link2.h5",
- "visit",
- NULL
-};
+static const char *FILENAME[] = {"link0", "link1.h5", "link2.h5", "visit", NULL};
-
/*-------------------------------------------------------------------------
* Function: test_basic_links
*
@@ -67,17 +60,17 @@ static const char *FILENAME[] = {
* October 16, 2009
*-------------------------------------------------------------------------
*/
-static void test_basic_links(hid_t fapl_id, hbool_t new_format)
+static void
+test_basic_links(hid_t fapl_id, hbool_t new_format)
{
hsize_t size[1] = {1};
- char filename[NAME_BUF_SIZE];
+ char filename[NAME_BUF_SIZE];
// Use the file access template id to create a file access prop. list.
FileAccPropList fapl(fapl_id);
- try
- {
- if(new_format)
+ try {
+ if (new_format)
SUBTEST("Link creation (w/new group format)")
else
SUBTEST("Link creation")
@@ -86,7 +79,7 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format)
H5File file(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
// Create simple dataspace
- DataSpace scalar (1, size, size);
+ DataSpace scalar(1, size, size);
// Create a group then close it by letting the object go out of scope
{
@@ -103,25 +96,19 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format)
// Because these are not implemented in the C++ API yet, they are
// used so CommonFG::getLinkval can be tested.
// Create a hard link
- if(H5Lcreate_hard(
- file_id, "dset1", H5L_SAME_LOC, "grp1/hard1",
- H5P_DEFAULT, H5P_DEFAULT) < 0)
+ if (H5Lcreate_hard(file_id, "dset1", H5L_SAME_LOC, "grp1/hard1", H5P_DEFAULT, H5P_DEFAULT) < 0)
throw Exception("test_basic_links", "H5Lcreate_hard failed");
// Create a symbolic link
- if(H5Lcreate_soft(
- "/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ if (H5Lcreate_soft("/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0)
throw Exception("test_basic_links", "H5Lcreate_soft failed");
// Create a symbolic link to something that doesn't exist
- if(H5Lcreate_soft(
- "foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ if (H5Lcreate_soft("foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0)
throw Exception("test_basic_links", "H5Lcreate_soft failed");
// Create a recursive symbolic link
- if(H5Lcreate_soft(
- "/grp1/recursive", file_id, "/grp1/recursive",
- H5P_DEFAULT, H5P_DEFAULT) < 0)
+ if (H5Lcreate_soft("/grp1/recursive", file_id, "/grp1/recursive", H5P_DEFAULT, H5P_DEFAULT) < 0)
throw Exception("test_basic_links", "H5Lcreate_soft failed");
// Verify link values before closing the file
@@ -136,26 +123,24 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format)
verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__);
} // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg());
}
// Open the file and check on the links in it
- try
- {
+ try {
// Open the file above
H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl);
// Verify link existence
- if(file.nameExists("dset1", LinkAccPropList::DEFAULT) != TRUE)
+ if (file.nameExists("dset1", LinkAccPropList::DEFAULT) != TRUE)
throw InvalidActionException("H5File::nameExists", "dset1 doesn't exist");
- if(file.nameExists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE)
+ if (file.nameExists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE)
throw InvalidActionException("H5File::nameExists", "grp1/soft doesn't exist");
// Deprecated
- if(file.exists("dset1", LinkAccPropList::DEFAULT) != TRUE)
+ if (file.exists("dset1", LinkAccPropList::DEFAULT) != TRUE)
throw InvalidActionException("H5File::exists", "dset1 doesn't exist");
- if(file.exists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE)
+ if (file.exists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE)
throw InvalidActionException("H5File::exists", "grp1/soft doesn't exist");
// Verify link values
@@ -167,13 +152,11 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format)
PASSED();
} // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_basic_links
-
/*-------------------------------------------------------------------------
* Function: test_lcpl
*
@@ -191,16 +174,15 @@ static void
test_lcpl(hid_t fapl_id, hbool_t new_format)
{
H5L_info2_t linfo;
- char filename[1024];
- hsize_t dims[2];
+ char filename[1024];
+ hsize_t dims[2];
- if(new_format)
+ if (new_format)
SUBTEST("Link creation property lists (w/new group format)")
else
SUBTEST("Link creation property lists")
- try
- {
+ try {
FileAccPropList fapl(fapl_id);
// Create a new file.
@@ -213,7 +195,7 @@ test_lcpl(hid_t fapl_id, hbool_t new_format)
// Check that its character encoding is the default.
linfo = file.getLinkInfo(GROUP1NAME);
- if(linfo.cset != H5T_CSET_ASCII)
+ if (linfo.cset != H5T_CSET_ASCII)
throw InvalidActionException("H5Lget_info", "Character encoding is not default");
// Create and commit a datatype with the default LCPL.
@@ -228,7 +210,7 @@ test_lcpl(hid_t fapl_id, hbool_t new_format)
// Create a simple dataspace.
dims[0] = H5L_DIM1;
dims[1] = H5L_DIM2;
- DataSpace dspace(2 ,dims);
+ DataSpace dspace(2, dims);
// Create a dataset using the default LCPL.
DataSet dset(file.createDataSet("/dataset", PredType::NATIVE_INT, dspace));
@@ -252,13 +234,11 @@ test_lcpl(hid_t fapl_id, hbool_t new_format)
PASSED();
} // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_lcpl()", __LINE__, __FILE__, E.getCDetailMsg());
}
} // end test_lcpl()
-
/*-------------------------------------------------------------------------
* Function: test_move
*
@@ -272,15 +252,14 @@ test_lcpl(hid_t fapl_id, hbool_t new_format)
static void
test_move(hid_t fapl_id, hbool_t new_format)
{
- char filename[1024];
+ char filename[1024];
- if(new_format)
+ if (new_format)
SUBTEST("Group::moveLink (w/new group format)")
else
SUBTEST("Group::moveLink")
- try
- {
+ try {
FileAccPropList fapl(fapl_id);
// Create two new files
@@ -303,15 +282,16 @@ test_move(hid_t fapl_id, hbool_t new_format)
grp_1.moveLink("group_move", file_b, "group_new_name");
// Should throw an exception but didn't
- H5_FAILED();
- cerr << " Group group_move should not be moved across files" << endl;
- } catch (Exception& E) {
+ H5_FAILED();
+ cerr << " Group group_move should not be moved across files" << endl;
+ }
+ catch (Exception &E) {
// expected
}
// Move a soft link across files, should succeed
grp_2.moveLink("soft", file_b, "soft_new_name");
- if(file_b.exists("soft_new_name") != TRUE)
+ if (file_b.exists("soft_new_name") != TRUE)
throw InvalidActionException("H5File::exists", "grp1/soft doesn't exist");
// Move a group across groups in the same file while renaming it
@@ -326,9 +306,10 @@ test_move(hid_t fapl_id, hbool_t new_format)
moved_grp = grp_1.openGroup("group_move");
// Should throw an exception but didn't
- H5_FAILED();
- cerr << " Group group_move should not be in original location" << endl;
- } catch (Exception& E) {
+ H5_FAILED();
+ cerr << " Group group_move should not be in original location" << endl;
+ }
+ catch (Exception &E) {
// expected
}
@@ -360,46 +341,49 @@ test_move(hid_t fapl_id, hbool_t new_format)
moved_grp = grp_1.openGroup("group_newer_name");
moved_grp.close();
- H5_FAILED(); // Should throw an exception but didn't
- cerr << " Group group_newer_name should not be in GROUP1NAME" << endl;
- } catch (Exception& E) {
+ H5_FAILED(); // Should throw an exception but didn't
+ cerr << " Group group_newer_name should not be in GROUP1NAME" << endl;
+ }
+ catch (Exception &E) {
// expected
}
try {
moved_grp = grp_2.openGroup("group_newer_name");
moved_grp.close();
- H5_FAILED(); // Should throw an exception but didn't
- cerr << " Group group_newer_name should not be in GROUP2NAME" << endl;
- } catch (Exception& E) {
+ H5_FAILED(); // Should throw an exception but didn't
+ cerr << " Group group_newer_name should not be in GROUP2NAME" << endl;
+ }
+ catch (Exception &E) {
// expected
}
try {
moved_grp = grp_2.openGroup("group_new_name");
moved_grp.close();
- H5_FAILED(); // Should throw an exception but didn't
- cerr << " Group group_new_name should not be in GROUP2NAME" << endl;
- } catch (Exception& E) {
+ H5_FAILED(); // Should throw an exception but didn't
+ cerr << " Group group_new_name should not be in GROUP2NAME" << endl;
+ }
+ catch (Exception &E) {
// expected
}
try {
moved_grp = grp_1.openGroup("group_copy");
moved_grp.close();
- H5_FAILED(); // Should throw an exception but didn't
- cerr << " Group group_copy should not be in GROUP1NAME" << endl;
- } catch (Exception& E) {
+ H5_FAILED(); // Should throw an exception but didn't
+ cerr << " Group group_copy should not be in GROUP1NAME" << endl;
+ }
+ catch (Exception &E) {
// expected
}
PASSED();
} // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_move()", __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_move
-
+
/*-------------------------------------------------------------------------
* Function: test_copy
*
@@ -410,17 +394,17 @@ test_move(hid_t fapl_id, hbool_t new_format)
* March, 2018
*-------------------------------------------------------------------------
*/
-static void test_copy(hid_t fapl_id, hbool_t new_format)
+static void
+test_copy(hid_t fapl_id, hbool_t new_format)
{
char filename[1024];
- if(new_format)
+ if (new_format)
SUBTEST("Group::copyLink (w/new group format)")
else
SUBTEST("Group::copyLink")
- try
- {
+ try {
// Create two new files
h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);
H5File file_a(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl_id);
@@ -439,7 +423,8 @@ static void test_copy(hid_t fapl_id, hbool_t new_format)
// Copy a group across files, should fail
try {
grp_1.copyLink("group_copy", file_b, "group_new_name");
- } catch (Exception& E) {
+ }
+ catch (Exception &E) {
// expected
}
@@ -509,9 +494,10 @@ static void test_copy(hid_t fapl_id, hbool_t new_format)
moved_grp = grp_2.openGroup("group_newer_name");
moved_grp.close();
- H5_FAILED(); // Should throw an exception but didn't
- cerr << " Group group_newer_name should not be in GROUP2NAME" << endl;
- } catch (Exception& E) {
+ H5_FAILED(); // Should throw an exception but didn't
+ cerr << " Group group_newer_name should not be in GROUP2NAME" << endl;
+ }
+ catch (Exception &E) {
// expected
}
@@ -521,21 +507,20 @@ static void test_copy(hid_t fapl_id, hbool_t new_format)
moved_grp = grp_1.openGroup("group_copy");
moved_grp.close();
- H5_FAILED(); // Should throw an exception but didn't
- cerr << " Group group_copy should not be in GROUP1NAME" << endl;
- } catch (Exception& E) {
+ H5_FAILED(); // Should throw an exception but didn't
+ cerr << " Group group_copy should not be in GROUP1NAME" << endl;
+ }
+ catch (Exception &E) {
// expected
}
PASSED();
} // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_copy()", __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_copy
-
/*-------------------------------------------------------------------------
* Function: test_num_links
*
@@ -547,17 +532,17 @@ static void test_copy(hid_t fapl_id, hbool_t new_format)
* October 16, 2009
*-------------------------------------------------------------------------
*/
-static void test_num_links(hid_t fapl_id, hbool_t new_format)
+static void
+test_num_links(hid_t fapl_id, hbool_t new_format)
{
char filename[NAME_BUF_SIZE];
- if(new_format)
+ if (new_format)
SUBTEST("Setting number of links (w/new group format)")
else
SUBTEST("Setting number of links")
- try
- {
+ try {
// Use the file access template id to create a file access prop. list.
FileAccPropList fapl(fapl_id);
@@ -565,7 +550,7 @@ static void test_num_links(hid_t fapl_id, hbool_t new_format)
H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl);
LinkAccPropList lapl;
- size_t nlinks = 5;
+ size_t nlinks = 5;
lapl.setNumLinks(nlinks);
// Read it back and verify
@@ -574,13 +559,11 @@ static void test_num_links(hid_t fapl_id, hbool_t new_format)
PASSED();
} // end of try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_num_links()", __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_num_links
-
// Data for visit on the file
static const obj_visit_t file_visit[] = {
{".", H5O_TYPE_GROUP},
@@ -600,22 +583,25 @@ const H5std_string FILE_NAME("tvisit.h5");
const H5std_string GROUP_NAME("/Data");
const H5std_string DSET1_NAME("/Data/Compressed_Data");
const H5std_string DSET2_NAME("/Data/Float_Data");
-const int RANK = 2;
-const int DIM1 = 2;
+const int RANK = 2;
+const int DIM1 = 2;
// Operator function
-static int visit_obj_cb(H5Object& obj, const H5std_string name, const H5O_info2_t *oinfo, void *_op_data)
+static int
+visit_obj_cb(H5Object &obj, const H5std_string name, const H5O_info2_t *oinfo, void *_op_data)
{
- ovisit_ud_t *op_data = static_cast <ovisit_ud_t *>(_op_data);
+ ovisit_ud_t *op_data = static_cast<ovisit_ud_t *>(_op_data);
// Check for correct object information
- if(strcmp(op_data->info[op_data->idx].path, name.c_str())) return(H5_ITER_ERROR);
- if(op_data->info[op_data->idx].type != oinfo->type) return(H5_ITER_ERROR);
+ if (strcmp(op_data->info[op_data->idx].path, name.c_str()))
+ return (H5_ITER_ERROR);
+ if (op_data->info[op_data->idx].type != oinfo->type)
+ return (H5_ITER_ERROR);
// Advance to next location
op_data->idx++;
- return(H5_ITER_CONT);
+ return (H5_ITER_CONT);
}
/*-------------------------------------------------------------------------
@@ -628,93 +614,90 @@ static int visit_obj_cb(H5Object& obj, const H5std_string name, const H5O_info2_
* February 8, 2019
*-------------------------------------------------------------------------
*/
-static void test_visit(hid_t fapl_id, hbool_t new_format)
+static void
+test_visit(hid_t fapl_id, hbool_t new_format)
{
- hsize_t dims[2];
- hsize_t cdims[2];
- char filename[NAME_BUF_SIZE];
+ hsize_t dims[2];
+ hsize_t cdims[2];
+ char filename[NAME_BUF_SIZE];
- if(new_format)
+ if (new_format)
SUBTEST("H5Object::visit (w/new group format)")
else
SUBTEST("H5Object::visit")
- try
- {
+ try {
// Use the file access template id to create a file access prop. list
FileAccPropList fapl(fapl_id);
// Build the hdf5 file name and create the file
h5_fixname(FILENAME[3], fapl_id, filename, sizeof filename);
- H5File *file = new H5File(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
+ H5File *file = new H5File(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
// Create a group
- Group* group = new Group(file->createGroup(GROUP_NAME));
+ Group *group = new Group(file->createGroup(GROUP_NAME));
// Create a chunked/compressed dataset within this group specified by path
- dims[0] = 20;
- dims[1] = 2;
- cdims[0] = 2;
- cdims[1] = 2;
- DataSpace *dataspace = new DataSpace(RANK, dims); // create new dspace
- DSetCreatPropList ds_creatplist; // create dataset creation prop list
- ds_creatplist.setChunk(2, cdims); // then modify it for compression
- ds_creatplist.setDeflate(6);
-
- DataSet* dataset = new DataSet(file->createDataSet(DSET1_NAME,
- PredType::NATIVE_INT, *dataspace, ds_creatplist));
-
- delete dataset;
- delete dataspace;
-
- // Create another dataset
- dims[0] = 5;
- dims[1] = 2;
- dataspace = new DataSpace(RANK, dims); // create second dspace
- dataset = new DataSet(file->createDataSet(DSET2_NAME,
- PredType::NATIVE_FLOAT, *dataspace));
+ dims[0] = 20;
+ dims[1] = 2;
+ cdims[0] = 2;
+ cdims[1] = 2;
+ DataSpace * dataspace = new DataSpace(RANK, dims); // create new dspace
+ DSetCreatPropList ds_creatplist; // create dataset creation prop list
+ ds_creatplist.setChunk(2, cdims); // then modify it for compression
+ ds_creatplist.setDeflate(6);
+
+ DataSet *dataset =
+ new DataSet(file->createDataSet(DSET1_NAME, PredType::NATIVE_INT, *dataspace, ds_creatplist));
+
+ delete dataset;
+ delete dataspace;
+
+ // Create another dataset
+ dims[0] = 5;
+ dims[1] = 2;
+ dataspace = new DataSpace(RANK, dims); // create second dspace
+ dataset = new DataSet(file->createDataSet(DSET2_NAME, PredType::NATIVE_FLOAT, *dataspace));
// Close everything
- delete dataset;
- delete dataspace;
- delete group;
- delete file;
+ delete dataset;
+ delete dataspace;
+ delete group;
+ delete file;
- // Reopen the file and group in the file.
- file = new H5File(filename, H5F_ACC_RDWR);
- group = new Group(file->openGroup("Data"));
+ // Reopen the file and group in the file.
+ file = new H5File(filename, H5F_ACC_RDWR);
+ group = new Group(file->openGroup("Data"));
// Open the group
- dataset = new DataSet(group->openDataSet(DSET2_NAME));
+ dataset = new DataSet(group->openDataSet(DSET2_NAME));
delete dataset;
// Visit objects in the file
- ovisit_ud_t udata; /* User-data for visiting */
- udata.idx = 0;
+ ovisit_ud_t udata; /* User-data for visiting */
+ udata.idx = 0;
udata.info = file_visit;
file->visit(H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC);
// Visit objects in the group
- udata.idx = 0;
+ udata.idx = 0;
udata.info = group_visit;
group->visit(H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC);
- // Close the group and file.
- delete group;
- delete file;
+ // Close the group and file.
+ delete group;
+ delete file;
PASSED();
} // end of try block
- catch (Exception& E)
- {
- cerr << "in catch" << endl;
+ catch (Exception &E) {
+ cerr << "in catch" << endl;
issue_fail_msg("test_visit()", __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_visit()
-
/*-------------------------------------------------------------------------
* Function: test_links
*
@@ -725,35 +708,33 @@ static void test_visit(hid_t fapl_id, hbool_t new_format)
* October 16, 2009
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_links()
+extern "C" void
+test_links()
{
- hid_t fapl_id, fapl2_id; /* File access property lists */
- unsigned new_format; /* Whether to use the new format or not */
+ hid_t fapl_id, fapl2_id; /* File access property lists */
+ unsigned new_format; /* Whether to use the new format or not */
- if((fapl_id = h5_fileaccess()) < 0)
+ if ((fapl_id = h5_fileaccess()) < 0)
throw Exception("test_links", "Unable to get file access property list");
// Output message about test being performed
MESSAGE(5, ("Testing Various Links\n"));
- try
- {
+ try {
/* Copy the file access property list */
- if((fapl2_id = H5Pcopy(fapl_id)) < 0)
+ if ((fapl2_id = H5Pcopy(fapl_id)) < 0)
throw Exception("test_links", "H5Pcopy failed");
/* Set the "use the latest version of the format" bounds for creating
objects in the file */
- if(H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ if (H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
throw Exception("test_links", "H5Pset_libver_bounds failed");
/* Loop over using new group format */
- for(new_format = FALSE; new_format <= TRUE; new_format++)
- {
+ for (new_format = FALSE; new_format <= TRUE; new_format++) {
hid_t my_fapl_id;
/* Check for FAPL to use */
- if(new_format)
+ if (new_format)
my_fapl_id = fapl2_id;
else
my_fapl_id = fapl_id;
@@ -773,13 +754,11 @@ void test_links()
h5_clean_files(FILENAME, fapl_id);
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_links()", __LINE__, __FILE__, E.getCDetailMsg());
}
}
-
/*-------------------------------------------------------------------------
* Function: cleanup_links
*
@@ -788,8 +767,8 @@ void test_links()
* Return none
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_links()
+extern "C" void
+cleanup_links()
{
HDremove(FILENAME[0]);
HDremove(FILENAME[1]);
diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp
index 9b5dd68..991df3f 100644
--- a/c++/test/tobject.cpp
+++ b/c++/test/tobject.cpp
@@ -23,29 +23,28 @@
#endif
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
-
-const H5std_string FILE_OBJECTS("tobjects.h5");
-const H5std_string FILE_OBJHDR("tobject_header.h5");
-const H5std_string GROUP1("Top Group");
-const H5std_string GROUP1_PATH("/Top Group");
-const H5std_string GROUP1_1("Sub-Group 1.1");
-const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1");
-const H5std_string GROUP1_2("Sub-Group 1.2");
-const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2");
-const H5std_string DSET_DEFAULT_NAME("default");
-const H5std_string DSET_IN_FILE("Dataset in File");
-const H5std_string DSET_IN_FILE_PATH("/Dataset in File");
-const H5std_string DSET_IN_GRP1("Dataset_in_Group_1");
-const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset_in_Group_1");
-const H5std_string DSET_IN_GRP1_2("Dataset_in_Group_1.2");
-const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_in_Group_1.2");
-
-
+#include "h5cpputil.h" // C++ utilility header file
+
+const H5std_string FILE_OBJECTS("tobjects.h5");
+const H5std_string FILE_OBJHDR("tobject_header.h5");
+const H5std_string GROUP1("Top Group");
+const H5std_string GROUP1_PATH("/Top Group");
+const H5std_string GROUP1_1("Sub-Group 1.1");
+const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1");
+const H5std_string GROUP1_2("Sub-Group 1.2");
+const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2");
+const H5std_string DSET_DEFAULT_NAME("default");
+const H5std_string DSET_IN_FILE("Dataset in File");
+const H5std_string DSET_IN_FILE_PATH("/Dataset in File");
+const H5std_string DSET_IN_GRP1("Dataset_in_Group_1");
+const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset_in_Group_1");
+const H5std_string DSET_IN_GRP1_2("Dataset_in_Group_1.2");
+const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_in_Group_1.2");
+
/*-------------------------------------------------------------------------
* Function: test_get_objname
*
@@ -68,7 +67,8 @@ const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_
* Friday, March 4, 2014
*-------------------------------------------------------------------------
*/
-static void test_get_objname()
+static void
+test_get_objname()
{
SUBTEST("H5Object::getObjName on Groups and Datasets");
@@ -77,7 +77,7 @@ static void test_get_objname()
H5File file(FILE_OBJECTS, H5F_ACC_TRUNC);
// Create a top group and 2 subgroups
- Group grp1 = file.createGroup(GROUP1, 0);
+ Group grp1 = file.createGroup(GROUP1, 0);
Group grp1_1 = grp1.createGroup(GROUP1_1, 0);
Group grp1_2 = grp1.createGroup(GROUP1_2, 0);
@@ -88,27 +88,24 @@ static void test_get_objname()
ssize_t name_len = grp1.getObjName(NULL);
// Random length is 4
- if (name_len > 4)
- {
- char* grp1_name = new char[5];
- name_len = grp1.getObjName(grp1_name, 5);
- verify_val((const char*)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__);
- delete []grp1_name;
+ if (name_len > 4) {
+ char *grp1_name = new char[5];
+ name_len = grp1.getObjName(grp1_name, 5);
+ verify_val((const char *)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__);
+ delete[] grp1_name;
}
// Create a data space
- hsize_t dims[2];
+ hsize_t dims[2];
dims[0] = 2;
dims[1] = 5;
- DataSpace space (2, dims, NULL);
+ DataSpace space(2, dims, NULL);
// Create a dataset in the file
- DataSet dsinfile = file.createDataSet(DSET_IN_FILE,
- PredType::NATIVE_DOUBLE, space);
+ DataSet dsinfile = file.createDataSet(DSET_IN_FILE, PredType::NATIVE_DOUBLE, space);
// Create a dataset in the group
- DataSet dsingrp = grp1.createDataSet(DSET_IN_GRP1,
- PredType::NATIVE_INT, space);
+ DataSet dsingrp = grp1.createDataSet(DSET_IN_GRP1, PredType::NATIVE_INT, space);
// Get and verify the name of each dataset, using
// H5std_string getObjName() and
@@ -135,23 +132,21 @@ static void test_get_objname()
// Reopen that same dataset then check the name again with another
// overload: ssize_t getObjName(H5std_string& obj_name, size_t len = 0)
- dsingrp = grp1_2.openDataSet(DSET_IN_GRP1_2);
+ dsingrp = grp1_2.openDataSet(DSET_IN_GRP1_2);
name_len = dsingrp.getObjName(ds_name);
verify_val(ds_name, DSET_IN_GRP1_2_PATH, "DataSet::getObjName", __LINE__, __FILE__);
// Everything will be closed as they go out of scope
PASSED();
- } // try block
+ } // try block
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_get_objname", __LINE__, __FILE__);
}
-} // test_get_objname
+} // test_get_objname
-
/*-------------------------------------------------------------------------
* Function: test_existance
*
@@ -174,7 +169,8 @@ static void test_get_objname()
* Friday, March 4, 2014
*-------------------------------------------------------------------------
*/
-static void test_existance()
+static void
+test_existance()
{
SUBTEST("H5File::exists and Group::exists");
@@ -222,7 +218,7 @@ static void test_existance()
// Check if a dataset exists given dataset as location with full path name
DataSet dset1 = file.openDataSet(DSET_IN_FILE);
- exists = dset1.nameExists("/Top Group/Dataset_in_Group_1");
+ exists = dset1.nameExists("/Top Group/Dataset_in_Group_1");
verify_val(exists, TRUE, "Group::nameExists given dataset with full path name", __LINE__, __FILE__);
exists = grp1_2.nameExists(DSET_IN_GRP1);
@@ -236,16 +232,14 @@ static void test_existance()
// Everything will be closed as they go out of scope
PASSED();
- } // try block
+ } // try block
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_existance", __LINE__, __FILE__);
}
-} // test_existance
+} // test_existance
-
/*-------------------------------------------------------------------------
* Function: test_get_objname_ontypes
*
@@ -258,7 +252,8 @@ static void test_existance()
* March 4, 2014
*-------------------------------------------------------------------------
*/
-static void test_get_objname_ontypes()
+static void
+test_get_objname_ontypes()
{
SUBTEST("H5Object::getObjName on Committed Datatypes");
@@ -267,7 +262,7 @@ static void test_get_objname_ontypes()
H5File file(FILE_OBJECTS, H5F_ACC_RDWR);
// Create a group
- Group grp = file.createGroup ("typetests");
+ Group grp = file.createGroup("typetests");
// Create a datatype and save it
IntType inttype(PredType::STD_B8LE);
@@ -326,7 +321,8 @@ static void test_get_objname_ontypes()
// Name this datatype
new_int_type.commit(grp, "IntType NATIVE_INT");
ssize_t name_len = new_int_type.getObjName(type_name); // default len
- verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName", __LINE__, __FILE__);
+ verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName",
+ __LINE__, __FILE__);
verify_val(type_name, "/typetests/IntType NATIVE_INT", "DataType::getObjName", __LINE__, __FILE__);
// Close everything or they can be closed when objects go out of scope
@@ -338,13 +334,11 @@ static void test_get_objname_ontypes()
PASSED();
} // end top try block
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_get_objname_ontypes", __LINE__, __FILE__);
}
-} // test_get_objname_ontypes
+} // test_get_objname_ontypes
-
/*-------------------------------------------------------------------------
* Function: test_get_objtype
*
@@ -357,7 +351,8 @@ static void test_get_objname_ontypes()
* Friday, March 4, 2014
*-------------------------------------------------------------------------
*/
-static void test_get_objtype()
+static void
+test_get_objtype()
{
SUBTEST("H5File::childObjType and H5Group::childObjType");
@@ -398,16 +393,14 @@ static void test_get_objtype()
// Everything will be closed as they go out of scope
PASSED();
- } // try block
+ } // try block
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_get_objtype", __LINE__, __FILE__);
}
-} // test_get_objtype
+} // test_get_objtype
-
/*-------------------------------------------------------------------------
* Function: test_open_object_header
*
@@ -427,9 +420,10 @@ const H5std_string DSETNAME("dataset");
#define DIM0 5
#define DIM1 10
-static void test_open_object_header()
+static void
+test_open_object_header()
{
- hsize_t dims[2];
+ hsize_t dims[2];
// Output message about test being performed
SUBTEST("Group::getObjId");
@@ -452,16 +446,16 @@ static void test_open_object_header()
dims[0] = DIM0;
dims[1] = DIM1;
DataSpace dspace(RANK, dims);
- DataSet dset(file1.createDataSet(DSETNAME, PredType::NATIVE_INT, dspace));
+ DataSet dset(file1.createDataSet(DSETNAME, PredType::NATIVE_INT, dspace));
// Close dataset and dataspace
dset.close();
dspace.close();
// Now make sure that getObjId can open all three types of objects
- hid_t obj_grp = file1.getObjId(GROUPNAME);
+ hid_t obj_grp = file1.getObjId(GROUPNAME);
hid_t obj_dtype = file1.getObjId(DTYPENAME);
- hid_t obj_dset = file1.getObjId(DSETNAME);
+ hid_t obj_dset = file1.getObjId(DSETNAME);
// Make sure that each is the right kind of ID
H5I_type_t id_type = IdComponent::getHDFObjType(obj_grp);
@@ -473,7 +467,7 @@ static void test_open_object_header()
/* Do something more complex with each of the IDs to make sure */
- Group grp2(obj_grp);
+ Group grp2(obj_grp);
hsize_t num_objs = grp2.getNumObjs();
verify_val(num_objs, 1, "H5Gget_info", __LINE__, __FILE__);
// There should be one object, the datatype
@@ -482,7 +476,7 @@ static void test_open_object_header()
file1.closeObjId(obj_dtype);
dset.setId(obj_dset);
- dspace = dset.getSpace();
+ dspace = dset.getSpace();
bool is_simple = dspace.isSimple();
verify_val(is_simple, true, "isSimple", __LINE__, __FILE__);
dspace.close();
@@ -509,23 +503,20 @@ static void test_open_object_header()
grp2.close();
PASSED();
- } // end of try block
+ } // end of try block
// catch invalid action exception
- catch (InvalidActionException& E)
- {
+ catch (InvalidActionException &E) {
cerr << " in InvalidActionException" << endl;
cerr << " *FAILED*" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
}
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " in Exception" << endl;
issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_open_object_header
+} // test_open_object_header
-
/*-------------------------------------------------------------------------
* Function: test_getobjectinfo_same_file
*
@@ -540,9 +531,10 @@ static void test_open_object_header()
const H5std_string FILE_OBJINFO("tobject_getinfo.h5");
const H5std_string GROUP1NAME("group1");
const H5std_string GROUP2NAME("group2");
-static void test_getobjectinfo_same_file()
+static void
+test_getobjectinfo_same_file()
{
- H5O_info2_t oinfo1, oinfo2; /* Object info structs */
+ H5O_info2_t oinfo1, oinfo2; /* Object info structs */
// Output message about test being performed
SUBTEST("Group::getObjinfo");
@@ -588,7 +580,6 @@ static void test_getobjectinfo_same_file()
grp2.getObjinfo(oinfo2);
verify_val(oinfo1.fileno, oinfo2.fileno, "file number from getObjinfo", __LINE__, __FILE__);
-
// Reset object info
HDmemset(&oinfo1, 0, sizeof(oinfo1));
HDmemset(&oinfo2, 0, sizeof(oinfo2));
@@ -604,16 +595,15 @@ static void test_getobjectinfo_same_file()
file2.close();
PASSED();
- } // end of try block
+ } // end of try block
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " in Exception " << E.getCFuncName() << "detail: " << E.getCDetailMsg() << endl;
issue_fail_msg("test_getobjectinfo_same_file()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_getobjectinfo_same_file
-
+} // test_getobjectinfo_same_file
+
/*-------------------------------------------------------------------------
* Function: test_intermediate_groups
*
@@ -636,7 +626,8 @@ const H5std_string GROUP20NAME("/group20");
const H5std_string GROUP21NAME("/group20/group21");
const H5std_string GROUP22NAME("group21/group22");
const H5std_string GROUP22FULLNAME("/group20/group21/group22");
-static void test_intermediate_groups()
+static void
+test_intermediate_groups()
{
// Output message about test being performed
SUBTEST("Group::set/getCreateIntermediateGroup");
@@ -663,7 +654,9 @@ static void test_intermediate_groups()
// fail because group GROUP13NAME is missing
try {
Group grp14_nopl(file.createGroup(GROUP14NAME));
- } catch (FileIException& expected1) {} // Failure is ignored
+ }
+ catch (FileIException &expected1) {
+ } // Failure is ignored
// Create GROUP14NAME with the flag to create missing groups set
// to FALSE, should fail because group GROUP13NAME is missing
@@ -677,14 +670,15 @@ static void test_intermediate_groups()
try {
Group grp14_false(file.createGroup(GROUP14NAME, lcpl));
- } catch (FileIException& expected2) {} // Failure is ignored
+ }
+ catch (FileIException &expected2) {
+ } // Failure is ignored
// Set the flag to create missing groups set to TRUE
lcpl.setCreateIntermediateGroup(true);
crt_int_grps = lcpl.getCreateIntermediateGroup();
verify_val(crt_int_grps, true, "LinkCreatPropList::getCreateIntermediateGroup", __LINE__, __FILE__);
-
// Create GROUP14NAME with the use of link create plist
Group grp14(file.createGroup(GROUP14NAME, lcpl));
@@ -715,16 +709,15 @@ static void test_intermediate_groups()
Group grp22fromfile(file.openGroup(GROUP22FULLNAME));
PASSED();
- } // end of try block
+ } // end of try block
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
cerr << " in Exception " << E.getCFuncName() << "detail: " << E.getCDetailMsg() << endl;
issue_fail_msg("test_intermediate_groups()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_intermediate_groups
-
+} // test_intermediate_groups
+
/*-------------------------------------------------------------------------
* Function: test_object
*
@@ -736,8 +729,8 @@ static void test_intermediate_groups()
* March 4, 2014
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_object()
+extern "C" void
+test_object()
{
// Output message about test being performed
MESSAGE(5, ("Testing Object Functions\n"));
@@ -750,9 +743,8 @@ void test_object()
test_getobjectinfo_same_file(); // Test object info in same file
test_intermediate_groups(); // Test intermediate group property
-} // test_object
+} // test_object
-
/*-------------------------------------------------------------------------
* Function: cleanup_objects
*
@@ -761,8 +753,8 @@ void test_object()
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_object()
+extern "C" void
+cleanup_object()
{
HDremove(FILE_OBJECTS.c_str());
} // cleanup_objects
diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp
index b46ae29..beba36a 100644
--- a/c++/test/trefer.cpp
+++ b/c++/test/trefer.cpp
@@ -26,22 +26,22 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
-const H5std_string FILE1("trefer1.h5");
-const H5std_string FILE2("trefer2.h5");
+const H5std_string FILE1("trefer1.h5");
+const H5std_string FILE2("trefer2.h5");
// Dataset 1
-const H5std_string DSET1_NAME("Dataset1");
-const H5std_string DSET2_NAME("Dataset2");
+const H5std_string DSET1_NAME("Dataset1");
+const H5std_string DSET2_NAME("Dataset2");
-const H5std_string MEMBER1( "a_name" );
-const H5std_string MEMBER2( "b_name" );
-const H5std_string MEMBER3( "c_name" );
+const H5std_string MEMBER1("a_name");
+const H5std_string MEMBER2("b_name");
+const H5std_string MEMBER3("c_name");
// 1-D dataset with fixed dimensions
const int SPACE1_RANK = 1;
@@ -58,10 +58,9 @@ const int POINT1_NPOINTS = 10;
typedef struct s1_t {
unsigned int a;
unsigned int b;
- float c;
+ float c;
} s1_t;
-
/*-------------------------------------------------------------------------
* Function: test_reference_params
*
@@ -70,30 +69,31 @@ typedef struct s1_t {
* Return None
*-------------------------------------------------------------------------
*/
-static void test_reference_params()
+static void
+test_reference_params()
{
const char *write_comment = "Foo!"; /* Comments for group */
// Output message about test being performed
SUBTEST("Object Reference Parameters");
- H5File* file1 = NULL;
+ H5File *file1 = NULL;
try {
- hobj_ref_t *wbuf, // buffer to write to disk
- *rbuf, // buffer read from disk
- *tbuf; // temp. buffer read from disk
+ hobj_ref_t *wbuf, // buffer to write to disk
+ *rbuf, // buffer read from disk
+ *tbuf; // temp. buffer read from disk
// Allocate write & read buffers
- int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t));
- wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1);
- rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1);
- tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1);
+ int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t));
+ wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
+ rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
+ tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
// Create file FILE1
- file1 = new H5File (FILE1, H5F_ACC_TRUNC);
+ file1 = new H5File(FILE1, H5F_ACC_TRUNC);
// Create dataspace for datasets
- hsize_t dims1[] = {SPACE1_DIM1};
+ hsize_t dims1[] = {SPACE1_DIM1};
DataSpace sid1(SPACE1_RANK, dims1);
// Create a group
@@ -105,10 +105,10 @@ static void test_reference_params()
// Create a dataset (inside /Group1)
DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1);
- unsigned *tu32; // Temporary pointer to uint32 data
- int i;
- for (tu32=(unsigned *)wbuf, i=0; i<SPACE1_DIM1; i++)
- *tu32++=i*3; // from C test
+ unsigned *tu32; // Temporary pointer to uint32 data
+ int i;
+ for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++)
+ *tu32++ = i * 3; // from C test
// Write selection to disk
dataset.write(wbuf, PredType::NATIVE_UINT);
@@ -143,19 +143,29 @@ static void test_reference_params()
/* Test parameters to H5Location::reference */
try {
file1->reference(NULL, "/Group1/Dataset1");
- } catch (ReferenceException& E) {} // We expect this to fail
+ }
+ catch (ReferenceException &E) {
+ } // We expect this to fail
try {
file1->reference(&wbuf[0], NULL);
- } catch (ReferenceException& E) {} // We expect this to fail
+ }
+ catch (ReferenceException &E) {
+ } // We expect this to fail
try {
file1->reference(&wbuf[0], "");
- } catch (ReferenceException& E) {} // We expect this to fail
+ }
+ catch (ReferenceException &E) {
+ } // We expect this to fail
try {
file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_MAXTYPE);
- } catch (ReferenceException& E) {} // We expect this to fail
+ }
+ catch (ReferenceException &E) {
+ } // We expect this to fail
try {
file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_DATASET_REGION);
- } catch (ReferenceException& E) {} // We expect this to fail
+ }
+ catch (ReferenceException &E) {
+ } // We expect this to fail
// Close resources
dataset.close();
@@ -169,17 +179,14 @@ static void test_reference_params()
PASSED();
} // end try
- catch (Exception& E)
- {
- issue_fail_msg("test_reference_param()",__LINE__,__FILE__,
- E.getCFuncName(), E.getCDetailMsg());
+ catch (Exception &E) {
+ issue_fail_msg("test_reference_param()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg());
}
- if(file1)
+ if (file1)
delete file1;
-} /* test_reference_param() */
+} /* test_reference_param() */
-
/*-------------------------------------------------------------------------
* Function: test_reference_obj
*
@@ -189,31 +196,32 @@ static void test_reference_params()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_reference_obj()
+static void
+test_reference_obj()
{
- int i; // counting variables
- const H5std_string write_comment="Foo!"; // Comments for group
+ int i; // counting variables
+ const H5std_string write_comment = "Foo!"; // Comments for group
// Output message about test being performed
SUBTEST("Object Reference Functions");
- H5File* file1 = NULL;
+ H5File *file1 = NULL;
try {
- hobj_ref_t *wbuf, // buffer to write to disk
- *rbuf, // buffer read from disk
- *tbuf; // temp. buffer read from disk
+ hobj_ref_t *wbuf, // buffer to write to disk
+ *rbuf, // buffer read from disk
+ *tbuf; // temp. buffer read from disk
// Allocate write & read buffers
- int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t));
- wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1);
- rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1);
- tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1);
+ int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t));
+ wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
+ rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
+ tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
// Create file FILE1
- file1 = new H5File (FILE1, H5F_ACC_TRUNC);
+ file1 = new H5File(FILE1, H5F_ACC_TRUNC);
// Create dataspace for datasets
- hsize_t dims1[] = {SPACE1_DIM1};
+ hsize_t dims1[] = {SPACE1_DIM1};
DataSpace sid1(SPACE1_RANK, dims1);
// Create dataset access property list
@@ -228,9 +236,9 @@ static void test_reference_obj()
// Create a dataset (inside /Group1)
DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1);
- unsigned *tu32; // Temporary pointer to uint32 data
+ unsigned *tu32; // Temporary pointer to uint32 data
for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++)
- *tu32++=i*3; // from C test
+ *tu32++ = i * 3; // from C test
// Write selection to disk
dataset.write(wbuf, PredType::NATIVE_UINT);
@@ -265,22 +273,22 @@ static void test_reference_obj()
// Create reference to dataset and test getRefObjType
file1->reference(&wbuf[0], "/Group1/Dataset1");
H5O_type_t refobj_type = dataset.getRefObjType(&wbuf[0], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__);
+ verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__);
// Create reference to dataset and test getRefObjType
file1->reference(&wbuf[1], "/Group1/Dataset2");
refobj_type = dataset.getRefObjType(&wbuf[1], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__);
+ verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__);
// Create reference to group
file1->reference(&wbuf[2], "/Group1");
refobj_type = dataset.getRefObjType(&wbuf[2], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType",__LINE__,__FILE__);
+ verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType", __LINE__, __FILE__);
// Create reference to named datatype
file1->reference(&wbuf[3], "/Group1/Datatype1");
refobj_type = dataset.getRefObjType(&wbuf[3], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType",__LINE__,__FILE__);
+ verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType", __LINE__, __FILE__);
// Write selection to disk
dataset.write(wbuf, PredType::STD_REF_OBJ);
@@ -304,15 +312,15 @@ static void test_reference_obj()
DataSet dset2(dataset, &rbuf[0], H5R_OBJECT, dapl);
// Check information in the referenced dataset
- sid1 = dset2.getSpace();
+ sid1 = dset2.getSpace();
hssize_t n_elements = sid1.getSimpleExtentNpoints();
- verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__);
+ verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Read from disk
dset2.read(tbuf, PredType::NATIVE_UINT);
- for(tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++)
- verify_val(*tu32, (uint32_t)(i*3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__);
+ for (tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++)
+ verify_val(*tu32, (uint32_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Close dereferenced dataset
dset2.close();
@@ -323,18 +331,19 @@ static void test_reference_obj()
// Get group's comment using
// H5std_string getComment(const char* name, <buf_size=0 by default>)
H5std_string read_comment1 = group.getComment(".", 10);
- verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__);
+ verify_val(read_comment1.c_str(), write_comment, "Group::getComment", __LINE__, __FILE__);
// Test with the old default value
read_comment1 = group.getComment(".", 256);
- verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__);
+ verify_val(read_comment1.c_str(), write_comment, "Group::getComment", __LINE__, __FILE__);
// Test that getComment handles failures gracefully, using
// H5std_string getComment(const char* name, <buf_size=0 by default>)
try {
H5std_string read_comment_tmp = group.getComment(NULL);
}
- catch (Exception& E) {} // We expect this to fail
+ catch (Exception &E) {
+ } // We expect this to fail
// Close group
group.close();
@@ -349,9 +358,9 @@ static void test_reference_obj()
H5T_class_t tclass;
tclass = dtype1.getClass();
- verify_val(tclass, H5T_COMPOUND, "DataType::getClass",__LINE__,__FILE__);
+ verify_val(tclass, H5T_COMPOUND, "DataType::getClass", __LINE__, __FILE__);
int n_members = dtype1.getNmembers();
- verify_val(n_members, 3, "CompType::getNmembers",__LINE__,__FILE__);
+ verify_val(n_members, 3, "CompType::getNmembers", __LINE__, __FILE__);
// Close all objects and file
dtype1.close();
@@ -365,17 +374,14 @@ static void test_reference_obj()
PASSED();
} // end try
- catch (Exception& E)
- {
- issue_fail_msg("test_reference_obj()",__LINE__,__FILE__,
- E.getCFuncName(), E.getCDetailMsg());
+ catch (Exception &E) {
+ issue_fail_msg("test_reference_obj()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg());
}
- if(file1)
+ if (file1)
delete file1;
-} // test_reference_obj()
+} // test_reference_obj()
-
/*-------------------------------------------------------------------------
* Function: test_reference_group
*
@@ -384,23 +390,24 @@ static void test_reference_obj()
* Return None
*-------------------------------------------------------------------------
*/
-#define GROUPNAME "/group"
-#define GROUPNAME2 "group2"
-#define GROUPNAME3 "group3"
-#define DSETNAME "/dset"
-#define DSETNAME2 "dset2"
-#define NAME_SIZE 16
-
-static void test_reference_group()
+#define GROUPNAME "/group"
+#define GROUPNAME2 "group2"
+#define GROUPNAME3 "group3"
+#define DSETNAME "/dset"
+#define DSETNAME2 "dset2"
+#define NAME_SIZE 16
+
+static void
+test_reference_group()
{
- hobj_ref_t wref; /* Reference to write */
- hobj_ref_t rref; /* Reference to read */
- const H5std_string write_comment="Foo!"; // Comments for group
+ hobj_ref_t wref; /* Reference to write */
+ hobj_ref_t rref; /* Reference to read */
+ const H5std_string write_comment = "Foo!"; // Comments for group
// Output message about test being performed
SUBTEST("Object Reference to Group");
- H5File* file1 = NULL;
+ H5File *file1 = NULL;
try {
/*
* Create file with a group and a dataset containing an object
@@ -408,7 +415,7 @@ static void test_reference_group()
*/
// Create file FILE1
- file1 = new H5File (FILE1, H5F_ACC_TRUNC);
+ file1 = new H5File(FILE1, H5F_ACC_TRUNC);
// Create scalar dataspace
DataSpace sid1;
@@ -467,25 +474,25 @@ static void test_reference_group()
// Check number of objects in the group dereferenced by constructor
hsize_t nobjs = refgroup.getNumObjs();
- verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__);
+ verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__);
// Check number of objects in the group dereferenced by ::reference
nobjs = group.getNumObjs();
- verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__);
+ verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__);
// Check getting file name given the group dereferenced via constructor
H5std_string fname = refgroup.getFileName();
- verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__);
+ verify_val(fname, FILE1, "H5Group::getFileName", __LINE__, __FILE__);
// Check getting file name given the group dereferenced by ::reference
fname = group.getFileName();
- verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__);
+ verify_val(fname, FILE1, "H5Group::getFileName", __LINE__, __FILE__);
// Check object type using Group::getObjinfo()
H5O_info2_t oinfo;
HDmemset(&oinfo, 0, sizeof(oinfo));
group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, oinfo);
- verify_val(oinfo.type, H5O_TYPE_DATASET, "Group::getObjinfo",__LINE__,__FILE__);
+ verify_val(oinfo.type, H5O_TYPE_DATASET, "Group::getObjinfo", __LINE__, __FILE__);
// Check for out of bound query by index
try {
@@ -494,12 +501,14 @@ static void test_reference_group()
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("Group::getObjinfo", "Out of bound index.");
- } catch (Exception& err) {} // do nothing, failure expected
+ }
+ catch (Exception &err) {
+ } // do nothing, failure expected
// Unlink one of the objects in the dereferenced group, and re-check
refgroup.unlink(GROUPNAME2);
nobjs = refgroup.getNumObjs();
- verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs",__LINE__,__FILE__);
+ verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs", __LINE__, __FILE__);
// Close resources
group.close();
@@ -509,17 +518,14 @@ static void test_reference_group()
PASSED();
} // end try
- catch (Exception& E)
- {
- issue_fail_msg("test_reference_group()",__LINE__,__FILE__,
- E.getCFuncName(), E.getCDetailMsg());
+ catch (Exception &E) {
+ issue_fail_msg("test_reference_group()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg());
}
- if(file1)
+ if (file1)
delete file1;
-} /* test_reference_group() */
+} /* test_reference_group() */
-
/*-------------------------------------------------------------------------
* Function: test_reference_region_1D
*
@@ -528,30 +534,31 @@ static void test_reference_group()
* Return None
*-------------------------------------------------------------------------
*/
-static void test_reference_region_1D()
+static void
+test_reference_region_1D()
{
- hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */
- hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */
- hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */
- hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */
- hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */
- hsize_t * coords; /* Coordinate buffer */
- hsize_t low[SPACE3_RANK]; /* Selection bounds */
- hsize_t high[SPACE3_RANK]; /* Selection bounds */
- int i; /* counting variables */
+ hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */
+ hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */
+ hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */
+ hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */
+ hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */
+ hsize_t *coords; /* Coordinate buffer */
+ hsize_t low[SPACE3_RANK]; /* Selection bounds */
+ hsize_t high[SPACE3_RANK]; /* Selection bounds */
+ int i; /* counting variables */
// Output message about test being performed
SUBTEST("1-D Dataset Region Reference Functions");
try {
- hdset_reg_ref_t *wbuf, // buffer to write to disk
- *rbuf; // buffer read from disk
- uint8_t *dwbuf, // Buffer for writing numeric data to disk
- *drbuf; // Buffer for reading numeric data from disk
+ hdset_reg_ref_t *wbuf, // buffer to write to disk
+ *rbuf; // buffer read from disk
+ uint8_t *dwbuf, // Buffer for writing numeric data to disk
+ *drbuf; // Buffer for reading numeric data from disk
// Allocate write & read buffers
- wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1);
- rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1);
+ wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1);
+ rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1);
dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE3_DIM1);
drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1);
@@ -559,7 +566,7 @@ static void test_reference_region_1D()
H5File file1(FILE2, H5F_ACC_TRUNC);
// Create dataspace for datasets
- hsize_t dims3[] = {SPACE3_DIM1};
+ hsize_t dims3[] = {SPACE3_DIM1};
DataSpace sid3(SPACE3_RANK, dims3);
// Create dataset access property list
@@ -568,7 +575,7 @@ static void test_reference_region_1D()
// Create a dataset
DataSet dset3 = file1.createDataSet(DSET2_NAME, PredType::STD_U8LE, sid3);
- uint8_t *tu8; // Temporary pointer to uint8 data
+ uint8_t *tu8; // Temporary pointer to uint8 data
for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++)
*tu8++ = i * 3; // from C test
@@ -579,7 +586,7 @@ static void test_reference_region_1D()
dset3.close();
// Create dataspace for datasets
- hsize_t dims1[] = {SPACE1_DIM1};
+ hsize_t dims1[] = {SPACE1_DIM1};
DataSpace sid1(SPACE1_RANK, dims1);
// Create a dataset
@@ -590,24 +597,24 @@ static void test_reference_region_1D()
*/
/* Select 15 2x1 hyperslabs for first reference */
- start[0] = 2;
+ start[0] = 2;
stride[0] = 5;
- count[0] = 15;
- block[0] = 2;
+ count[0] = 15;
+ block[0] = 2;
// Select a hyperslab region to add to the current selected region
sid3.selectHyperslab(H5S_SELECT_SET, count, start, stride, block);
// Get and verify the number of elements in a dataspace selection
hssize_t nelms = sid3.getSelectNpoints();
- verify_val(nelms, 30, "DataSet::getRefObjType",__LINE__,__FILE__);
+ verify_val(nelms, 30, "DataSet::getRefObjType", __LINE__, __FILE__);
// Store first dataset region
file1.reference(&wbuf[0], "/Dataset2", sid3);
// Get and verify object type
H5O_type_t obj_type = dset1.getRefObjType(&wbuf[0], H5R_DATASET_REGION);
- verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__);
+ verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__);
/* Select sequence of ten points for second reference */
coord1[0][0] = 16;
@@ -626,7 +633,7 @@ static void test_reference_region_1D()
// Get and verify the number of elements in a dataspace selection
nelms = sid3.getSelectNpoints();
- verify_val(nelms, 10, "DataSet::getRefObjType",__LINE__,__FILE__);
+ verify_val(nelms, 10, "DataSet::getRefObjType", __LINE__, __FILE__);
// Store first dataset region
file1.reference(&wbuf[1], "/Dataset2", sid3);
@@ -658,12 +665,12 @@ static void test_reference_region_1D()
// Get and verify object type
obj_type = dset1.getRefObjType(&rbuf[0], H5R_DATASET_REGION);
- verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__);
+ verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__);
// Get dataspace of dset3 the verify number of elements
- sid1 = dset3.getSpace();
+ sid1 = dset3.getSpace();
nelms = sid1.getSimpleExtentNpoints();
- verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__);
+ verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
} // End of test DataSet::dereference
{ // Test DataSet constructor -by dereference
@@ -672,9 +679,9 @@ static void test_reference_region_1D()
DataSet newds(dset1, &rbuf[0], H5R_DATASET_REGION, dapl);
// Get dataspace of newds then verify number of elements
- sid1 = newds.getSpace();
+ sid1 = newds.getSpace();
nelms = sid1.getSimpleExtentNpoints();
- verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__);
+ verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Close objects for this mini test
newds.close();
@@ -684,8 +691,8 @@ static void test_reference_region_1D()
// Read from disk
dset3.read(drbuf, PredType::STD_U8LE);
- for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++)
- verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__);
+ for (tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++)
+ verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
/*
* Test getting the referenced region
@@ -696,11 +703,11 @@ static void test_reference_region_1D()
// Get and verify number of elements in a dataspace selection
nelms = reg_sp.getSelectNpoints();
- verify_val((long)nelms, 30, "DataSpace::getSelectNpoints",__LINE__,__FILE__);
+ verify_val((long)nelms, 30, "DataSpace::getSelectNpoints", __LINE__, __FILE__);
// Get and verify number of hyperslab blocks
nelms = reg_sp.getSelectHyperNblocks();
- verify_val((long)nelms, 15, "DataSpace::getSelectNpoints",__LINE__,__FILE__);
+ verify_val((long)nelms, 15, "DataSpace::getSelectNpoints", __LINE__, __FILE__);
/* Allocate space for the hyperslab blocks */
coords = (hsize_t *)HDmalloc(nelms * SPACE3_RANK * sizeof(hsize_t) * 2);
@@ -709,43 +716,43 @@ static void test_reference_region_1D()
reg_sp.getSelectHyperBlocklist((hsize_t)0, (hsize_t)nelms, coords);
// Verify values in the list
- verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[4],(hsize_t)12, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[5],(hsize_t)13, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[6],(hsize_t)17, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[7],(hsize_t)18, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[8],(hsize_t)22, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[9],(hsize_t)23, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[10],(hsize_t)27, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[11],(hsize_t)28, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[12],(hsize_t)32, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[13],(hsize_t)33, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[14],(hsize_t)37, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[15],(hsize_t)38, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[16],(hsize_t)42, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[17],(hsize_t)43, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[18],(hsize_t)47, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[19],(hsize_t)48, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[20],(hsize_t)52, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[21],(hsize_t)53, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[22],(hsize_t)57, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[23],(hsize_t)58, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[24],(hsize_t)62, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[25],(hsize_t)63, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[26],(hsize_t)67, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[27],(hsize_t)68, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[28],(hsize_t)72, "Hyperslab Coordinates",__LINE__,__FILE__);
- verify_val(coords[29],(hsize_t)73, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[4], (hsize_t)12, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[5], (hsize_t)13, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[6], (hsize_t)17, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[7], (hsize_t)18, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[8], (hsize_t)22, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[9], (hsize_t)23, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[10], (hsize_t)27, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[11], (hsize_t)28, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[12], (hsize_t)32, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[13], (hsize_t)33, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[14], (hsize_t)37, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[15], (hsize_t)38, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[16], (hsize_t)42, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[17], (hsize_t)43, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[18], (hsize_t)47, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[19], (hsize_t)48, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[20], (hsize_t)52, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[21], (hsize_t)53, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[22], (hsize_t)57, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[23], (hsize_t)58, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[24], (hsize_t)62, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[25], (hsize_t)63, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[26], (hsize_t)67, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[27], (hsize_t)68, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[28], (hsize_t)72, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(coords[29], (hsize_t)73, "Hyperslab Coordinates", __LINE__, __FILE__);
HDfree(coords);
// Check boundaries
reg_sp.getSelectBounds(low, high);
- verify_val(low[0],(hsize_t)2, "DataSpace::getSelectBounds",__LINE__,__FILE__);
- verify_val(high[0],(hsize_t)73, "DataSpace::getSelectBounds",__LINE__,__FILE__);
+ verify_val(low[0], (hsize_t)2, "DataSpace::getSelectBounds", __LINE__, __FILE__);
+ verify_val(high[0], (hsize_t)73, "DataSpace::getSelectBounds", __LINE__, __FILE__);
/* Close region space */
reg_sp.close();
@@ -759,7 +766,7 @@ static void test_reference_region_1D()
// Get and verify number of element points in the current selection
hssize_t nelmspts = elm_sp.getSelectElemNpoints();
- verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints",__LINE__,__FILE__);
+ verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints", __LINE__, __FILE__);
/* Allocate space for the hyperslab blocks */
coords = (hsize_t *)HDmalloc(nelmspts * SPACE3_RANK * sizeof(hsize_t));
@@ -768,23 +775,23 @@ static void test_reference_region_1D()
elm_sp.getSelectElemPointlist((hsize_t)0, (hsize_t)nelmspts, coords);
// Verify points
- verify_val(coords[0], coord1[0][0], "Element Coordinates",__LINE__,__FILE__);
- verify_val(coords[1], coord1[1][0], "Element Coordinates",__LINE__,__FILE__);
- verify_val(coords[2], coord1[2][0], "Element Coordinates",__LINE__,__FILE__);
- verify_val(coords[3], coord1[3][0], "Element Coordinates",__LINE__,__FILE__);
- verify_val(coords[4], coord1[4][0], "Element Coordinates",__LINE__,__FILE__);
- verify_val(coords[5], coord1[5][0], "Element Coordinates",__LINE__,__FILE__);
- verify_val(coords[6], coord1[6][0], "Element Coordinates",__LINE__,__FILE__);
- verify_val(coords[7], coord1[7][0], "Element Coordinates",__LINE__,__FILE__);
- verify_val(coords[8], coord1[8][0], "Element Coordinates",__LINE__,__FILE__);
- verify_val(coords[9], coord1[9][0], "Element Coordinates",__LINE__,__FILE__);
+ verify_val(coords[0], coord1[0][0], "Element Coordinates", __LINE__, __FILE__);
+ verify_val(coords[1], coord1[1][0], "Element Coordinates", __LINE__, __FILE__);
+ verify_val(coords[2], coord1[2][0], "Element Coordinates", __LINE__, __FILE__);
+ verify_val(coords[3], coord1[3][0], "Element Coordinates", __LINE__, __FILE__);
+ verify_val(coords[4], coord1[4][0], "Element Coordinates", __LINE__, __FILE__);
+ verify_val(coords[5], coord1[5][0], "Element Coordinates", __LINE__, __FILE__);
+ verify_val(coords[6], coord1[6][0], "Element Coordinates", __LINE__, __FILE__);
+ verify_val(coords[7], coord1[7][0], "Element Coordinates", __LINE__, __FILE__);
+ verify_val(coords[8], coord1[8][0], "Element Coordinates", __LINE__, __FILE__);
+ verify_val(coords[9], coord1[9][0], "Element Coordinates", __LINE__, __FILE__);
HDfree(coords);
// Check boundaries
elm_sp.getSelectBounds(low, high);
- verify_val(low[0],(hsize_t)3, "DataSpace::getSelectBounds",__LINE__,__FILE__);
- verify_val(high[0],(hsize_t)97, "DataSpace::getSelectBounds",__LINE__,__FILE__);
+ verify_val(low[0], (hsize_t)3, "DataSpace::getSelectBounds", __LINE__, __FILE__);
+ verify_val(high[0], (hsize_t)97, "DataSpace::getSelectBounds", __LINE__, __FILE__);
// Close element space
elm_sp.close();
@@ -803,12 +810,10 @@ static void test_reference_region_1D()
PASSED();
} // end try
- catch (Exception& E)
- {
- issue_fail_msg("test_reference_region_1D()",__LINE__,__FILE__,
- E.getCFuncName(), E.getCDetailMsg());
+ catch (Exception &E) {
+ issue_fail_msg("test_reference_region_1D()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg());
}
-} /* test_reference_region_1D() */
+} /* test_reference_region_1D() */
/*-------------------------------------------------------------------------
*
@@ -816,8 +821,8 @@ static void test_reference_region_1D()
*
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_reference()
+extern "C" void
+test_reference()
{
// Output message about test being performed
MESSAGE(5, ("Testing References\n"));
@@ -827,9 +832,8 @@ void test_reference()
test_reference_group(); // Test group reference functionality
test_reference_region_1D(); // Test 1-D reference functionality
-} // test_reference()
+} // test_reference()
-
/*-------------------------------------------------------------------------
* Function: cleanup_reference
*
@@ -838,10 +842,9 @@ void test_reference()
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_reference()
+extern "C" void
+cleanup_reference()
{
HDremove(FILE1.c_str());
HDremove(FILE2.c_str());
}
-
diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp
index b8846f4..7411e37 100644
--- a/c++/test/ttypes.cpp
+++ b/c++/test/ttypes.cpp
@@ -25,17 +25,17 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
/*
* Offset from alinged memory returned by malloc(). This can be used to test
* that type conversions handle non-aligned buffers correctly.
*/
-#define ALIGNMENT 1
+#define ALIGNMENT 1
/*
* Define if you want to test alignment code on a machine that doesn't
@@ -50,35 +50,34 @@ using namespace H5;
#define H5T_FRIEND
#include "H5Tpkg.h"
#endif
-#define SET_ALIGNMENT(TYPE,VAL) \
- H5T_NATIVE_##TYPE##_ALIGN_g=MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL)
+#define SET_ALIGNMENT(TYPE, VAL) H5T_NATIVE_##TYPE##_ALIGN_g = MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL)
#endif
- /* #include "H5Tpkg.h"
+/* #include "H5Tpkg.h"
*/
-const char *FILENAME[] = {
- "dtypes1.h5",
- "dtypes2.h5",
- "dtypes3.h5",
- "dtypes4.h5",
- NULL
-};
+const char *FILENAME[] = {"dtypes1.h5", "dtypes2.h5", "dtypes3.h5", "dtypes4.h5", NULL};
/*
* Count up or down depending on whether the machine is big endian or little
* endian. If local variable `endian' is H5T_ORDER_BE then the result will
* be I, otherwise the result will be Z-(I+1).
*/
-#define ENDIAN(Z,I) (H5T_ORDER_BE==endian?(I):(Z)-((I)+1))
+#define ENDIAN(Z, I) (H5T_ORDER_BE == endian ? (I) : (Z) - ((I) + 1))
-
-typedef enum flt_t {
- FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER
-} flt_t;
+typedef enum flt_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER } flt_t;
typedef enum int_t {
- INT_CHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT,
- INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, INT_OTHER
+ INT_CHAR,
+ INT_UCHAR,
+ INT_SHORT,
+ INT_USHORT,
+ INT_INT,
+ INT_UINT,
+ INT_LONG,
+ INT_ULONG,
+ INT_LLONG,
+ INT_ULLONG,
+ INT_OTHER
} int_t;
typedef struct {
@@ -88,7 +87,6 @@ typedef struct {
double d;
} src_typ_t;
-
/*-------------------------------------------------------------------------
* Function: test_classes
*
@@ -100,7 +98,8 @@ typedef struct {
* January, 2007
*-------------------------------------------------------------------------
*/
-static void test_classes()
+static void
+test_classes()
{
SUBTEST("PredType::getClass()");
try {
@@ -108,24 +107,23 @@ static void test_classes()
// PredType::NATIVE_INT should be in H5T_INTEGER class
H5T_class_t tcls = PredType::NATIVE_INT.getClass();
- if (H5T_INTEGER!=tcls) {
+ if (H5T_INTEGER != tcls) {
puts(" Invalid type class for H5T_NATIVE_INT");
}
// PredType::NATIVE_DOUBLE should be in H5T_FLOAT class
tcls = PredType::NATIVE_DOUBLE.getClass();
- if (H5T_FLOAT!=tcls) {
- verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, __FILE__);
+ if (H5T_FLOAT != tcls) {
+ verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__,
+ __FILE__);
}
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_classes", __LINE__, __FILE__, E.getCDetailMsg());
}
}
-
/*-------------------------------------------------------------------------
* Function: test_copy
*
@@ -137,7 +135,8 @@ static void test_classes()
* January, 2007
*-------------------------------------------------------------------------
*/
-static void test_copy()
+static void
+test_copy()
{
SUBTEST("DataType::copy() and DataType::operator=");
@@ -148,7 +147,7 @@ static void test_copy()
// Test copying a predefined type using DataType::copy
DataType copied_type;
- copied_type.copy (PredType::STD_B8LE);
+ copied_type.copy(PredType::STD_B8LE);
// Test copying a user-defined type using DataType::operator=
DataType assigned_usertype;
@@ -159,7 +158,7 @@ static void test_copy()
copied_usertype.copy(copied_type);
// Test copying a user-defined int type using DataType::operator=
- IntType orig_int(PredType::STD_B8LE);
+ IntType orig_int(PredType::STD_B8LE);
DataType generic_type;
generic_type = orig_int;
@@ -172,13 +171,11 @@ static void test_copy()
PASSED();
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_copy", __LINE__, __FILE__, E.getCDetailMsg());
}
}
-
/*-------------------------------------------------------------------------
* Function: test_detect_type_class
*
@@ -190,29 +187,30 @@ static void test_copy()
* August, 2017
*-------------------------------------------------------------------------
*/
-typedef struct { /* Struct with atomic fields */
- int i;
- float f;
- char c;
- double d;
- short s;
+typedef struct { /* Struct with atomic fields */
+ int i;
+ float f;
+ char c;
+ double d;
+ short s;
} atomic_typ_t;
-typedef struct { /* Struct with complex fields */
- hobj_ref_t arr_r[3][3];
- int i;
- hvl_t vl_f;
- hvl_t vl_s;
- char c;
- short s;
+typedef struct { /* Struct with complex fields */
+ hobj_ref_t arr_r[3][3];
+ int i;
+ hvl_t vl_f;
+ hvl_t vl_s;
+ char c;
+ short s;
} complex_typ_t;
-static void test_detect_type_class()
+static void
+test_detect_type_class()
{
SUBTEST("DataType::detectClass()");
try {
- bool in_class = false; // indicates whether a datatype is in a class
+ bool in_class = false; // indicates whether a datatype is in a class
/*
* Test class of some atomic types.
@@ -260,8 +258,8 @@ static void test_detect_type_class()
*/
// Create an array datatype with an atomic base type
- unsigned rank = 2; // Rank for array datatype
- hsize_t dims[2] = {3,3}; // Dimensions for array datatype
+ unsigned rank = 2; // Rank for array datatype
+ hsize_t dims[2] = {3, 3}; // Dimensions for array datatype
ArrayType atom_arr(PredType::STD_REF_OBJ, rank, dims);
// Make certain that the correct classes can be detected
@@ -367,13 +365,11 @@ static void test_detect_type_class()
PASSED();
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_detect_type_class", __LINE__, __FILE__, E.getCDetailMsg());
}
}
-
/*-------------------------------------------------------------------------
* Function: test_vltype
*
@@ -385,12 +381,12 @@ static void test_detect_type_class()
* August, 2017
*-------------------------------------------------------------------------
*/
-static void test_vltype()
+static void
+test_vltype()
{
// Output message about test being performed
SUBTEST("VarLenType functions");
- try
- {
+ try {
VarLenType vltype(PredType::NATIVE_INT);
bool in_class = vltype.detectClass(H5T_VLEN);
@@ -408,9 +404,11 @@ static void test_vltype()
in_class = vltype2.detectClass(H5T_VLEN);
verify_val(in_class, true, "VarLenType::detectClass() with H5T_VLEN for vltype2", __LINE__, __FILE__);
in_class = vltype2.detectClass(H5T_INTEGER);
- verify_val(in_class, true, "VarLenType::detectClass() with H5T_INTEGER for vltype2", __LINE__, __FILE__);
+ verify_val(in_class, true, "VarLenType::detectClass() with H5T_INTEGER for vltype2", __LINE__,
+ __FILE__);
in_class = vltype2.detectClass(H5T_FLOAT);
- verify_val(in_class, false, "VarLenType::detectClass() with H5T_FLOAT for vltype2", __LINE__, __FILE__);
+ verify_val(in_class, false, "VarLenType::detectClass() with H5T_FLOAT for vltype2", __LINE__,
+ __FILE__);
// Create a new file to use in this test
H5File file(FILENAME[3], H5F_ACC_TRUNC);
@@ -435,17 +433,16 @@ static void test_vltype()
in_class = vltype2.detectClass(H5T_VLEN);
verify_val(in_class, true, "VarLenType::detectClass() with H5T_VLEN for vltype2", __LINE__, __FILE__);
in_class = first_vlt_again.detectClass(H5T_FLOAT);
- verify_val(in_class, true, "VarLenType::detectClass() with H5T_FLOAT for first_vlt_again", __LINE__, __FILE__);
+ verify_val(in_class, true, "VarLenType::detectClass() with H5T_FLOAT for first_vlt_again", __LINE__,
+ __FILE__);
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_vltype", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_vltype
+} // test_vltype
-
/*-------------------------------------------------------------------------
* Function: test_query
*
@@ -460,14 +457,14 @@ static void test_vltype()
const H5std_string CompT_NAME("Compound_type");
const H5std_string EnumT_NAME("Enum_type");
-static void test_query()
+static void
+test_query()
{
- short enum_val;
+ short enum_val;
// Output message about test being performed
SUBTEST("Query functions of compound and enumeration types");
- try
- {
+ try {
// Create File
H5File file(FILENAME[2], H5F_ACC_TRUNC);
@@ -482,11 +479,11 @@ static void test_query()
// Create a enumerate datatype
EnumType tid2(sizeof(short));
- tid2.insert("RED", (enum_val=0,&enum_val));
- tid2.insert("GREEN", (enum_val=1,&enum_val));
- tid2.insert("BLUE", (enum_val=2,&enum_val));
- tid2.insert("ORANGE", (enum_val=3,&enum_val));
- tid2.insert("YELLOW", (enum_val=4,&enum_val));
+ tid2.insert("RED", (enum_val = 0, &enum_val));
+ tid2.insert("GREEN", (enum_val = 1, &enum_val));
+ tid2.insert("BLUE", (enum_val = 2, &enum_val));
+ tid2.insert("ORANGE", (enum_val = 3, &enum_val));
+ tid2.insert("YELLOW", (enum_val = 4, &enum_val));
// Query member number and member index by name, for compound type
int nmembs = tid1.getNmembers();
@@ -506,10 +503,10 @@ static void test_query()
// prop list, then close it
tid1.commit(file, CompT_NAME);
PropList tcpl = tid1.getCreatePlist();
- if (!IdComponent::isValid(tcpl.getId()))
- {
+ if (!IdComponent::isValid(tcpl.getId())) {
// Throw an invalid action exception
- throw InvalidActionException("H5Object::createAttribute", "Datatype creation property list is not valid");
+ throw InvalidActionException("H5Object::createAttribute",
+ "Datatype creation property list is not valid");
}
tcpl.close();
tid1.close();
@@ -518,10 +515,10 @@ static void test_query()
// prop list, then close it
tid2.commit(file, EnumT_NAME);
tcpl = tid2.getCreatePlist();
- if (!IdComponent::isValid(tcpl.getId()))
- {
+ if (!IdComponent::isValid(tcpl.getId())) {
// Throw an invalid action exception
- throw InvalidActionException("H5Object::createAttribute", "Datatype creation property list is not valid");
+ throw InvalidActionException("H5Object::createAttribute",
+ "Datatype creation property list is not valid");
}
tcpl.close();
tid2.close();
@@ -560,14 +557,12 @@ static void test_query()
H5File file1(FILENAME[2], H5F_ACC_TRUNC);
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_query", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_query
+} // test_query
-
/*-------------------------------------------------------------------------
* Function: test_transient
*
@@ -579,17 +574,18 @@ static void test_query()
* January, 2007
*-------------------------------------------------------------------------
*/
-const char* filename1 = "dtypes1.h5";
+const char *filename1 = "dtypes1.h5";
-static void test_transient ()
+static void
+test_transient()
{
- static hsize_t ds_size[2] = {10, 20};
+ static hsize_t ds_size[2] = {10, 20};
SUBTEST("Transient datatypes");
try {
// Create the file and the dataspace.
- H5File file(filename1, H5F_ACC_TRUNC);
+ H5File file(filename1, H5F_ACC_TRUNC);
DataSpace space(2, ds_size, ds_size);
// Copying a predefined type results in a modifiable copy
@@ -600,8 +596,11 @@ static void test_transient ()
try {
Attribute attr(type.createAttribute("attr1", PredType::NATIVE_INT, space));
// Should FAIL but didn't, so throw an invalid action exception
- throw InvalidActionException("H5Object::createAttribute", "Attempted to commit a predefined datatype.");
- } catch (AttributeIException& err) {} // do nothing, failure expected
+ throw InvalidActionException("H5Object::createAttribute",
+ "Attempted to commit a predefined datatype.");
+ }
+ catch (AttributeIException &err) {
+ } // do nothing, failure expected
// Create a dataset from a transient datatype
// type.close(); - put trace in H5Tclose to make sure it's closed
@@ -614,8 +613,11 @@ static void test_transient ()
itype.setPrecision(256);
// Should FAIL but didn't, so throw an invalid action exception
- throw InvalidActionException("PredType::setPrecision", "Dataset datatypes should not be modifiable!");
- } catch (DataTypeIException& err) {}
+ throw InvalidActionException("PredType::setPrecision",
+ "Dataset datatypes should not be modifiable!");
+ }
+ catch (DataTypeIException &err) {
+ }
itype.close();
// Get a copy of the dataset's datatype by applying DataType::copy()
@@ -635,14 +637,12 @@ static void test_transient ()
type.close();
space.close();
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_transient", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_transient
+} // test_transient
-
/*-------------------------------------------------------------------------
* Function: test_named
*
@@ -656,12 +656,13 @@ static void test_transient ()
*/
const H5std_string filename2("dtypes2.h5");
-static void test_named ()
+static void
+test_named()
{
static hsize_t ds_size[2] = {10, 20};
- hsize_t i;
- unsigned attr_data[10][20];
- DataType *ds_type = NULL;
+ hsize_t i;
+ unsigned attr_data[10][20];
+ DataType * ds_type = NULL;
SUBTEST("Named datatypes");
try {
@@ -678,15 +679,16 @@ static void test_named ()
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("PredType::commit", "Attempted to commit a predefined datatype.");
- } catch (DataTypeIException& err) {}
+ }
+ catch (DataTypeIException &err) {
+ }
// Copy a predefined datatype and commit the copy.
IntType itype(PredType::NATIVE_INT);
itype.commit(file, "native-int");
// Test commit passing in const H5File& for prototype with const
- try
- {
+ try {
// Create random char type
IntType atype(PredType::NATIVE_UCHAR);
@@ -696,9 +698,8 @@ static void test_named ()
// Commit type passing in const group; compilation would fail if
// no matching prototype
atype.commit(const_grp, "random uchar");
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_named", __LINE__, __FILE__, "Commit at const group");
}
@@ -708,11 +709,14 @@ static void test_named ()
// We should not be able to modify a type after it has been committed.
try {
- itype.setPrecision(256); // attempt an invalid action...
+ itype.setPrecision(256); // attempt an invalid action...
// Should FAIL but didn't, so throw an invalid action exception
- throw InvalidActionException("IntType::setPrecision", "Attempted to modify a committed datatype.");
- } catch (DataTypeIException& err) {}
+ throw InvalidActionException("IntType::setPrecision",
+ "Attempted to modify a committed datatype.");
+ }
+ catch (DataTypeIException &err) {
+ }
// We should not be able to re-commit a committed type
try {
@@ -720,12 +724,14 @@ static void test_named ()
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("IntType::commit", "Attempted to re-commit a committed datatype.");
- } catch (DataTypeIException& err) {} // do nothing, failure expected
+ }
+ catch (DataTypeIException &err) {
+ } // do nothing, failure expected
// It should be possible to define an attribute for the named type
Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space);
- for (i=0; i<ds_size[0]*ds_size[1]; i++)
- attr_data[0][i] = (int)i;/*tricky*/
+ for (i = 0; i < ds_size[0] * ds_size[1]; i++)
+ attr_data[0][i] = (int)i; /*tricky*/
attr1.write(PredType::NATIVE_UINT, attr_data);
attr1.close();
@@ -734,13 +740,15 @@ static void test_named ()
IntType trans_type;
trans_type.copy(itype);
bool iscommitted = trans_type.committed();
- verify_val(iscommitted, 0, "DataType::committed() - Copying a named type should result in a transient type!", __LINE__, __FILE__);
+ verify_val(iscommitted, 0,
+ "DataType::committed() - Copying a named type should result in a transient type!",
+ __LINE__, __FILE__);
trans_type.setPrecision(256);
trans_type.close();
// Close the committed type and reopen it. It should be a named type.
itype.close();
- itype = file.openIntType("native-int");
+ itype = file.openIntType("native-int");
iscommitted = itype.committed();
if (!iscommitted)
throw InvalidActionException("IntType::committed()", "Opened named types should be named types!");
@@ -748,8 +756,8 @@ static void test_named ()
// Create a dataset that uses the named type, then get the dataset's
// datatype and make sure it's a named type.
DataSet dset = file.createDataSet("dset1", itype, space);
- ds_type = new DataType(dset.getDataType());
- iscommitted = ds_type->committed();
+ ds_type = new DataType(dset.getDataType());
+ iscommitted = ds_type->committed();
if (!iscommitted)
throw InvalidActionException("IntType::committed()", "Dataset type should be named type!");
dset.close();
@@ -758,8 +766,8 @@ static void test_named ()
// Reopen the dataset and its type, then make sure the type is
// a named type.
- dset = file.openDataSet("dset1");
- ds_type = new DataType(dset.getDataType());
+ dset = file.openDataSet("dset1");
+ ds_type = new DataType(dset.getDataType());
iscommitted = ds_type->committed();
if (!iscommitted)
throw InvalidActionException("IntType::committed()", "Dataset type should be named type!");
@@ -773,8 +781,8 @@ static void test_named ()
delete ds_type;
// Reopen the second dataset and make sure the type is shared
- dset = file.openDataSet("dset2");
- ds_type = new DataType(dset.getDataType());
+ dset = file.openDataSet("dset2");
+ ds_type = new DataType(dset.getDataType());
iscommitted = ds_type->committed();
if (!iscommitted)
throw InvalidActionException("DataType::iscommitted()", "Dataset type should be named type!");
@@ -793,17 +801,15 @@ static void test_named ()
space.close();
file.close();
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_named", __LINE__, __FILE__, E.getCDetailMsg());
}
- if(ds_type)
+ if (ds_type)
delete ds_type;
-} // test_named
+} // test_named
-
/*-------------------------------------------------------------------------
* Function: test_encode_decode
*
@@ -816,12 +822,13 @@ static void test_named ()
*-------------------------------------------------------------------------
*/
const H5std_string filename3("encode_decode.h5");
-const int ARRAY1_RANK = 1;
-const int ARRAY1_DIM = 10;
+const int ARRAY1_RANK = 1;
+const int ARRAY1_DIM = 10;
-static void test_encode_decode()
+static void
+test_encode_decode()
{
- short enum_val;
+ short enum_val;
SUBTEST("DataType::encode() and DataType::decode()");
try {
@@ -847,7 +854,7 @@ static void test_encode_decode()
verify_val(cmptyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Decode compound type's buffer to a new CompType
- CompType* decoded_cmp_ptr(static_cast<CompType *>(cmptyp.decode()));
+ CompType *decoded_cmp_ptr(static_cast<CompType *>(cmptyp.decode()));
// Verify that the datatype was copied exactly via encoding/decoding
verify_val(cmptyp == *decoded_cmp_ptr, true, "DataType::decode", __LINE__, __FILE__);
@@ -871,11 +878,11 @@ static void test_encode_decode()
// Create a enumerate datatype
EnumType enumtyp(sizeof(short));
- enumtyp.insert("RED", (enum_val=0,&enum_val));
- enumtyp.insert("GREEN", (enum_val=1,&enum_val));
- enumtyp.insert("BLUE", (enum_val=2,&enum_val));
- enumtyp.insert("ORANGE", (enum_val=3,&enum_val));
- enumtyp.insert("YELLOW", (enum_val=4,&enum_val));
+ enumtyp.insert("RED", (enum_val = 0, &enum_val));
+ enumtyp.insert("GREEN", (enum_val = 1, &enum_val));
+ enumtyp.insert("BLUE", (enum_val = 2, &enum_val));
+ enumtyp.insert("ORANGE", (enum_val = 3, &enum_val));
+ enumtyp.insert("YELLOW", (enum_val = 4, &enum_val));
// Encode compound type in a buffer
enumtyp.encode();
@@ -884,7 +891,7 @@ static void test_encode_decode()
verify_val(enumtyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Decode enumeration type's buffer to a new EnumType
- EnumType* decoded_enum_ptr(static_cast<EnumType *>(enumtyp.decode()));
+ EnumType *decoded_enum_ptr(static_cast<EnumType *>(enumtyp.decode()));
// Verify that the datatype was copied exactly via encoding/decoding
verify_val(enumtyp == *decoded_enum_ptr, true, "DataType::decode", __LINE__, __FILE__);
@@ -916,7 +923,7 @@ static void test_encode_decode()
verify_val(vlsttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Decode the variable-length type's buffer to a new StrType
- StrType* decoded_str_ptr(static_cast<StrType *>(vlsttyp.decode()));
+ StrType *decoded_str_ptr(static_cast<StrType *>(vlsttyp.decode()));
verify_val(vlsttyp == *decoded_str_ptr, true, "DataType::decode", __LINE__, __FILE__);
verify_val(decoded_str_ptr->isVariableStr(), true, "DataType::decode", __LINE__, __FILE__);
@@ -926,7 +933,7 @@ static void test_encode_decode()
// Test decoding the type by way of DataType*
// Decode variable-length string type to a new DataType
- DataType* decoded_vlstr_ptr(vlsttyp.decode());
+ DataType *decoded_vlstr_ptr(vlsttyp.decode());
// Create a StrType instance from the DataType object and verify it
StrType decoded_vlsttyp(decoded_vlstr_ptr->getId());
@@ -951,7 +958,7 @@ static void test_encode_decode()
verify_val(arrtyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Create an ArrayType instance from the decoded pointer and verify it
- ArrayType* decoded_arr_ptr(static_cast<ArrayType *>(arrtyp.decode()));
+ ArrayType *decoded_arr_ptr(static_cast<ArrayType *>(arrtyp.decode()));
verify_val(arrtyp == *decoded_arr_ptr, true, "DataType::decode", __LINE__, __FILE__);
@@ -983,7 +990,7 @@ static void test_encode_decode()
verify_val(inttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Create an IntType instance from the decoded pointer and verify it
- IntType* decoded_int_ptr(static_cast<IntType *>(inttyp.decode()));
+ IntType * decoded_int_ptr(static_cast<IntType *>(inttyp.decode()));
H5T_sign_t int_sign = decoded_int_ptr->getSign();
verify_val(int_sign, H5T_SGN_NONE, "DataType::decode", __LINE__, __FILE__);
verify_val(inttyp == *decoded_int_ptr, true, "DataType::decode", __LINE__, __FILE__);
@@ -1004,27 +1011,25 @@ static void test_encode_decode()
verify_val(flttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Decode the array type's buffer
- DataType* decoded_flt_ptr(flttyp.decode());
+ DataType *decoded_flt_ptr(flttyp.decode());
// Create a IntType instance from the decoded pointer and verify it
FloatType decoded_flttyp(decoded_flt_ptr->getId());
verify_val(flttyp == decoded_flttyp, true, "DataType::decode", __LINE__, __FILE__);
- //H5std_string norm_string;
- //H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string);
- //verify_val(decoded_flttyp.isVariableStr(), true, "DataType::decode", __LINE__, __FILE__);
+ // H5std_string norm_string;
+ // H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string);
+ // verify_val(decoded_flttyp.isVariableStr(), true, "DataType::decode", __LINE__, __FILE__);
delete decoded_flt_ptr;
PASSED();
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_encode_decode", __LINE__, __FILE__, E.getCDetailMsg());
}
}
-
/*-------------------------------------------------------------------------
* Function: test_operators
*
@@ -1038,9 +1043,10 @@ static void test_encode_decode()
*/
const H5std_string filename4("h5_type_operators.h5");
-static void test_operators()
+static void
+test_operators()
{
- short enum_val;
+ short enum_val;
SUBTEST("DataType::operator== and DataType::operator!=");
try {
@@ -1073,9 +1079,9 @@ static void test_operators()
// Create an enumerate datatype
EnumType enumtyp(sizeof(short));
- enumtyp.insert("RED", (enum_val=0,&enum_val));
- enumtyp.insert("GREEN", (enum_val=1,&enum_val));
- enumtyp.insert("BLUE", (enum_val=2,&enum_val));
+ enumtyp.insert("RED", (enum_val = 0, &enum_val));
+ enumtyp.insert("GREEN", (enum_val = 1, &enum_val));
+ enumtyp.insert("BLUE", (enum_val = 2, &enum_val));
// Verify that operator== and operator!= work properly
verify_val(cmptyp == enumtyp, false, "DataType::operator==", __LINE__, __FILE__);
@@ -1086,7 +1092,7 @@ static void test_operators()
//
// Create random atomic datatypes
- IntType inttyp(PredType::NATIVE_INT);
+ IntType inttyp(PredType::NATIVE_INT);
FloatType flttyp(PredType::NATIVE_FLOAT);
// Get the NATIVE_INT member from the compound datatype above
@@ -1106,13 +1112,11 @@ static void test_operators()
PASSED();
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_operators", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_operators
+} // test_operators
-
/*-------------------------------------------------------------------------
* Function: test_types
*
@@ -1121,8 +1125,8 @@ static void test_operators()
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_types()
+extern "C" void
+test_types()
{
// Output message about test being performed
MESSAGE(5, ("Testing Generic Data Types\n"));
@@ -1138,9 +1142,8 @@ void test_types()
test_encode_decode();
test_operators();
-} // test_types()
+} // test_types()
-
/*-------------------------------------------------------------------------
* Function: cleanup_types
*
@@ -1149,9 +1152,9 @@ void test_types()
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_types()
+extern "C" void
+cleanup_types()
{
for (int i = 0; i < 3; i++)
HDremove(FILENAME[i]);
-} // cleanup_types
+} // cleanup_types
diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp
index 2421a87..8f0c0ab 100644
--- a/c++/test/tvlstr.cpp
+++ b/c++/test/tvlstr.cpp
@@ -27,17 +27,17 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
// Data file used in most test functions
const H5std_string FILENAME("tvlstr.h5");
// 1-D dataset with fixed dimensions
-const int SPACE1_RANK = 1;
+const int SPACE1_RANK = 1;
const hsize_t SPACE1_DIM1 = 4;
/*-------------------------------------------------------------------------
@@ -137,10 +137,11 @@ static void test_vlstr_free_custom(void *_mem, void *info)
const H5std_string DSET1_NAME("String_ds");
const H5std_string DSET1_DATA("String Dataset");
-static void test_vlstring_dataset()
+static void
+test_vlstring_dataset()
{
char *dynstring_ds_write = NULL;
- char *string_ds_check = NULL;
+ char *string_ds_check = NULL;
// Output message about test being performed
SUBTEST("VL String on Datasets");
@@ -156,7 +157,7 @@ static void test_vlstring_dataset()
Group root = file1.openGroup("/");
// Create dataspace for the dataset.
- DataSpace ds_space (H5S_SCALAR);
+ DataSpace ds_space(H5S_SCALAR);
// Create an dataset in the root group.
DataSet dset1 = root.createDataSet(DSET1_NAME, vlst, ds_space);
@@ -166,17 +167,19 @@ static void test_vlstring_dataset()
// Read and verify the dataset string as a string of chars.
dset1.read(&string_ds_check, vlst);
- if(HDstrcmp(string_ds_check, DSET1_DATA.c_str())!=0)
- TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n",__LINE__, DSET1_DATA.c_str(), string_ds_check);
+ if (HDstrcmp(string_ds_check, DSET1_DATA.c_str()) != 0)
+ TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n", __LINE__,
+ DSET1_DATA.c_str(), string_ds_check);
- HDfree(string_ds_check); // note: no need for std::string test
+ HDfree(string_ds_check); // note: no need for std::string test
string_ds_check = NULL;
// Read and verify the dataset string as an std::string.
H5std_string read_str;
dset1.read(read_str, vlst);
if (read_str != DSET1_DATA)
- TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,read_str=%s\n",__LINE__, DSET1_DATA.c_str(), read_str.c_str());
+ TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,read_str=%s\n", __LINE__,
+ DSET1_DATA.c_str(), read_str.c_str());
// Close the dataset.
dset1.close();
@@ -184,7 +187,7 @@ static void test_vlstring_dataset()
// Test scalar type dataset with 1 value.
dset1 = root.createDataSet("test_scalar_small", vlst, ds_space);
- dynstring_ds_write = (char*)HDcalloc(1, sizeof(char));
+ dynstring_ds_write = (char *)HDcalloc(1, sizeof(char));
HDmemset(dynstring_ds_write, 'A', 1);
// Write data to the dataset, then read it back.
@@ -192,8 +195,9 @@ static void test_vlstring_dataset()
dset1.read(&string_ds_check, vlst);
// Verify data read.
- if(HDstrcmp(string_ds_check,dynstring_ds_write)!=0)
- TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n",dynstring_ds_write,string_ds_check);
+ if (HDstrcmp(string_ds_check, dynstring_ds_write) != 0)
+ TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n",
+ dynstring_ds_write, string_ds_check);
HDfree(string_ds_check);
string_ds_check = NULL;
dset1.close();
@@ -209,16 +213,15 @@ static void test_vlstring_dataset()
} // end try block
// Catch all exceptions.
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_vlstring_dataset()", __LINE__, __FILE__, E.getCDetailMsg());
}
- if(dynstring_ds_write)
+ if (dynstring_ds_write)
HDfree(dynstring_ds_write);
- if(string_ds_check)
+ if (string_ds_check)
HDfree(string_ds_check);
-} // test_vlstring_dataset()
+} // test_vlstring_dataset()
/*-------------------------------------------------------------------------
* Function: test_vlstring_array_dataset
@@ -234,22 +237,22 @@ static void test_vlstring_dataset()
*/
const H5std_string DSSTRARR_NAME("StringArray_dset");
-static void test_vlstring_array_dataset()
+static void
+test_vlstring_array_dataset()
{
- const char *string_ds_array[SPACE1_DIM1]= {
- "Line 1", "Line 2", "Line 3", "Line 4"
- }; // Information to write
+ const char *string_ds_array[SPACE1_DIM1] = {"Line 1", "Line 2", "Line 3",
+ "Line 4"}; // Information to write
// Output message about test being performed
SUBTEST("VL String Array on Datasets");
- H5File* file1 = NULL;
+ H5File *file1 = NULL;
try {
// Create file.
file1 = new H5File(FILENAME, H5F_ACC_RDWR);
// Create dataspace for datasets.
- hsize_t dims1[] = {SPACE1_DIM1};
+ hsize_t dims1[] = {SPACE1_DIM1};
DataSpace ds_space(SPACE1_RANK, dims1);
// Create a datatype to refer to.
@@ -265,10 +268,10 @@ static void test_vlstring_array_dataset()
dataset.read(string_ds_check, vlst);
hsize_t ii;
- for (ii = 0; ii < SPACE1_DIM1; ii++)
- {
- if(HDstrcmp(string_ds_check[ii], string_ds_array[ii])!=0)
- TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, string_ds_array[ii], string_ds_check[ii]);
+ for (ii = 0; ii < SPACE1_DIM1; ii++) {
+ if (HDstrcmp(string_ds_check[ii], string_ds_array[ii]) != 0)
+ TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n", __LINE__,
+ string_ds_array[ii], string_ds_check[ii]);
HDfree(string_ds_check[ii]);
}
@@ -286,14 +289,14 @@ static void test_vlstring_array_dataset()
// Create and write another dataset.
DataSet dataset2(file1->createDataSet("Dataset2", vlst, scalar_space));
- char *wdata2 = (char*)HDcalloc(65534, sizeof(char));
+ char * wdata2 = (char *)HDcalloc(65534, sizeof(char));
HDmemset(wdata2, 'A', 65533);
dataset2.write(&wdata2, vlst);
char *rdata2;
dataset2.read(&rdata2, vlst);
- if (HDstrcmp(wdata2, rdata2)!=0)
- TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, wdata2, rdata2);
+ if (HDstrcmp(wdata2, rdata2) != 0)
+ TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n", __LINE__, wdata2, rdata2);
// Release resources from second dataset operation.
scalar_space.close();
@@ -310,12 +313,11 @@ static void test_vlstring_array_dataset()
} // end try
// Catch all exceptions.
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg());
}
- if(file1)
+ if (file1)
delete file1;
} // end test_vlstring_array_dataset()
@@ -332,11 +334,12 @@ static void test_vlstring_array_dataset()
*
*-------------------------------------------------------------------------
*/
-static void test_vlstrings_special()
+static void
+test_vlstrings_special()
{
- const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"};
+ const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"};
const char *wdata2[SPACE1_DIM1] = {NULL, NULL, NULL, NULL};
- char *rdata[SPACE1_DIM1]; // Information read in
+ char * rdata[SPACE1_DIM1]; // Information read in
// Output message about test being performed.
SUBTEST("Special VL Strings");
@@ -346,7 +349,7 @@ static void test_vlstrings_special()
H5File file1(FILENAME, H5F_ACC_TRUNC);
// Create dataspace for datasets.
- hsize_t dims1[] = {SPACE1_DIM1};
+ hsize_t dims1[] = {SPACE1_DIM1};
DataSpace sid1(SPACE1_RANK, dims1);
// Create a datatype to refer to.
@@ -360,30 +363,29 @@ static void test_vlstrings_special()
// Check data read in.
hsize_t ii; // counting variable
- for (ii=0; ii<SPACE1_DIM1; ii++)
- if(rdata[ii]!=NULL)
- TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]);
+ for (ii = 0; ii < SPACE1_DIM1; ii++)
+ if (rdata[ii] != NULL)
+ TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]);
// Write dataset to disk, then read it back.
dataset.write(wdata, vlst);
dataset.read(rdata, vlst);
// Compare data read in.
- for (ii = 0; ii < SPACE1_DIM1; ii++)
- {
+ for (ii = 0; ii < SPACE1_DIM1; ii++) {
size_t wlen = HDstrlen(wdata[ii]);
size_t rlen = HDstrlen(rdata[ii]);
- if(wlen != rlen)
- {
- TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n", (int)ii, (unsigned)wlen, (int)ii, (unsigned)rlen);
+ if (wlen != rlen) {
+ TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n",
+ (int)ii, (unsigned)wlen, (int)ii, (unsigned)rlen);
continue;
} // end if
- if(HDstrcmp(wdata[ii],rdata[ii]) != 0)
- {
- TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)ii, wdata[ii], (int)ii, rdata[ii]);
+ if (HDstrcmp(wdata[ii], rdata[ii]) != 0) {
+ TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)ii, wdata[ii],
+ (int)ii, rdata[ii]);
continue;
} // end if
- } // end for
+ } // end for
// Reclaim the read VL data.
DataSet::vlenReclaim((void *)rdata, vlst, sid1);
@@ -398,7 +400,7 @@ static void test_vlstrings_special()
// Create the property list and set the fill value for the second
// dataset.
DSetCreatPropList dcpl;
- char *fill = NULL; // Fill value
+ char * fill = NULL; // Fill value
dcpl.setFillValue(vlst, &fill);
dataset = file1.createDataSet("Dataset4", vlst, sid1, dcpl);
@@ -409,9 +411,9 @@ static void test_vlstrings_special()
dataset.read(rdata, vlst);
// Check data read in.
- for (ii=0; ii<SPACE1_DIM1; ii++)
- if(rdata[ii]!=NULL)
- TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]);
+ for (ii = 0; ii < SPACE1_DIM1; ii++)
+ if (rdata[ii] != NULL)
+ TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]);
// Try to write nil strings to disk.
dataset.write(wdata2, vlst);
@@ -420,9 +422,9 @@ static void test_vlstrings_special()
dataset.read(rdata, vlst);
// Check data read in.
- for (ii=0; ii<SPACE1_DIM1; ii++)
- if(rdata[ii]!=NULL)
- TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]);
+ for (ii = 0; ii < SPACE1_DIM1; ii++)
+ if (rdata[ii] != NULL)
+ TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]);
// Close objects and file.
dataset.close();
@@ -434,8 +436,7 @@ static void test_vlstrings_special()
} // end try
// Catch all exceptions.
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_vlstrings_special()", __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_vlstrings_special
@@ -452,14 +453,15 @@ static void test_vlstrings_special()
*
*-------------------------------------------------------------------------
*/
-const H5std_string VLSTR_TYPE("vl_string_type");
+const H5std_string VLSTR_TYPE("vl_string_type");
-static void test_vlstring_type()
+static void
+test_vlstring_type()
{
// Output message about test being performed.
SUBTEST("VL String Type");
- H5File* file1 = NULL;
+ H5File *file1 = NULL;
try {
// Open file.
file1 = new H5File(FILENAME, H5F_ACC_RDWR);
@@ -525,12 +527,11 @@ static void test_vlstring_type()
} // end try block
// Catch all exceptions.
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_vlstring_type()", __LINE__, __FILE__, E.getCDetailMsg());
}
- if(file1)
+ if (file1)
delete file1;
} // end test_vlstring_type()
@@ -546,7 +547,8 @@ static void test_vlstring_type()
*
*-------------------------------------------------------------------------
*/
-static void test_compact_vlstring()
+static void
+test_compact_vlstring()
{
// Output message about test being performed
SUBTEST("VL Strings on Compact Dataset");
@@ -556,7 +558,7 @@ static void test_compact_vlstring()
H5File file1(FILENAME, H5F_ACC_TRUNC);
// Create dataspace for datasets
- hsize_t dims1[] = {SPACE1_DIM1};
+ hsize_t dims1[] = {SPACE1_DIM1};
DataSpace sid1(SPACE1_RANK, dims1);
// Create a datatype to refer to
@@ -574,21 +576,23 @@ static void test_compact_vlstring()
dataset.write(wdata, vlst);
// Read dataset from disk
- char *rdata[SPACE1_DIM1]; // Information read in
+ char *rdata[SPACE1_DIM1]; // Information read in
dataset.read(rdata, vlst);
// Compare data read in
hsize_t i;
- for (i=0; i<SPACE1_DIM1; i++) {
- if (HDstrlen(wdata[i])!=strlen(rdata[i])) {
- TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",(int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i]));
+ for (i = 0; i < SPACE1_DIM1; i++) {
+ if (HDstrlen(wdata[i]) != strlen(rdata[i])) {
+ TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",
+ (int)i, (int)strlen(wdata[i]), (int)i, (int)strlen(rdata[i]));
continue;
} // end if
- if (HDstrcmp(wdata[i],rdata[i]) != 0) {
- TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",(int)i,wdata[i],(int)i,rdata[i]);
+ if (HDstrcmp(wdata[i], rdata[i]) != 0) {
+ TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)i, wdata[i],
+ (int)i, rdata[i]);
continue;
} // end if
- } // end for
+ } // end for
// Reclaim the read VL data
DataSet::vlenReclaim((void *)rdata, vlst, sid1);
@@ -604,11 +608,10 @@ static void test_compact_vlstring()
} // end try
// Catch all exceptions.
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_compact_vlstrings()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_compact_vlstrings
+} // test_compact_vlstrings
/*-------------------------------------------------------------------------
* Function: test_vlstring_attribute
@@ -622,11 +625,12 @@ static void test_compact_vlstring()
*
*-------------------------------------------------------------------------
*/
-static char *string_att_write=NULL;
+static char * string_att_write = NULL;
const H5std_string ATTRSTR_NAME("String_attr");
const H5std_string ATTRSTR_DATA("String Attribute");
-static void test_vlstring_attribute()
+static void
+test_vlstring_attribute()
{
// Output message about test being performed
SUBTEST("VL String on Attributes");
@@ -642,7 +646,7 @@ static void test_vlstring_attribute()
Group root = file1.openGroup("/");
// Create dataspace for the attribute.
- DataSpace att_space (H5S_SCALAR);
+ DataSpace att_space(H5S_SCALAR);
// Create an attribute for the root group.
Attribute gr_attr = root.createAttribute(ATTRSTR_NAME, vlst, att_space);
@@ -653,16 +657,18 @@ static void test_vlstring_attribute()
// Read and verify the attribute string as a string of chars.
char *string_att_check;
gr_attr.read(vlst, &string_att_check);
- if(HDstrcmp(string_att_check, ATTRSTR_DATA.c_str())!=0)
- TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), string_att_check);
+ if (HDstrcmp(string_att_check, ATTRSTR_DATA.c_str()) != 0)
+ TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",
+ __LINE__, ATTRSTR_DATA.c_str(), string_att_check);
- HDfree(string_att_check); // note: no need for std::string test
+ HDfree(string_att_check); // note: no need for std::string test
// Read and verify the attribute string as an std::string.
H5std_string read_str;
gr_attr.read(vlst, read_str);
if (read_str != ATTRSTR_DATA)
- TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_str.c_str());
+ TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n", __LINE__,
+ ATTRSTR_DATA.c_str(), read_str.c_str());
// Close group's attribute.
gr_attr.close();
@@ -670,7 +676,7 @@ static void test_vlstring_attribute()
// Test creating a "large" sized string attribute
gr_attr = root.createAttribute("test_scalar_large", vlst, att_space);
- string_att_write = (char*)HDcalloc(8192, sizeof(char));
+ string_att_write = (char *)HDcalloc(8192, sizeof(char));
HDmemset(string_att_write, 'A', 8191);
// Write data to the attribute, then read it back.
@@ -678,8 +684,9 @@ static void test_vlstring_attribute()
gr_attr.read(vlst, &string_att_check);
// Verify data read.
- if(HDstrcmp(string_att_check,string_att_write)!=0)
- TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check);
+ if (HDstrcmp(string_att_check, string_att_write) != 0)
+ TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",
+ string_att_write, string_att_check);
// Release resources.
HDfree(string_att_check);
@@ -691,11 +698,10 @@ static void test_vlstring_attribute()
} // end try block
// Catch all exceptions.
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_vlstring_attribute()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_vlstring_attribute()
+} // test_vlstring_attribute()
#if 0
/*-------------------------------------------------------------------------
@@ -774,11 +780,11 @@ static void test_read_vl_string_attribute()
*/
const H5std_string ATTRSTRARR_NAME("StringArray_attr");
-static void test_vlstring_array_attribute()
+static void
+test_vlstring_array_attribute()
{
- const char *string_att_array[SPACE1_DIM1]= {
- "Line 1", "Line 2", "Line 3", "Line 4"
- }; // Information to write
+ const char *string_att_array[SPACE1_DIM1] = {"Line 1", "Line 2", "Line 3",
+ "Line 4"}; // Information to write
// Output message about test being performed
SUBTEST("VL String Array on Attributes");
@@ -794,7 +800,7 @@ static void test_vlstring_array_attribute()
Group root = file1.openGroup("/");
// Create dataspace for datasets.
- hsize_t dims1[] = {SPACE1_DIM1};
+ hsize_t dims1[] = {SPACE1_DIM1};
DataSpace att_space(SPACE1_RANK, dims1);
// Create an attribute for the root group.
@@ -809,12 +815,12 @@ static void test_vlstring_array_attribute()
gr_attr.read(vlst, &string_att_check);
hsize_t ii;
- for (ii = 0; ii < SPACE1_DIM1; ii++)
- {
- if(HDstrcmp(string_att_check[ii], string_att_array[ii])!=0)
- TestErrPrintf("Line %d: Attribute data different: written=%s,read=%s\n",__LINE__, string_att_check[ii], string_att_check[ii]);
+ for (ii = 0; ii < SPACE1_DIM1; ii++) {
+ if (HDstrcmp(string_att_check[ii], string_att_array[ii]) != 0)
+ TestErrPrintf("Line %d: Attribute data different: written=%s,read=%s\n", __LINE__,
+ string_att_check[ii], string_att_check[ii]);
- HDfree(string_att_check[ii]); // note: no need for std::string test
+ HDfree(string_att_check[ii]); // note: no need for std::string test
}
// Close group's attribute.
@@ -825,15 +831,14 @@ static void test_vlstring_array_attribute()
} // end try block
// Catch all exceptions.
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_vlstring_array_attribute()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_vlstring_array_attribute()
+} // test_vlstring_array_attribute()
/* Helper routine for test_vl_rewrite() */
-static void write_scalar_dset(H5File& file, DataType& type, DataSpace& space,
- char *name, char *data)
+static void
+write_scalar_dset(H5File &file, DataType &type, DataSpace &space, char *name, char *data)
{
DataSet dset;
try {
@@ -841,34 +846,34 @@ static void write_scalar_dset(H5File& file, DataType& type, DataSpace& space,
dset.write(&data, type, space, space);
dset.close();
} // end try
- catch (FileIException& ferr) {
+ catch (FileIException &ferr) {
throw;
}
- catch (DataSetIException& derr) {
+ catch (DataSetIException &derr) {
throw;
}
}
/* Helper routine for test_vl_rewrite() */
-static void read_scalar_dset(H5File& file, DataType& type, DataSpace& space,
- char *name, char *data)
+static void
+read_scalar_dset(H5File &file, DataType &type, DataSpace &space, char *name, char *data)
{
- char *data_read;
+ char * data_read;
DataSet dset;
try {
dset = file.openDataSet(name);
dset.read(&data_read, type, space, space);
dset.close();
- if(HDstrcmp(data, data_read))
+ if (HDstrcmp(data, data_read))
TestErrPrintf("Expected %s for dataset %s but read %s\n", data, name, data_read);
HDfree(data_read);
} // end try
- catch (FileIException& ferr) {
+ catch (FileIException &ferr) {
throw;
}
- catch (DataSetIException& derr) {
+ catch (DataSetIException &derr) {
throw;
}
}
@@ -887,9 +892,10 @@ static void read_scalar_dset(H5File& file, DataType& type, DataSpace& space,
*-------------------------------------------------------------------------
*/
const H5std_string FILENAME2("tvlstr2.h5");
-const int REWRITE_NDATASETS = 32;
+const int REWRITE_NDATASETS = 32;
-static void test_vl_rewrite()
+static void
+test_vl_rewrite()
{
// Output message about test being performed
SUBTEST("I/O on VL strings with link/unlink");
@@ -903,37 +909,37 @@ static void test_vl_rewrite()
StrType type(0, H5T_VARIABLE);
// Create dataspace for the attribute.
- DataSpace space (H5S_SCALAR);
+ DataSpace space(H5S_SCALAR);
// Create in file 1.
- int i;
+ int i;
char name[256]; // Buffer for names & data
- for (i=0; i<REWRITE_NDATASETS; i++) {
+ for (i = 0; i < REWRITE_NDATASETS; i++) {
sprintf(name, "/set_%d", i);
write_scalar_dset(file1, type, space, name, name);
}
// Effectively copy data from file 1 to 2.
- for (i=0; i<REWRITE_NDATASETS; i++) {
+ for (i = 0; i < REWRITE_NDATASETS; i++) {
sprintf(name, "/set_%d", i);
read_scalar_dset(file1, type, space, name, name);
write_scalar_dset(file2, type, space, name, name);
}
// Read back from file 2.
- for (i=0; i<REWRITE_NDATASETS; i++) {
+ for (i = 0; i < REWRITE_NDATASETS; i++) {
sprintf(name, "/set_%d", i);
read_scalar_dset(file2, type, space, name, name);
}
// Remove from file 2.
- for (i=0; i<REWRITE_NDATASETS; i++) {
+ for (i = 0; i < REWRITE_NDATASETS; i++) {
sprintf(name, "/set_%d", i);
file2.unlink(name);
}
// Effectively copy from file 1 to file 2.
- for (i=0; i<REWRITE_NDATASETS; i++) {
+ for (i = 0; i < REWRITE_NDATASETS; i++) {
sprintf(name, "/set_%d", i);
read_scalar_dset(file1, type, space, name, name);
write_scalar_dset(file2, type, space, name, name);
@@ -949,8 +955,7 @@ static void test_vl_rewrite()
} // end try
// Catch all exceptions.
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_vl_rewrite()", __LINE__, __FILE__, E.getCDetailMsg());
}
} // end test_vl_rewrite()
@@ -967,8 +972,8 @@ static void test_vl_rewrite()
*
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_vlstrings()
+extern "C" void
+test_vlstrings()
{
// Output message about test being performed
MESSAGE(5, ("Testing Variable-Length Strings"));
@@ -990,9 +995,8 @@ void test_vlstrings()
// Test writing VL datasets in files with lots of unlinking
test_vl_rewrite();
-} // test_vlstrings()
+} // test_vlstrings()
-
/*-------------------------------------------------------------------------
* Function: cleanup_vlstrings
*
@@ -1001,10 +1005,9 @@ void test_vlstrings()
* Return none
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_vlstrings()
+extern "C" void
+cleanup_vlstrings()
{
HDremove(FILENAME.c_str());
HDremove(FILENAME2.c_str());
}
-