summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2016-04-22 15:26:39 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2016-04-22 15:26:39 (GMT)
commit5aea4260b5537793352e6c78a7737d700159f16f (patch)
treec0dcba82daf483fdec33d0e5c15f628c5f1effa8 /c++
parent5d4e4ed0cbb5c4eab3076e5f61813facaf72f82d (diff)
downloadhdf5-5aea4260b5537793352e6c78a7737d700159f16f.zip
hdf5-5aea4260b5537793352e6c78a7737d700159f16f.tar.gz
hdf5-5aea4260b5537793352e6c78a7737d700159f16f.tar.bz2
[svn-r29761] Purpose: Add function
Description: Added member function ArrayType::operator= because ArrayType has pointer data members. Merged from trunk r29306. Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test)
Diffstat (limited to 'c++')
-rw-r--r--c++/src/H5AbstractDs.cpp2
-rw-r--r--c++/src/H5AbstractDs.h2
-rw-r--r--c++/src/H5ArrayType.cpp38
-rw-r--r--c++/src/H5ArrayType.h3
-rw-r--r--c++/src/H5Attribute.cpp6
-rw-r--r--c++/src/H5CommonFG.cpp2
-rw-r--r--c++/src/H5DataSet.cpp6
-rw-r--r--c++/src/H5DataSpace.cpp6
-rw-r--r--c++/src/H5DataType.cpp6
-rw-r--r--c++/src/H5Exception.cpp6
-rw-r--r--c++/src/H5Group.cpp6
-rw-r--r--c++/src/H5Location.cpp2
-rw-r--r--c++/src/H5PropList.cpp3
-rw-r--r--c++/test/dsets.cpp28
-rw-r--r--c++/test/tarray.cpp118
15 files changed, 171 insertions, 63 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp
index 4e9a4d5..8d88c53 100644
--- a/c++/src/H5AbstractDs.cpp
+++ b/c++/src/H5AbstractDs.cpp
@@ -49,7 +49,7 @@ AbstractDs::AbstractDs(){}
// removal does not raise any problems in 1.10, it will be removed from 1.8 in
// subsequent releases.
//--------------------------------------------------------------------------
-AbstractDs::AbstractDs(const hid_t ds_id){}
+// Mar 2016 -BMR, AbstractDs::AbstractDs(const hid_t ds_id){}
//--------------------------------------------------------------------------
// Function: AbstractDs::getTypeClass
diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h
index ee2e45e..6975d6f 100644
--- a/c++/src/H5AbstractDs.h
+++ b/c++/src/H5AbstractDs.h
@@ -85,7 +85,7 @@ class H5_DLLCPP AbstractDs {
// other will be removed from 1.10 release, and then from 1.8 if its
// removal does not raise any problems in two 1.10 releases.
- AbstractDs(const hid_t h5_id);
+ // Mar 2016 -BMR, AbstractDs(const hid_t h5_id);
// Copy constructor
// AbstractDs( const AbstractDs& original );
diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp
index 0f09631..5792467 100644
--- a/c++/src/H5ArrayType.cpp
+++ b/c++/src/H5ArrayType.cpp
@@ -93,6 +93,44 @@ ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims)
}
//--------------------------------------------------------------------------
+// Function: ArrayType::operator=
+///\brief Assignment operator
+///\param rhs - IN: Reference to the existing array datatype
+///\return Reference to ArrayType instance
+///\exception H5::DataTypeIException
+/// std::bad_alloc
+// Description
+// Closes the id on the lhs object first with setId, then copies
+// each data member from the rhs object.
+// Programmer Binh-Minh Ribler - Mar 2016
+// Modification
+//--------------------------------------------------------------------------
+ArrayType& ArrayType::operator=(const ArrayType& rhs)
+{
+ if (this != &rhs)
+ {
+ // handling references to this id
+ try {
+ setId(rhs.id);
+ // Note: a = b, so there are two objects with the same hdf5 id
+ // that's why incRefCount is needed, and it is called by setId
+ }
+ catch (Exception close_error) {
+ throw DataTypeIException(inMemFunc("operator="), close_error.getDetailMsg());
+ }
+
+ // Copy the rank of the rhs array
+ rank = rhs.rank;
+
+ // Allocate space then copy the dimensions from the rhs array
+ dimensions = new hsize_t[rank];
+ for (int i = 0; i < rank; i++)
+ dimensions[i] = rhs.dimensions[i];
+ }
+ return(*this);
+}
+
+//--------------------------------------------------------------------------
// Function: ArrayType::setArrayInfo
///\brief Retrieves the rank and dimensions from the array datatype
/// and store the info in this ArrayType object.
diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h
index c0f4b38..ddbb5e2 100644
--- a/c++/src/H5ArrayType.h
+++ b/c++/src/H5ArrayType.h
@@ -31,6 +31,9 @@ class H5_DLLCPP ArrayType : public DataType {
// specified base type.
ArrayType(const DataType& base_type, int ndims, const hsize_t* dims);
+ // Assignment operator
+ ArrayType& operator=(const ArrayType& rhs);
+
// Stores the rank and dimensions in memory.
void setArrayInfo();
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index 6705739..7d5b421 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -60,9 +60,8 @@ Attribute::Attribute() : AbstractDs(), IdComponent(), id(H5I_INVALID_HID) {}
///\param original - IN: Original Attribute object to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Attribute::Attribute(const Attribute& original) : AbstractDs(), IdComponent()
+Attribute::Attribute(const Attribute& original) : AbstractDs(), IdComponent(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
@@ -74,9 +73,8 @@ Attribute::Attribute(const Attribute& original) : AbstractDs(), IdComponent()
///\exception H5::AttributeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Attribute::Attribute(const hid_t existing_id) : AbstractDs(), IdComponent()
+Attribute::Attribute(const hid_t existing_id) : AbstractDs(), IdComponent(), id(existing_id)
{
- id = existing_id;
incRefCount(); // increment number of references to this id
}
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index a482fc2..84d137f 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -327,7 +327,7 @@ void CommonFG::unlink( const H5std_string& name ) const
/// Exercise care in moving groups as it is possible to render
/// data in a file inaccessible with Group::move. Please refer
/// to the Group Interface in the HDF5 User's Guide for details at:
-/// http://www.hdfgroup.org/HDF5/doc/UG/UG_frame09Groups.html
+/// https://www.hdfgroup.org/HDF5/doc/UG/HDF5_Users_Guide-Responsive%20HTML5/index.html#t=HDF5_Users_Guide%2FGroups%2FHDF5_Groups.htm
// Programmer Binh-Minh Ribler - 2000
// Modification
// 2007: QAK modified to use H5L APIs - BMR
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp
index af1277a..f62c48c 100644
--- a/c++/src/H5DataSet.cpp
+++ b/c++/src/H5DataSet.cpp
@@ -67,9 +67,8 @@ DataSet::DataSet() : H5Object(), AbstractDs(), id(H5I_INVALID_HID) {}
// when one of those objects is deleted, the id will be closed if
// the reference counter is only 1.
//--------------------------------------------------------------------------
-DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs()
+DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs(), id(existing_id)
{
- id = existing_id;
incRefCount(); // increment number of references to this id
}
@@ -79,9 +78,8 @@ DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs()
///\param original - IN: DataSet instance to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs()
+DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index 311180f..42ac4c7 100644
--- a/c++/src/H5DataSpace.cpp
+++ b/c++/src/H5DataSpace.cpp
@@ -132,9 +132,8 @@ DataSpace::DataSpace( int rank, const hsize_t * dims, const hsize_t * maxdims) :
///\exception H5::DataSpaceIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSpace::DataSpace(const hid_t existing_id) : IdComponent()
+DataSpace::DataSpace(const hid_t existing_id) : IdComponent(), id(existing_id)
{
- id = existing_id;
incRefCount(); // increment number of references to this id
}
@@ -144,9 +143,8 @@ DataSpace::DataSpace(const hid_t existing_id) : IdComponent()
///\param original - IN: DataSpace object to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSpace::DataSpace(const DataSpace& original) : IdComponent()
+DataSpace::DataSpace(const DataSpace& original) : IdComponent(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index d98a0cf..cb48942 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -69,9 +69,8 @@ DataType::DataType() : H5Object(), id(H5I_INVALID_HID) {}
// Removed second argument, "predefined", after changing to the
// new ref counting mechanism that relies on C's ref counting.
//--------------------------------------------------------------------------
-DataType::DataType(const hid_t existing_id) : H5Object()
+DataType::DataType(const hid_t existing_id) : H5Object(), id(existing_id)
{
- id = existing_id;
incRefCount(); // increment number of references to this id
}
@@ -134,9 +133,8 @@ DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type)
///\brief Copy constructor: makes a copy of the original DataType object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataType::DataType(const DataType& original) : H5Object()
+DataType::DataType(const DataType& original) : H5Object(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp
index f2aa38a..e3c6a62 100644
--- a/c++/src/H5Exception.cpp
+++ b/c++/src/H5Exception.cpp
@@ -47,11 +47,7 @@ Exception::Exception(const H5std_string& func, const H5std_string& message) : de
///\param orig - IN: Exception instance to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Exception::Exception( const Exception& orig )
-{
- detail_message = orig.detail_message;
- func_name = orig.func_name;
-}
+Exception::Exception( const Exception& orig ) : detail_message(orig.detail_message), func_name(orig.func_name) {}
//--------------------------------------------------------------------------
// Function: Exception::getMajorString
diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp
index 174dd1e..d679960 100644
--- a/c++/src/H5Group.cpp
+++ b/c++/src/H5Group.cpp
@@ -60,9 +60,8 @@ Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) {}
///\param original - IN: Original group to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Group::Group(const Group& original) : H5Object(), CommonFG()
+Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
@@ -83,9 +82,8 @@ hid_t Group::getLocId() const
///\param existing_id - IN: Id of an existing group
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Group::Group(const hid_t existing_id) : H5Object(), CommonFG()
+Group::Group(const hid_t existing_id) : H5Object(), CommonFG(), id(existing_id)
{
- id = existing_id;
incRefCount(); // increment number of references to this id
}
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp
index 30a7bc5..66901f7 100644
--- a/c++/src/H5Location.cpp
+++ b/c++/src/H5Location.cpp
@@ -232,7 +232,7 @@ int H5Location::iterateAttrs( attr_operator_t user_op, unsigned *_idx, void *op_
// call the C library routine H5Aiterate2 to iterate the attributes
hsize_t idx = _idx ? (hsize_t)*_idx : 0;
int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx,
- userAttrOpWrpr, (void *) userData);
+ userAttrOpWrpr, static_cast<void *>(userData));
// release memory
delete userData;
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index 807aa0a..81bb023 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -104,9 +104,8 @@ PropList::PropList() : IdComponent(), id(H5P_DEFAULT) {}
///\param original - IN: The original property list to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-PropList::PropList(const PropList& original) : IdComponent()
+PropList::PropList(const PropList& original) : IdComponent(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp
index e57e50e..f35696a 100644
--- a/c++/test/dsets.cpp
+++ b/c++/test/dsets.cpp
@@ -246,10 +246,10 @@ test_simple_io( H5File& file)
DataSet dataset (file.createDataSet (DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space));
// Write the data to the dataset
- dataset.write ((void*) points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Read the dataset back
- dataset.read ((void*) check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < 100; i++)
@@ -395,10 +395,10 @@ test_tconv( H5File& file)
DataSet dataset (file.createDataSet (DSET_TCONV_NAME, PredType::STD_I32LE, space));
// Write the data to the dataset
- dataset.write ((void*) out, PredType::STD_I32LE);
+ dataset.write (static_cast<void*>(out), PredType::STD_I32LE);
// Read data with byte order conversion
- dataset.read ((void*) in, PredType::STD_I32BE);
+ dataset.read (static_cast<void*>(in), PredType::STD_I32BE);
// Check
for (int i = 0; i < 1000000; i++) {
@@ -539,7 +539,7 @@ test_compression(H5File& file)
*/
SUBTEST("Compression (uninitialized read)");
- dataset->read ((void*) check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
@@ -569,7 +569,7 @@ test_compression(H5File& file)
}
}
- dataset->write ((void*) points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
PASSED();
@@ -580,7 +580,7 @@ test_compression(H5File& file)
SUBTEST("Compression (read)");
// Read the dataset back
- dataset->read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < size[0]; i++)
@@ -609,10 +609,10 @@ test_compression(H5File& file)
points[i][j] = rand ();
}
}
- dataset->write ((void*)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Read the dataset back and check it
- dataset->read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < size[0]; i++)
@@ -637,7 +637,7 @@ test_compression(H5File& file)
delete dataset;
dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME));
- dataset->read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < size[0]; i++)
@@ -667,8 +667,8 @@ test_compression(H5File& file)
}
}
space1.selectHyperslab( H5S_SELECT_SET, hs_size, hs_offset );
- dataset->write ((void*)points, PredType::NATIVE_INT, space1, space1, xfer);
- dataset->read ((void*)check, PredType::NATIVE_INT, space1, space1, xfer);
+ dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, space1, space1, xfer);
+ dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, space1, space1, xfer);
// Check that the values read are the same as the values written
for (i=0; i<hs_size[0]; i++) {
@@ -714,8 +714,8 @@ test_compression(H5File& file)
DataSpace space2 (2, size, NULL);
dataset = new DataSet (file.createDataSet (DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist));
- dataset->write ((void*)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
- dataset->read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < size[0]; i++)
diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp
index 69b4438..a6cbae4 100644
--- a/c++/test/tarray.cpp
+++ b/c++/test/tarray.cpp
@@ -42,9 +42,9 @@
#include "h5cpputil.h" // C++ utilility header file
const H5std_string FILENAME("tarray.h5");
-const hsize_t SPACE1_RANK = 1;
+const int SPACE1_RANK = 1;
const hsize_t SPACE1_DIM1 = 4;
-const hsize_t ARRAY1_RANK = 1;
+const int ARRAY1_RANK = 1;
const hsize_t ARRAY1_DIM1 = 4;
typedef enum flt_t {
@@ -83,15 +83,19 @@ static void test_array_compound_array()
hsize_t sdims1[] = {SPACE1_DIM1};
hsize_t tdims1[] = {ARRAY1_DIM1};
int nmemb; // Number of compound members
- int ii, jj, kk; // counting variables
+ int ii; // counting variables
+ hsize_t idxi, idxj, idxk; // dimension indicing variables
H5T_class_t mclass; // Datatype class for field
// Initialize array data to write
- for (ii =0; ii < SPACE1_DIM1; ii++)
- for (jj = 0; jj < ARRAY1_DIM1; jj++) {
- wdata[ii][jj].i = ii * 10 + jj;
- for(kk = 0; kk < ARRAY1_DIM1; kk++)
- wdata[ii][jj].f[kk]=(float)(ii * 10.0F + jj * 2.5F + kk);
+ for (idxi =0; idxi < SPACE1_DIM1; idxi++)
+ for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) {
+ wdata[idxi][idxj].i = idxi * 10 + idxj;
+ for(idxk = 0; idxk < ARRAY1_DIM1; idxk++)
+ {
+ float temp = idxi * 10.0 + idxj * 2.5 + idxk;
+ wdata[idxi][idxj].f[idxk] = temp;
+ }
} // end for
try {
@@ -130,6 +134,7 @@ static void test_array_compound_array()
// Create a dataset
DataSet dataset = file1.createDataSet("Dataset1", arrtype, space);
+ dataset = file1.openDataSet("Dataset1");
// Write dataset to disk
dataset.write(wdata, arrtype);
@@ -153,7 +158,8 @@ static void test_array_compound_array()
// Verify that it is an array of compounds
DataType dstype = dataset.getDataType();
mclass = dstype.getClass();
- verify_val(mclass, H5T_ARRAY, "f2_type.getClass", __LINE__, __FILE__);
+ verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__);
+
dstype.close();
// Get the array datatype to check
@@ -170,7 +176,7 @@ static void test_array_compound_array()
// Check the array dimensions
for (ii =0; ii <ndims; ii++)
if (rdims1[ii]!=tdims1[ii]) {
- TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n", (int)ii, (int)rdims1[ii], (int)ii, (int)tdims1[ii]);
+ TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n", ii, rdims1[ii], ii, tdims1[ii]);
continue;
} // end if
@@ -187,7 +193,7 @@ static void test_array_compound_array()
// Check the array dimensions
for (ii = 0; ii < ndims; ii++)
if (rdims1[ii] != tdims1[ii]) {
- TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n", (int)ii, (int)rdims1[ii], (int)ii, (int)tdims1[ii]);
+ TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n", ii, rdims1[ii], ii, tdims1[ii]);
continue;
} // end if
@@ -199,7 +205,7 @@ static void test_array_compound_array()
// array datatype atype_check.
DataType base_type = atype_check.getSuper();
mclass = base_type.getClass();
- verify_val(mclass, H5T_COMPOUND, "atype_check.getClass", __LINE__, __FILE__);
+ verify_val(mclass==H5T_COMPOUND, true, "atype_check.getClass", __LINE__, __FILE__);
// Verify the compound datatype info
CompType ctype_check(base_type.getId());
@@ -219,7 +225,7 @@ static void test_array_compound_array()
// Get the 2nd field's class, this 2nd field should have an array type
mclass = f2_type.getClass();
- verify_val(mclass, H5T_ARRAY, "f2_type.getClass", __LINE__, __FILE__);
+ verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__);
f2_type.close();
// Get the 2nd field, array of floats datatype, to check
@@ -236,7 +242,7 @@ static void test_array_compound_array()
// Check the array dimensions
for (ii = 0; ii < ndims; ii++)
if (rdims1[ii] != tdims1[ii]) {
- TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n",(int)ii, (int)rdims1[ii], (int)ii, (int)tdims1[ii]);
+ TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n", ii, rdims1[ii], ii, tdims1[ii]);
continue;
} // end if
@@ -248,10 +254,10 @@ static void test_array_compound_array()
dataset.read(rdata, atype_check);
// Compare data read in
- for (ii = 0; ii < SPACE1_DIM1; ii++) {
- for (jj = 0; jj < ARRAY1_DIM1; jj++) {
- if (wdata[ii][jj].i != rdata[ii][jj].i) {
- TestErrPrintf("Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n",(int)ii,(int)jj,(int)wdata[ii][jj].i,(int)ii,(int)jj,(int)rdata[ii][jj].i);
+ for (idxi = 0; idxi < SPACE1_DIM1; idxi++) {
+ for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) {
+ if (wdata[idxi][idxj].i != rdata[idxi][idxj].i) {
+ TestErrPrintf("Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n",idxi,idxj,wdata[idxi][idxj].i,idxi,idxj,rdata[idxi][idxj].i);
continue;
} // end if
} // end for
@@ -270,6 +276,79 @@ static void test_array_compound_array()
} // end test_array_compound_array()
+/*-------------------------------------------------------------------------
+ * Function: test_array_assignment
+ *
+ * Purpose: Tests the operator=
+ *
+ * Return: None.
+ *
+ * Programmer: Binh-Minh Ribler (using C version)
+ * March, 2016
+ *
+ * Description:
+ * Used user's sample code in HDFFV-9562
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+/*
+ * Helper routine to demonstrate the issue in HDFFV-9562
+ */
+H5::DataType getArr()
+{
+ hsize_t *dims = new hsize_t;
+ *dims = 5;
+ H5::ArrayType ret;
+ ret = H5::ArrayType(H5::PredType::NATIVE_INT, 1, dims);
+ delete[] dims;
+ return ret; }
+
+static void test_array_assignment()
+{
+ hsize_t sdims1[] = {SPACE1_DIM1};
+ SUBTEST("ArrayType::operator=");
+
+ try {
+ // Create File
+ H5File file1(FILENAME, H5F_ACC_TRUNC);
+
+ // Create dataspace for datasets
+ DataSpace space(SPACE1_RANK, sdims1, NULL);
+
+ /*
+ * Create an array datatype of compounds, arrtype. Each compound
+ * datatype, comptype, contains an integer and an array of floats,
+ * arrfltype.
+ */
+
+ // Create a compound datatype
+ CompType comptype(static_cast<size_t>(24));
+
+ // Insert integer field
+ comptype.insertMember("i", 0, PredType::NATIVE_INT);
+
+ // Insert float array field
+ comptype.insertMember("a", 4, getArr());
+
+ // Create a dataset
+ DataSet dataset = file1.createDataSet("Dataset1", comptype, space);
+
+ // Close all
+ dataset.close();
+ comptype.close();
+ space.close();
+ file1.close();
+
+ PASSED();
+ } // end of try block
+ catch (Exception E) {
+ issue_fail_msg("test_array_assignment", __LINE__, __FILE__, E.getCDetailMsg());
+ }
+} // end test_array_assignment()
+
+
/****************************************************************
**
** test_array(): Main datatypes testing routine.
@@ -286,6 +365,9 @@ void test_array()
// Test array of compounds with array field
test_array_compound_array();
+ // Test operator= (HDFFV-9562)
+ test_array_assignment();
+
} // test_array()