summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2004-08-06 22:24:32 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2004-08-06 22:24:32 (GMT)
commit0da9b3db8d18ab29ad2eb0b7371ea8781dabe77e (patch)
treef727af47a12cf197328bc6c15ee1eca8f91c0b0d /c++
parent619d3b02d1190a2baaace1fd6c9832207be3d7d2 (diff)
downloadhdf5-0da9b3db8d18ab29ad2eb0b7371ea8781dabe77e.zip
hdf5-0da9b3db8d18ab29ad2eb0b7371ea8781dabe77e.tar.gz
hdf5-0da9b3db8d18ab29ad2eb0b7371ea8781dabe77e.tar.bz2
[svn-r9043] Purpose: Clean up tests
Description: Replaced cout's with cerr's. Cleanup various places in the tests to make them more consistent. Platforms tested: SunOS 5.7 (arabica) Linux 2.4 (eirene) Misc. update:
Diffstat (limited to 'c++')
-rw-r--r--c++/test/dsets.cpp91
-rw-r--r--c++/test/h5cpputil.cpp6
-rw-r--r--c++/test/h5cpputil.h4
-rw-r--r--c++/test/tfile.cpp33
-rw-r--r--c++/test/th5s.cpp14
5 files changed, 74 insertions, 74 deletions
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp
index b92381a..97c5e51 100644
--- a/c++/test/dsets.cpp
+++ b/c++/test/dsets.cpp
@@ -32,9 +32,9 @@
#include <iostream>
#endif
-#include "H5Cpp.h"
-#include "h5test.h"
#include "testhdf5.h"
+#include "h5test.h"
+#include "H5Cpp.h"
#ifndef H5_NO_NAMESPACE
using namespace H5;
@@ -42,11 +42,7 @@ using namespace H5;
#include "h5cpputil.h"
-const char *FILENAME[] = {
- "dataset",
- NULL
-};
-
+const string FILE1("dataset.h5");
#define DSET_DEFAULT_NAME "default"
#define DSET_CHUNKED_NAME "chunked"
#define DSET_SIMPLE_IO_NAME "simple_io"
@@ -56,9 +52,10 @@ const char *FILENAME[] = {
#define H5Z_FILTER_BOGUS 305
-/* Local prototypes for filter functions */
+// Local prototypes
static size_t bogus(unsigned int flags, size_t cd_nelmts,
const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
+void cleanup_dsets(void);
/*-------------------------------------------------------------------------
@@ -113,7 +110,7 @@ test_create( H5File& file)
(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space));
// continuation here, that means no exception has been thrown
H5_FAILED();
- cout << " Library allowed overwrite of existing dataset." << endl;
+ cerr << " Library allowed overwrite of existing dataset." << endl;
goto error;
}
catch (FileIException E ) // catching invalid creating dataset
@@ -136,7 +133,7 @@ test_create( H5File& file)
dataset = new DataSet (file.openDataSet( "does_not_exist" ));
// continuation here, that means no exception has been thrown
H5_FAILED();
- cout << " Opened a non-existent dataset." << endl;
+ cerr << " Opened a non-existent dataset." << endl;
goto error;
}
catch (FileIException E ) // catching creating non-existent dataset
@@ -203,8 +200,8 @@ check_values (hsize_t i, hsize_t j, int apoint, int acheck)
if (apoint != acheck)
{
H5_FAILED();
- cout << " Read different values than written.\n" << endl;
- cout << " At index " << (unsigned long)i << "," <<
+ cerr << " Read different values than written.\n" << endl;
+ cerr << " At index " << (unsigned long)i << "," <<
(unsigned long)j << endl;
return -1;
}
@@ -353,14 +350,14 @@ test_tconv( H5File& file)
in[4*i+3]!=out[4*i+0])
{
H5_FAILED();
- cout << " Read with byte order conversion failed." << endl;
+ cerr << " Read with byte order conversion failed." << endl;
goto error;
}
}
delete [] out;
delete [] in;
- cout << " PASSED" << endl;
+ cerr << " PASSED" << endl;
return 0;
} // end try
@@ -493,8 +490,8 @@ test_compression(H5File& file)
for (j=0; j<size[1]; j++) {
if (0!=check[i][j]) {
H5_FAILED();
- cout << " Read a non-zero value." << endl;
- cout << " At index " << (unsigned long)i << "," <<
+ cerr << " Read a non-zero value." << endl;
+ cerr << " At index " << (unsigned long)i << "," <<
(unsigned long)j << endl;
goto error;
}
@@ -620,12 +617,12 @@ test_compression(H5File& file)
if (points[hs_offset[0]+i][hs_offset[1]+j] !=
check[hs_offset[0]+i][hs_offset[1]+j]) {
H5_FAILED();
- cout << " Read different values than written.\n" << endl;
- cout << " At index " << (unsigned long)(hs_offset[0]+i) <<
+ cerr << " Read different values than written.\n" << endl;
+ cerr << " At index " << (unsigned long)(hs_offset[0]+i) <<
"," << (unsigned long)(hs_offset[1]+j) << endl;
- cout << " At original: " << (int)points[hs_offset[0]+i][hs_offset[1]+j] << endl;
- cout << " At returned: " << (int)check[hs_offset[0]+i][hs_offset[1]+j] << endl;
+ cerr << " At original: " << (int)points[hs_offset[0]+i][hs_offset[1]+j] << endl;
+ cerr << " At returned: " << (int)check[hs_offset[0]+i][hs_offset[1]+j] << endl;
goto error;
}
}
@@ -638,7 +635,7 @@ test_compression(H5File& file)
#else
TESTING("deflate filter");
SKIPPED();
- cout << not_supported << endl;
+ cerr << not_supported << endl;
#endif
/*----------------------------------------------------------------------
@@ -750,7 +747,7 @@ test_multiopen (H5File& file)
if (cur_size[0]!=tmp_size[0])
{
H5_FAILED();
- cout << " Got " << (int)tmp_size[0] << " instead of "
+ cerr << " Got " << (int)tmp_size[0] << " instead of "
<< (int)cur_size[0] << "!" << endl;
delete space;
goto error;
@@ -845,7 +842,7 @@ test_types(H5File& file)
// catch exceptions thrown in try block of bitfield_1
catch (Exception E) {
- cout << "Failure in " << E.getFuncName() << " - "
+ cerr << "Failure in " << E.getFuncName() << " - "
<< E.getDetailMsg() << endl;
goto error;
}
@@ -866,7 +863,7 @@ test_types(H5File& file)
try { dset->write (buf, type); }
catch(DataSetIException E)
{
- cout << "Failure in " << E.getFuncName() << " - "
+ cerr << "Failure in " << E.getFuncName() << " - "
<< E.getDetailMsg() << endl;
delete dset;
goto error;
@@ -876,7 +873,7 @@ test_types(H5File& file)
// catch exceptions thrown in try block of bitfield_2
catch (Exception E) {
- cout << "Failure in " << E.getFuncName() << " - "
+ cerr << "Failure in " << E.getFuncName() << " - "
<< E.getDetailMsg() << endl;
goto error;
}
@@ -908,12 +905,12 @@ test_types(H5File& file)
// catch exceptions thrown in try block of opaque_1
catch (DataSetIException E) {
delete optype;
- cout << "Failure in " << E.getFuncName() << " - "
+ cerr << "Failure in " << E.getFuncName() << " - "
<< E.getDetailMsg() << endl;
goto error;
}
catch (Exception E) {
- cout << "Failure in " << E.getFuncName() << " - "
+ cerr << "Failure in " << E.getFuncName() << " - "
<< E.getDetailMsg() << endl;
goto error;
}
@@ -943,12 +940,12 @@ test_types(H5File& file)
} //end try block of opaque_2
catch (DataSetIException E) {
delete optype;
- cout << "Failure in " << E.getFuncName() << " - "
+ cerr << "Failure in " << E.getFuncName() << " - "
<< E.getDetailMsg() << endl;
goto error;
}
catch (Exception E) {
- cout << "Failure in " << E.getFuncName() << " - "
+ cerr << "Failure in " << E.getFuncName() << " - "
<< E.getDetailMsg() << endl;
goto error;
}
@@ -958,7 +955,7 @@ test_types(H5File& file)
} // end top try block
catch (Exception E) { // Group and DataType exceptions
- cout << "Failure in " << E.getFuncName() << " - "
+ cerr << "Failure in " << E.getFuncName() << " - "
<< E.getDetailMsg() << endl;
goto error;
}
@@ -995,9 +992,6 @@ main(void)
hid_t fapl_id;
fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template
- char filename[1024];
- h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);
-
int nerrors=0; // keep track of number of failures occurr
try
{
@@ -1010,9 +1004,9 @@ main(void)
// list object to pass in H5File::H5File
FileAccPropList fapl(fapl_id);
- H5File file( filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
+ H5File file(FILE1, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
- /* Cause the library to emit initial messages */
+ // Cause the library to emit initial messages
Group grp = file.createGroup( "emit diagnostics", 0);
grp.setComment( ".", "Causes diagnostic messages to be emitted");
@@ -1032,10 +1026,31 @@ main(void)
{
return(test_report(nerrors, string(" Dataset")));
}
- /* use C test utility routine to clean up data files */
- h5_cleanup(FILENAME, fapl_id);
- /* print out dsets test results */
+ // Clean up data file
+ cleanup_dsets();
+
+ // Print out dsets test results
cerr << endl << endl;
return(test_report(nerrors, string(" Dataset")));
}
+
+/*-------------------------------------------------------------------------
+ * Function: cleanup_dsets
+ *
+ * Purpose: Cleanup temporary test files
+ *
+ * Return: none
+ *
+ * Programmer: (use C version)
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+cleanup_dsets(void)
+{
+ remove(FILE1.c_str());
+} /* cleanup_dsets */
+
diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp
index e1f3e90..4a301d8 100644
--- a/c++/test/h5cpputil.cpp
+++ b/c++/test/h5cpputil.cpp
@@ -58,16 +58,16 @@ int test_report( int nerrors, const string& testname )
{
nerrors = MAX(1, nerrors);
if (1 == nerrors)
- cout << "***** " << nerrors << testname
+ cerr << "***** " << nerrors << testname
<< " TEST FAILED! *****" << endl;
else
- cout << "***** " << nerrors << testname
+ cerr << "***** " << nerrors << testname
<< " TESTS FAILED! *****" << endl;
return 1;
}
else
{
- cout << "All" << testname << " tests passed." << endl;
+ cerr << "All" << testname << " tests passed." << endl;
return 0;
}
}
diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h
index 2a269a9..cccbb7b 100644
--- a/c++/test/h5cpputil.h
+++ b/c++/test/h5cpputil.h
@@ -31,8 +31,8 @@ using std::endl;
int test_report (int, const string&);
#endif
-template <class Type>
- void verify_val(Type x, Type 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)
{
if (GetTestVerbosity()>=VERBO_HI)
{
diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp
index afbbb40..bb53f45 100644
--- a/c++/test/tfile.cpp
+++ b/c++/test/tfile.cpp
@@ -18,9 +18,7 @@
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_cleanup() -- in h5test.c, cleanup temporary test files
***************************************************************************/
@@ -45,33 +43,24 @@ using namespace H5;
#define F1_LENGTH_SIZE sizeof(hsize_t)
#define F1_SYM_LEAF_K 4
#define F1_SYM_INTERN_K 16
-const string FILE1("tfile1.h5");
+const char* FILE1("tfile1.h5");
#define F2_USERBLOCK_SIZE (hsize_t)512
#define F2_OFFSET_SIZE 8
#define F2_LENGTH_SIZE 8
#define F2_SYM_LEAF_K 8
#define F2_SYM_INTERN_K 32
-const string FILE2("tfile2.h5");
+const char* FILE2("tfile2.h5");
#define F3_USERBLOCK_SIZE (hsize_t)0
#define F3_OFFSET_SIZE F2_OFFSET_SIZE
#define F3_LENGTH_SIZE F2_LENGTH_SIZE
#define F3_SYM_LEAF_K F2_SYM_LEAF_K
#define F3_SYM_INTERN_K F2_SYM_INTERN_K
-const string FILE3("tfile3.h5");
+const char* FILE3("tfile3.h5");
#define KB 1024
-//#define FILE4 "tfile4.h5"
-const string FILE4("tfile4.h5");
-
-const char *FILENAME[] = {
- "tfile1.h5",
- "tfile2.h5",
- "tfile3.h5",
- "tfile4.h5",
- NULL
-};
+const char* FILE4("tfile4.h5");
/*-------------------------------------------------------------------------
@@ -99,7 +88,7 @@ test_file_create(void)
/* Create with H5F_ACC_EXCL */
/* First ensure the file does not exist */
- remove(FILE1.c_str());
+ remove(FILE1);
try {
H5File* file1 = new H5File (FILE1, H5F_ACC_EXCL);
@@ -492,10 +481,6 @@ test_file(void)
test_file_open(); /* Test file opening */
test_file_size(); /* Test file size */
test_file_name(); /* Test getting file's name */
-
- /* use C test utility routine to clean up data files */
- // h5_cleanup(FILENAME, fapl_id); already called by AddTest
-
} /* test_file() */
@@ -515,8 +500,8 @@ test_file(void)
void
cleanup_file(void)
{
- remove(FILE1.c_str());
- remove(FILE2.c_str());
- remove(FILE3.c_str());
- remove(FILE4.c_str());
+ remove(FILE1);
+ remove(FILE2);
+ remove(FILE3);
+ remove(FILE4);
} /* cleanup_file */
diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp
index f00bb03..5f69a66 100644
--- a/c++/test/th5s.cpp
+++ b/c++/test/th5s.cpp
@@ -27,15 +27,15 @@
#include <iostream>
#endif
-#include "H5Cpp.h"
#include "testhdf5.h"
+#include "H5Cpp.h"
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif /* !H5_NO_NAMESPACE */
-#define TESTFILE "th5s.h5"
-#define DATAFILE "th5s1.h5"
+const char* TESTFILE("th5s.h5");
+const char* DATAFILE("th5s1.h5");
/* 3-D dataset with fixed dimensions */
#define SPACE1_NAME "Space1"
@@ -203,7 +203,7 @@ test_h5s_basic(void)
// catch exception thrown by H5File constructor
catch( FileIException error ) {
CHECK_I(FAIL, error.getCFuncName());
- cout << "***cannot open the pre-created H5S_MAX_RANK test file" <<
+ cerr << "***cannot open the pre-created H5S_MAX_RANK test file" <<
testfile << endl;
}
@@ -468,11 +468,11 @@ test_h5s_compound_scalar_read(void)
// Verify read data
if(HDmemcmp(&space4_data,&rdata,sizeof(struct space4_struct)))
{
- cout << "scalar data different: space4_data.c1="
+ cerr << "scalar data different: space4_data.c1="
<< space4_data.c1 << ", read_data4.c1=" << rdata.c1 << endl;
- cout << "scalar data different: space4_data.u="
+ cerr << "scalar data different: space4_data.u="
<< space4_data.u << ", read_data4.u=" << rdata.u << endl;
- cout << "scalar data different: space4_data.f="
+ 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);