summaryrefslogtreecommitdiffstats
path: root/c++/test
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2014-06-19 20:09:06 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2014-06-19 20:09:06 (GMT)
commit67ba5eb6e8a71a110d47fd3079edcc1fe09fb95f (patch)
tree92735056c19013281c6ba687e836ed59772e2f3e /c++/test
parent02eab2eb72a18fa685545ba7c7c5ac7715693d1b (diff)
downloadhdf5-67ba5eb6e8a71a110d47fd3079edcc1fe09fb95f.zip
hdf5-67ba5eb6e8a71a110d47fd3079edcc1fe09fb95f.tar.gz
hdf5-67ba5eb6e8a71a110d47fd3079edcc1fe09fb95f.tar.bz2
[svn-r25333] Bring revisions #24948 - #25120 from trunk to revise_chunks.
Tested on jam, ostrich, koala, platypus.
Diffstat (limited to 'c++/test')
-rw-r--r--c++/test/CMakeLists.txt1
-rw-r--r--c++/test/Makefile.am4
-rw-r--r--c++/test/Makefile.in10
-rw-r--r--c++/test/dsets.cpp38
-rw-r--r--c++/test/h5cpputil.h15
-rw-r--r--c++/test/tattr.cpp49
-rw-r--r--c++/test/tcompound.cpp8
-rw-r--r--c++/test/tdspl.cpp5
-rw-r--r--c++/test/testhdf5.cpp71
-rw-r--r--c++/test/tfile.cpp1
-rw-r--r--c++/test/tfilter.cpp2
-rw-r--r--c++/test/tobject.cpp335
-rw-r--r--c++/test/trefer.cpp4
-rw-r--r--c++/test/ttypes.cpp17
-rw-r--r--c++/test/tvlstr.cpp12
15 files changed, 487 insertions, 85 deletions
diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt
index 220d4b1..acb2b7f 100644
--- a/c++/test/CMakeLists.txt
+++ b/c++/test/CMakeLists.txt
@@ -20,6 +20,7 @@ set (CPP_TEST_SRCS
${HDF5_CPP_TEST_SOURCE_DIR}/tfilter.cpp
${HDF5_CPP_TEST_SOURCE_DIR}/th5s.cpp
${HDF5_CPP_TEST_SOURCE_DIR}/tlinks.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/tobject.cpp
${HDF5_CPP_TEST_SOURCE_DIR}/trefer.cpp
${HDF5_CPP_TEST_SOURCE_DIR}/ttypes.cpp
${HDF5_CPP_TEST_SOURCE_DIR}/tvlstr.cpp
diff --git a/c++/test/Makefile.am b/c++/test/Makefile.am
index 6cef381..2717e9c 100644
--- a/c++/test/Makefile.am
+++ b/c++/test/Makefile.am
@@ -38,8 +38,8 @@ check_PROGRAMS=$(TEST_PROG)
LDADD=$(LIBH5TEST) $(LIBH5CPP) $(LIBHDF5)
testhdf5_SOURCES=testhdf5.cpp dsets.cpp tattr.cpp tcompound.cpp \
- tdspl.cpp tfile.cpp tfilter.cpp th5s.cpp tlinks.cpp trefer.cpp \
- ttypes.cpp tvlstr.cpp h5cpputil.cpp
+ tdspl.cpp tfile.cpp tfilter.cpp th5s.cpp tlinks.cpp tobject.cpp \
+ trefer.cpp ttypes.cpp tvlstr.cpp h5cpputil.cpp
# Tell conclude.am that these are C++ tests.
CXX_API=yes
diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in
index 59cab8f..621618e 100644
--- a/c++/test/Makefile.in
+++ b/c++/test/Makefile.in
@@ -117,8 +117,8 @@ am__EXEEXT_1 = testhdf5$(EXEEXT)
am_testhdf5_OBJECTS = testhdf5.$(OBJEXT) dsets.$(OBJEXT) \
tattr.$(OBJEXT) tcompound.$(OBJEXT) tdspl.$(OBJEXT) \
tfile.$(OBJEXT) tfilter.$(OBJEXT) th5s.$(OBJEXT) \
- tlinks.$(OBJEXT) trefer.$(OBJEXT) ttypes.$(OBJEXT) \
- tvlstr.$(OBJEXT) h5cpputil.$(OBJEXT)
+ tlinks.$(OBJEXT) tobject.$(OBJEXT) trefer.$(OBJEXT) \
+ ttypes.$(OBJEXT) tvlstr.$(OBJEXT) h5cpputil.$(OBJEXT)
testhdf5_OBJECTS = $(am_testhdf5_OBJECTS)
testhdf5_LDADD = $(LDADD)
testhdf5_DEPENDENCIES = $(LIBH5TEST) $(LIBH5CPP) $(LIBHDF5)
@@ -503,7 +503,6 @@ LIPO = @LIPO@
LL_PATH = @LL_PATH@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
-LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@
LT_STATIC_EXEC = @LT_STATIC_EXEC@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
@@ -681,8 +680,8 @@ TEST_PROG = testhdf5
# The tests depend on the hdf5 library, test library, and the c++ library
LDADD = $(LIBH5TEST) $(LIBH5CPP) $(LIBHDF5)
testhdf5_SOURCES = testhdf5.cpp dsets.cpp tattr.cpp tcompound.cpp \
- tdspl.cpp tfile.cpp tfilter.cpp th5s.cpp tlinks.cpp trefer.cpp \
- ttypes.cpp tvlstr.cpp h5cpputil.cpp
+ tdspl.cpp tfile.cpp tfilter.cpp th5s.cpp tlinks.cpp tobject.cpp \
+ trefer.cpp ttypes.cpp tvlstr.cpp h5cpputil.cpp
# Tell conclude.am that these are C++ tests.
@@ -774,6 +773,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tfilter.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/th5s.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tlinks.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tobject.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trefer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttypes.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tvlstr.Po@am__quote@
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp
index 72d7977..d1ced1d 100644
--- a/c++/test/dsets.cpp
+++ b/c++/test/dsets.cpp
@@ -49,6 +49,7 @@
const H5std_string FILE1("dataset.h5");
const H5std_string DSET_DEFAULT_NAME("default");
+const H5std_string DSET_DEFAULT_NAME_PATH("/default");
const H5std_string DSET_CHUNKED_NAME("chunked");
const H5std_string DSET_SIMPLE_IO_NAME("simple_io");
const H5std_string DSET_TCONV_NAME ("tconv");
@@ -96,6 +97,7 @@ test_create( H5File& file)
dataset = new DataSet (file.createDataSet
(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space));
+
// Add a comment to the dataset
file.setComment (DSET_DEFAULT_NAME, "This is a dataset");
@@ -120,10 +122,15 @@ test_create( H5File& file)
// way to open an existing dataset for accessing.
dataset = new DataSet (file.openDataSet (DSET_DEFAULT_NAME));
+ // Get and verify the name of this dataset, using
+ // H5std_string getObjName()
+ H5std_string ds_name = dataset->getObjName();
+ verify_val(ds_name, DSET_DEFAULT_NAME_PATH, "DataSet::getObjName", __LINE__, __FILE__);
+
// Get and verify the comment from this dataset, using
// H5std_string getComment(const H5std_string& name, <buf_size=0, by default>)
H5std_string comment = file.getComment(DSET_DEFAULT_NAME);
- verify_val(comment, "This is a dataset", "H5Location::getComment", __LINE__, __FILE__);
+ verify_val(comment, "This is a dataset", "DataSet::getComment", __LINE__, __FILE__);
// Close the dataset when accessing is completed
delete dataset;
@@ -305,10 +312,14 @@ test_datasize(FileAccPropList &fapl)
// Get the dimension sizes.
hsize_t dims[2];
int n_dims = space.getSimpleExtentDims(dims);
+ if (n_dims < 0)
+ {
+ throw Exception("test_compression", "DataSpace::getSimpleExtentDims() failed");
+ }
// Calculate the supposed size. Size of each value is int (4), from
// test_simple_io.
- int expected_size = 4 * dims[0] * dims[1];
+ size_t expected_size = 4 * dims[0] * dims[1];
// getInMemDataSize() returns the in memory size of the data.
size_t ds_size = dset.getInMemDataSize();
@@ -1050,11 +1061,6 @@ void test_dset()
try
{
- // Turn of the auto-printing when failure occurs so that we can
- // handle the errors appropriately since sometime failures are
- // caused deliberately and expected.
- Exception::dontPrint();
-
// Use the file access template id to create a file access prop.
// list object to pass in H5File::H5File
FileAccPropList fapl(fapl_id);
@@ -1065,18 +1071,12 @@ void test_dset()
Group grp = file.createGroup( "emit diagnostics", 0);
grp.setComment("Causes diagnostic messages to be emitted");
- nerrors += test_create(file)<0 ?1:0;
- nerrors += test_simple_io(file)<0 ?1:0;
- nerrors += test_tconv(file)<0 ?1:0;
- nerrors += test_compression(file)<0 ?1:0;
- nerrors += test_multiopen (file)<0 ?1:0;
- nerrors += test_types(file)<0 ?1:0;
-
- // Get part of the comment, random length using
- // ssize_t getComment(const char* name, const size_t buf_size, char* comment)
- char* comment = new char[11];
- ssize_t comment_len = file.getComment("emit diagnostics", 11, comment);
- verify_val((const char*)comment, "Causes dia", "H5Location::getComment", __LINE__, __FILE__);
+ nerrors += test_create(file) < 0 ? 1:0;
+ nerrors += test_simple_io(file) < 0 ? 1:0;
+ nerrors += test_tconv(file) < 0 ? 1:0;
+ nerrors += test_compression(file) < 0 ? 1:0;
+ nerrors += test_multiopen (file) < 0 ? 1:0;
+ nerrors += test_types(file) < 0 ? 1:0;
// Close group "emit diagnostics".
grp.close();
diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h
index cc135bd..8625213 100644
--- a/c++/test/h5cpputil.h
+++ b/c++/test/h5cpputil.h
@@ -115,6 +115,19 @@ template <class Type1, class Type2>
}
}
+template <class Type1, class Type2>
+ void CHECK(Type1 x, Type2 value, const char* msg, int line, const char* file_name)
+{
+ if (x == value)
+ {
+ cerr << endl;
+ cerr << "*** Function " << msg << " FAILED at line " << line << endl;
+ IncTestNumErrs();
+ throw TestFailedException(file_name, msg);
+ }
+}
+
+
/* Prototypes for the test routines */
#ifdef __cplusplus
extern "C" {
@@ -126,6 +139,7 @@ void test_file();
void test_filters();
void test_links();
void test_h5s();
+void test_object();
void test_reference();
void test_types();
void test_vlstrings();
@@ -140,6 +154,7 @@ void cleanup_file();
void cleanup_filters();
void cleanup_links();
void cleanup_h5s();
+void cleanup_object();
void cleanup_reference();
void cleanup_types();
void cleanup_vlstrings();
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp
index e2e347b..29f50f8 100644
--- a/c++/test/tattr.cpp
+++ b/c++/test/tattr.cpp
@@ -248,16 +248,20 @@ static void test_attr_basic_write()
**
** Test these functions:
** A. ssize_t Attribute::getName(char* attr_name, size_t buf_size)
-** 1. With arbitrary buf_size that is larger than the name size
-** 2. With arbitrary buf_size that is smaller than the name's length.
-** 3. With a buf_size that equals the name's length.
+** 1. With arbitrary buf_size that is larger than the name size
+** 2. With arbitrary buf_size that is smaller than the name's length.
+** 3. With a buf_size that equals the name's length.
**
** B. ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size)
-** With buffer smaller than the actual name
+** 1. With buffer smaller than the actual name
+** 2. Same test but with retiring overloaded function
+** ssize_t Attribute::getName(size_t buf_size, H5std_string& attr_name)
**
-** C. H5std_string Attribute::getName() with file's and dataset's attrs.
+** C. H5std_string Attribute::getName()
**
-** D. ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size)
+** D. H5std_string Attribute::getName(size_t len)
+**
+** E. ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size)
** With buffer size equals the name's length, i.e., buf_size=0
**
****************************************************************/
@@ -292,6 +296,8 @@ static void test_attr_getname()
HDmemset(fattr1_name, 0, buf_size+1);
ssize_t name_size = 0; // actual length of attribute name
name_size = fattr1.getName(fattr1_name, buf_size+1);
+ CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__);
+ verify_val((size_t)name_size, FATTR1_NAME.length(), "Attribute::getName", __LINE__, __FILE__);
verify_val((const char*)fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__);
delete []fattr1_name;
@@ -302,6 +308,8 @@ static void test_attr_getname()
fattr1_name = new char[buf_size+1];
HDmemset(fattr1_name, 0, buf_size+1);
name_size = fattr1.getName(fattr1_name, buf_size+1);
+ CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__);
+ verify_val((size_t)name_size, FATTR1_NAME.size(), "Attribute::getName", __LINE__, __FILE__);
verify_val((const char*)fattr1_name, (const char*)short_name, "Attribute::getName", __LINE__, __FILE__);
delete []fattr1_name;
@@ -310,6 +318,7 @@ static void test_attr_getname()
fattr1_name = new char[buf_size+1];
HDmemset(fattr1_name, 0, buf_size+1);
name_size = fattr1.getName(fattr1_name, buf_size+1);
+ CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__);
verify_val(fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__);
delete []fattr1_name;
@@ -319,6 +328,14 @@ static void test_attr_getname()
buf_size = 4;
H5std_string fattr1_name2;
name_size = fattr1.getName(fattr1_name2, buf_size);
+ verify_val(fattr1_name2, "File", "Attribute::getName", __LINE__, __FILE__);
+
+ // Same test as above, but with deprecated overloaded function
+ // ssize_t Attribute::getName(size_t buf_size, H5std_string& attr_name)
+ // using buffer smaller than the actual name
+ H5std_string fattr1_name2a;
+ name_size = fattr1.getName(fattr1_name2a, buf_size);
+ verify_val(fattr1_name2a, "File", "Attribute::getName", __LINE__, __FILE__);
// C. Get file attribute's name with
// H5std_string Attribute::getName()
@@ -326,7 +343,8 @@ static void test_attr_getname()
verify_val(fattr1_name3, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__);
//
- // Open the dataset DSET1_NAME and test getName with its attribute
+ // D. Test getName getting part of an attribute's name using
+ // H5std_string Attribute::getName(len)
//
// Open dataset DSET1_NAME
@@ -340,12 +358,11 @@ static void test_attr_getname()
// Open attribute
Attribute attr1(dataset.openAttribute(ATTR1_NAME));
- // Get dataset attribute's name with
- // H5std_string Attribute::getName()
- H5std_string dattr_name1 = attr1.getName();
- verify_val(dattr_name1, ATTR1_NAME, "Attribute::getName", __LINE__, __FILE__);
+ size_t len = 4;
+ H5std_string dattr_name1 = attr1.getName(len);
+ verify_val(dattr_name1, "Attr", "Attribute::getName", __LINE__, __FILE__);
- // D. Get attribute name with
+ // E. Get dataset's attribute name with
// H5std_string Attribute::getName(H5std_string attr_name, buf_size=0)
H5std_string dattr_name2;
name_size = attr1.getName(dattr_name2);
@@ -607,7 +624,7 @@ 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
- int i,j;
+ hsize_t i,j;
// Output message about test being performed
SUBTEST("Basic Attribute Functions");
@@ -1590,6 +1607,10 @@ extern "C"
#endif
void cleanup_attr()
{
- //HDremove(FILENAME.c_str());
+ HDremove(FILE_BASIC.c_str());
+ HDremove(FILE_COMPOUND.c_str());
+ HDremove(FILE_SCALAR.c_str());
+ HDremove(FILE_MULTI.c_str());
+ HDremove(FILE_DTYPE.c_str());
}
diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp
index 60d44b2..156f438 100644
--- a/c++/test/tcompound.cpp
+++ b/c++/test/tcompound.cpp
@@ -742,13 +742,12 @@ cerr << "test_compound_7 in catch" << endl;
*
*-------------------------------------------------------------------------
*/
-#define COMPFILE "tcompound_types.h5"
+const H5std_string COMPFILE("tcompound_types.h5");
static void test_compound_set_size()
{
typedef struct {
int a, b, c[4], d, e;
} src_typ_t;
- src_typ_t *s_ptr;
// Output message about test being performed
SUBTEST("Setting Size on Compound Datatype");
@@ -794,7 +793,7 @@ static void test_compound_set_size()
// Verify setSize() actually set size
size_t new_size = dtype.getSize();
- verify_val(new_size, 33, "DataType::getSize", __LINE__, __FILE__);
+ verify_val(new_size, (size_t)33, "DataType::getSize", __LINE__, __FILE__);
// Shrink the type, and verify that it became packed
dtype.setSize((size_t)32);
@@ -803,7 +802,7 @@ static void test_compound_set_size()
// Verify setSize() actually set size again
new_size = dtype.getSize();
- verify_val(new_size, 32, "DataType::getSize", __LINE__, __FILE__);
+ verify_val(new_size, (size_t)32, "DataType::getSize", __LINE__, __FILE__);
/* Close types and file */
dtype_tmp.close();
@@ -867,4 +866,5 @@ extern "C"
#endif
void cleanup_compound()
{
+ HDremove(COMPFILE.c_str());
} // cleanup_file
diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp
index 5944fb1..5c1d953 100644
--- a/c++/test/tdspl.cpp
+++ b/c++/test/tdspl.cpp
@@ -50,7 +50,6 @@ static void test_transfplist()
const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
/* inverses the utrans transform in init_test to get back original array */
const char* utrans_inv = "(x/3)*4 - 100";
- char *c_to_f_read=NULL, *simple_read=NULL, *utrans_inv_read=NULL;
SUBTEST("DSetMemXferPropList::set/getDataTransform()");
try {
@@ -75,7 +74,7 @@ static void test_transfplist()
// Find out the length of the transform expression, allocate the buffer
// for it, then read and verify the expression from the copied plist
ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL);
- c_to_f_read = (char *)HDmalloc(tran_len+1);
+ char *c_to_f_read = (char *)HDmalloc(tran_len+1);
HDmemset(c_to_f_read, 0, tran_len+1);
dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len+1);
verify_val((const char*)c_to_f_read, (const char*)c_to_f,
@@ -106,7 +105,7 @@ static void test_transfplist()
// Get and verify the expression with:
// ssize_t getDataTransform(char* exp, const size_t buf_size)
tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0);
- utrans_inv_read = (char *)HDmalloc(tran_len+1);
+ char *utrans_inv_read = (char *)HDmalloc(tran_len+1);
HDmemset(utrans_inv_read, 0, tran_len+1);
dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len+1);
verify_val((const char*)utrans_inv_read, (const char*)utrans_inv,
diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp
index 57210d0..19b4f0d 100644
--- a/c++/test/testhdf5.cpp
+++ b/c++/test/testhdf5.cpp
@@ -67,41 +67,54 @@
int
main(int argc, char *argv[])
{
- /* Initialize testing framework */
- TestInit(argv[0], NULL, NULL);
-
- // testing file creation and opening in tfile.cpp
- AddTest("tfile", test_file, cleanup_file, "File I/O Operations", NULL);
- // testing dataset functionalities in dset.cpp
- AddTest("dsets", test_dset, cleanup_dsets, "Dataset I/O Operations", NULL);
- // testing dataspace functionalities in th5s.cpp
- AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL);
- // testing attribute functionalities in tattr.cpp
- AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL);
- // testing reference functionalities in trefer.cpp
- AddTest("trefer", test_reference, cleanup_reference, "References", NULL);
- // testing variable-length strings in tvlstr.cpp
- AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL);
- AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL);
- AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL);
- AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL);
- AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL);
- AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL);
+ try
+ {
+ // Turn of the auto-printing when failure occurs so that we can
+ // handle the errors appropriately since sometime failures are
+ // caused deliberately and expected.
+ Exception::dontPrint();
+ /* Initialize testing framework */
+ TestInit(argv[0], NULL, NULL);
+
+ // testing file creation and opening in tfile.cpp
+ AddTest("tfile", test_file, cleanup_file, "File I/O Operations", NULL);
+ // testing dataset functionalities in dset.cpp
+ AddTest("dsets", test_dset, cleanup_dsets, "Dataset I/O Operations", NULL);
+ // testing dataspace functionalities in th5s.cpp
+ AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL);
+ // testing attribute functionalities in tattr.cpp
+ AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL);
+ // testing object functionalities in tobject.cpp
+ AddTest("tobject", test_object, cleanup_object, "Objects", NULL);
+ // testing reference functionalities in trefer.cpp
+ AddTest("trefer", test_reference, cleanup_reference, "References", NULL);
+ // testing variable-length strings in tvlstr.cpp
+ AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL);
+ AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL);
+ AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL);
+ AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL);
+ AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL);
+ AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL);
/* Comment out tests that are not done yet. - BMR, Feb 2001
- AddTest("select", test_select, cleanup_select, "Selections", NULL);
- AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL);
- AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL);
- AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL);
- AddTest("array", test_array, cleanup_array, "Array Datatypes", NULL);
- AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL);
- AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL);
+ AddTest("select", test_select, cleanup_select, "Selections", NULL);
+ AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL);
+ AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL);
+ AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL);
+ AddTest("array", test_array, cleanup_array, "Array Datatypes", NULL);
+ AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL);
+ AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL);
Comment out tests that are not done yet */
/* Tentative - BMR 2007/1/12
- AddTest("datatypes", test_dtypes, cleanup_dtypes, "Data Types", NULL);
- AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL);
+ AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL);
*/
+ }
+ catch (Exception E)
+ {
+ issue_fail_msg("Tests failed", __LINE__, __FILE__, E.getCDetailMsg());
+ }
+
/* Display testing information */
TestInfo(argv[0]);
diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp
index 965065a..1f53e61 100644
--- a/c++/test/tfile.cpp
+++ b/c++/test/tfile.cpp
@@ -654,4 +654,5 @@ void cleanup_file()
HDremove(FILE2.c_str());
HDremove(FILE3.c_str());
HDremove(FILE4.c_str());
+ HDremove(FILE5.c_str());
} // cleanup_file
diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp
index 257e4be..854c7bb 100644
--- a/c++/test/tfilter.cpp
+++ b/c++/test/tfilter.cpp
@@ -165,7 +165,7 @@ static void test_null_filter()
const H5std_string DSET_SZIP_NAME("szipped dataset");
-void test_szip_filter(H5File& file1)
+static void test_szip_filter(H5File& file1)
{
#ifdef H5_HAVE_FILTER_SZIP
int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2];
diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp
new file mode 100644
index 0000000..b86d7cb
--- /dev/null
+++ b/c++/test/tobject.cpp
@@ -0,0 +1,335 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*****************************************************************************
+ FILE
+ tobject.cpp - HDF5 C++ testing object related functionality
+
+ ***************************************************************************/
+
+#ifdef OLD_HEADER_FILENAME
+#include <iostream.h>
+#else
+#include <iostream>
+#endif
+#include <string>
+
+#ifndef H5_NO_NAMESPACE
+#ifndef H5_NO_STD
+ using std::cerr;
+ using std::endl;
+#endif // H5_NO_STD
+#endif
+
+#include "H5Cpp.h" // C++ API header file
+
+#ifndef H5_NO_NAMESPACE
+ using namespace H5;
+#endif
+
+#include "h5cpputil.h" // C++ utilility header file
+
+const H5std_string FILE_OBJECTS("tobjects.h5");
+const H5std_string GROUP1("Top Group");
+const H5std_string GROUP1_PATH("/Top Group");
+const H5std_string GROUP1_1("Sub-Group 1.1");
+const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1");
+const H5std_string GROUP1_2("Sub-Group 1.2");
+const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2");
+const H5std_string DSET_DEFAULT_NAME("default");
+const H5std_string DSET_IN_FILE("Dataset in File");
+const H5std_string DSET_IN_FILE_PATH("/Dataset in File");
+const H5std_string DSET_IN_GRP1("Dataset in Group 1");
+const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1");
+const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2");
+const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2");
+
+/*-------------------------------------------------------------------------
+ * Function: test_get_objname
+ *
+ * Purpose: Tests getting object name of groups and datasets.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Binh-Minh Ribler
+ * Friday, March 4, 2014
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void test_get_objname()
+{
+ SUBTEST("H5Object::getObjName on Groups and Datasets");
+
+ try {
+ // Create file
+ H5File file(FILE_OBJECTS, H5F_ACC_TRUNC);
+
+ // Create a top group and 2 subgroups
+ Group grp1 = file.createGroup(GROUP1, 0);
+ Group grp1_1 = grp1.createGroup(GROUP1_1, 0);
+ Group grp1_2 = grp1.createGroup(GROUP1_2, 0);
+
+ // Get part of the group's name, random length using
+ // ssize_t getObjName(char* comment, size_t buf_size)
+
+ // Get the length of the group's name first
+ ssize_t name_len = grp1.getObjName(NULL);
+
+ // Random length is 4
+ if (name_len > 4)
+ {
+ char* grp1_name = new char[5];
+ name_len = grp1.getObjName(grp1_name, 5);
+ verify_val((const char*)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__);
+ delete []grp1_name;
+ }
+
+ // Create a data space
+ hsize_t dims[2];
+ dims[0] = 2;
+ dims[1] = 5;
+ DataSpace space (2, dims, NULL);
+
+ // Create a dataset in the file
+ DataSet dsinfile = file.createDataSet(DSET_IN_FILE,
+ PredType::NATIVE_DOUBLE, space);
+
+ // Create a dataset in the group
+ DataSet dsingrp = grp1.createDataSet(DSET_IN_GRP1,
+ PredType::NATIVE_INT, space);
+
+ // Get and verify the name of each dataset, using
+ // H5std_string getObjName() and
+ // ssize_t getObjName(H5std_string& obj_name, size_t len = 0)
+ H5std_string ds_name = dsinfile.getObjName();
+ verify_val(ds_name, DSET_IN_FILE_PATH, "DataSet::getObjName", __LINE__, __FILE__);
+
+ name_len = dsingrp.getObjName(ds_name); // default len
+ verify_val(ds_name, DSET_IN_GRP1_PATH, "DataSet::getObjName", __LINE__, __FILE__);
+
+ // Close dataset
+ dsingrp.close();
+
+ // Create a dataset in sub-group 1.2
+ dsingrp = grp1_2.createDataSet(DSET_IN_GRP1_2, PredType::NATIVE_INT, space);
+
+ // Get and verify the name of the dataset that belongs to subgroup
+ // 1.2, using H5std_string getObjName()
+ ds_name = dsingrp.getObjName();
+ verify_val(ds_name, DSET_IN_GRP1_2_PATH, "DataSet::getObjName", __LINE__, __FILE__);
+
+ // Close dataset
+ dsingrp.close();
+
+ // Reopen that same dataset then check the name again with another
+ // overload: ssize_t getObjName(H5std_string& obj_name, size_t len = 0)
+ dsingrp = grp1_2.openDataSet(DSET_IN_GRP1_2);
+ name_len = dsingrp.getObjName(ds_name);
+ verify_val(ds_name, DSET_IN_GRP1_2_PATH, "DataSet::getObjName", __LINE__, __FILE__);
+
+ // Everything will be closed as they go out of scope
+
+ PASSED();
+ } // try block
+
+ // catch all other exceptions
+ catch (Exception E)
+ {
+ issue_fail_msg("test_get_objname", __LINE__, __FILE__);
+ }
+} // test_get_objname
+
+/*-------------------------------------------------------------------------
+ * Function: test_get_objname_ontypes
+ *
+ * Purpose: Test getting object name from various committed types.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Binh-Minh Ribler
+ * March 4, 2014
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void test_get_objname_ontypes()
+{
+ SUBTEST("H5Object::getObjName on Committed Datatypes");
+
+ try {
+ // Create a file with default prop lists
+ H5File file(FILE_OBJECTS, H5F_ACC_RDWR);
+
+ // Create a group
+ Group grp = file.createGroup ("typetests");
+
+ // Create a datatype and save it
+ DataType dtype(PredType::STD_B8LE);
+ dtype.commit(file, "STD_B8LE");
+
+ // Get and verify its name
+ H5std_string type_name = dtype.getObjName();
+ verify_val(type_name, "/STD_B8LE", "DataSet::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__);
+
+ // Test copying an integer predefined type
+ IntType new_int_type(PredType::NATIVE_INT);
+
+ // 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__);
+
+ // 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
+
+ catch (Exception E)
+ {
+ issue_fail_msg("test_get_objname_ontypes", __LINE__, __FILE__);
+ }
+} // test_get_objname_ontypes
+
+/*-------------------------------------------------------------------------
+ * Function: test_get_objtype
+ *
+ * Purpose: Tests getting object type
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Binh-Minh Ribler
+ * Friday, March 4, 2014
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void test_get_objtype()
+{
+ SUBTEST("H5File::childObjType and H5Group::childObjType");
+
+ try {
+ // Open file
+ H5File file(FILE_OBJECTS, H5F_ACC_RDWR);
+
+ // Open the top group
+ Group grp1 = file.openGroup(GROUP1);
+
+ // Create a datatype and save it
+ DataType dtype(PredType::STD_I32LE);
+ dtype.commit(grp1, "STD_I32LE");
+
+ // Get and verify object type with
+ // H5O_type_t childObjType(const H5std_string& objname)
+ H5O_type_t objtype = file.childObjType(DSET_IN_FILE);
+ verify_val(objtype, H5O_TYPE_DATASET, "DataSet::childObjType", __LINE__, __FILE__);
+
+ // Get and verify object type with
+ // H5O_type_t childObjType(const char* objname)
+ objtype = grp1.childObjType(GROUP1_1.c_str());
+ verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__);
+
+ // Get and verify object type with
+ // H5O_type_t childObjType(hsize_t index, H5_index_t index_type,
+ // H5_iter_order_t order, const char* objname=".")
+ objtype = grp1.childObjType((hsize_t)1, H5_INDEX_NAME, H5_ITER_INC);
+ verify_val(objtype, H5O_TYPE_NAMED_DATATYPE, "DataSet::childObjType", __LINE__, __FILE__);
+
+ // Get and verify object type with
+ // H5O_type_t childObjType(hsize_t index,
+ // H5_index_t index_type=H5_INDEX_NAME,
+ // H5_iter_order_t order=H5_ITER_INC, const char* objname=".")
+ objtype = grp1.childObjType((hsize_t)2);
+ verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__);
+
+ // Everything will be closed as they go out of scope
+
+ PASSED();
+ } // try block
+
+ // catch all other exceptions
+ catch (Exception E)
+ {
+ issue_fail_msg("test_get_objtype", __LINE__, __FILE__);
+ }
+} // test_get_objtype
+
+/*-------------------------------------------------------------------------
+ * Function: test_objects
+ *
+ * Purpose: Tests HDF5 object related functionality
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Binh-Minh Ribler
+ * Friday, Mar 4, 2014
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifdef __cplusplus
+extern "C"
+#endif
+void test_object()
+{
+ // Output message about test being performed
+ MESSAGE(5, ("Testing Object Functions\n"));
+
+ test_get_objname(); // Test get object name from groups/datasets
+ test_get_objname_ontypes(); // Test get object name from types
+ test_get_objtype(); // Test get object type
+
+} // test_objects
+
+/*-------------------------------------------------------------------------
+ * Function: cleanup_objects
+ *
+ * Purpose: Cleanup temporary test files
+ *
+ * Return: none
+ *
+ * Programmer: (use C version)
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifdef __cplusplus
+extern "C"
+#endif
+void cleanup_object()
+{
+ HDremove(FILE_OBJECTS.c_str());
+} // cleanup_objects
diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp
index e7a28de..dcfb644 100644
--- a/c++/test/trefer.cpp
+++ b/c++/test/trefer.cpp
@@ -321,6 +321,10 @@ static void test_reference_obj(void)
H5std_string read_comment1 = group.getComment(".", 10);
verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__);
+ // Test with the old default value
+ read_comment1 = group.getComment(".", 256);
+ verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__);
+
// Test that getComment handles failures gracefully, using
// H5std_string getComment(const char* name, <buf_size=0 by default>)
try {
diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp
index 933181c..e9e1427 100644
--- a/c++/test/ttypes.cpp
+++ b/c++/test/ttypes.cpp
@@ -414,6 +414,23 @@ static void test_named ()
IntType itype(PredType::NATIVE_INT);
itype.commit(file, "native-int");
+ // Test commit passing in const H5File& for prototype with const
+ try
+ {
+ // Create random char type
+ IntType atype(PredType::NATIVE_UCHAR);
+
+ // Creating group, declared as const
+ const Group const_grp = file.createGroup("GR as loc");
+
+ // Commit type passing in const group; compilation would fail if
+ // no matching prototype
+ atype.commit(const_grp, "random uchar");
+ } // end of try block
+ catch (Exception E) {
+ issue_fail_msg("test_named", __LINE__, __FILE__, "Commit at const group");
+ }
+
// Check that it is committed.
if (itype.committed() == false)
cerr << "IntType::committed() returned false" << endl;
diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp
index 89f24f2..a2669db 100644
--- a/c++/test/tvlstr.cpp
+++ b/c++/test/tvlstr.cpp
@@ -50,10 +50,6 @@ const H5std_string FILENAME("tvlstr.h5");
const int SPACE1_RANK = 1;
const hsize_t SPACE1_DIM1 = 4;
-// Utility functions - not used now, later though.
-void *test_vlstr_alloc_custom(size_t size, void *info);
-void test_vlstr_free_custom(void *mem, void *info);
-
/****************************************************************
**
** test_vlstr_alloc_custom(): Test VL datatype custom memory
@@ -62,9 +58,9 @@ void test_vlstr_free_custom(void *mem, void *info);
** allocated. It is passed into setVlenMemManager.
**
** Note: exact copy from the C version.
-**
+** (Not used now)
****************************************************************/
-void *test_vlstr_alloc_custom(size_t size, void *info)
+static void *test_vlstr_alloc_custom(size_t size, void *info)
{
void *ret_value=NULL; // Pointer to return
size_t *mem_used=(size_t *)info; // Get the pointer to the memory used
@@ -94,9 +90,9 @@ void *test_vlstr_alloc_custom(size_t size, void *info)
** allocated. It is passed into setVlenMemManager.
**
** Note: exact copy from the C version.
-**
+** (Not used now)
****************************************************************/
-void test_vlstr_free_custom(void *_mem, void *info)
+static void test_vlstr_free_custom(void *_mem, void *info)
{
unsigned char *mem;
size_t *mem_used=(size_t *)info; // Get the pointer to the memory used