diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-04-22 22:42:22 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-04-22 22:42:22 (GMT) |
commit | d490c837eb601c4a7eee8fba62ce8ba9adb0e9a1 (patch) | |
tree | 604b7e94e35625072c61f2a286862f779dba93c6 /c++/test | |
parent | 58803d08320c0f704bc4cca600e9701572ddc1b4 (diff) | |
download | hdf5-d490c837eb601c4a7eee8fba62ce8ba9adb0e9a1.zip hdf5-d490c837eb601c4a7eee8fba62ce8ba9adb0e9a1.tar.gz hdf5-d490c837eb601c4a7eee8fba62ce8ba9adb0e9a1.tar.bz2 |
[svn-r29769] 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
Merged from trunk r29759 and r29766
Platforms tested:
Linux/32 2.6 (jam)
Linux/64 (platypus)
Darwin (osx1010test)
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/dsets.cpp | 36 | ||||
-rw-r--r-- | c++/test/h5cpputil.cpp | 16 | ||||
-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 | 33 | ||||
-rw-r--r-- | c++/test/tfilter.cpp | 6 | ||||
-rw-r--r-- | c++/test/th5s.cpp | 18 | ||||
-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, 187 insertions, 140 deletions
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index f35696a..6f60950 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,7 +246,7 @@ 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 (static_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 (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); @@ -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; @@ -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] = (int)n++; } } + char* tconv_buf = new char [1000]; DataSet* dataset = NULL; try @@ -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 7ad7364..f56782f 100644 --- a/c++/test/h5cpputil.cpp +++ b/c++/test/h5cpputil.cpp @@ -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 0fefe22..d20466e 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() @@ -1154,7 +1165,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(); @@ -1174,7 +1185,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 @@ -1235,7 +1246,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() @@ -1392,7 +1404,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() @@ -1516,7 +1529,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() @@ -1560,10 +1574,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() @@ -1622,8 +1638,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(); @@ -1665,13 +1681,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() @@ -1708,7 +1725,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 @@ -1755,7 +1772,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() @@ -1845,7 +1863,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 de4a9b8..e293ded 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 16648c9..dbf7e3e 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 78b3611..b40b34c 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 @@ -131,7 +131,7 @@ static void test_file_create() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "File already exists."); } - catch( FileIException E ) // catching creating existing file + catch (FileIException& E) // catching creating existing file {} // do nothing, FAIL expected // Test create with H5F_ACC_TRUNC. This will truncate the existing file. @@ -145,7 +145,7 @@ static void test_file_create() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "H5F_ACC_TRUNC attempt on an opened file."); } - catch( FileIException E ) // catching truncating opened file + catch (FileIException& E) // catching truncating opened file {} // do nothing, FAIL expected // Try with H5F_ACC_EXCL. This should fail too because the file already @@ -156,7 +156,7 @@ static void test_file_create() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "H5F_ACC_EXCL attempt on an existing file."); } - catch( FileIException E ) // catching H5F_ACC_EXCL on existing file + catch (FileIException& E) // catching H5F_ACC_EXCL on existing file {} // do nothing, FAIL expected // Get the file-creation template @@ -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 @@ -336,7 +336,7 @@ static void test_file_open() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "Attempt truncating an opened file."); } - catch( FileIException E ) // catching H5F_ACC_TRUNC on opened file + catch (FileIException& E) // catching H5F_ACC_TRUNC on opened file {} // do nothing, FAIL expected // Now, really close the file. @@ -353,7 +353,8 @@ static void test_file_open() PASSED(); } // end of try block - catch( Exception E ) { + catch (Exception& E) + { issue_fail_msg("test_file_open()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_file_open() @@ -411,7 +412,8 @@ static void test_file_size() PASSED(); } // end of try block - catch( Exception E ) { + catch (Exception& E) + { issue_fail_msg("test_file_size()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -505,7 +507,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 +554,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 +621,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 +709,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..7ef048b 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -178,7 +178,7 @@ static void test_h5s_basic() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("DataSpace constructor", "Library allowed overwrite of existing dataset"); } - catch( DataSpaceIException E ) // Simple data space with too many dims + catch (DataSpaceIException& E) // Simple data space with too many dims {} // do nothing, exception expected /* @@ -204,7 +204,7 @@ static void test_h5s_basic() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File::openDataSet", "Opening a dataset with higher dimensionality than what the library can handle"); } - catch( FileIException E ) // catching higher dimensionality dataset + catch (FileIException& E) // catching higher dimensionality dataset {} // do nothing, exception expected // CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure @@ -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 33d10ea..025fedc 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 0331c8d..d7c237f 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -148,19 +148,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(); @@ -174,7 +174,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()); } @@ -331,7 +332,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(); @@ -362,7 +363,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()); } @@ -490,7 +492,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()); } @@ -778,7 +781,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 3139551..217b7b9 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -122,7 +122,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()); } } @@ -177,7 +178,8 @@ static void test_copy() PASSED(); } - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_copy", __LINE__, __FILE__, E.getCDetailMsg()); } } @@ -288,7 +290,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 @@ -331,7 +334,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 @@ -345,7 +348,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() @@ -366,7 +369,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 @@ -411,7 +415,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); @@ -430,7 +434,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"); } @@ -444,7 +449,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 { @@ -452,7 +457,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); @@ -526,7 +531,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() |