diff options
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/tattr.cpp | 36 | ||||
-rw-r--r-- | c++/test/ttypes.cpp | 17 |
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; |