summaryrefslogtreecommitdiffstats
path: root/c++/test
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2014-04-17 23:25:01 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2014-04-17 23:25:01 (GMT)
commita75e8dd654268ba1dd35abf3a78da2f115802029 (patch)
tree55ce2f23d860187f021d11c3611fa43c314eff6b /c++/test
parentca6e13d3dff9c188d80cb84876cf3ccfeb6b6203 (diff)
downloadhdf5-a75e8dd654268ba1dd35abf3a78da2f115802029.zip
hdf5-a75e8dd654268ba1dd35abf3a78da2f115802029.tar.gz
hdf5-a75e8dd654268ba1dd35abf3a78da2f115802029.tar.bz2
[svn-r25061] Description:
Put back overloaded functions for backward compatibility: - were replaced by better prototyped versions, such as Attribute::getName. - were modified to add const to constant arguments. Added notes for future removal in documentation. Platforms tested: Linux/ppc64 (ostrich) Linux/32 2.6 (jam) SunOS 5.11 (emu)
Diffstat (limited to 'c++/test')
-rw-r--r--c++/test/tattr.cpp36
-rw-r--r--c++/test/ttypes.cpp17
2 files changed, 41 insertions, 12 deletions
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp
index 9abdd83..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
**
****************************************************************/
@@ -324,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()
@@ -331,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
@@ -345,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);
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;