diff options
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/tarray.cpp | 16 | ||||
-rw-r--r-- | c++/test/tobject.cpp | 21 |
2 files changed, 33 insertions, 4 deletions
diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp index 7fe2e6b..f10016f 100644 --- a/c++/test/tarray.cpp +++ b/c++/test/tarray.cpp @@ -34,6 +34,7 @@ using namespace H5; #include "h5cpputil.h" // C++ utilility header file const H5std_string FILENAME("tarray.h5"); +const H5std_string ARRAYTYPE_NAME("/Array type 1"); const int SPACE1_RANK = 1; const hsize_t SPACE1_DIM1 = 4; const int ARRAY1_RANK = 1; @@ -130,9 +131,22 @@ static void test_array_compound_array() // Write dataset to disk dataset.write(wdata, arrtype); + // Test opening ArrayType with opening constructor (Dec 2016) + + // Commit the arrtype to give it a name + arrtype.commit(file1, ARRAYTYPE_NAME); + + // Close it, then re-open with the opening constructor + arrtype.close(); + ArrayType named_type(file1, ARRAYTYPE_NAME); + + // Get and verify the type's name + H5std_string type_name = named_type.getObjName(); + verify_val(type_name, ARRAYTYPE_NAME, "DataType::getObjName tests constructor", __LINE__, __FILE__); + named_type.close(); + // Close all dataset.close(); - arrtype.close(); space.close(); file1.close(); diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index b8654c3..e142f02 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -23,8 +23,6 @@ #else #include <iostream> #endif -using std::cerr; -using std::endl; #include <string> #include "H5Cpp.h" // C++ API header file @@ -184,6 +182,16 @@ static void test_get_objname_ontypes() 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 with + // the constructor + inttype.close(); + IntType newtype(file, "INT type of STD_B8LE"); + + // Get and verify its name + H5std_string type_name = newtype.getObjName(); + verify_val(type_name, "/INT type of STD_B8LE", "DataType::getObjName tests constructor", __LINE__, __FILE__); + newtype.close(); + // Make copy of a predefined type and save it DataType dtype(PredType::STD_B8LE); dtype.commit(file, "STD_B8LE"); @@ -197,7 +205,14 @@ static void test_get_objname_ontypes() dtype = file.openDataType("STD_B8LE"); // Get and verify its name - H5std_string type_name = dtype.getObjName(); + type_name = dtype.getObjName(); + verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); + + // Repeat the test with openDataType's replacement + DataType dtype2(file, "STD_B8LE"); + + // Get and verify its name + type_name = dtype2.getObjName(); verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__); // Test getting type's name from copied type |