diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-04-22 11:22:34 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-04-22 11:22:34 (GMT) |
commit | c37607eb58994041cbeaabdab5f1e9902794a3e9 (patch) | |
tree | b96792d17d5bce03ad862b556f137a7b06c1449d /c++/test | |
parent | c63f96d6e78cfe98de8001b662ec685467fd65df (diff) | |
download | hdf5-c37607eb58994041cbeaabdab5f1e9902794a3e9.zip hdf5-c37607eb58994041cbeaabdab5f1e9902794a3e9.tar.gz hdf5-c37607eb58994041cbeaabdab5f1e9902794a3e9.tar.bz2 |
[svn-r29759] Purpose: Code improvements
Description:
- Changed object in catch statements to reference
- Replaced old-style casts or reinterpret_cast with static_cast
- Removed unused name H5Library::need_cleanup
- Removed Exception::printError from documentation
Platforms tested:
Linux/32 2.6 (jam)
Linux/64 (platypus)
Darwin (osx1010test)
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/dsets.cpp | 62 | ||||
-rw-r--r-- | c++/test/h5cpputil.cpp | 20 | ||||
-rw-r--r-- | c++/test/tarray.cpp | 6 | ||||
-rw-r--r-- | c++/test/tattr.cpp | 79 | ||||
-rw-r--r-- | c++/test/tcompound.cpp | 33 | ||||
-rw-r--r-- | c++/test/tdspl.cpp | 3 | ||||
-rw-r--r-- | c++/test/testhdf5.cpp | 2 | ||||
-rw-r--r-- | c++/test/tfile.cpp | 19 | ||||
-rw-r--r-- | c++/test/tfilter.cpp | 6 | ||||
-rw-r--r-- | c++/test/th5s.cpp | 14 | ||||
-rw-r--r-- | c++/test/tlinks.cpp | 6 | ||||
-rw-r--r-- | c++/test/tobject.cpp | 6 | ||||
-rw-r--r-- | c++/test/trefer.cpp | 24 | ||||
-rw-r--r-- | c++/test/ttypes.cpp | 28 | ||||
-rw-r--r-- | c++/test/tvlstr.cpp | 31 |
15 files changed, 192 insertions, 147 deletions
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 60e875c..6c27895 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -116,7 +116,7 @@ test_create( H5File& file) // continuation here, that means no exception has been thrown throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); } - catch (FileIException E) // catching invalid creating dataset + catch (FileIException& E) // catching invalid creating dataset {} // do nothing, exception expected // Open the dataset we created above and then close it. This is one @@ -148,7 +148,7 @@ test_create( H5File& file) // continuation here, that means no exception has been thrown throw InvalidActionException("H5File::openDataSet", "Attempted to open a non-existent dataset"); } - catch (FileIException E ) // catching creating non-existent dataset + catch (FileIException& E ) // catching creating non-existent dataset {} // do nothing, exception expected // Create a new dataset that uses chunked storage instead of the default @@ -170,7 +170,7 @@ test_create( H5File& file) return 0; } // outer most try block - catch (InvalidActionException E) + catch (InvalidActionException& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -181,7 +181,7 @@ test_create( H5File& file) return -1; } // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_create", __LINE__, __FILE__); @@ -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(reinterpret_cast<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 (reinterpret_cast<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++) @@ -267,7 +267,7 @@ test_simple_io( H5File& file) } // end try // catch all dataset, space, plist exceptions - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -339,7 +339,7 @@ test_datasize(FileAccPropList &fapl) } // end try // catch all dataset, space, plist exceptions - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -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 (reinterpret_cast<void*>(out), PredType::STD_I32LE); + dataset.write (static_cast<void*>(out), PredType::STD_I32LE); // Read data with byte order conversion - dataset.read (reinterpret_cast<void*>(in), PredType::STD_I32BE); + dataset.read (static_cast<void*>(in), PredType::STD_I32BE); // Check for (int i = 0; i < 1000000; i++) { @@ -419,7 +419,7 @@ test_tconv( H5File& file) } // end try // catch all dataset and space exceptions - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -504,6 +504,7 @@ test_compression(H5File& file) points[i][j] = static_cast<int>(n++); } } + char* tconv_buf = new char [1000]; DataSet* dataset = NULL; try @@ -539,7 +540,7 @@ test_compression(H5File& file) */ SUBTEST("Compression (uninitialized read)"); - dataset->read (reinterpret_cast<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 +570,7 @@ test_compression(H5File& file) } } - dataset->write (reinterpret_cast<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 +581,7 @@ test_compression(H5File& file) SUBTEST("Compression (read)"); // Read the dataset back - dataset->read (reinterpret_cast<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 +610,10 @@ test_compression(H5File& file) points[i][j] = rand (); } } - dataset->write (reinterpret_cast<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 (reinterpret_cast<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 +638,7 @@ test_compression(H5File& file) delete dataset; dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME)); - dataset->read (reinterpret_cast<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 +668,8 @@ test_compression(H5File& file) } } space1.selectHyperslab( H5S_SELECT_SET, hs_size, hs_offset ); - dataset->write (reinterpret_cast<void*>(points), PredType::NATIVE_INT, space1, space1, xfer); - dataset->read (reinterpret_cast<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 +715,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 (reinterpret_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - dataset->read (reinterpret_cast<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++) @@ -738,7 +739,7 @@ test_compression(H5File& file) } // end try // catch all dataset, file, space, and plist exceptions - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -824,7 +825,7 @@ test_multiopen (H5File& file) } // end try block // catch all dataset, file, space, and plist exceptions - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -907,7 +908,7 @@ test_types(H5File& file) } // end try block of bitfield_1 // catch exceptions thrown in try block of bitfield_1 - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << "bitfield_1: " << E.getFuncName() @@ -939,7 +940,8 @@ test_types(H5File& file) } // end try block of bitfield_2 // catch exceptions thrown in try block of bitfield_2 - catch (Exception E) { + catch (Exception& E) + { cerr << " FAILED" << endl; cerr << " <<< " << "bitfield_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl << endl; @@ -971,7 +973,8 @@ test_types(H5File& file) } // end try block of opaque_1 // catch exceptions thrown in try block of opaque_1 - catch (Exception E) { + catch (Exception& E) + { cerr << " FAILED" << endl; cerr << " <<< " << "opaque_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl << endl; @@ -1004,7 +1007,8 @@ test_types(H5File& file) } //end try block of opaque_2 // catch exceptions thrown in try block of opaque_2 - catch (Exception E) { + catch (Exception& E) + { cerr << " FAILED" << endl; cerr << " <<< " << "opaque_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl << endl; @@ -1019,7 +1023,7 @@ test_types(H5File& file) return 0; } // end top try block - catch (Exception E) + catch (Exception& E) { return -1; } @@ -1084,7 +1088,7 @@ void test_dset() nerrors += test_datasize(fapl) <0 ? 1:0; } - catch (Exception E) + catch (Exception& E) { test_report(nerrors, H5std_string(" Dataset")); } diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp index 9bbb183..05a4d9a 100644 --- a/c++/test/h5cpputil.cpp +++ b/c++/test/h5cpputil.cpp @@ -98,7 +98,7 @@ int test_report( int nerrors, const H5std_string& testname ) void issue_fail_msg(const char* where, int line, const char* file_name, const char* message) { - //if (GetTestVerbosity()>=VERBO_HI) + if (GetTestVerbosity()>=VERBO_HI) { cerr << endl; cerr << ">>> FAILED in " << where << " at line " << line @@ -121,7 +121,7 @@ void issue_fail_msg(const char* where, int line, const char* file_name, void issue_fail_msg(const char* where, int line, const char* file_name, const char* func_name, const char* message) { - //if (GetTestVerbosity()>=VERBO_HI) + if (GetTestVerbosity()>=VERBO_HI) { cerr << endl; cerr << ">>> FAILED in " << where << ": " << func_name << endl << @@ -156,8 +156,8 @@ int check_values (hsize_t i, hsize_t j, int apoint, int acheck) if (apoint != acheck) { cerr << " Read different values than written.\n" << endl; - cerr << " At index " << (unsigned long)i << "," << - (unsigned long)j << endl; + cerr << " At index " << static_cast<unsigned long>(i) << "," << + static_cast<unsigned long>(j) << endl; return -1; } return 0; @@ -212,10 +212,10 @@ InvalidActionException::InvalidActionException():Exception(){} // which the failure should have occurred but didn't, and a // message explaining why it should fail. // Parameters -// func_name - IN: Name of the function where failure should occur -// message - IN: Message +// func - IN: Name of the function where failure should occur +// message - IN: Message //-------------------------------------------------------------------------- -InvalidActionException::InvalidActionException(const H5std_string func_name, const H5std_string message) : Exception(func_name, message) {} +InvalidActionException::InvalidActionException(const H5std_string func, const H5std_string message) : Exception(func, message) {} //-------------------------------------------------------------------------- // Function: InvalidActionException destructor @@ -234,10 +234,10 @@ TestFailedException::TestFailedException():Exception(){} // which the failure should have occurred but didn't, and a // message explaining why it should fail. // Parameters -// func_name - IN: Name of the function where failure should occur -// message - IN: Message +// func - IN: Name of the function where failure should occur +// message - IN: Message //-------------------------------------------------------------------------- -TestFailedException::TestFailedException(const H5std_string func_name, const H5std_string message) : Exception(func_name, message) {} +TestFailedException::TestFailedException(const H5std_string func, const H5std_string message) : Exception(func, message) {} //-------------------------------------------------------------------------- // Function: TestFailedException destructor diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp index a6cbae4..5d78b3c 100644 --- a/c++/test/tarray.cpp +++ b/c++/test/tarray.cpp @@ -269,7 +269,8 @@ static void test_array_compound_array() file1.close(); PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_array_compound_array", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -343,7 +344,8 @@ static void test_array_assignment() PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_array_assignment", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_array_assignment() diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 936ee63..e8c2a78 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -164,7 +164,7 @@ static void test_attr_basic_write() // continuation here, that means no exception has been thrown throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); } - catch (AttributeIException E) // catching invalid creating attribute + catch (AttributeIException& E) // catching invalid creating attribute {} // do nothing, exception expected // Write attribute information @@ -223,7 +223,7 @@ static void test_attr_basic_write() throw InvalidActionException("H5Group::createAttribute", "Attempting to create an existing attribute"); } - catch (AttributeIException E) // catching invalid creating attribute + catch (AttributeIException& E) // catching invalid creating attribute {} // do nothing, exception expected // Write attribute information @@ -237,7 +237,8 @@ static void test_attr_basic_write() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_basic_write()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_basic_write() @@ -371,7 +372,8 @@ static void test_attr_getname() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_getname()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_getname() @@ -481,7 +483,8 @@ static void test_attr_rename() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_rename()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_rename() @@ -549,7 +552,8 @@ static void test_attr_basic_read() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_basic_read()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_basic_read() @@ -599,7 +603,7 @@ static void test_attr_compound_write() try { Attribute invalid_attr = dataset.createAttribute (ATTR4_NAME, comp_type, sid2); } - catch (AttributeIException E) // catching invalid creating attribute + catch (AttributeIException& E) // catching invalid creating attribute {} // do nothing, exception expected // Write complex attribute data @@ -608,7 +612,8 @@ static void test_attr_compound_write() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_compound_write()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_compound_write() @@ -743,7 +748,8 @@ static void test_attr_compound_read() verify_val(attr_name, ATTR4_NAME, "Attribute::getName", __LINE__, __FILE__); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -758,7 +764,8 @@ static void test_attr_compound_read() PASSED(); } // end try block - catch (FileIException E) { + catch (FileIException& E) + { issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, "Unable to truncate file, possibly because some objects are left opened"); } } // test_attr_compound_read() @@ -803,7 +810,7 @@ static void test_attr_scalar_write() // continuation here, that means no exception has been thrown throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); } - catch (AttributeIException E) // catching invalid creating attribute + catch (AttributeIException& E) // catching invalid creating attribute {} // do nothing, exception expected // Write attribute information @@ -812,7 +819,8 @@ static void test_attr_scalar_write() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_scalar_write() @@ -856,7 +864,8 @@ static void test_attr_scalar_read() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_scalar_read() @@ -919,7 +928,7 @@ static void test_attr_mult_write() // continuation here, that means no exception has been thrown throw InvalidActionException("DataSet::createAttribute", "Attempting to create a duplicate attribute"); } - catch (AttributeIException E) // catching invalid creating attribute + catch (AttributeIException& E) // catching invalid creating attribute {} // do nothing, exception expected // Write 3rd attribute information @@ -928,7 +937,8 @@ static void test_attr_mult_write() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_mult_write()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_mult_write() @@ -1118,7 +1128,8 @@ static void test_attr_mult_read() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_mult_read()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_mult_read() @@ -1153,7 +1164,7 @@ static void test_attr_delete() // Verify the name of the only file attribute left Attribute fattr = fid1.openAttribute((unsigned)0); - H5std_string attr_name = fattr.getName(); + attr_name = fattr.getName(); verify_val(attr_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); fattr.close(); @@ -1173,7 +1184,7 @@ static void test_attr_delete() // continuation here, that means no exception has been thrown throw InvalidActionException("DataSet::removeAttr", "Attempting to remove non-existing attribute"); } - catch (AttributeIException E) // catching invalid removing attribute + catch (AttributeIException& E) // catching invalid removing attribute {} // do nothing, exception expected // Test deleting dataset's attributes @@ -1234,7 +1245,8 @@ static void test_attr_delete() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_delete()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_delete() @@ -1391,7 +1403,8 @@ static void test_attr_dtype_shared() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_dtype_shared()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_dtype_shared() @@ -1515,7 +1528,8 @@ static void test_string_attr() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_string_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_string_attr() @@ -1559,10 +1573,12 @@ static void test_attr_exists() PASSED(); } // end try block - catch (InvalidActionException E) { + catch (InvalidActionException& E) + { issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_exists() @@ -1621,8 +1637,8 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, // Retrieve limits for compact/dense attribute storage and verify them dcpl.getAttrPhaseChange(max_compact, min_dense); - verify_val(max_compact, 7, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - verify_val(min_dense, 5, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(max_compact, static_cast<unsigned>(7), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(min_dense, static_cast<unsigned>(5), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); // Close property list dcpl.close(); @@ -1664,13 +1680,14 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, // continuation here, that means no exception has been thrown throw InvalidActionException("DataSet::createAttribute", "Maximum number of attributes has been reached"); } - catch (AttributeIException E) // catching invalid action + catch (AttributeIException& E) // catching invalid action {} // do nothing, exception expected PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_dense_create()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_dense_create() @@ -1707,7 +1724,7 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, // continuation here, that means no exception has been thrown throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", "Indexing cannot be set alone, order tracking is required"); } - catch (PropListIException E) // catching invalid action + catch (PropListIException& E) // catching invalid action {} // do nothing, exception expected // Set attribute creation order tracking & indexing for object then @@ -1754,7 +1771,8 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_corder_create_basic()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_corder_create_basic() @@ -1843,7 +1861,8 @@ void test_attr() } // end for } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr() diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index dbf2f0c..e08c81d 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -78,8 +78,8 @@ static void test_compound_1() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_1 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } } // test_compound_1() @@ -200,8 +200,8 @@ static void test_compound_2() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_2 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } @@ -322,8 +322,8 @@ static void test_compound_3() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_3 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } @@ -454,8 +454,8 @@ static void test_compound_4() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_4 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } @@ -558,8 +558,8 @@ static void test_compound_5() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_5 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } @@ -655,8 +655,8 @@ static void test_compound_6() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_6 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } } // test_compound_6() @@ -714,7 +714,7 @@ static void test_compound_7() tid2.insertMember("d", HOFFSET(s2_typ_t, d), PredType::NATIVE_DOUBLE); // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("CompType::insertMember", "Attempted to insert field past end of compound data type."); - } catch (DataTypeIException err) {} + } catch (DataTypeIException& err) {} /* Release resources */ tid1.close(); @@ -722,8 +722,8 @@ static void test_compound_7() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_7 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } } // test_compound_7() @@ -812,7 +812,8 @@ static void test_compound_set_size() PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } } // test_compound_set_size() diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp index 5c1d953..ab93c26 100644 --- a/c++/test/tdspl.cpp +++ b/c++/test/tdspl.cpp @@ -114,7 +114,8 @@ static void test_transfplist() PASSED(); } - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_transfplist", __LINE__, __FILE__, E.getCDetailMsg()); } } diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp index b29c6fb..b3415f1 100644 --- a/c++/test/testhdf5.cpp +++ b/c++/test/testhdf5.cpp @@ -110,7 +110,7 @@ Comment out tests that are not done yet */ AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL); */ } - catch (Exception E) + catch (Exception& E) { issue_fail_msg("Tests failed", __LINE__, __FILE__, E.getCDetailMsg()); } diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index f84ce3a..4ff15ce 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -116,7 +116,7 @@ static void test_file_create() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "Attempted to create an existing file."); } - catch( FileIException E ) // catch truncating existing file + catch (FileIException& E) // catch truncating existing file {} // do nothing, FAIL expected // Close file1 @@ -181,7 +181,7 @@ static void test_file_create() // Close first file delete file1; } - catch (InvalidActionException E) + catch (InvalidActionException& E) { cerr << " *FAILED*" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -189,7 +189,7 @@ static void test_file_create() delete file1; } // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); if (file1 != NULL) // clean up @@ -268,7 +268,7 @@ static void test_file_create() PASSED(); } // catch all exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); if (tmpl1 != NULL) // clean up @@ -505,7 +505,8 @@ static void test_file_name() PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -551,7 +552,7 @@ static void test_file_attribute() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File createAttribute", "Attempted to create an existing attribute."); } - catch( AttributeIException E ) // catch creating existing attribute + catch (AttributeIException& E) // catch creating existing attribute {} // do nothing, FAIL expected // Create a new dataset @@ -618,7 +619,8 @@ static void test_file_attribute() PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_file_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_file_attribute() @@ -705,7 +707,8 @@ static void test_libver_bounds_real( // Everything should be closed as they go out of scope } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_libver_bounds_real()", __LINE__, __FILE__, E.getCDetailMsg()); } diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp index ff3901d..19549b3 100644 --- a/c++/test/tfilter.cpp +++ b/c++/test/tfilter.cpp @@ -148,7 +148,7 @@ static void test_null_filter() } // end of try // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_null_filter()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -232,7 +232,7 @@ static void test_szip_filter(H5File& file1) } // end of try // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_szip_filter()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -280,7 +280,7 @@ void test_filters() test_null_filter(); test_szip_filter(file1); } - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_filters()", __LINE__, __FILE__, E.getCDetailMsg()); } diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index b7a39b4..181c09f 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -213,13 +213,13 @@ static void test_h5s_basic() PASSED(); } // end of try block - catch (InvalidActionException E) + catch (InvalidActionException& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; } // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_h5s_basic()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -283,7 +283,7 @@ static void test_h5s_scalar_write() PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_h5s_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -343,7 +343,7 @@ static void test_h5s_scalar_read() PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); @@ -399,7 +399,7 @@ static void test_h5s_null() PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_h5s_null()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -471,7 +471,7 @@ static void test_h5s_compound_scalar_write() PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_compound_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); @@ -545,7 +545,7 @@ static void test_h5s_compound_scalar_read() } // end if PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_compound_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index 57738d7..a3eb690 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -415,7 +415,7 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__); } // end of try block - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -441,7 +441,7 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -630,7 +630,7 @@ void test_links() /* nerrors += external_reset_register() < 0 ? 1 : 0; */ } - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_links()", __LINE__, __FILE__, E.getCDetailMsg()); } diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index 2381ec2..046e67a 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -148,7 +148,7 @@ static void test_get_objname() } // try block // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_get_objname", __LINE__, __FILE__); } @@ -233,7 +233,7 @@ static void test_get_objname_ontypes() PASSED(); } // end top try block - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_get_objname_ontypes", __LINE__, __FILE__); } @@ -298,7 +298,7 @@ static void test_get_objtype() } // try block // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_get_objtype", __LINE__, __FILE__); } diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index 9d072be..1974541 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -144,19 +144,19 @@ test_reference_params(void) /* Test parameters to H5Location::reference */ try { file1->reference(NULL, "/Group1/Dataset1"); - } catch (ReferenceException E) {} // We expect this to fail + } catch (ReferenceException& E) {} // We expect this to fail try { file1->reference(&wbuf[0], NULL); - } catch (ReferenceException E) {} // We expect this to fail + } catch (ReferenceException& E) {} // We expect this to fail try { file1->reference(&wbuf[0], ""); - } catch (ReferenceException E) {} // We expect this to fail + } catch (ReferenceException& E) {} // We expect this to fail try { file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_MAXTYPE); - } catch (ReferenceException E) {} // We expect this to fail + } catch (ReferenceException& E) {} // We expect this to fail try { file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_DATASET_REGION); - } catch (ReferenceException E) {} // We expect this to fail + } catch (ReferenceException& E) {} // We expect this to fail // Close resources dataset.close(); @@ -170,7 +170,8 @@ test_reference_params(void) PASSED(); } // end try - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_reference_param()",__LINE__,__FILE__, E.getCFuncName(), E.getCDetailMsg()); } @@ -330,7 +331,7 @@ static void test_reference_obj(void) try { H5std_string read_comment_tmp = group.getComment(NULL); } - catch (Exception E) {} // We expect this to fail + catch (Exception& E) {} // We expect this to fail // Close group group.close(); @@ -361,7 +362,8 @@ static void test_reference_obj(void) PASSED(); } // end try - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_reference_obj()",__LINE__,__FILE__, E.getCFuncName(), E.getCDetailMsg()); } @@ -489,7 +491,8 @@ test_reference_group(void) PASSED(); } // end try - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_reference_group()",__LINE__,__FILE__, E.getCFuncName(), E.getCDetailMsg()); } @@ -780,7 +783,8 @@ test_reference_region_1D(void) PASSED(); } // end try - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_reference_region_1D()",__LINE__,__FILE__, E.getCFuncName(), E.getCDetailMsg()); } diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index 971a06f..c65d6a5 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -124,7 +124,8 @@ static void test_classes() } PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_classes", __LINE__, __FILE__, E.getCDetailMsg()); } } @@ -180,7 +181,8 @@ static void test_copy() PASSED(); } - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_copy", __LINE__, __FILE__, E.getCDetailMsg()); } } @@ -291,7 +293,8 @@ static void test_query() PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_query", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_query @@ -334,7 +337,7 @@ static void test_transient () Attribute attr(type.createAttribute("attr1", PredType::NATIVE_INT, space)); // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5Object::createAttribute", "Attempted to commit a predefined datatype."); - } catch (AttributeIException err) {} // do nothing, failure expected + } catch (AttributeIException& err) {} // do nothing, failure expected // Create a dataset from a transient datatype // type.close(); - put trace in H5Tclose to make sure it's closed @@ -348,7 +351,7 @@ static void test_transient () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("PredType::setPrecision", "Dataset datatypes should not be modifiable!"); - } catch (DataTypeIException err) {} + } catch (DataTypeIException& err) {} itype.close(); // Get a copy of the dataset's datatype by applying DataType::copy() @@ -369,7 +372,8 @@ static void test_transient () space.close(); PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_transient", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_transient @@ -414,7 +418,7 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("PredType::commit", "Attempted to commit a predefined datatype."); - } catch (DataTypeIException err) {} + } catch (DataTypeIException& err) {} // Copy a predefined datatype and commit the copy. IntType itype(PredType::NATIVE_INT); @@ -433,7 +437,8 @@ static void test_named () // no matching prototype atype.commit(const_grp, "random uchar"); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_named", __LINE__, __FILE__, "Commit at const group"); } @@ -447,7 +452,7 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("IntType::setPrecision", "Attempted to modify a committed datatype."); - } catch (DataTypeIException err) {} + } catch (DataTypeIException& err) {} // We should not be able to re-commit a committed type try { @@ -455,7 +460,7 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("IntType::commit", "Attempted to re-commit a committed datatype."); - } catch (DataTypeIException err) {} // do nothing, failure expected + } catch (DataTypeIException& err) {} // do nothing, failure expected // It should be possible to define an attribute for the named type Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space); @@ -529,7 +534,8 @@ static void test_named () file.close(); PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_named", __LINE__, __FILE__, E.getCDetailMsg()); } diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index 7c81a8e..6ec7f25 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -207,7 +207,8 @@ static void test_vlstring_dataset() } // end try block // Catch all exceptions. - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_vlstring_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -306,7 +307,7 @@ static void test_vlstring_array_dataset() } // end try // Catch all exceptions. - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -427,7 +428,7 @@ static void test_vlstrings_special() } // end try // Catch all exceptions. - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_vlstrings_special()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -513,7 +514,7 @@ static void test_vlstring_type() } // end try block // Catch all exceptions. - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_vlstring_type()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -592,7 +593,7 @@ static void test_compact_vlstring() } // end try // Catch all exceptions. - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_compact_vlstrings()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -682,7 +683,8 @@ static void test_vlstring_attribute() } // end try block // Catch all exceptions. - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_vlstring_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_vlstring_attribute() @@ -743,7 +745,8 @@ static void test_read_vl_string_attribute() } // end try // Catch all exceptions. - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_read_vl_string_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_read_vl_string_attribute @@ -814,7 +817,8 @@ static void test_vlstring_array_attribute() } // end try block // Catch all exceptions. - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_vlstring_array_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_vlstring_array_attribute() @@ -829,10 +833,10 @@ static void write_scalar_dset(H5File& file, DataType& type, DataSpace& space, dset.write(&data, type, space, space); dset.close(); } // end try - catch (FileIException ferr) { + catch (FileIException& ferr) { throw; } - catch (DataSetIException derr) { + catch (DataSetIException& derr) { throw; } } @@ -853,10 +857,10 @@ static void read_scalar_dset(H5File& file, DataType& type, DataSpace& space, HDfree(data_read); } // end try - catch (FileIException ferr) { + catch (FileIException& ferr) { throw; } - catch (DataSetIException derr) { + catch (DataSetIException& derr) { throw; } } @@ -936,7 +940,8 @@ static void test_vl_rewrite() } // end try // Catch all exceptions. - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_vl_rewrite()", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_vl_rewrite() |