summaryrefslogtreecommitdiffstats
path: root/c++/test/dsets.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2001-03-25 04:54:15 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2001-03-25 04:54:15 (GMT)
commit6f26403376abe8bc48285fd25f6fbee6f24e8172 (patch)
tree0e7313c54395e205d512e861f197cf589b46b93d /c++/test/dsets.cpp
parentba6cba5d30f35b2b75e36477041f8c82df68ea30 (diff)
downloadhdf5-6f26403376abe8bc48285fd25f6fbee6f24e8172.zip
hdf5-6f26403376abe8bc48285fd25f6fbee6f24e8172.tar.gz
hdf5-6f26403376abe8bc48285fd25f6fbee6f24e8172.tar.bz2
[svn-r3708] Purpose: Code cleanup and adding more test
Description: dsets.cpp: - Added routine's headers to be consistent with the C tests - Added the following tests (they are not in the C version test because they are C++ specific): + Test copying a user-defined type using DataType::copy + Test copying a user-defined type using DataType::operator= + Test copying a user-defined int type using DataType::operator= + Test copying an integer predefined type using a constructor + Test copying an integer predefined type using DataType::operator= th5s.cpp: - Added routine's headers to be consistent with the C tests - Cleanup old couts and statements used during debugging Platforms tested: arabica (sparc-sun-solaris 2.7)
Diffstat (limited to 'c++/test/dsets.cpp')
-rw-r--r--c++/test/dsets.cpp80
1 files changed, 69 insertions, 11 deletions
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp
index d22cc77..c48cd7e 100644
--- a/c++/test/dsets.cpp
+++ b/c++/test/dsets.cpp
@@ -798,8 +798,29 @@ test_types(H5File& file)
unsigned char buf[32];
hsize_t nelmts = sizeof(buf);
DataType type;
- try { // block 1
+ try { // block of bitfield_1
+ // test copying a predefined type
type.copy (PredType::STD_B8LE);
+
+ // Test copying a user-defined type using DataType::copy
+ DataType copied_type;
+ copied_type.copy(type);
+ // Test copying a user-defined type using DataType::operator=
+ DataType another_copied_type;
+ another_copied_type = type;
+
+ // Test copying a user-defined int type using DataType::operator=
+ IntType orig_int(PredType::STD_B8LE);
+ DataType generic_type;
+ generic_type = orig_int;
+
+ // Test copying an integer predefined type
+ IntType new_int_type(PredType::STD_B8LE);
+
+ // Test copying an int predefined type using DataType::operator=
+ IntType another_int_type;
+ another_int_type = new_int_type;
+
DataSpace space (1, &nelmts);
DataSet* dset = new DataSet(grp.createDataSet("bitfield_1", type, space));
@@ -820,12 +841,15 @@ test_types(H5File& file)
} // end try block of bitfield_1
// catch exceptions thrown in try block of bitfield_1
- catch (Exception E) { goto error; }
+ catch (Exception E) {
+ cout << "Failure in " << E.getFuncName() << " - "
+ << E.getDetailMsg() << endl;
+ goto error;
+ }
/* bitfield_2 */
nelmts = sizeof(buf)/2;
try { // bitfield_2 block
-
type.copy (PredType::STD_B16LE);
DataSpace space (1, &nelmts);
DataSet* dset = new DataSet(grp.createDataSet("bitfield_2", type, space));
@@ -839,6 +863,8 @@ test_types(H5File& file)
try { dset->write (buf, type); }
catch(DataSetIException E)
{
+ cout << "Failure in " << E.getFuncName() << " - "
+ << E.getDetailMsg() << endl;
delete dset;
goto error;
}
@@ -846,7 +872,11 @@ test_types(H5File& file)
} // end try block of bitfield_2
// catch exceptions thrown in try block of bitfield_2
- catch (Exception E) { goto error; }
+ catch (Exception E) {
+ cout << "Failure in " << E.getFuncName() << " - "
+ << E.getDetailMsg() << endl;
+ goto error;
+ }
/* opaque_1 */
DataType* optype = new DataType(H5T_OPAQUE, 1);
@@ -873,8 +903,17 @@ test_types(H5File& file)
} // end try block of opaque_1
// catch exceptions thrown in try block of opaque_1
- catch (DataSetIException E) { delete optype; goto error; }
- catch (Exception E) { goto error; }
+ catch (DataSetIException E) {
+ delete optype;
+ cout << "Failure in " << E.getFuncName() << " - "
+ << E.getDetailMsg() << endl;
+ goto error;
+ }
+ catch (Exception E) {
+ cout << "Failure in " << E.getFuncName() << " - "
+ << E.getDetailMsg() << endl;
+ goto error;
+ }
/* opaque_2 */
try { // block opaque_2
@@ -899,13 +938,27 @@ test_types(H5File& file)
delete dset;
delete optype;
} //end try block of opaque_2
- catch (DataSetIException E) { delete optype; goto error; }
- catch (Exception E) { goto error; }
+ catch (DataSetIException E) {
+ delete optype;
+ cout << "Failure in " << E.getFuncName() << " - "
+ << E.getDetailMsg() << endl;
+ goto error;
+ }
+ catch (Exception E) {
+ cout << "Failure in " << E.getFuncName() << " - "
+ << E.getDetailMsg() << endl;
+ goto error;
+ }
PASSED();
return 0;
} // end top try block
- catch (Exception E) { goto error; } // Group and DataType exceptions
+
+ catch (Exception E) { // Group and DataType exceptions
+ cout << "Failure in " << E.getFuncName() << " - "
+ << E.getDetailMsg() << endl;
+ goto error;
+ }
error:
return -1;
@@ -966,15 +1019,20 @@ int test_report( int nerrors )
*
*-------------------------------------------------------------------------
*/
+static hid_t tempid = H5T_STD_B8LE;
+// the following statement caused seg. fault, need to check into - BMR
+//static PredType temp = PredType::STD_B8LE;
+// because PredType::STD_B8LE was not defined yet, so ref_counter is nil
+// and it'll fail when the ref_counter is being incremented
+// this can be a problem; must check ref_counter before increment or decrement
+
int
main(void)
{
-
h5_reset(); // in h5test.c, resets the library by closing it
hid_t fapl_id;
fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template
- // should create an object from this id - BMR
#if 0
/* BMR: leave paralell stuff out! */