diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2007-03-17 16:26:53 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2007-03-17 16:26:53 (GMT) |
commit | 1c4e6d163f781003ce1151781b3d403dc9b52e66 (patch) | |
tree | b07834021d14510d51e90736877fd938c1a9d904 /c++/test/tattr.cpp | |
parent | c4bbce8be19cd60e7ffd0180194c0e0e92091381 (diff) | |
download | hdf5-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/tattr.cpp')
-rw-r--r-- | c++/test/tattr.cpp | 155 |
1 files changed, 82 insertions, 73 deletions
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index ede7e31..c6225229 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -44,24 +44,18 @@ #include "h5cpputil.h" // C++ utilility header file const H5std_string FILENAME("tattr.h5"); -const size_t ATTR_MAX_DIMS = 7; const H5std_string ATTR_TMP_NAME("temp_name"); +const size_t ATTR_MAX_DIMS = 7; /* 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; -/* Dataset Information */ +/* Object names */ const H5std_string DSET1_NAME("Dataset1"); -const H5std_string DSET2_NAME("Dataset2"); - -/* Group Information */ const H5std_string GROUP1_NAME("/Group1"); - -/* Named Datatype Information */ const H5std_string TYPE1_NAME("/Type"); /* Attribute Rank & Dimensions */ @@ -115,8 +109,7 @@ int attr_data1a[ATTR1_DIM1]={256,11945,-22107}; ** Tests integer attributes on both datasets and groups ** ****************************************************************/ -static void -test_attr_basic_write(void) +static void test_attr_basic_write() { hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; hsize_t dims2[] = {ATTR1_DIM1}; @@ -125,7 +118,7 @@ test_attr_basic_write(void) int i; // Output message about test being performed - MESSAGE(5, ("Testing Basic Attribute Writing Functions\n")); + SUBTEST("Testing Basic Attribute Writing Functions"); try { // Create file @@ -134,6 +127,10 @@ test_attr_basic_write(void) // Create dataspace for dataset DataSpace ds_space (SPACE1_RANK, dims1); + /* + * Test attribute with dataset + */ + // Create a dataset DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space); @@ -220,26 +217,27 @@ test_attr_basic_write(void) attr_size = gr_attr.getStorageSize(); verify_val((long)attr_size, (long)(ATTR2_DIM1*ATTR2_DIM2*sizeof(int)), "Attribute::getStorageSize", __LINE__, __FILE__); + + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_basic_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_attr_basic_write() */ +} // test_attr_basic_write() /**************************************************************** ** ** test_attr_rename(): Test renaming attribute function. ** ****************************************************************/ -static void -test_attr_rename(void) +static void test_attr_rename() { int read_data1[ATTR1_DIM1]={0}; // Buffer for reading the attribute int i; // Output message about test being performed - MESSAGE(5, ("Testing Rename Attribute Function\n")); + SUBTEST("Testing Rename Attribute Function"); try { // Open file @@ -291,25 +289,26 @@ test_attr_rename(void) // Change first attribute back to the original name dataset.renameAttr(ATTR_TMP_NAME, ATTR1_NAME); + + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_rename()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_attr_rename() */ +} // test_attr_rename() /******************************************************************** ** ** test_attr_basic_read(): Test basic read attribute. ** ********************************************************************/ -static void -test_attr_basic_read(void) +static void test_attr_basic_read() { int i, j; // Output message about test being performed - MESSAGE(5, ("Testing Basic Attribute Reading Functions\n")); + SUBTEST("Testing Basic Attribute Reading Functions"); try { // Open file @@ -359,24 +358,24 @@ test_attr_basic_read(void) 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_data1[i]); } + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_basic_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_attr_basic_read() */ +} // test_attr_basic_read() /**************************************************************** ** ** test_attr_compound_write(): Tests compound datatype attributes ** ****************************************************************/ -static void -test_attr_compound_write(void) +static void test_attr_compound_write() { // Output message about test being performed - MESSAGE(5, ("Testing Multiple Attribute Functions\n")); + SUBTEST("Testing Multiple Attribute Functions"); try { // Create file @@ -418,20 +417,20 @@ test_attr_compound_write(void) // Write complex attribute data attr.write(comp_type, attr_data4); + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_compound_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_attr_compound_write() */ +} // test_attr_compound_write() /**************************************************************** ** ** test_attr_compound_read(): Test basic H5A (attribute) code. ** ****************************************************************/ -static void -test_attr_compound_read(void) +static void test_attr_compound_read() { hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions size_t size; // Attribute datatype size as stored in file @@ -440,7 +439,7 @@ test_attr_compound_read(void) int i,j; // Output message about test being performed - MESSAGE(5, ("Testing Basic Attribute Functions\n")); + SUBTEST("Testing Basic Attribute Functions"); try { // Open file @@ -553,23 +552,23 @@ test_attr_compound_read(void) // Verify name H5std_string attr_name = attr.getName(); verify_val(attr_name, ATTR4_NAME, "Attribute::getName", __LINE__, __FILE__); + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_attr_compound_read() */ +} // test_attr_compound_read() /**************************************************************** ** ** test_attr_scalar_write(): Test scalar attribute writing functionality. ** ****************************************************************/ -static void -test_attr_scalar_write(void) +static void test_attr_scalar_write() { // Output message about test being performed - MESSAGE(5, ("Testing Basic Scalar Attribute Writing Functions\n")); + SUBTEST("Testing Basic Scalar Attribute Writing Functions"); try { // Create file @@ -606,23 +605,24 @@ test_attr_scalar_write(void) // Write attribute information ds_attr.write (PredType::NATIVE_FLOAT, &attr_data5); + + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_attr_scalar_write() */ +} // test_attr_scalar_write() /**************************************************************** ** ** test_attr_scalar_read(): Test scalar attribute reading functionality. ** ****************************************************************/ -static void -test_attr_scalar_read(void) +static void test_attr_scalar_read() { // Output message about test being performed - MESSAGE(5, ("Testing Basic Scalar Attribute Reading Functions\n")); + SUBTEST("Testing Basic Scalar Attribute Reading Functions"); try { // Open file @@ -649,23 +649,24 @@ test_attr_scalar_read(void) // Make certain the dataspace is scalar H5S_class_t space_type = att_space.getSimpleExtentType(); verify_val(space_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__); + + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_attr_scalar_read() */ +} // test_attr_scalar_read() /**************************************************************** ** ** test_attr_mult_write(): Test multiple attributes ** ****************************************************************/ -static void -test_attr_mult_write(void) +static void test_attr_mult_write() { // Output message about test being performed - MESSAGE(5, ("Testing Multiple Attribute Writing Functions\n")); + SUBTEST("Testing Multiple Attribute Writing Functions"); try { // Create file @@ -720,20 +721,21 @@ test_attr_mult_write(void) // Write 3rd attribute information ds_attr3.write (PredType::NATIVE_DOUBLE, attr_data3); + + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_mult_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_attr_mult_write() */ +} // test_attr_mult_write() /**************************************************************** ** ** test_attr_mult_read(): Test reading multiple attributes. ** ****************************************************************/ -static void -test_attr_mult_read(void) +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 @@ -741,7 +743,7 @@ test_attr_mult_read(void) int i,j,k; // Output message about test being performed - MESSAGE(5, ("Testing Multiple Attribute Reading Functions\n")); + SUBTEST("Testing Multiple Attribute Reading Functions"); try { // Open file @@ -910,12 +912,14 @@ test_attr_mult_read(void) // Verify Name attr_name = attr.getName(); verify_val(attr_name, ATTR3_NAME, "DataType::getName", __LINE__, __FILE__); + + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_mult_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_attr_mult_read() */ +} // test_attr_mult_read() /**************************************************************** ** @@ -923,13 +927,12 @@ test_attr_mult_read(void) ** hdf5 objects. ** ****************************************************************/ -static void -test_attr_delete(void) +static void test_attr_delete() { H5std_string attr_name; // Buffer for attribute names // Output message about test being performed - MESSAGE(5, ("Testing Removing Attribute Function\n")); + SUBTEST("Testing Removing Attribute Function"); try { // Open file @@ -1004,12 +1007,14 @@ test_attr_delete(void) // Verify the correct number of attributes num_attrs = dataset.getNumAttrs(); verify_val(num_attrs, 0, "H5Object::getNumAttrs", __LINE__, __FILE__); + + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_delete()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_attr_delete() */ +} // test_attr_delete() /**************************************************************** ** @@ -1017,8 +1022,7 @@ test_attr_delete(void) ** in attributes. ** ****************************************************************/ -static void -test_attr_dtype_shared(void) +static void test_attr_dtype_shared() { int data=8; /* Data to write */ int rdata=0; /* Read read in */ @@ -1026,7 +1030,7 @@ test_attr_dtype_shared(void) h5_stat_size_t filesize; /* Size of file after modifications */ // Output message about test being performed - MESSAGE(5, ("Testing Shared Datatypes with Attributes\n")); + SUBTEST("Testing Shared Datatypes with Attributes"); try { // Create a file @@ -1135,12 +1139,14 @@ test_attr_dtype_shared(void) // Check size of file filesize=h5_get_file_size(FILENAME.c_str()); verify_val((long)filesize, (long)empty_filesize, "Checking file size", __LINE__, __FILE__); + + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_attr_dtype_shared()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_attr_dtype_shared() */ +} // test_attr_dtype_shared() /**************************************************************** ** @@ -1152,11 +1158,10 @@ test_attr_dtype_shared(void) const H5std_string ATTRSTR_NAME("String_attr"); const H5std_string ATTRSTR_DATA("String Attribute"); -static void -test_string_attr(void) +static void test_string_attr() { // Output message about test being performed - MESSAGE(5, ("Testing Basic Attribute Writing Functions\n")); + SUBTEST("Testing Basic Attribute Writing Functions"); try { // Create file @@ -1188,12 +1193,14 @@ test_string_attr(void) gr_attr.read(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()); + + PASSED(); } // end try block catch (Exception E) { - issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_string_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_string_attr() */ +} // test_string_attr() /**************************************************************** ** @@ -1203,7 +1210,7 @@ test_string_attr(void) #ifdef __cplusplus extern "C" #endif -void test_attr(void) +void test_attr() { // Output message about test being performed MESSAGE(5, ("Testing Attributes\n")); @@ -1226,7 +1233,7 @@ void test_attr(void) test_string_attr(); // Test read/write string attribute -} /* test_attr() */ +} // test_attr() /*------------------------------------------------------------------------- * Function: cleanup_attr @@ -1242,9 +1249,11 @@ void test_attr(void) * *------------------------------------------------------------------------- */ -void -cleanup_attr(void) +#ifdef __cplusplus +extern "C" +#endif +void cleanup_attr() { - remove(FILENAME.c_str()); + HDremove(FILENAME.c_str()); } |