summaryrefslogtreecommitdiffstats
path: root/c++/test
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2004-12-20 19:59:01 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2004-12-20 19:59:01 (GMT)
commit2d19c37ca4216ad28fb30f4c57592509a34dfc20 (patch)
tree41fe8116b9d9c602c4291e72299e4c28cc82e6e2 /c++/test
parent5de680a8f8306d6b30ae8efb1ab4ea75cfb48126 (diff)
downloadhdf5-2d19c37ca4216ad28fb30f4c57592509a34dfc20.zip
hdf5-2d19c37ca4216ad28fb30f4c57592509a34dfc20.tar.gz
hdf5-2d19c37ca4216ad28fb30f4c57592509a34dfc20.tar.bz2
[svn-r9695] Purpose: Clean up tests
Description: Replaced macro VERIFY with template function verify_val to verify read data/info. 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++/test')
-rw-r--r--c++/test/h5cpputil.cpp22
-rw-r--r--c++/test/h5cpputil.h2
-rw-r--r--c++/test/tfile.cpp121
-rw-r--r--c++/test/th5s.cpp136
4 files changed, 154 insertions, 127 deletions
diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp
index 4a301d8..020bab0 100644
--- a/c++/test/h5cpputil.cpp
+++ b/c++/test/h5cpputil.cpp
@@ -72,3 +72,25 @@ int test_report( int nerrors, const string& testname )
}
}
+/*-------------------------------------------------------------------------
+ * Function: issue_fail_msg
+ *
+ * Purpose: Displays that a function has failed with its location.
+ *
+ * Return: None
+ *
+ * Programmer: Binh-Minh Ribler (copied and modified macro CHECK from C)
+ * Monday, December 20, 2004
+ *
+ *-------------------------------------------------------------------------
+ */
+void issue_fail_msg(const char* where, int line, const char* file_name)
+{
+ if (GetTestVerbosity()>=VERBO_HI)
+ {
+ cerr << " Call to routine: " << where << " at line " << line
+ << " in " << file_name << "has failed" << endl;
+ }
+}
+
+
diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h
index cccbb7b..d67c459 100644
--- a/c++/test/h5cpputil.h
+++ b/c++/test/h5cpputil.h
@@ -31,6 +31,8 @@ using std::endl;
int test_report (int, const string&);
#endif
+void issue_fail_msg(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)
{
diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp
index f15f836..858c74c 100644
--- a/c++/test/tfile.cpp
+++ b/c++/test/tfile.cpp
@@ -38,29 +38,29 @@
using namespace H5;
#endif
-#define F1_USERBLOCK_SIZE (hsize_t)0
-#define F1_OFFSET_SIZE sizeof(haddr_t)
-#define F1_LENGTH_SIZE sizeof(hsize_t)
-#define F1_SYM_LEAF_K 4
-#define F1_SYM_INTERN_K 16
-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 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 char* FILE3 = "tfile3.h5";
-
-#define KB 1024
-const char* FILE4 = "tfile4.h5";
+const int F1_USERBLOCK_SIZE = (hsize_t)0;
+const int F1_OFFSET_SIZE = sizeof(haddr_t);
+const int F1_LENGTH_SIZE = sizeof(hsize_t);
+const int F1_SYM_LEAF_K = 4;
+const int F1_SYM_INTERN_K = 16;
+const string FILE1("tfile1.h5");
+
+const int F2_USERBLOCK_SIZE = (hsize_t)512;
+const int F2_OFFSET_SIZE = 8;
+const int F2_LENGTH_SIZE = 8;
+const int F2_SYM_LEAF_K = 8;
+const int F2_SYM_INTERN_K = 32;
+const string FILE2("tfile2.h5");
+
+const int F3_USERBLOCK_SIZE = (hsize_t)0;
+const int F3_OFFSET_SIZE = F2_OFFSET_SIZE;
+const int F3_LENGTH_SIZE = F2_LENGTH_SIZE;
+const int F3_SYM_LEAF_K = F2_SYM_LEAF_K;
+const int F3_SYM_INTERN_K = F2_SYM_INTERN_K;
+const string FILE3("tfile3.h5");
+
+const int KB = 1024;
+const string FILE4("tfile4.h5");
/*-------------------------------------------------------------------------
@@ -88,7 +88,7 @@ test_file_create(void)
/* Create with H5F_ACC_EXCL */
/* First ensure the file does not exist */
- remove(FILE1);
+ remove(FILE1.c_str());
try {
H5File* file1 = new H5File (FILE1, H5F_ACC_EXCL);
@@ -102,9 +102,9 @@ test_file_create(void)
// Should FAIL but didn't - BMR (Note 1): a macro, with a diff
// name, that skips the comparison b/w the 1st & 2nd args would
- // be more appropriate, but VERIFY can be used for now - Mar 13, 01
+ // be more appropriate, but verify_val can be used for now;
// also, more text about what is testing would be better.
- VERIFY(file2.getId(), FAIL, "H5File constructor");
+ verify_val(file2.getId(), FAIL, "H5File constructor", __LINE__, __FILE__);
}
catch( FileIException E ) {} // do nothing, FAIL expected
@@ -118,7 +118,7 @@ test_file_create(void)
*/
try {
file1 = new H5File( FILE1, H5F_ACC_EXCL ); // should throw E
- VERIFY(file1->getId(), FAIL, "H5File constructor");
+ verify_val(file1->getId(), FAIL, "H5File constructor", __LINE__, __FILE__);
}
catch( FileIException E ) {} // do nothing, FAIL expected
@@ -131,7 +131,7 @@ test_file_create(void)
*/
try {
H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E
- VERIFY(file2.getId(), FAIL, "H5File constructor");
+ verify_val(file2.getId(), FAIL, "H5File constructor", __LINE__, __FILE__);
}
catch( FileIException E ) {} // do nothing, FAIL expected
@@ -141,7 +141,7 @@ test_file_create(void)
*/
try {
H5File file3 (FILE1, H5F_ACC_EXCL); // should throw E
- VERIFY(file3.getId(), FAIL, "H5File constructor");
+ verify_val(file3.getId(), FAIL, "H5File constructor", __LINE__, __FILE__);
}
catch( FileIException E ) {} // do nothing, FAIL expected
@@ -149,12 +149,12 @@ test_file_create(void)
FileCreatPropList tmpl1 = file1->getCreatePlist();
hsize_t ublock = tmpl1.getUserblock();
- VERIFY(ublock, F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock");
+ verify_val(ublock, F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);
size_t parm1, parm2; /*file-creation parameters */
tmpl1.getSizes( parm1, parm2);
- VERIFY(parm1, F1_OFFSET_SIZE, "FileCreatPropList::getSizes");
- VERIFY(parm2, F1_LENGTH_SIZE, "FileCreatPropList::getSizes");
+ verify_val(parm1, F1_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
+ verify_val(parm2, F1_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
int iparm1; /*file-creation parameters */
#ifdef H5_WANT_H5_V1_4_COMPAT
@@ -163,8 +163,8 @@ test_file_create(void)
unsigned iparm2; /*file-creation parameters */
#endif /* H5_WANT_H5_V1_4_COMPAT */
tmpl1.getSymk( iparm1, iparm2);
- VERIFY(iparm1, F1_SYM_INTERN_K, "FileCreatPropList::getSymk");
- VERIFY(iparm2, F1_SYM_LEAF_K, "FileCreatPropList::getSymk");
+ verify_val(iparm1, F1_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
+ verify_val(iparm2, F1_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
// tmpl1 is automatically closed; if error occurs, it'll be
// caught in the catch block
@@ -173,10 +173,10 @@ test_file_create(void)
delete file1;
}
catch( PropListIException E ) {
- CHECK(FAIL, FAIL, E.getCFuncName());
+ issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__);
}
catch( FileIException E ) {
- CHECK(FAIL, FAIL, E.getCFuncName());
+ issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__);
}
try
@@ -203,12 +203,12 @@ test_file_create(void)
/* Get the file-creation parameters */
hsize_t ublock = tmpl1->getUserblock();
- VERIFY(ublock, F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock");
+ verify_val(ublock, F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);
size_t parm1, parm2; /*file-creation parameters */
tmpl1->getSizes( parm1, parm2);
- VERIFY(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes");
- VERIFY(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes");
+ verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
+ verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
int iparm1; /*file-creation parameters */
#ifdef H5_WANT_H5_V1_4_COMPAT
@@ -217,8 +217,8 @@ test_file_create(void)
unsigned iparm2; /*file-creation parameters */
#endif /* H5_WANT_H5_V1_4_COMPAT */
tmpl1->getSymk( iparm1, iparm2);
- VERIFY(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk");
- VERIFY(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk");
+ 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;
@@ -241,21 +241,21 @@ test_file_create(void)
/* Get the file-creation parameters */
ublock = tmpl1->getUserblock();
- VERIFY(ublock, F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock");
+ verify_val(ublock, F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);
tmpl1->getSizes( parm1, parm2);
- VERIFY(parm1, F3_OFFSET_SIZE, "FileCreatPropList::getSizes");
- VERIFY(parm2, F3_LENGTH_SIZE, "FileCreatPropList::getSizes");
+ verify_val(parm1, F3_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
+ verify_val(parm2, F3_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
tmpl1->getSymk( iparm1, iparm2);
- VERIFY(iparm1, F3_SYM_INTERN_K, "FileCreatPropList::getSymk");
- VERIFY(iparm2, F3_SYM_LEAF_K, "FileCreatPropList::getSymk");
+ verify_val(iparm1, F3_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
+ verify_val(iparm2, F3_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
/* Dynamically release file-creation template */
delete tmpl1;
}
catch( PropListIException E ) {
- CHECK(FAIL, FAIL, E.getCFuncName());
+ issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__);
}
} /* test_file_create() */
@@ -290,12 +290,13 @@ test_file_open(void)
/* Get the file-creation parameters */
hsize_t ublock = tmpl1.getUserblock();
- VERIFY(ublock, F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock");
+ verify_val(ublock, F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);
+ verify_val(ublock, F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);
size_t parm1, parm2; /*file-creation parameters */
tmpl1.getSizes( parm1, parm2);
- VERIFY(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes");
- VERIFY(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes");
+ verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
+ verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
int iparm1; /*file-creation parameters */
#ifdef H5_WANT_H5_V1_4_COMPAT
@@ -304,12 +305,12 @@ test_file_open(void)
unsigned iparm2; /*file-creation parameters */
#endif /* H5_WANT_H5_V1_4_COMPAT */
tmpl1.getSymk( iparm1, iparm2);
- VERIFY(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk");
- VERIFY(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk");
+ verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
+ verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
} // end of try block
catch( Exception E ) {
- CHECK(FAIL, FAIL, E.getCFuncName());
+ issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__);
}
} /* test_file_open() */
@@ -355,11 +356,11 @@ test_file_size(void)
// Check if file size is reasonable. It's supposed to be 2KB now.
if(file_size<1*KB || file_size>4*KB)
- CHECK(FAIL, FAIL, "H5File::getFileSize");
+ issue_fail_msg("H5File::getFileSize", __LINE__, __FILE__);
} // end of try block
catch( Exception E ) {
- CHECK(FAIL, FAIL, E.getCFuncName());
+ issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__);
}
// use C test utility routine to close property list.
@@ -451,7 +452,7 @@ test_file_name()
verify_val(file_name, FILE4, "CompType::getFileName", __LINE__, __FILE__);
} // end of try block
catch (Exception E) {
- CHECK(FAIL, FAIL, E.getCFuncName());
+ issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__);
}
} /* test_file_name() */
@@ -500,8 +501,8 @@ test_file(void)
void
cleanup_file(void)
{
- remove(FILE1);
- remove(FILE2);
- remove(FILE3);
- remove(FILE4);
+ remove(FILE1.c_str());
+ remove(FILE2.c_str());
+ remove(FILE3.c_str());
+ remove(FILE4.c_str());
} /* cleanup_file */
diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp
index 09f8f82..5f62ed5 100644
--- a/c++/test/th5s.cpp
+++ b/c++/test/th5s.cpp
@@ -29,6 +29,7 @@
#include "testhdf5.h"
#include "H5Cpp.h"
+#include "h5cpputil.h"
#ifndef H5_NO_NAMESPACE
using namespace H5;
@@ -38,36 +39,36 @@ const char* TESTFILE = "th5s.h5";
const char* DATAFILE = "th5s1.h5";
/* 3-D dataset with fixed dimensions */
-#define SPACE1_NAME "Space1"
-#define SPACE1_RANK 3
-#define SPACE1_DIM1 3
-#define SPACE1_DIM2 15
-#define SPACE1_DIM3 13
+const string SPACE1_NAME("Space1");
+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 */
-#define SPACE2_NAME "Space2"
-#define SPACE2_RANK 4
-#define SPACE2_DIM1 0
-#define SPACE2_DIM2 15
-#define SPACE2_DIM3 13
-#define SPACE2_DIM4 23
-#define SPACE2_MAX1 H5S_UNLIMITED
-#define SPACE2_MAX2 15
-#define SPACE2_MAX3 13
-#define SPACE2_MAX4 23
+const 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;
/* Scalar dataset with simple datatype */
-#define SPACE3_NAME "Scalar1"
-#define SPACE3_RANK 0
+const string SPACE3_NAME("Scalar1");
+const int SPACE3_RANK = 0;
unsigned space3_data=65;
/* Scalar dataset with compound datatype */
-#define SPACE4_NAME "Scalar2"
-#define SPACE4_RANK 0
-#define SPACE4_FIELDNAME1 "c1"
-#define SPACE4_FIELDNAME2 "u"
-#define SPACE4_FIELDNAME3 "f"
-#define SPACE4_FIELDNAME4 "c2"
+const string SPACE4_NAME("Scalar2");
+const int SPACE4_RANK = 0;
+const string SPACE4_FIELDNAME1("c1");
+const string SPACE4_FIELDNAME2("u");
+const string SPACE4_FIELDNAME3("f");
+const string SPACE4_FIELDNAME4("c2");
size_t space4_field1_off=0;
size_t space4_field2_off=0;
size_t space4_field3_off=0;
@@ -117,20 +118,20 @@ test_h5s_basic(void)
// Get simple extent npoints of the dataspace sid1 and verify it
hssize_t n; /* Number of dataspace elements */
n = sid1.getSimpleExtentNpoints();
- VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3,
- "H5Sget_simple_extent_npoints");
+ verify_val(n, 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 */
rank = sid1.getSimpleExtentNdims();
- VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims");
+ 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 */
ndims = sid1.getSimpleExtentDims( tdims );
- VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(unsigned)), 0,
- "H5Sget_simple_extent_dims");
+ verify_val(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(unsigned)), 0,
+ "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
// Create simple dataspace sid2
hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4};
@@ -138,24 +139,24 @@ test_h5s_basic(void)
// Get simple extent npoints of dataspace sid2 and verify it
n = sid2.getSimpleExtentNpoints();
- VERIFY(n, SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4,
- "H5Sget_simple_extent_npoints");
+ verify_val(n, SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4,
+ "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of dataspace sid2 and verify it
rank = sid2.getSimpleExtentNdims();
- VERIFY(rank, SPACE2_RANK, "H5Sget_simple_extent_ndims");
+ verify_val(rank, SPACE2_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
// Retrieves dimension size and max size of dataspace sid2 and
// verify them
ndims = sid2.getSimpleExtentDims( tdims, tmax );
- VERIFY(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(unsigned)), 0,
- "H5Sget_simple_extent_dims");
- VERIFY(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0,
- "H5Sget_simple_extent_dims");
+ 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__);
} // end of first try block
catch( DataSpaceIException error )
{
- CHECK(FAIL, FAIL, error.getCFuncName());
+ issue_fail_msg(error.getCFuncName(), __LINE__, __FILE__);
}
/*
@@ -165,10 +166,8 @@ test_h5s_basic(void)
try {
DataSpace manydims_ds(H5S_MAX_RANK+1, dims3, NULL);
- // Should FAIL but didn't - BMR (Note 1): a new macro that skips
- // the comparison b/w the 1st & 2nd args would be more appropriate,
- // but VERIFY will still do - Mar 12, 01
- VERIFY(manydims_ds.getId(), FAIL, "DataSpace constructor");
+ // Should FAIL but didn't, so issue an error message
+ issue_fail_msg("DataSpace constructor", __LINE__, __FILE__);
}
catch( DataSpaceIException error ) {} // do nothing, FAIL expected
@@ -195,14 +194,16 @@ test_h5s_basic(void)
// what the library can handle and this operation should fail.
try {
DataSet dset1 = fid1.openDataSet( "dset" );
- VERIFY( dset1.getId(), FAIL, "H5File::openDataSet");
+
+ // but didn't, issue an error message
+ issue_fail_msg("H5File::openDataSet", __LINE__, __FILE__);
}
catch( FileIException error ) { } // do nothing, FAIL expected
} // end of try block for testing higher dimensionality
// catch exception thrown by H5File constructor
catch( FileIException error ) {
- CHECK_I(FAIL, error.getCFuncName());
+ issue_fail_msg(error.getCFuncName(), __LINE__, __FILE__);
cerr << "***cannot open the pre-created H5S_MAX_RANK test file" <<
testfile << endl;
}
@@ -214,7 +215,8 @@ test_h5s_basic(void)
dims1[0] = 0;
try {
DataSpace wrongdim_ds (SPACE1_RANK, dims1);
- VERIFY(wrongdim_ds.getId(), FAIL, "DataSpace constructor");
+ verify_val(wrongdim_ds.getId(), FAIL, "DataSpace constructor", __LINE__, __FILE__);
+
}
catch( DataSpaceIException error ) {} // do nothing; FAIL expected
@@ -222,13 +224,13 @@ test_h5s_basic(void)
DataSpace sid3 (H5S_SIMPLE);
// Attempts to use incorrect dimensions, should fail
- try { sid3.setExtentSimple( SPACE1_RANK, dims1 ); }
- catch( DataSpaceIException error )
- {
- // ret value is already < 0 for an exception to be thrown;
- // also see Note 1 above
- VERIFY(FAIL, FAIL, error.getCFuncName());
+ try {
+ sid3.setExtentSimple( SPACE1_RANK, dims1 );
+
+ // but didn't, issue an error message
+ issue_fail_msg("DataSpace::setExtentSimple", __LINE__, __FILE__);
}
+ catch (DataSpaceIException error) {} // do nothing, FAIL expected
} /* test_h5s_basic() */
/*-------------------------------------------------------------------------
@@ -263,22 +265,22 @@ test_h5s_scalar_write(void)
//n = H5Sget_simple_extent_npoints(sid1);
hssize_t n; /* Number of dataspace elements */
n = sid1.getSimpleExtentNpoints();
- VERIFY(n, 1, "DataSpace::getSimpleExtentNpoints");
+ verify_val(n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
int rank; /* Logical rank of dataspace */
rank = sid1.getSimpleExtentNdims();
- VERIFY(rank, SPACE3_RANK, "DataSpace::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 */
ndims = sid1.getSimpleExtentDims( tdims );
- VERIFY(ndims, 0, "DataSpace::getSimpleExtentDims");
+ verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
/* Verify extent type */
H5S_class_t ext_type; /* Extent type */
ext_type = sid1.getSimpleExtentType();
- VERIFY(ext_type, H5S_SCALAR, "DataSpace::getSimpleExtentType");
+ verify_val(ext_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__);
/* Create a dataset */
DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1);
@@ -287,7 +289,7 @@ test_h5s_scalar_write(void)
} // end of try block
catch (Exception error)
{
- CHECK(FAIL, FAIL, error.getCFuncName());
+ issue_fail_msg(error.getCFuncName(), __LINE__, __FILE__);
}
} /* test_h5s_scalar_write() */
@@ -325,23 +327,23 @@ test_h5s_scalar_read(void)
// Get the number of dataspace elements
hssize_t n = sid1.getSimpleExtentNpoints();
- VERIFY(n, 1, "H5Sget_simple_extent_npoints");
+ verify_val(n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of the dataspace
int ndims = sid1.getSimpleExtentNdims();
- VERIFY(ndims, SPACE3_RANK, "H5Sget_simple_extent_ndims");
+ verify_val(ndims, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
ndims = sid1.getSimpleExtentDims(tdims);
- VERIFY(ndims, 0, "H5Sget_simple_extent_dims");
+ verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
unsigned rdata; /* Scalar data read in */
dataset.read(&rdata, PredType::NATIVE_UINT);
- VERIFY(rdata, space3_data, "H5Dread");
+ verify_val(rdata, space3_data, "DataSet::read", __LINE__, __FILE__);
} // end of try block
catch (Exception error)
{
// all the exceptions caused by negative returned values by C APIs
- CHECK(FAIL, FAIL, error.getCFuncName());
+ issue_fail_msg(error.getCFuncName(), __LINE__, __FILE__);
}
} /* test_h5s_scalar_read() */
@@ -393,15 +395,15 @@ test_h5s_compound_scalar_write(void)
// Get the number of dataspace elements
hssize_t n = sid1.getSimpleExtentNpoints();
- VERIFY(n, 1, "H5Sget_simple_extent_npoints");
+ verify_val(n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of the dataspace
int ndims = sid1.getSimpleExtentNdims();
- VERIFY(ndims, SPACE3_RANK, "H5Sget_simple_extent_ndims");
+ verify_val(ndims, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
hsize_t tdims[4]; /* Dimension array to test with */
ndims = sid1.getSimpleExtentDims(tdims);
- VERIFY(ndims, 0, "H5Sget_simple_extent_dims");
+ verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
/* Create a dataset */
DataSet dataset = fid1.createDataSet("Dataset1", tid1, sid1);
@@ -411,7 +413,7 @@ test_h5s_compound_scalar_write(void)
catch (Exception error)
{
// all the exceptions caused by negative returned values by C APIs
- CHECK(FAIL, FAIL, error.getCFuncName());
+ issue_fail_msg(error.getCFuncName(), __LINE__, __FILE__);
}
} /* test_h5s_compound_scalar_write() */
@@ -450,14 +452,14 @@ test_h5s_compound_scalar_read(void)
// Get the number of dataspace elements
hssize_t n = sid1.getSimpleExtentNpoints();
- VERIFY(n, 1, "H5Sget_simple_extent_npoints");
+ verify_val(n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of the dataspace
int ndims = sid1.getSimpleExtentNdims();
- VERIFY(ndims, SPACE3_RANK, "H5Sget_simple_extent_ndims");
+ verify_val(ndims, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
ndims = sid1.getSimpleExtentDims(tdims);
- VERIFY(ndims, 0, "H5Sget_simple_extent_dims");
+ verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
// Get the datatype of this dataset.
CompType type(dataset);
@@ -481,7 +483,7 @@ test_h5s_compound_scalar_read(void)
catch (Exception error)
{
// all the exceptions caused by negative returned values by C APIs
- CHECK(FAIL, FAIL, error.getCFuncName());
+ issue_fail_msg(error.getCFuncName(), __LINE__, __FILE__);
}
} /* test_h5s_compound_scalar_read() */