summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2005-06-19 21:02:56 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2005-06-19 21:02:56 (GMT)
commitd066938224ad12a3a5dc8fe482f5d813b63027e5 (patch)
tree7d48ad7703dc6815507e5359076b672a8d37e60a
parent47bd0eecd65317c8ffbae0b403e0f412d6d17551 (diff)
downloadhdf5-d066938224ad12a3a5dc8fe482f5d813b63027e5.zip
hdf5-d066938224ad12a3a5dc8fe482f5d813b63027e5.tar.gz
hdf5-d066938224ad12a3a5dc8fe482f5d813b63027e5.tar.bz2
[svn-r10954] Purpose: Updating C++ tests
Description: Added an overloaded function for the template function verify_val. Updated various comments/headers. Platforms tested: Linux 2.4 (heping) HPUX 11.00 (kelgia)
-rw-r--r--c++/test/dsets.cpp293
-rw-r--r--c++/test/h5cpputil.h16
-rw-r--r--c++/test/testhdf5.cpp21
-rw-r--r--c++/test/tfile.cpp47
-rw-r--r--c++/test/th5s.cpp121
5 files changed, 257 insertions, 241 deletions
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp
index 5aa2032..180cc1f 100644
--- a/c++/test/dsets.cpp
+++ b/c++/test/dsets.cpp
@@ -15,12 +15,12 @@
/*****************************************************************************
FILE
dsets.cpp - HDF5 C++ testing the functionalities associated with the
- C dataset interface (H5D)
+ C dataset interface (H5D)
EXTERNAL ROUTINES/VARIABLES:
These routines are in the test directory of the C library:
- h5_reset() -- in h5test.c, resets the library by closing it
- h5_fileaccess() -- in h5test.c, returns a file access template
+ h5_reset() -- in h5test.c, resets the library by closing it
+ h5_fileaccess() -- in h5test.c, returns a file access template
***************************************************************************/
@@ -30,14 +30,14 @@
#include <iostream>
#endif
-#include "testhdf5.h"
-#include "H5Cpp.h"
+#include "testhdf5.h" // C test header file
+#include "H5Cpp.h" // C++ API header file
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
-#include "h5cpputil.h"
+#include "h5cpputil.h" // C++ utilility header file
const string FILE1("dataset.h5");
const string DSET_DEFAULT_NAME("default");
@@ -74,12 +74,12 @@ void cleanup_dsets(void);
static herr_t
test_create( H5File& file)
{
- TESTING("create, open, close");
+ TESTING("create, open, close");
// Setting this to NULL for cleaning up in failure situations
DataSet *dataset = NULL;
try {
- // Create the data space
+ // Create a data space
hsize_t dims[2];
dims[0] = 256;
dims[1] = 512;
@@ -87,38 +87,38 @@ test_create( H5File& file)
// Create a dataset using the default dataset creation properties.
// We're not sure what they are, so we won't check.
- DataSet *dataset = new DataSet (file.createDataSet
+ 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");
+
// Close the dataset
delete dataset;
dataset = NULL;
- // Add a comment to the dataset
- file.setComment (DSET_DEFAULT_NAME, "This is a dataset");
-
- // Try creating a dataset that already exists. This should fail since a
- // dataset can only be created once. If an exception is not thrown
- // for this action by createDataSet, then display failure information
- // and throw an exception.
+ // Try creating a dataset that already exists. This should fail since a
+ // 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));
+
// continuation here, that means no exception has been thrown
- throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset");
- }
- catch (FileIException E ) // catching invalid creating dataset
- {} // do nothing, exception expected
+ throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset");
+ }
+ catch (FileIException E) // catching invalid creating dataset
+ {} // do nothing, exception expected
- // Open the dataset we created above and then close it. This is how
- // existing datasets are accessed.
+ // 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));
// Close the dataset when accessing is completed
delete dataset;
- // This is another way to open an existing dataset for accessing.
- DataSet another_dataset(file.openDataSet (DSET_DEFAULT_NAME));
+ // This is another way to open an existing dataset for accessing.
+ 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
@@ -149,7 +149,7 @@ test_create( H5File& file)
PASSED();
return 0;
- } // outer most try block
+ } // outer most try block
catch (InvalidActionException E)
{
@@ -171,19 +171,18 @@ test_create( H5File& file)
delete dataset;
return -1;
}
-}
+} // test_create
/*-------------------------------------------------------------------------
* Function: check_values
*
* Purpose: Checks a read value against the written value. If they are
- * different, the function will
- * print out a message and the different values. This function
- * is made to reuse the code segment that is used in various
- * places throughout test_compression and in test_simple_io.
- * Where the C version
+ * different, the function will print out a message and the
+ * different values. This function is made to reuse the code
+ * segment that is used in various places throughout
+ * test_compression and in test_simple_io. Where the C version
* of this code segment "goto error," this function will
- * return -1, so that the caller can "goto error."
+ * return -1.
*
* Return: Success: 0
*
@@ -201,7 +200,6 @@ check_values (hsize_t i, hsize_t j, int apoint, int acheck)
{
if (apoint != acheck)
{
- H5_FAILED();
cerr << " Read different values than written.\n" << endl;
cerr << " At index " << (unsigned long)i << "," <<
(unsigned long)j << endl;
@@ -278,6 +276,7 @@ test_simple_io( H5File& file)
throw Exception("DataSet::read");
}
+ // clean up and return with success
delete [] tconv_buf;
PASSED();
return 0;
@@ -286,15 +285,15 @@ test_simple_io( H5File& file)
// catch all dataset, space, plist exceptions
catch (Exception E)
{
- cerr << " FAILED" << endl;
- cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
+ cerr << " FAILED" << endl;
+ cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
- // clean up and return with failure
- if (tconv_buf)
- delete [] tconv_buf;
- return -1;
+ // clean up and return with failure
+ if (tconv_buf)
+ delete [] tconv_buf;
+ return -1;
}
-}
+} // test_simple_io
/*-------------------------------------------------------------------------
* Function: test_tconv
@@ -369,22 +368,22 @@ test_tconv( H5File& file)
// catch all dataset and space exceptions
catch (Exception E)
{
- cerr << " FAILED" << endl;
- cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
+ cerr << " FAILED" << endl;
+ cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
- // clean up and return with failure
- delete [] out;
- delete [] in;
- return -1;
+ // clean up and return with failure
+ delete [] out;
+ delete [] in;
+ return -1;
}
-}
+} // test_tconv
/* This message derives from H5Z */
const H5Z_class_t H5Z_BOGUS[1] = {{
H5Z_FILTER_BOGUS, /* Filter id number */
"bogus", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
bogus, /* The actual filter function */
}};
@@ -398,7 +397,7 @@ const H5Z_class_t H5Z_BOGUS[1] = {{
* Failure: 0
*
* Programmer: Robb Matzke
- * Tuesday, April 21, 1998
+ * Tuesday, April 21, 1998
*
* Modifications:
*
@@ -436,7 +435,6 @@ bogus(unsigned int flags, size_t cd_nelmts,
*
*-------------------------------------------------------------------------
*/
-
static herr_t
test_compression(H5File& file)
{
@@ -461,8 +459,7 @@ test_compression(H5File& file)
// Create the data space
DataSpace space1(2, size, NULL);
- // Create a small conversion buffer to test strip mining. We
- // might as well test all we can!
+ // Create a small conversion buffer to test strip mining
DSetMemXferPropList xfer;
xfer.setBuffer (1000, tconv_buf, NULL);
@@ -475,13 +472,13 @@ test_compression(H5File& file)
dscreatplist.setDeflate (6);
#ifdef H5_HAVE_FILTER_DEFLATE
- TESTING("compression (setup)");
+ TESTING("compression (setup)");
// Create the dataset
dataset = new DataSet (file.createDataSet
(DSET_COMPRESS_NAME, PredType::NATIVE_INT, space1, dscreatplist));
- PASSED();
+ PASSED();
/*----------------------------------------------------------------------
* STEP 1: Read uninitialized data. It should be zero.
@@ -502,7 +499,7 @@ test_compression(H5File& file)
}
}
}
- PASSED();
+ PASSED();
/*----------------------------------------------------------------------
* STEP 2: Test compression by setting up a chunked dataset and writing
@@ -521,7 +518,7 @@ test_compression(H5File& file)
dataset->write ((void*) points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
- PASSED();
+ PASSED();
/*----------------------------------------------------------------------
* STEP 3: Try to read the data we just wrote.
@@ -541,7 +538,7 @@ test_compression(H5File& file)
throw Exception("test_compression", "Failed in read");
}
- PASSED();
+ PASSED();
/*----------------------------------------------------------------------
* STEP 4: Write new data over the top of the old data. The new data is
@@ -573,7 +570,7 @@ test_compression(H5File& file)
throw Exception("test_compression", "Failed in modify");
}
- PASSED();
+ PASSED();
/*----------------------------------------------------------------------
* STEP 5: Close the dataset and then open it and read it again. This
@@ -583,7 +580,7 @@ test_compression(H5File& file)
*/
TESTING("compression (re-open)");
- // close this dataset
+ // close this dataset to reuse the var
delete dataset;
dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME));
@@ -598,7 +595,7 @@ test_compression(H5File& file)
throw Exception("test_compression", "Failed in re-open");
}
- PASSED();
+ PASSED();
/*----------------------------------------------------------------------
@@ -640,12 +637,12 @@ test_compression(H5File& file)
delete dataset;
dataset = NULL;
- PASSED();
+ PASSED();
#else
- TESTING("deflate filter");
- SKIPPED();
- cerr << not_supported << endl;
+ TESTING("deflate filter");
+ SKIPPED();
+ cerr << not_supported << endl;
#endif
/*----------------------------------------------------------------------
@@ -656,10 +653,10 @@ test_compression(H5File& file)
TESTING("compression (app-defined method)");
#ifdef H5_WANT_H5_V1_4_COMPAT
- if (H5Zregister (H5Z_FILTER_BOGUS, "bogus", bogus)<0)
+ if (H5Zregister (H5Z_FILTER_BOGUS, "bogus", bogus)<0)
throw Exception("test_compression", "Failed in app-defined method");
#else /* H5_WANT_H5_V1_4_COMPAT */
- if (H5Zregister (H5Z_BOGUS)<0)
+ if (H5Zregister (H5Z_BOGUS)<0)
throw Exception("test_compression", "Failed in app-defined method");
#endif /* H5_WANT_H5_V1_4_COMPAT */
if (H5Pset_filter (dscreatplist.getId(), H5Z_FILTER_BOGUS, 0, 0, NULL)<0)
@@ -695,17 +692,17 @@ test_compression(H5File& file)
// catch all dataset, file, space, and plist exceptions
catch (Exception E)
{
- cerr << " FAILED" << endl;
- cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
-
- // clean up and return with failure
- if (dataset != NULL)
- delete dataset;
- if (tconv_buf)
- delete [] tconv_buf;
- return -1;
+ cerr << " FAILED" << endl;
+ cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
+
+ // clean up and return with failure
+ if (dataset != NULL)
+ delete dataset;
+ if (tconv_buf)
+ delete [] tconv_buf;
+ return -1;
}
-}
+} // test_compression
/*-------------------------------------------------------------------------
* Function: test_multiopen
@@ -781,14 +778,15 @@ test_multiopen (H5File& file)
// catch all dataset, file, space, and plist exceptions
catch (Exception E)
{
- cerr << " FAILED" << endl;
- cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
+ cerr << " FAILED" << endl;
+ cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
- if (space != NULL)
- delete space;
- return -1;
+ // clean up and return with failure
+ if (space != NULL)
+ delete space;
+ return -1;
}
-}
+} // test_multiopen
/*-------------------------------------------------------------------------
@@ -801,7 +799,7 @@ test_multiopen (H5File& file)
* Failure: -1
*
* Programmer: Binh-Minh Ribler (using C version)
- * February 17, 2001
+ * February 17, 2001
*
* Modifications:
*
@@ -854,24 +852,23 @@ test_types(H5File& file)
for (i=0; i<sizeof buf; i++)
buf[i] = (unsigned char)0xff ^ (unsigned char)i;
- // Write data from buf using all default dataspaces and property
- // list
- dset->write (buf, type);
+ // Write data from buf using all default dataspaces and property list
+ dset->write (buf, type);
- // no failure in bitfield_1, close this dataset
- delete dset;
+ // 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)
- {
- cerr << " FAILED" << endl;
- cerr << " <<< " << "bitfield_1: " << E.getFuncName()
- << " - " << E.getDetailMsg() << " >>>" << endl << endl;
- if (dset != NULL)
- delete dset;
- return -1;
- }
+ {
+ cerr << " FAILED" << endl;
+ cerr << " <<< " << "bitfield_1: " << E.getFuncName()
+ << " - " << E.getDetailMsg() << " >>>" << endl << endl;
+ if (dset != NULL)
+ delete dset;
+ return -1;
+ }
/* bitfield_2 */
nelmts = sizeof(buf)/2;
@@ -884,27 +881,27 @@ test_types(H5File& file)
for (i=0; i<sizeof(buf); i++)
buf[i] = (unsigned char)0xff ^ (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);
+ // Write data from buf using all default dataspaces and property
+ // list; if writing fails, deallocate dset and return.
+ dset->write (buf, type);
- // no failure in bitfield_2, close this dataset and reset for
- // variable reuse
- delete dset;
- dset = NULL;
+ // no failure in bitfield_2, close this dataset and reset for
+ // variable reuse
+ delete dset;
+ dset = NULL;
} // end try block of bitfield_2
// catch exceptions thrown in try block of bitfield_2
catch (Exception E) {
- cerr << " FAILED" << endl;
- cerr << " <<< " << "bitfield_2: " << E.getFuncName()
- << " - " << E.getDetailMsg() << " >>>" << endl << endl;
- if (dset != NULL)
- delete dset;
- throw E; // propagate the exception
- }
-
- /* opaque_1 */
+ cerr << " FAILED" << 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;
try { // opaque_1 block
optype = new DataType(H5T_OPAQUE, 1);
@@ -917,25 +914,25 @@ test_types(H5File& file)
for (i=0; i<sizeof buf; i++)
buf[i] = (unsigned char)0xff ^ (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);
+ // Write data from buf using all default dataspaces and property
+ // list; if writing fails, deallocate dset and return.
+ dset->write (buf, *optype);
- // no failure in opaque_1
- delete dset; dset = NULL;
- delete optype; optype = NULL;
+ // no failure in opaque_1
+ delete dset; dset = NULL;
+ delete optype; optype = NULL;
} // end try block of opaque_1
// catch exceptions thrown in try block of opaque_1
- catch (DataSetIException E) {
- cerr << " FAILED" << endl;
- cerr << " <<< " << "opaque_1: " << E.getFuncName()
- << " - " << E.getDetailMsg() << " >>>" << endl << endl;
- if (dset != NULL)
- delete dset;
- if (optype != NULL)
- delete optype;
- throw E; // propagate the exception
+ catch (Exception E) {
+ cerr << " FAILED" << endl;
+ cerr << " <<< " << "opaque_1: " << E.getFuncName()
+ << " - " << E.getDetailMsg() << " >>>" << endl << endl;
+ if (dset != NULL)
+ delete dset;
+ if (optype != NULL)
+ delete optype;
+ throw E; // propagate the exception
}
/* opaque_2 */
@@ -948,38 +945,38 @@ test_types(H5File& file)
// Fill buffer
for (i=0; i<sizeof(buf); i++)
- buf[i] = (unsigned char)0xff ^ (unsigned char)i;
+ buf[i] = (unsigned char)0xff ^ (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);
+ // Write data from buf using all default dataspaces and property
+ // list; if writing fails, deallocate dset and return.
+ dset->write (buf, *optype);
- // no failure in opaque_1
- delete dset; dset = NULL;
- delete optype; optype = NULL;
+ // no failure in opaque_1
+ 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) {
- cerr << " FAILED" << endl;
- cerr << " <<< " << "opaque_2: " << E.getFuncName()
- << " - " << E.getDetailMsg() << " >>>" << endl << endl;
- if (dset != NULL)
- delete dset;
- if (optype != NULL)
- delete optype;
- throw E; // propagate the exception
+ cerr << " FAILED" << endl;
+ cerr << " <<< " << "opaque_2: " << E.getFuncName()
+ << " - " << E.getDetailMsg() << " >>>" << endl << endl;
+ if (dset != NULL)
+ delete dset;
+ if (optype != NULL)
+ delete optype;
+ throw E; // propagate the exception
}
- PASSED();
- return 0;
+ PASSED();
+ return 0;
} // end top try block
catch (Exception E)
{
- return -1;
+ return -1;
}
-}
+} // test_types
/*-------------------------------------------------------------------------
* Function: main
@@ -1047,7 +1044,7 @@ main(void)
// Print out dsets test results
cerr << endl << endl;
return(test_report(nerrors, string(" Dataset")));
-}
+} // main
/*-------------------------------------------------------------------------
* Function: cleanup_dsets
diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h
index bef8f4a..38ecbcb 100644
--- a/c++/test/h5cpputil.h
+++ b/c++/test/h5cpputil.h
@@ -23,6 +23,8 @@
#ifndef _h5cpputil_h
#define _h5cpputil_h
+#include "h5test.h"
+
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
@@ -51,7 +53,19 @@ template <class Type1, class Type2>
cerr << "*** UNEXPECTED VALUE from " << where << " should be "
<< value << ", but is " << x << " at line " << line
<< " in " << file_name << endl;
- H5Eprint (stderr);
+ IncTestNumErrs();
+ }
+}
+
+template <class Type1, class Type2>
+ void verify_val(Type1 x, Type2 value, const char* msg, const char* file_name, int line)
+{
+ if (x != value)
+ {
+ cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line
+ << ":" << msg << " different: " << x << ", should be " << value
+ << endl;
+ IncTestNumErrs();
}
}
diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp
index b93689b..7ea88a1 100644
--- a/c++/test/testhdf5.cpp
+++ b/c++/test/testhdf5.cpp
@@ -17,21 +17,28 @@
testhdf5.cpp - HDF5 testing framework main file.
REMARKS
- General test wrapper for HDF5 base library test programs
+ General test wrapper for HDF5 C++ library test programs
DESIGN
Each test function should be implemented as function having no
parameters and returning void (i.e. no return value). They should be put
- into the list of InitTest() calls in main() below. Functions which depend
- on other functionality should be placed below the InitTest() call for the
+ into the list of AddTest() calls in main() below. Functions which depend
+ on other functionality should be placed below the AddTest() call for the
base functionality testing.
Each test module should include testhdf5.h and define a unique set of
names for test files they create.
- BUGS/LIMITATIONS
-
- EXPORTED ROUTINES/VARIABLES:
- Two variables are exported: num_errs, and Verbosity.
+ EXTERNAL ROUTINES/VARIABLES:
+ TestInit(...) -- Initialize testing framework
+ TestInfo(...) -- Print test info
+ AddTest(...) -- Setup a test function and add it to the list of tests
+ TestParseCmdLine(...) -- Parse command line arguments
+ PerformTests() -- Perform requested testing
+ GetTestSummary() -- Retrieve Summary request value
+ TestSummary() -- Display test summary
+ GetTestCleanup() -- Retrieve Cleanup request value
+ TestCleanup() -- Clean up files from testing
+ GetTestNumErrs() -- Retrieve the number of testing errors
***************************************************************************/
diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp
index 74210ea..f4a68a9 100644
--- a/c++/test/tfile.cpp
+++ b/c++/test/tfile.cpp
@@ -30,14 +30,15 @@
#include <iostream>
#endif
-#include "H5Cpp.h"
-#include "testhdf5.h"
-#include "h5cpputil.h"
+#include "testhdf5.h" // C test header file
+#include "H5Cpp.h" // C++ API header file
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
+#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);
@@ -114,8 +115,8 @@ test_file_create(void)
// Setting this to NULL for cleaning up in failure situations
H5File* file1 = NULL;
try {
- // Create file FILE1
- file1 = new H5File (FILE1, H5F_ACC_EXCL);
+ // Create file FILE1
+ 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.
@@ -146,7 +147,7 @@ test_file_create(void)
// Test create with H5F_ACC_TRUNC. This will truncate the existing file.
file1 = new H5File (FILE1, H5F_ACC_TRUNC);
- // Try to truncate first file again. This should fail because file1
+ // Try to truncate 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
@@ -174,15 +175,15 @@ test_file_create(void)
hsize_t ublock = tmpl1.getUserblock();
verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);
- size_t parm1, parm2; /*file-creation parameters */
+ 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__);
#ifdef H5_WANT_H5_V1_4_COMPAT
- int iparm1, iparm2; /*file-creation parameters */
+ int iparm1, iparm2; // file-creation parameters
#else /* H5_WANT_H5_V1_4_COMPAT */
- unsigned iparm1, iparm2; /*file-creation parameters */
+ unsigned iparm1, iparm2; // file-creation parameters
#endif /* H5_WANT_H5_V1_4_COMPAT */
tmpl1.getSymk( iparm1, iparm2);
verify_val(iparm1, F1_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
@@ -284,12 +285,14 @@ test_file_create(void)
// Release file-creation template
delete tmpl1;
}
- catch( PropListIException E ) {
+ // catch all exceptions
+ catch (Exception E)
+ {
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
- if (tmpl1 != NULL) // clean up
- delete tmpl1;
+ if (tmpl1 != NULL) // clean up
+ delete tmpl1;
}
-} /* test_file_create() */
+} // test_file_create()
/*-------------------------------------------------------------------------
@@ -303,7 +306,7 @@ test_file_create(void)
* January, 2001
*
* Modifications:
- * January, 2005: C tests' macro VERIFY casts values to 'long' for all
+ * January, 2005: C tests' macro VERIFY casts values to 'long' for all
* cases. Since there are no operator<< for 'long long'
* or int64 in VS C++ ostream, I casted the hsize_t values
* passed to verify_val to 'long' as well. If problems
@@ -349,7 +352,7 @@ test_file_open(void)
catch( Exception E ) {
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
-} /* test_file_open() */
+} // test_file_open()
/*-------------------------------------------------------------------------
@@ -383,7 +386,7 @@ test_file_size(void)
// 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();
+ // fapl.setSec2();
// Create a file
H5File file4( FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
@@ -403,7 +406,7 @@ test_file_size(void)
// use C test utility routine to close property list.
H5Pclose(fapl_id);
-} /* test_file_size() */
+} // test_file_size()
/*-------------------------------------------------------------------------
@@ -456,7 +459,7 @@ test_file_name()
file_name = group.getFileName();
verify_val(file_name, FILE4, "Group::getFileName", __LINE__, __FILE__);
- // Create the data space
+ // Create the data space
hsize_t dims[RANK] = {NX, NY};
DataSpace space(RANK, dims);
@@ -493,13 +496,13 @@ test_file_name()
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
-} /* test_file_name() */
+} // test_file_name()
/*-------------------------------------------------------------------------
* Function: test_file
*
- * Purpose: Main program
+ * Purpose: Main file testing routine
*
* Return: None
*
@@ -520,7 +523,7 @@ test_file(void)
test_file_open(); // Test file opening
test_file_size(); // Test file size
test_file_name(); // Test getting file's name
-} /* test_file() */
+} // test_file()
/*-------------------------------------------------------------------------
@@ -543,4 +546,4 @@ cleanup_file(void)
remove(FILE2.c_str());
remove(FILE3.c_str());
remove(FILE4.c_str());
-} /* cleanup_file */
+} // cleanup_file
diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp
index 190646f..d8bde63 100644
--- a/c++/test/th5s.cpp
+++ b/c++/test/th5s.cpp
@@ -27,13 +27,14 @@
#include <iostream>
#endif
-#include "testhdf5.h"
-#include "H5Cpp.h"
-#include "h5cpputil.h"
+#include "testhdf5.h" // C test header file
+#include "H5Cpp.h" // C++ API header file
#ifndef H5_NO_NAMESPACE
using namespace H5;
-#endif /* !H5_NO_NAMESPACE */
+#endif
+
+#include "h5cpputil.h" // C++ utilility header file
const string TESTFILE("th5s.h5");
const string DATAFILE("th5s1.h5");
@@ -109,32 +110,29 @@ test_h5s_basic(void)
hsize_t dims3[H5S_MAX_RANK+1];
hsize_t tmax[4];
- /* Output message about test being performed */
+ // Output message about test being performed
MESSAGE(5, ("Testing Dataspace Manipulation\n"));
try
{ // beginning of first try block
- /* Create file - removed this since the following operations don't
- need the file to be opened */
-
// Create simple dataspace sid1
DataSpace sid1 (SPACE1_RANK, dims1 );
// Get simple extent npoints of the dataspace sid1 and verify it
- hssize_t n; /* Number of dataspace elements */
+ 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__);
// Get the logical rank of dataspace sid1 and verify it
- int rank; /* Logical rank of dataspace */
+ int rank; // Logical rank of dataspace
rank = sid1.getSimpleExtentNdims();
verify_val(rank, SPACE1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
// Retrieves dimension size of dataspace sid1 and verify it
- int ndims; /* Number of dimensions */
- hsize_t tdims[4]; /* Dimension array to test with */
+ int ndims; // Number of dimensions
+ hsize_t tdims[4]; // Dimension array to test with
ndims = sid1.getSimpleExtentDims( tdims );
verify_val(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(unsigned)), 0,
"DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
@@ -236,7 +234,7 @@ test_h5s_basic(void)
{
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
-} /* test_h5s_basic() */
+} // test_h5s_basic()
/*-------------------------------------------------------------------------
*
@@ -261,8 +259,7 @@ test_h5s_basic(void)
static void
test_h5s_scalar_write(void)
{
-
- /* Output message about test being performed */
+ // Output message about test being performed
MESSAGE(5, ("Testing Scalar Dataspace Writing\n"));
try
@@ -270,39 +267,39 @@ test_h5s_scalar_write(void)
// Create file
H5File fid1(DATAFILE, H5F_ACC_TRUNC);
- /* Create scalar dataspace */
+ // Create scalar dataspace
DataSpace sid1(SPACE3_RANK, NULL);
//n = H5Sget_simple_extent_npoints(sid1);
- hssize_t n; /* Number of dataspace elements */
+ hssize_t n; // Number of dataspace elements
n = sid1.getSimpleExtentNpoints();
verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
- int rank; /* Logical rank of dataspace */
+ int rank; // Logical rank of dataspace
rank = sid1.getSimpleExtentNdims();
verify_val(rank, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
// Retrieves dimension size of dataspace sid1 and verify it
- int ndims; /* Number of dimensions */
- hsize_t tdims[4]; /* Dimension array to test with */
+ int ndims; // Number of dimensions
+ hsize_t tdims[4]; // Dimension array to test with
ndims = sid1.getSimpleExtentDims( tdims );
verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
- /* Verify extent type */
- H5S_class_t ext_type; /* Extent type */
+ // Verify extent type
+ H5S_class_t ext_type; // Extent type
ext_type = sid1.getSimpleExtentType();
verify_val(ext_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__);
- /* Create a dataset */
+ // Create a dataset
DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1);
dataset.write(&space3_data, PredType::NATIVE_UINT);
} // end of try block
- catch (Exception error)
+ catch (Exception E)
{
- issue_fail_msg(error.getCFuncName(), __LINE__, __FILE__);
+ issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
-} /* test_h5s_scalar_write() */
+} // test_h5s_scalar_write()
/*-------------------------------------------------------------------------
*
@@ -327,17 +324,17 @@ test_h5s_scalar_write(void)
static void
test_h5s_scalar_read(void)
{
- hsize_t tdims[4]; /* Dimension array to test with */
+ hsize_t tdims[4]; // Dimension array to test with
- /* Output message about test being performed */
+ // Output message about test being performed
MESSAGE(5, ("Testing Scalar Dataspace Reading\n"));
try
{
- /* Create file */
+ // Create file
H5File fid1(DATAFILE, H5F_ACC_RDWR);
- /* Create a dataset */
+ // Create a dataset
DataSet dataset = fid1.openDataSet("Dataset1");
DataSpace sid1 = dataset.getSpace();
@@ -353,17 +350,17 @@ test_h5s_scalar_read(void)
ndims = sid1.getSimpleExtentDims(tdims);
verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
- unsigned rdata; /* Scalar data read in */
+ unsigned rdata; // Scalar data read in
dataset.read(&rdata, PredType::NATIVE_UINT);
verify_val(rdata, space3_data, "DataSet::read", __LINE__, __FILE__);
} // end of try block
- catch (Exception error)
+ catch (Exception E)
{
// all the exceptions caused by negative returned values by C APIs
- issue_fail_msg(error.getCFuncName(), __LINE__, __FILE__);
+ issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
-} /* test_h5s_scalar_read() */
+} // test_h5s_scalar_read()
/*-------------------------------------------------------------------------
*
@@ -389,16 +386,15 @@ test_h5s_scalar_read(void)
static void
test_h5s_compound_scalar_write(void)
{
-
- /* Output message about test being performed */
+ // Output message about test being performed
MESSAGE(5, ("Testing Compound Dataspace Writing\n"));
try
{
- /* Create file */
+ // Create file
H5File fid1(DATAFILE, H5F_ACC_TRUNC);
- /* Create the compound datatype. */
+ // 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,
@@ -413,7 +409,7 @@ test_h5s_compound_scalar_write(void)
tid1.insertMember(SPACE4_FIELDNAME4, space4_field4_off,
PredType::NATIVE_SCHAR);
- /* Create scalar dataspace */
+ // Create scalar dataspace
DataSpace sid1(SPACE3_RANK, NULL);
// Get the number of dataspace elements
@@ -424,22 +420,21 @@ test_h5s_compound_scalar_write(void)
int ndims = sid1.getSimpleExtentNdims();
verify_val(ndims, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
- hsize_t tdims[4]; /* Dimension array to test with */
+ hsize_t tdims[4]; // Dimension array to test with
ndims = sid1.getSimpleExtentDims(tdims);
verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
- /* Create a dataset */
+ // Create a dataset
DataSet dataset = fid1.createDataSet("Dataset1", tid1, sid1);
dataset.write(&space4_data, tid1);
} // end of try block
- catch (Exception error)
+ catch (Exception E)
{
// all the exceptions caused by negative returned values by C APIs
- issue_fail_msg(error.getCFuncName(), __LINE__, __FILE__);
+ issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
-
-} /* test_h5s_compound_scalar_write() */
+} // test_h5s_compound_scalar_write()
/*-------------------------------------------------------------------------
*
@@ -465,16 +460,16 @@ test_h5s_compound_scalar_write(void)
static void
test_h5s_compound_scalar_read(void)
{
- hsize_t tdims[4]; /* Dimension array to test with */
+ hsize_t tdims[4]; // Dimension array to test with
- /* Output message about test being performed */
+ // Output message about test being performed
MESSAGE(5, ("Testing Compound Dataspace Reading\n"));
try
{
- /* Create file */
+ // Create file
H5File fid1(DATAFILE, H5F_ACC_RDWR);
- /* Create a dataset */
+ // Create a dataset
DataSet dataset = fid1.openDataSet("Dataset1");
DataSpace sid1 = dataset.getSpace();
@@ -493,7 +488,7 @@ test_h5s_compound_scalar_read(void)
// Get the datatype of this dataset.
CompType type(dataset);
- struct space4_struct rdata; /* Scalar data read in */
+ struct space4_struct rdata; // Scalar data read in
dataset.read(&rdata, type);
// Verify read data
@@ -507,20 +502,20 @@ test_h5s_compound_scalar_read(void)
<< 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 */
+ } // end if
} // end of try block
- catch (Exception error)
+ catch (Exception E)
{
// all the exceptions caused by negative returned values by C APIs
- issue_fail_msg(error.getCFuncName(), __LINE__, __FILE__);
+ issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
-} /* test_h5s_compound_scalar_read() */
+} // test_h5s_compound_scalar_read()
/*-------------------------------------------------------------------------
*
* Function: test_h5s
*
- * Purpose: Main H5S (dataspace) testing routine
+ * Purpose: Main dataspace testing routine
*
* Return: none
*
@@ -533,15 +528,15 @@ test_h5s_compound_scalar_read(void)
void
test_h5s(void)
{
- /* Output message about test being performed */
+ // 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_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_compound_scalar_write(); // Test compound datatype scalar H5S writing code
+ test_h5s_compound_scalar_read(); // Test compound datatype scalar H5S reading code
+} // test_h5s()
/*-------------------------------------------------------------------------
@@ -562,5 +557,5 @@ void
cleanup_h5s(void)
{
remove(DATAFILE.c_str());
-}
+} // cleanup_h5s