diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-03-27 05:09:59 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-03-27 05:09:59 (GMT) |
commit | 764128aaf245f915e85929858b2808591b606bdf (patch) | |
tree | bfc9220aa154127366a454dadf01f4394581a4b6 /c++/test/tcompound.cpp | |
parent | d9020f2e35342605b26b6260e05cc4a2cef2327b (diff) | |
download | hdf5-764128aaf245f915e85929858b2808591b606bdf.zip hdf5-764128aaf245f915e85929858b2808591b606bdf.tar.gz hdf5-764128aaf245f915e85929858b2808591b606bdf.tar.bz2 |
[svn-r24913] Purpose: Fix HDFFV-8642
Description:
Added CompType::setSize(size_t size) to set size for compound data type
as H5Tset_size had been changed.
Merged from trunk-24912
Platforms tested:
Linux/ppc64 (ostrich)
Linux/32 2.6 (jam)
SunOS 5.11 (emu)
Diffstat (limited to 'c++/test/tcompound.cpp')
-rw-r--r-- | c++/test/tcompound.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index fbb1219..14bcd42 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -727,7 +727,96 @@ cerr << "test_compound_7 in catch" << endl; issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } } // test_compound_7() + +/*------------------------------------------------------------------------- + * Function: test_compound_set_size + * + * Purpose: Tests member function setSize() on compound datatype + * + * Return: None + * + * Programmer: Binh-Minh Ribler (use partial C version test_ooo_order) + * March, 2014 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +#define 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"); + try { + // Create File + H5File file(COMPFILE, H5F_ACC_TRUNC); + + // Create a compound datatype + CompType dtype(sizeof(src_typ_t)); + dtype.insertMember("a", HOFFSET(src_typ_t, a), PredType::NATIVE_INT); + dtype.insertMember("b", HOFFSET(src_typ_t, b), PredType::NATIVE_FLOAT); + dtype.insertMember("c", HOFFSET(src_typ_t, c), PredType::NATIVE_LONG); + dtype.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_DOUBLE); + + // Verify that the compound is not packed + // bool packed = dtype.packed(); // not until C library provides API + // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); + + dtype.commit(file, "dtype"); + + // Close the type and file + dtype.close(); + file.close(); + + // Open the file for read/write + file.openFile(COMPFILE, H5F_ACC_RDWR); + + // Open the data type "dtype" + CompType dtype_tmp = file.openCompType("dtype"); + + // Make a copy of the data type + dtype = dtype_tmp; + + // Verify that the compound is not packed + // packed = dtype_tmp.packed(); // not until C library provides API + // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); + + // Expand the type, and verify that it became unpacked + dtype.setSize((size_t)33); + // packed = dtype.packed(); // not until C library provides API + // verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__); + + // Verify setSize() actually set size + size_t new_size = dtype.getSize(); + verify_val(new_size, 33, "DataType::getSize", __LINE__, __FILE__); + + // Shrink the type, and verify that it became packed + dtype.setSize((size_t)32); + // packed = dtype.packed(); // not until C library provides API + // verify_val(packed, TRUE, "DataType::packed", __LINE__, __FILE__); + + // Verify setSize() actually set size again + new_size = dtype.getSize(); + verify_val(new_size, 32, "DataType::getSize", __LINE__, __FILE__); + + /* Close types and file */ + dtype_tmp.close(); + dtype.close(); + file.close(); + + PASSED(); + } // end of try block + + catch (Exception E) { + issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); + } +} // test_compound_set_size() /*------------------------------------------------------------------------- * Function: test_compound @@ -759,6 +848,7 @@ void test_compound() test_compound_5(); // optimized struct converter test_compound_6(); // compound element growing test_compound_7(); // compound element insertion + test_compound_set_size(); // set size on compound data types } // test_compound() |