mirror of
https://github.com/boostorg/function.git
synced 2025-07-04 16:26:31 +02:00
TST: Do not catch exceptions by value
This commit is contained in:
committed by
James E. King III
parent
86f05aa602
commit
df1f33eb00
@ -631,7 +631,7 @@ test_ref()
|
|||||||
boost::function2<int, int, int> f(ref(atc));
|
boost::function2<int, int, int> f(ref(atc));
|
||||||
BOOST_CHECK(f(1, 3) == 4);
|
BOOST_CHECK(f(1, 3) == 4);
|
||||||
}
|
}
|
||||||
catch(std::runtime_error e) {
|
catch(std::runtime_error const&) {
|
||||||
BOOST_ERROR("Nonthrowing constructor threw an exception");
|
BOOST_ERROR("Nonthrowing constructor threw an exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,7 @@ test_ref()
|
|||||||
boost::function<int (int, int)> f(boost::ref(atc));
|
boost::function<int (int, int)> f(boost::ref(atc));
|
||||||
BOOST_CHECK(f(1, 3) == 4);
|
BOOST_CHECK(f(1, 3) == 4);
|
||||||
}
|
}
|
||||||
catch(std::runtime_error e) {
|
catch(std::runtime_error const&) {
|
||||||
BOOST_ERROR("Nonthrowing constructor threw an exception");
|
BOOST_ERROR("Nonthrowing constructor threw an exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -651,14 +651,14 @@ static void test_empty_ref()
|
|||||||
f2();
|
f2();
|
||||||
BOOST_ERROR("Exception didn't throw for reference to empty function.");
|
BOOST_ERROR("Exception didn't throw for reference to empty function.");
|
||||||
}
|
}
|
||||||
catch(std::runtime_error e) {}
|
catch(std::runtime_error const&) {}
|
||||||
|
|
||||||
f1 = dummy;
|
f1 = dummy;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
f2();
|
f2();
|
||||||
}
|
}
|
||||||
catch(std::runtime_error e) {
|
catch(std::runtime_error const&) {
|
||||||
BOOST_ERROR("Error calling referenced function.");
|
BOOST_ERROR("Error calling referenced function.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -673,7 +673,7 @@ static void test_exception()
|
|||||||
f(5, 4);
|
f(5, 4);
|
||||||
BOOST_CHECK(false);
|
BOOST_CHECK(false);
|
||||||
}
|
}
|
||||||
catch(boost::bad_function_call) {
|
catch(boost::bad_function_call const&) {
|
||||||
// okay
|
// okay
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user