diff options
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/CMakeLists.txt | 2 | ||||
-rw-r--r-- | c++/test/dsets.cpp | 8 | ||||
-rw-r--r-- | c++/test/tattr.cpp | 68 | ||||
-rw-r--r-- | c++/test/tcompound.cpp | 2 | ||||
-rw-r--r-- | c++/test/tfile.cpp | 142 | ||||
-rw-r--r-- | c++/test/tfilter.cpp | 12 | ||||
-rw-r--r-- | c++/test/tobject.cpp | 28 | ||||
-rw-r--r-- | c++/test/trefer.cpp | 74 | ||||
-rw-r--r-- | c++/test/ttypes.cpp | 23 | ||||
-rw-r--r-- | c++/test/tvlstr.cpp | 40 |
10 files changed, 292 insertions, 107 deletions
diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt index fe463fa..dcdf3a3 100644 --- a/c++/test/CMakeLists.txt +++ b/c++/test/CMakeLists.txt @@ -36,7 +36,7 @@ configure_file (${HDF5_CPP_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @O add_executable (cpp_testhdf5 ${CPP_TEST_SRCS} ) TARGET_NAMING (cpp_testhdf5 ${LIB_TYPE}) -TARGET_C_PROPERTIES (cpp_testhdf5 " " " ") +TARGET_C_PROPERTIES (cpp_testhdf5 ${LIB_TYPE} " " " ") target_link_libraries (cpp_testhdf5 ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET} diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index fc0ea3a..9f1916d 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -56,11 +56,12 @@ const H5std_string DSET_TCONV_NAME ("tconv"); const H5std_string DSET_COMPRESS_NAME("compressed"); const H5std_string DSET_BOGUS_NAME ("bogus"); +/* Temporary filter IDs used for testing */ const int H5Z_FILTER_BOGUS = 305; -// Local prototypes static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +// UNUSED variables caused warning, but taking them out caused failure. /*------------------------------------------------------------------------- * Function: test_create @@ -458,13 +459,10 @@ const H5Z_class2_t H5Z_BOGUS[1] = {{ *------------------------------------------------------------------------- */ static size_t -/*bogus(unsigned int UNUSED flags, size_t UNUSED cd_nelmts, - const unsigned int UNUSED cd_values[], size_t nbytes, - size_t UNUSED *buf_size, void UNUSED **buf) -BMR: removed UNUSED for now until asking Q. or R. to pass compilation*/ filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], size_t nbytes, size_t *buf_size, void **buf) +// UNUSED variables caused warning, but taking them out caused failure. { return nbytes; } diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 29f50f8..c9422ce 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -53,9 +53,9 @@ const size_t ATTR_MAX_DIMS = 7; /* 3-D dataset with fixed dimensions */ const int SPACE1_RANK = 3; -const int SPACE1_DIM1 = 3; -const int SPACE1_DIM2 = 15; -const int SPACE1_DIM3 = 13; +const hsize_t SPACE1_DIM1 = 3; +const hsize_t SPACE1_DIM2 = 15; +const hsize_t SPACE1_DIM3 = 13; /* Object names */ const H5std_string DSET1_NAME("Dataset1"); @@ -65,7 +65,7 @@ const H5std_string TYPE1_NAME("/Type"); /* Attribute Rank & Dimensions */ const H5std_string ATTR1_NAME("Attr1"); const int ATTR1_RANK = 1; -const int ATTR1_DIM1 = 3; +const hsize_t ATTR1_DIM1 = 3; int attr_data1[ATTR1_DIM1]={512,-234,98123}; /* Test data for 1st attribute */ // File attribute, using the same rank and dimensions as ATTR1_NAME's @@ -74,8 +74,8 @@ const H5std_string FATTR2_NAME("File Attr2"); const H5std_string ATTR2_NAME("Attr2"); const int ATTR2_RANK = 2; -const int ATTR2_DIM1 = 2; -const int ATTR2_DIM2 = 2; +const hsize_t ATTR2_DIM1 = 2; +const hsize_t ATTR2_DIM2 = 2; int attr_data2[ATTR2_DIM1][ATTR2_DIM2]={{7614,-416},{197814,-3}}; /* Test data for 2nd attribute */ const H5std_string ATTR3_NAME("Attr3"); @@ -123,7 +123,7 @@ static void test_attr_basic_write() hsize_t dims2[] = {ATTR1_DIM1}; hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute - int i; + hsize_t i; // Output message about test being performed SUBTEST("Basic Attribute Writing Functions"); @@ -384,7 +384,7 @@ static void test_attr_getname() static void test_attr_rename() { int read_data1[ATTR1_DIM1]={0}; // Buffer for reading the attribute - int i; + hsize_t i; // Output message about test being performed SUBTEST("Checking for Existence and Renaming Attribute"); @@ -493,7 +493,7 @@ static void test_attr_rename() ********************************************************************/ static void test_attr_basic_read() { - int i, j; + hsize_t i, j; // Output message about test being performed SUBTEST("Basic Attribute Reading Functions"); @@ -624,7 +624,6 @@ static void test_attr_compound_read() size_t size; // Attribute datatype size as stored in file size_t offset; // Attribute datatype field offset struct attr4_struct read_data4[ATTR4_DIM1][ATTR4_DIM2]; // Buffer for reading 4th attribute - hsize_t i,j; // Output message about test being performed SUBTEST("Basic Attribute Functions"); @@ -654,7 +653,7 @@ static void test_attr_compound_read() // Get the dims of the dataspace and verify them int ndims = space.getSimpleExtentDims(dims); - if(dims[0]!=ATTR4_DIM1) + verify_val(ndims, ATTR4_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); verify_val((long)dims[0], (long)ATTR4_DIM1, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); verify_val((long)dims[1], (long)ATTR4_DIM2, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); @@ -673,13 +672,14 @@ static void test_attr_compound_read() // Verify that the fields have the same names as when the type // was created - for(i=0; i<fields; i++) + int j; + for(j=0; j<fields; j++) { - H5std_string fieldname = datatype.getMemberName(i); + H5std_string fieldname = datatype.getMemberName(j); if(!((fieldname == ATTR4_FIELDNAME1) || (fieldname == ATTR4_FIELDNAME2) || (fieldname == ATTR4_FIELDNAME3))) - TestErrPrintf("%d:invalid field name for field #%d: %s\n",__LINE__,i,fieldname.c_str()); + TestErrPrintf("%d:invalid field name for field #%d: %s\n",__LINE__,j,fieldname.c_str()); } /* end for */ offset = datatype.getMemberOffset(0); @@ -729,23 +729,38 @@ static void test_attr_compound_read() attr.read(datatype, read_data4); // Verify values read in - for(i=0; i<ATTR4_DIM1; i++) - for(j=0; j<ATTR4_DIM2; j++) - if(HDmemcmp(&attr_data4[i][j],&read_data4[i][j],sizeof(struct attr4_struct))) { - TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n",__LINE__,i,j,attr_data4[i][j].i,i,j,read_data4[i][j].i); - TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n",__LINE__,i,j,attr_data4[i][j].d,i,j,read_data4[i][j].d); - TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",__LINE__,i,j,attr_data4[i][j].c,i,j,read_data4[i][j].c); + hsize_t ii, jj; + for(ii=0; ii<ATTR4_DIM1; ii++) + for(jj=0; jj<ATTR4_DIM2; jj++) + if(HDmemcmp(&attr_data4[ii][jj],&read_data4[ii][jj],sizeof(struct attr4_struct))) { + TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n",__LINE__,ii,jj,attr_data4[ii][jj].i,ii,jj,read_data4[ii][jj].i); + TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n",__LINE__,ii,jj,attr_data4[ii][jj].d,ii,jj,read_data4[ii][jj].d); + TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",__LINE__,ii,jj,attr_data4[ii][jj].c,ii,jj,read_data4[ii][jj].c); } /* end if */ // 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("test_attr_compound_read()", __LINE__, __FILE__, E.getCDetailMsg()); } + + try + { + // Now, try truncating the file to make sure reference counting is good. + // If any references to ids in the previous block are left unterminated, + // the truncating will fail, because the file will not be closed in + // the file.close() above. + H5File file1(FILE_COMPOUND, H5F_ACC_TRUNC); + + PASSED(); + } // end try block + + catch (FileIException E) { + issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, "Unable to truncate file, possibly because some objects are left opened"); + } } // test_attr_compound_read() /**************************************************************** @@ -928,7 +943,7 @@ 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 double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{0}}}; // Buffer for reading 3rd attribute - int i,j,k; + hsize_t i,j,k; // Output message about test being performed SUBTEST("Multiple Attribute Reading Functions"); @@ -959,7 +974,7 @@ static void test_attr_mult_read() // Get the dims of the dataspace and verify them hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions int ndims = space.getSimpleExtentDims(dims); - if(dims[0]!=ATTR1_DIM1) + if ((long)dims[0] != (long)ATTR1_DIM1) TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n",__LINE__,(int)dims[0],ATTR1_DIM1); /* Verify Datatype */ @@ -1010,10 +1025,9 @@ static void test_attr_mult_read() // Get the dims of the dataspace and verify them ndims = space.getSimpleExtentDims(dims); - if(dims[0]!=ATTR2_DIM1) - TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n",__LINE__,(int)dims[0],ATTR2_DIM1); - if(dims[1]!=ATTR2_DIM2) - TestErrPrintf("%d:attribute dimensions different: dims[1]=%d, should be %d\n",__LINE__,(int)dims[1],ATTR2_DIM2); + + verify_val((long)dims[0], (long)ATTR2_DIM1, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); + verify_val((long)dims[1], (long)ATTR2_DIM2, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); /* Verify Datatype */ diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index 156f438..dbf2f0c 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -780,7 +780,7 @@ static void test_compound_set_size() CompType dtype_tmp = file.openCompType("dtype"); // Make a copy of the data type - dtype = dtype_tmp; + dtype.copy(dtype_tmp); // Verify that the compound is not packed // packed = dtype_tmp.packed(); // not until C library provides API diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index ad5e6fc..f3bbb16 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -330,6 +330,32 @@ static void test_file_open() verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); + // Test H5File constructor with existing file id + H5File file2(file1.getId()); + file1.close(); + + // Try truncating the file, and it should fail because the file is + // still opened with file2. + try { + H5File file3 (FILE2, H5F_ACC_TRUNC); // should throw E + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("H5File constructor", "Attempt truncating an opened file."); + } + catch( FileIException E ) // catching H5F_ACC_TRUNC on opened file + {} // do nothing, FAIL expected + + // Now, really close the file. + file2.close(); + + // Truncating should succeed now. + H5File file3(FILE2, H5F_ACC_TRUNC); + + // Opening another file to file3 object, FILE2 should be closed, so + // the next attempt to truncate FILE2 should succeed. + file3.openFile(FILE1, H5F_ACC_RDONLY); + H5File file4(FILE2, H5F_ACC_TRUNC); + PASSED(); } // end of try block @@ -501,6 +527,7 @@ const H5std_string FATTR1_NAME ("file attribute 1"); const H5std_string FATTR2_NAME ("file attribute 2"); int fattr_data[ATTR1_DIM1]={512,-234,98123}; /* Test data for file attribute */ int dattr_data[ATTR1_DIM1]={256,-123,1000}; /* Test data for dataset attribute */ + static void test_file_attribute() { int rdata[ATTR1_DIM1]; @@ -602,6 +629,119 @@ static void test_file_attribute() } } // test_file_attribute() +const H5std_string FILE6("tfile5.h5"); +const H5std_string ROOTGROUP("/"); +const H5std_string GROUP1("/G1"); +const H5std_string SUBGROUP3("/G1/G3"); + +/*------------------------------------------------------------------------- + * Function: test_libver_bounds_real + * + * Purpose: Verify that a file created and modified with the + * specified libver bounds has the specified object header + * versions for the right objects. + * + * Return: None + * + * Programmer: Binh-Minh Ribler (use C version) + * March, 2015 + * + *------------------------------------------------------------------------- + */ +static void test_libver_bounds_real( + H5F_libver_t libver_create, unsigned oh_vers_create, + H5F_libver_t libver_mod, unsigned oh_vers_mod) +{ + try { + + /* + * Create a new file using the default creation property and access property + * with latest library version. + */ + FileAccPropList fapl; + fapl.setLibverBounds(libver_create, H5F_LIBVER_LATEST); + H5File file(FILE6, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + + /* + * Make sure the root group has the correct object header version + */ + unsigned obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + + /* + * Reopen the file and make sure the root group still has the correct version + */ + file.close(); + + fapl.setLibverBounds(libver_mod, H5F_LIBVER_LATEST); + + file.openFile(FILE6, H5F_ACC_RDWR, fapl); + + obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + + /* + * Create a group named "/G1" in the file, and make sure it has the correct + * object header version + */ + Group group = file.createGroup(GROUP1); + + obj_version = file.childObjVersion(GROUP1); + verify_val(obj_version, oh_vers_mod, "H5File::childObjVersion", __LINE__, __FILE__); + + group.close(); // close "/G1" + + /* + * Create a group named "/G1/G3" in the file, and make sure it has the + * correct object header version + */ + group = file.createGroup(SUBGROUP3); + + obj_version = group.childObjVersion(SUBGROUP3); + verify_val(obj_version, oh_vers_mod, "H5File::childObjVersion", __LINE__, __FILE__); + + group.close(); // close "/G1/G3" + + /* + * Make sure the root group still has the correct object header version + */ + obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + + // Everything should be closed as they go out of scope + } // end of try block + + catch (Exception E) { + issue_fail_msg("test_libver_bounds_real()", __LINE__, __FILE__, E.getCDetailMsg()); + } + +} /* end test_libver_bounds_real() */ + +/*------------------------------------------------------------------------- + * + * Function: test_libver_bounds + * + * Purpose: Verify that a file created and modified with various + * libver bounds is handled correctly. + * + * Return: None + * + * Programmer: Binh-Minh Ribler (use C version) + * March 2015 + * + *------------------------------------------------------------------------- + */ +static void test_libver_bounds() +{ + // Output message about test being performed + SUBTEST("Setting library version bounds"); + + /* Run the tests */ + test_libver_bounds_real(H5F_LIBVER_EARLIEST, H5O_VERSION_1, H5F_LIBVER_LATEST, H5O_VERSION_2); + test_libver_bounds_real(H5F_LIBVER_LATEST, H5O_VERSION_2, H5F_LIBVER_EARLIEST, H5O_VERSION_1); + PASSED(); +} /* end test_libver_bounds() */ + /*------------------------------------------------------------------------- * Function: test_file * @@ -629,6 +769,7 @@ void test_file() test_file_size(); // Test file size test_file_name(); // Test getting file's name test_file_attribute(); // Test file attribute feature + test_libver_bounds(); // Test format version } // test_file() @@ -655,4 +796,5 @@ void cleanup_file() HDremove(FILE3.c_str()); HDremove(FILE4.c_str()); HDremove(FILE5.c_str()); + HDremove(FILE6.c_str()); } // cleanup_file diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp index 854c7bb..3edb83a 100644 --- a/c++/test/tfilter.cpp +++ b/c++/test/tfilter.cpp @@ -57,9 +57,13 @@ static herr_t test_filter_internal(hid_t fid, const char *name, hid_t dcpl, #endif /* Temporary filter IDs used for testing */ -#define H5Z_FILTER_BOGUS 305 +const int H5Z_FILTER_BOGUS = 305; + +#if 0 // UNUSED variables caused warning, so duplicated below with NULL instead static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +#endif +static size_t filter_bogus(size_t nbytes); /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ @@ -88,9 +92,12 @@ const H5Z_class2_t H5Z_BOGUS[1] = {{ *------------------------------------------------------------------------- */ static size_t +#if 0 // UNUSED variables caused warning, so duplicated below with NULL instead filter_bogus(unsigned int UNUSED flags, size_t UNUSED cd_nelmts, const unsigned int UNUSED *cd_values, size_t nbytes, size_t UNUSED *buf_size, void UNUSED **buf) +#endif +filter_bogus(size_t nbytes) { return nbytes; } @@ -239,7 +246,8 @@ static void test_szip_filter(H5File& file1) #else /* H5_HAVE_FILTER_SZIP */ SUBTEST("szip filter"); SKIPPED(); - puts(" Szip filter not enabled"); + H5std_string fname = file1.getFileName(); + cerr << " Szip filter not enabled for file '" << fname << "'" << endl; #endif /* H5_HAVE_FILTER_SZIP */ } // test_szip_filter diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index b86d7cb..2381ec2 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -181,19 +181,39 @@ static void test_get_objname_ontypes() Group grp = file.createGroup ("typetests"); // Create a datatype and save it + IntType inttype(PredType::STD_B8LE); + inttype.commit(file, "INT type of STD_B8LE"); + + // Close the type then open it again to test getting its name + inttype.close(); + inttype = file.openIntType("INT type of STD_B8LE"); + + // Get and verify its name + H5std_string inttype_name = inttype.getObjName(); + verify_val(inttype_name, "/INT type of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); + + // Make copy of a predefined type and save it DataType dtype(PredType::STD_B8LE); dtype.commit(file, "STD_B8LE"); + // Close the data type and file + dtype.close(); + file.close(); + + // Re-open the file and the data type to test getting its name + file.openFile(FILE_OBJECTS, H5F_ACC_RDWR); + dtype = file.openDataType("STD_B8LE"); + // Get and verify its name H5std_string type_name = dtype.getObjName(); - verify_val(type_name, "/STD_B8LE", "DataSet::getObjName", __LINE__, __FILE__); + verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); // Test getting type's name from copied type DataType copied_type; copied_type.copy(dtype); copied_type.commit(file, "copy of STD_B8LE"); type_name = copied_type.getObjName(); - verify_val(type_name, "/copy of STD_B8LE", "DataSet::getObjName", __LINE__, __FILE__); + verify_val(type_name, "/copy of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); // Test copying an integer predefined type IntType new_int_type(PredType::NATIVE_INT); @@ -201,14 +221,14 @@ static void test_get_objname_ontypes() // Name this datatype new_int_type.commit(grp, "IntType NATIVE_INT"); ssize_t name_len = new_int_type.getObjName(type_name); // default len - verify_val(type_name, "/typetests/IntType NATIVE_INT", "DataSet::getObjName", __LINE__, __FILE__); + verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName", __LINE__, __FILE__); + verify_val(type_name, "/typetests/IntType NATIVE_INT", "DataType::getObjName", __LINE__, __FILE__); // Close everything or they can be closed when objects go out of scope dtype.close(); copied_type.close(); new_int_type.close(); grp.close(); - file.close(); PASSED(); } // end top try block diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index dcfb644..9d072be 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -462,11 +462,11 @@ test_reference_group(void) // Check number of objects in the group dereferenced by constructor hsize_t nobjs = refgroup.getNumObjs(); - verify_val(nobjs, 3, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); // Check number of objects in the group dereferenced by ::reference nobjs = group.getNumObjs(); - verify_val(nobjs, 3, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); // Check getting file name given the group dereferenced via constructor H5std_string fname = refgroup.getFileName(); @@ -479,7 +479,7 @@ test_reference_group(void) // Unlink one of the objects in the dereferenced group, and re-check refgroup.unlink(GROUPNAME2); nobjs = refgroup.getNumObjs(); - verify_val(nobjs, 2, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs",__LINE__,__FILE__); // Close resources group.close(); @@ -686,43 +686,43 @@ test_reference_region_1D(void) reg_sp.getSelectHyperBlocklist((hsize_t)0, (hsize_t)nelms, coords); // Verify values in the list - verify_val(coords[0], 2, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[1], 3, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[2], 7, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[3], 8, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[4], 12, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[5], 13, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[6], 17, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[7], 18, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[8], 22, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[9], 23, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[10], 27, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[11], 28, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[12], 32, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[13], 33, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[14], 37, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[15], 38, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[16], 42, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[17], 43, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[18], 47, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[19], 48, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[20], 52, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[21], 53, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[22], 57, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[23], 58, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[24], 62, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[25], 63, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[26], 67, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[27], 68, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[28], 72, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[29], 73, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[4],(hsize_t)12, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[5],(hsize_t)13, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[6],(hsize_t)17, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[7],(hsize_t)18, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[8],(hsize_t)22, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[9],(hsize_t)23, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[10],(hsize_t)27, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[11],(hsize_t)28, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[12],(hsize_t)32, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[13],(hsize_t)33, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[14],(hsize_t)37, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[15],(hsize_t)38, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[16],(hsize_t)42, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[17],(hsize_t)43, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[18],(hsize_t)47, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[19],(hsize_t)48, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[20],(hsize_t)52, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[21],(hsize_t)53, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[22],(hsize_t)57, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[23],(hsize_t)58, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[24],(hsize_t)62, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[25],(hsize_t)63, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[26],(hsize_t)67, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[27],(hsize_t)68, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[28],(hsize_t)72, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[29],(hsize_t)73, "Hyperslab Coordinates",__LINE__,__FILE__); HDfree(coords); // Check boundaries reg_sp.getSelectBounds(low, high); - verify_val(low[0], 2, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0], 73, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(low[0],(hsize_t)2, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(high[0],(hsize_t)73, "DataSpace::getSelectBounds",__LINE__,__FILE__); /* Close region space */ reg_sp.close(); @@ -760,8 +760,8 @@ test_reference_region_1D(void) // Check boundaries elm_sp.getSelectBounds(low, high); - verify_val(low[0], 3, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0], 97, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(low[0],(hsize_t)3, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(high[0],(hsize_t)97, "DataSpace::getSelectBounds",__LINE__,__FILE__); // Close element space elm_sp.close(); diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index e9e1427..2e64051 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -109,7 +109,7 @@ static void test_classes() { SUBTEST("PredType::getClass()"); try { - int curr_nerrors = GetTestNumErrs(); + // maybe later, int curr_nerrors = GetTestNumErrs(); // PredType::NATIVE_INT should be in H5T_INTEGER class H5T_class_t tcls = PredType::NATIVE_INT.getClass(); @@ -283,10 +283,16 @@ static void test_query() tid2.close(); file.close(); + // Try truncating the file to make sure reference counting is good. + // If any references to ids of tid1 and tid2 are left unterminated, + // the truncating will fail, because the file will not be closed in + // the file.close() above. + H5File file1(FILENAME[2], H5F_ACC_TRUNC); + PASSED(); } // end of try block catch (Exception E) { - issue_fail_msg("test_query", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_query", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_query @@ -467,27 +473,20 @@ static void test_named () trans_type.setPrecision(256); trans_type.close(); - /* - * Close the committed type and reopen it. It should return a named type. -* This had something to do with the way IntType was returned and assigned -and caused itype.committed not working correctly. So, use another_type for -now. + // Close the committed type and reopen it. It should be a named type. itype.close(); itype = file.openIntType("native-int"); iscommitted = itype.committed(); -*/ - IntType another_type = file.openIntType("native-int"); - iscommitted = another_type.committed(); if (!iscommitted) throw InvalidActionException("IntType::committed()", "Opened named types should be named types!"); // Create a dataset that uses the named type, then get the dataset's // datatype and make sure it's a named type. - DataSet dset = file.createDataSet("dset1", another_type, space); + DataSet dset = file.createDataSet("dset1", itype, space); ds_type = new DataType(dset.getDataType()); iscommitted = ds_type->committed(); if (!iscommitted) - throw InvalidActionException("IntType::committed()", "1 Dataset type should be named type!"); + throw InvalidActionException("IntType::committed()", "Dataset type should be named type!"); dset.close(); ds_type->close(); delete ds_type; diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index a2669db..7c81a8e 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -60,6 +60,7 @@ const hsize_t SPACE1_DIM1 = 4; ** Note: exact copy from the C version. ** (Not used now) ****************************************************************/ +#if 0 // not used now static void *test_vlstr_alloc_custom(size_t size, void *info) { void *ret_value=NULL; // Pointer to return @@ -81,6 +82,7 @@ static void *test_vlstr_alloc_custom(size_t size, void *info) return(ret_value); } +#endif /**************************************************************** ** @@ -92,6 +94,7 @@ static void *test_vlstr_alloc_custom(size_t size, void *info) ** Note: exact copy from the C version. ** (Not used now) ****************************************************************/ +#if 0 // not used now static void test_vlstr_free_custom(void *_mem, void *info) { unsigned char *mem; @@ -111,6 +114,7 @@ static void test_vlstr_free_custom(void *_mem, void *info) HDfree(mem); } // end if } +#endif /*------------------------------------------------------------------------- * Function: test_vlstring_dataset @@ -256,7 +260,7 @@ static void test_vlstring_array_dataset() char *string_ds_check[SPACE1_DIM1]; dataset.read(string_ds_check, vlst); - int ii; + hsize_t ii; for (ii = 0; ii < SPACE1_DIM1; ii++) { if(HDstrcmp(string_ds_check[ii], string_ds_array[ii])!=0) @@ -351,25 +355,25 @@ static void test_vlstrings_special() dataset.read(rdata, vlst); // Check data read in. - hsize_t i; // counting variable - for (i=0; i<SPACE1_DIM1; i++) - if(rdata[i]!=NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)i,rdata[i]); + hsize_t ii; // counting variable + for (ii=0; ii<SPACE1_DIM1; ii++) + if(rdata[ii]!=NULL) + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]); // Write dataset to disk, then read it back. dataset.write(wdata, vlst); dataset.read(rdata, vlst); // Compare data read in. - for (i = 0; i < SPACE1_DIM1; i++) { - size_t wlen = HDstrlen(wdata[i]); - size_t rlen = HDstrlen(rdata[i]); + for (ii = 0; ii < SPACE1_DIM1; ii++) { + size_t wlen = HDstrlen(wdata[ii]); + size_t rlen = HDstrlen(rdata[ii]); if(wlen != rlen) { - TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n", (int)i, (unsigned)wlen, (int)i, (unsigned)rlen); + TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n", (int)ii, (unsigned)wlen, (int)ii, (unsigned)rlen); continue; } // end if - if(HDstrcmp(wdata[i],rdata[i]) != 0) { - TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)i, wdata[i], (int)i, rdata[i]); + if(HDstrcmp(wdata[ii],rdata[ii]) != 0) { + TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)ii, wdata[ii], (int)ii, rdata[ii]); continue; } // end if } // end for @@ -398,9 +402,9 @@ static void test_vlstrings_special() dataset.read(rdata, vlst); // Check data read in. - for (i=0; i<SPACE1_DIM1; i++) - if(rdata[i]!=NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)i,rdata[i]); + for (ii=0; ii<SPACE1_DIM1; ii++) + if(rdata[ii]!=NULL) + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]); // Try to write nil strings to disk. dataset.write(wdata2, vlst); @@ -409,9 +413,9 @@ static void test_vlstrings_special() dataset.read(rdata, vlst); // Check data read in. - for (i=0; i<SPACE1_DIM1; i++) - if(rdata[i]!=NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)i,rdata[i]); + for (ii=0; ii<SPACE1_DIM1; ii++) + if(rdata[ii]!=NULL) + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]); // Close objects and file. dataset.close(); @@ -793,7 +797,7 @@ static void test_vlstring_array_attribute() char *string_att_check[SPACE1_DIM1]; gr_attr.read(vlst, &string_att_check); - int ii; + hsize_t ii; for (ii = 0; ii < SPACE1_DIM1; ii++) { if(HDstrcmp(string_att_check[ii], string_att_array[ii])!=0) |