mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-30 15:32:37 +08:00
Purpose: Add more tests
Description: Added more tests for the new constructors that replaced openXxxType() Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test)
This commit is contained in:
parent
cd3bd5576f
commit
565aa10d8d
@ -639,10 +639,6 @@ const H5std_string SUBGROUP3("/G1/G3");
|
||||
static void test_libver_bounds_real(
|
||||
H5F_libver_t libver_create, unsigned oh_vers_create,
|
||||
H5F_libver_t libver_mod, unsigned oh_vers_mod)
|
||||
/* (H5F_LIBVER_EARLIEST, H5O_VERSION_1, H5F_LIBVER_LATEST, H5O_VERSION_2);
|
||||
(H5F_LIBVER_LATEST, H5O_VERSION_2, H5F_LIBVER_EARLIEST, H5O_VERSION_2);
|
||||
*/
|
||||
|
||||
{
|
||||
try {
|
||||
|
||||
|
@ -23,8 +23,6 @@
|
||||
#else
|
||||
#include <iostream>
|
||||
#endif
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
|
||||
#include <string>
|
||||
#include "H5Cpp.h" // C++ API header file
|
||||
@ -155,6 +153,7 @@ static void test_get_objname()
|
||||
issue_fail_msg("test_get_objname", __LINE__, __FILE__);
|
||||
}
|
||||
} // test_get_objname
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: test_existance
|
||||
*
|
||||
@ -263,12 +262,21 @@ static void test_get_objname_ontypes()
|
||||
|
||||
// Close the type then open it again to test getting its name
|
||||
inttype.close();
|
||||
inttype = file.openIntType("INT type of STD_B8LE");
|
||||
inttype = file.openIntType("INT type of STD_B8LE"); // deprecated
|
||||
|
||||
// Get and verify its name
|
||||
H5std_string inttype_name = inttype.getObjName();
|
||||
verify_val(inttype_name, "/INT type of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__);
|
||||
|
||||
// Close the type then open it again to test getting its name, but
|
||||
// with the constructor this time
|
||||
inttype.close();
|
||||
IntType std_b8le(file, "INT type of STD_B8LE");
|
||||
|
||||
// Get and verify its name
|
||||
H5std_string std_b8le_name = std_b8le.getObjName();
|
||||
verify_val(std_b8le_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");
|
||||
@ -279,15 +287,22 @@ static void test_get_objname_ontypes()
|
||||
|
||||
// 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");
|
||||
dtype = file.openDataType("STD_B8LE"); // deprecated
|
||||
|
||||
// Get and verify its name
|
||||
H5std_string type_name = dtype.getObjName();
|
||||
verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__);
|
||||
|
||||
// Close the type and open it again with the constructor then test
|
||||
// getting its name
|
||||
dtype.close();
|
||||
DataType dtype2(file, "STD_B8LE");
|
||||
type_name = dtype2.getObjName();
|
||||
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.copy(dtype2);
|
||||
copied_type.commit(file, "copy of STD_B8LE");
|
||||
type_name = copied_type.getObjName();
|
||||
verify_val(type_name, "/copy of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__);
|
||||
@ -302,7 +317,7 @@ static void test_get_objname_ontypes()
|
||||
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();
|
||||
dtype2.close();
|
||||
copied_type.close();
|
||||
new_int_type.close();
|
||||
grp.close();
|
||||
|
@ -257,28 +257,35 @@ static void test_query()
|
||||
tid2.close();
|
||||
|
||||
// Open the datatypes for query
|
||||
|
||||
// Deprecated functions
|
||||
tid1 = file.openCompType(CompT_NAME);
|
||||
tid1.close();
|
||||
tid2 = file.openEnumType(EnumT_NAME);
|
||||
tid2.close();
|
||||
|
||||
CompType comptype(file, CompT_NAME);
|
||||
EnumType enumtype(file, EnumT_NAME);
|
||||
|
||||
// Query member number and member index by name, for compound type
|
||||
nmembs = tid1.getNmembers();
|
||||
nmembs = comptype.getNmembers();
|
||||
verify_val(nmembs, 4, "CompType::getNmembers()", __LINE__, __FILE__);
|
||||
index = tid1.getMemberIndex("c");
|
||||
index = comptype.getMemberIndex("c");
|
||||
verify_val(index, 2, "CompType::getMemberIndex()", __LINE__, __FILE__);
|
||||
|
||||
// Query member number and member index by name, for enumeration type
|
||||
nmembs = tid2.getNmembers();
|
||||
nmembs = enumtype.getNmembers();
|
||||
verify_val(nmembs, 5, "EnumType::getNmembers()", __LINE__, __FILE__);
|
||||
index = tid2.getMemberIndex("ORANGE");
|
||||
index = enumtype.getMemberIndex("ORANGE");
|
||||
verify_val(index, 3, "EnumType::getMemberIndex()", __LINE__, __FILE__);
|
||||
|
||||
// Close datatypes and file
|
||||
tid1.close();
|
||||
tid2.close();
|
||||
comptype.close();
|
||||
enumtype.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,
|
||||
// If any references to ids of the accessed types 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);
|
||||
|
@ -479,10 +479,14 @@ static void test_vlstring_type()
|
||||
vlst.close();
|
||||
|
||||
// Try opening datatype again.
|
||||
vlst = file1->openStrType(VLSTR_TYPE);
|
||||
vlst = file1->openStrType(VLSTR_TYPE); // deprecated
|
||||
|
||||
// Close again and reopen with constructor.
|
||||
vlst.close();
|
||||
StrType vlst1(*file1, VLSTR_TYPE);
|
||||
|
||||
// Close datatype and file.
|
||||
vlst.close();
|
||||
vlst1.close();
|
||||
file1->close();
|
||||
delete file1;
|
||||
|
||||
@ -490,16 +494,16 @@ static void test_vlstring_type()
|
||||
file1 = new H5File(FILENAME, H5F_ACC_RDWR);
|
||||
|
||||
// Open the variable-length string datatype just created
|
||||
vlst = file1->openStrType(VLSTR_TYPE);
|
||||
StrType vlst2(*file1, VLSTR_TYPE);
|
||||
|
||||
// Verify character set and padding
|
||||
cset = vlst.getCset();
|
||||
cset = vlst2.getCset();
|
||||
verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__);
|
||||
pad = vlst.getStrpad();
|
||||
pad = vlst2.getStrpad();
|
||||
verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__);
|
||||
|
||||
// Close datatype and file
|
||||
vlst.close();
|
||||
vlst2.close();
|
||||
file1->close();
|
||||
|
||||
PASSED();
|
||||
|
Loading…
Reference in New Issue
Block a user