summaryrefslogtreecommitdiffstats
path: root/c++/test/tcompound.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2007-03-17 16:26:53 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2007-03-17 16:26:53 (GMT)
commit1c4e6d163f781003ce1151781b3d403dc9b52e66 (patch)
treeb07834021d14510d51e90736877fd938c1a9d904 /c++/test/tcompound.cpp
parentc4bbce8be19cd60e7ffd0180194c0e0e92091381 (diff)
downloadhdf5-1c4e6d163f781003ce1151781b3d403dc9b52e66.zip
hdf5-1c4e6d163f781003ce1151781b3d403dc9b52e66.tar.gz
hdf5-1c4e6d163f781003ce1151781b3d403dc9b52e66.tar.bz2
[svn-r13524] Purpose: Cleanup tests
Description: Added extern "C" to cleanup functions as well, forgot last time. Cleaned up/Added comments to some of the newly added tests. Platforms tested AIX 5.1 (copper) Linux 2.6 (kagiso) SunOS 5.8 64-bit (sol)
Diffstat (limited to 'c++/test/tcompound.cpp')
-rw-r--r--c++/test/tcompound.cpp87
1 files changed, 41 insertions, 46 deletions
diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp
index f6571b1..9532dd6 100644
--- a/c++/test/tcompound.cpp
+++ b/c++/test/tcompound.cpp
@@ -65,23 +65,22 @@ typedef struct complex_t {
*
*-------------------------------------------------------------------------
*/
-static void test_compound_1(void)
+static void test_compound_1()
{
// Output message about test being performed
SUBTEST("Compound Data Types");
- try
- {
+ try {
// Create an empty compound datatype
CompType complex_type(sizeof(complex_t));
// Add a couple of fields
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
catch (Exception E) {
+cerr << "test_compound_1 in catch" << endl;
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_compound_1()
@@ -103,7 +102,7 @@ static void test_compound_1(void)
*
*-------------------------------------------------------------------------
*/
-static void test_compound_2(void)
+static void test_compound_2()
{
typedef struct {
int a, b, c[4], d, e;
@@ -121,9 +120,8 @@ static void test_compound_2(void)
// Output message about test being performed
SUBTEST("Compound Element Reordering");
- try
- {
- /* Sizes should be the same, but be careful just in case */
+ try {
+ // Sizes should be the same, but be careful just in case
buf = (unsigned char*)malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
bkg = (unsigned char*)malloc(nelmts * sizeof(dst_typ_t));
orig = (unsigned char*)malloc(nelmts * sizeof(src_typ_t));
@@ -140,7 +138,7 @@ static void test_compound_2(void)
}
memcpy(buf, orig, nelmts*sizeof(src_typ_t));
- /* Build hdf5 datatypes */
+ // Build hdf5 datatypes
ArrayType* array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
// Create an empty compound datatype
@@ -163,10 +161,10 @@ static void test_compound_2(void)
dt.insertMember("e", HOFFSET(dst_typ_t, e), PredType::NATIVE_INT);
array_dt->close();
- /* Perform the conversion */
+ // Perform the conversion
st.convert(dt, (size_t)nelmts, buf, bkg);
- /* Compare results */
+ // Compare results
for (i=0; i<nelmts; i++) {
s_ptr = ((src_typ_t*)orig) + i;
d_ptr = ((dst_typ_t*)buf) + i;
@@ -188,22 +186,21 @@ static void test_compound_2(void)
<< "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 */
- free(buf);
- free(bkg);
- free(orig);
- s_ptr = NULL;
- d_ptr = NULL;
- st.close();
- dt.close();
-
- PASSED();
+ }
+ }
+ // Release resources
+ free(buf);
+ free(bkg);
+ free(orig);
+ s_ptr = NULL;
+ d_ptr = NULL;
+ st.close();
+ dt.close();
+ PASSED();
} // end of try block
catch (Exception E) {
+cerr << "test_compound_2 in catch" << endl;
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_compound_2()
@@ -225,7 +222,7 @@ static void test_compound_2(void)
*
*-------------------------------------------------------------------------
*/
-static void test_compound_3(void)
+static void test_compound_3()
{
typedef struct {
int a, b, c[4], d, e;
@@ -243,8 +240,7 @@ static void test_compound_3(void)
// Output message about test being performed
SUBTEST("Compound Datatype Subset Conversions");
- try
- {
+ try {
/* Initialize */
buf = (unsigned char*)malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
bkg = (unsigned char*)malloc(nelmts * sizeof(dst_typ_t));
@@ -317,11 +313,11 @@ static void test_compound_3(void)
d_ptr = NULL;
st.close();
dt.close();
-
PASSED();
} // end of try block
catch (Exception E) {
+cerr << "test_compound_3 in catch" << endl;
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_compound_3()
@@ -343,7 +339,7 @@ static void test_compound_3(void)
*
*-------------------------------------------------------------------------
*/
-static void test_compound_4(void)
+static void test_compound_4()
{
typedef struct {
@@ -366,8 +362,7 @@ static void test_compound_4(void)
// Output message about test being performed
SUBTEST("Compound Element Shrinking & Reordering");
- try
- {
+ try {
/* Sizes should be the same, but be careful just in case */
buf = (unsigned char*)malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
bkg = (unsigned char*)malloc(nelmts * sizeof(dst_typ_t));
@@ -445,11 +440,11 @@ static void test_compound_4(void)
d_ptr = NULL;
st.close();
dt.close();
-
PASSED();
} // end of try block
catch (Exception E) {
+cerr << "test_compound_4 in catch" << endl;
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_compound_4()
@@ -472,7 +467,7 @@ static void test_compound_4(void)
*
*-------------------------------------------------------------------------
*/
-static void test_compound_5(void)
+static void test_compound_5()
{
typedef struct {
char name[16];
@@ -495,8 +490,7 @@ static void test_compound_5(void)
// Output message about test being performed
SUBTEST("Optimized Struct Converter");
- try
- {
+ try {
/* Build datatypes */
ArrayType* array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims);
@@ -549,6 +543,7 @@ static void test_compound_5(void)
} // end of try block
catch (Exception E) {
+cerr << "test_compound_5 in catch" << endl;
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_compound_5()
@@ -570,7 +565,7 @@ static void test_compound_5(void)
*
*-------------------------------------------------------------------------
*/
-static void test_compound_6(void)
+static void test_compound_6()
{
typedef struct {
short b;
@@ -590,8 +585,7 @@ static void test_compound_6(void)
// Output message about test being performed
SUBTEST("Compound Element Growing");
- try
- {
+ try {
/* Sizes should be the same, but be careful just in case */
buf = (unsigned char*)malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
bkg = (unsigned char*)malloc(nelmts * sizeof(dst_typ_t));
@@ -639,11 +633,11 @@ static void test_compound_6(void)
d_ptr = NULL;
st.close();
dt.close();
-
PASSED();
} // end of try block
catch (Exception E) {
+cerr << "test_compound_6 in catch" << endl;
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_compound_6()
@@ -663,7 +657,7 @@ static void test_compound_6(void)
*
*-------------------------------------------------------------------------
*/
-static void test_compound_7(void)
+static void test_compound_7()
{
typedef struct {
int a;
@@ -680,8 +674,7 @@ static void test_compound_7(void)
// Output message about test being performed
SUBTEST("Compound Element Insertion");
- try
- {
+ try {
CompType tid1(sizeof(s1_typ_t));
tid1.insertMember("a", HOFFSET(s1_typ_t,a),PredType::NATIVE_INT);
@@ -707,11 +700,11 @@ static void test_compound_7(void)
/* Release resources */
tid1.close();
tid2.close();
-
PASSED();
} // end of try block
catch (Exception E) {
+cerr << "test_compound_7 in catch" << endl;
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_compound_7()
@@ -734,7 +727,7 @@ static void test_compound_7(void)
#ifdef __cplusplus
extern "C"
#endif
-void test_compound(void)
+void test_compound()
{
// Output message about test being performed
MESSAGE(5, ("Testing Compound Data Type operations\n"));
@@ -760,7 +753,9 @@ void test_compound(void)
*
*-------------------------------------------------------------------------
*/
-void
-cleanup_compound(void)
+#ifdef __cplusplus
+extern "C"
+#endif
+void cleanup_compound()
{
} // cleanup_file