Replaced BOOST_TEST

[SVN r27049]
This commit is contained in:
Stefan Slapeta
2005-02-03 11:09:28 +00:00
parent dc61dc6dc8
commit bb669b4fb5
4 changed files with 313 additions and 313 deletions

View File

@ -56,8 +56,8 @@ test_main(int, char*[])
function2<int, int, int, counting_allocator<int> > f; function2<int, int, int, counting_allocator<int> > f;
f = plus<int>(); f = plus<int>();
f.clear(); f.clear();
BOOST_TEST(alloc_count == 1); BOOST_CHECK(alloc_count == 1);
BOOST_TEST(dealloc_count == 1); BOOST_CHECK(dealloc_count == 1);
alloc_count = 0; alloc_count = 0;
dealloc_count = 0; dealloc_count = 0;
@ -69,8 +69,8 @@ test_main(int, char*[])
dealloc_count = 0; dealloc_count = 0;
fv = DoNothing(); fv = DoNothing();
fv.clear(); fv.clear();
BOOST_TEST(alloc_count == 1); BOOST_CHECK(alloc_count == 1);
BOOST_TEST(dealloc_count == 1); BOOST_CHECK(dealloc_count == 1);
alloc_count = 0; alloc_count = 0;
dealloc_count = 0; dealloc_count = 0;

View File

@ -36,18 +36,18 @@ static void target_test()
boost::function0<int> f; boost::function0<int> f;
f = &forty_two; f = &forty_two;
BOOST_TEST(*f.target<int (*)()>() == &forty_two); BOOST_CHECK(*f.target<int (*)()>() == &forty_two);
BOOST_TEST(!f.target<Seventeen>()); BOOST_CHECK(!f.target<Seventeen>());
f = Seventeen(); f = Seventeen();
BOOST_TEST(!f.target<int (*)()>()); BOOST_CHECK(!f.target<int (*)()>());
BOOST_TEST(f.target<Seventeen>()); BOOST_CHECK(f.target<Seventeen>());
Seventeen this_seventeen; Seventeen this_seventeen;
f = boost::ref(this_seventeen); f = boost::ref(this_seventeen);
BOOST_TEST(!f.target<int (*)()>()); BOOST_CHECK(!f.target<int (*)()>());
BOOST_TEST(f.target<Seventeen>()); BOOST_CHECK(f.target<Seventeen>());
BOOST_TEST(f.target<Seventeen>() == &this_seventeen); BOOST_CHECK(f.target<Seventeen>() == &this_seventeen);
} }
static void equal_test() static void equal_test()
@ -55,46 +55,46 @@ static void equal_test()
boost::function0<int> f; boost::function0<int> f;
f = &forty_two; f = &forty_two;
BOOST_TEST(f == &forty_two); BOOST_CHECK(f == &forty_two);
BOOST_TEST(f != ReturnInt(17)); BOOST_CHECK(f != ReturnInt(17));
#if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) #if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(&forty_two == f); BOOST_CHECK(&forty_two == f);
BOOST_TEST(ReturnInt(17) != f); BOOST_CHECK(ReturnInt(17) != f);
#endif #endif
BOOST_TEST(f.contains(&forty_two)); BOOST_CHECK(f.contains(&forty_two));
f = ReturnInt(17); f = ReturnInt(17);
BOOST_TEST(f != &forty_two); BOOST_CHECK(f != &forty_two);
BOOST_TEST(f == ReturnInt(17)); BOOST_CHECK(f == ReturnInt(17));
BOOST_TEST(f != ReturnInt(16)); BOOST_CHECK(f != ReturnInt(16));
#if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) #if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(&forty_two != f); BOOST_CHECK(&forty_two != f);
BOOST_TEST(ReturnInt(17) == f); BOOST_CHECK(ReturnInt(17) == f);
BOOST_TEST(ReturnInt(16) != f); BOOST_CHECK(ReturnInt(16) != f);
#endif #endif
BOOST_TEST(f.contains(ReturnInt(17))); BOOST_CHECK(f.contains(ReturnInt(17)));
#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX) #if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
boost::function<int(void)> g; boost::function<int(void)> g;
g = &forty_two; g = &forty_two;
BOOST_TEST(g == &forty_two); BOOST_CHECK(g == &forty_two);
BOOST_TEST(g != ReturnInt(17)); BOOST_CHECK(g != ReturnInt(17));
# if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) # if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(&forty_two == g); BOOST_CHECK(&forty_two == g);
BOOST_TEST(ReturnInt(17) != g); BOOST_CHECK(ReturnInt(17) != g);
# endif # endif
g = ReturnInt(17); g = ReturnInt(17);
BOOST_TEST(g != &forty_two); BOOST_CHECK(g != &forty_two);
BOOST_TEST(g == ReturnInt(17)); BOOST_CHECK(g == ReturnInt(17));
BOOST_TEST(g != ReturnInt(16)); BOOST_CHECK(g != ReturnInt(16));
# if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) # if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(&forty_two != g); BOOST_CHECK(&forty_two != g);
BOOST_TEST(ReturnInt(17) == g); BOOST_CHECK(ReturnInt(17) == g);
BOOST_TEST(ReturnInt(16) != g); BOOST_CHECK(ReturnInt(16) != g);
# endif # endif
#endif #endif
} }
@ -106,28 +106,28 @@ static void ref_equal_test()
boost::function0<int> f = boost::ref(ri); boost::function0<int> f = boost::ref(ri);
// References and values are equal // References and values are equal
BOOST_TEST(f == boost::ref(ri)); BOOST_CHECK(f == boost::ref(ri));
BOOST_TEST(f == ri); BOOST_CHECK(f == ri);
BOOST_TEST(boost::ref(ri) == f); BOOST_CHECK(boost::ref(ri) == f);
BOOST_TEST(!(f != boost::ref(ri))); BOOST_CHECK(!(f != boost::ref(ri)));
BOOST_TEST(!(f != ri)); BOOST_CHECK(!(f != ri));
BOOST_TEST(!(boost::ref(ri) != f)); BOOST_CHECK(!(boost::ref(ri) != f));
#if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) #if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(ri == f); BOOST_CHECK(ri == f);
BOOST_TEST(!(ri != f)); BOOST_CHECK(!(ri != f));
#endif #endif
// Values equal, references inequal // Values equal, references inequal
ReturnInt ri2(17); ReturnInt ri2(17);
BOOST_TEST(f == ri2); BOOST_CHECK(f == ri2);
BOOST_TEST(f != boost::ref(ri2)); BOOST_CHECK(f != boost::ref(ri2));
BOOST_TEST(boost::ref(ri2) != f); BOOST_CHECK(boost::ref(ri2) != f);
BOOST_TEST(!(f != ri2)); BOOST_CHECK(!(f != ri2));
BOOST_TEST(!(f == boost::ref(ri2))); BOOST_CHECK(!(f == boost::ref(ri2)));
BOOST_TEST(!(boost::ref(ri2) == f)); BOOST_CHECK(!(boost::ref(ri2) == f));
#if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) #if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(ri2 == f); BOOST_CHECK(ri2 == f);
BOOST_TEST(!(ri2 != f)); BOOST_CHECK(!(ri2 != f));
#endif #endif
} }
@ -137,28 +137,28 @@ static void ref_equal_test()
boost::function<int(void)> f = boost::ref(ri); boost::function<int(void)> f = boost::ref(ri);
// References and values are equal // References and values are equal
BOOST_TEST(f == boost::ref(ri)); BOOST_CHECK(f == boost::ref(ri));
BOOST_TEST(f == ri); BOOST_CHECK(f == ri);
BOOST_TEST(boost::ref(ri) == f); BOOST_CHECK(boost::ref(ri) == f);
BOOST_TEST(!(f != boost::ref(ri))); BOOST_CHECK(!(f != boost::ref(ri)));
BOOST_TEST(!(f != ri)); BOOST_CHECK(!(f != ri));
BOOST_TEST(!(boost::ref(ri) != f)); BOOST_CHECK(!(boost::ref(ri) != f));
# if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) # if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(ri == f); BOOST_CHECK(ri == f);
BOOST_TEST(!(ri != f)); BOOST_CHECK(!(ri != f));
# endif # endif
// Values equal, references inequal // Values equal, references inequal
ReturnInt ri2(17); ReturnInt ri2(17);
BOOST_TEST(f == ri2); BOOST_CHECK(f == ri2);
BOOST_TEST(f != boost::ref(ri2)); BOOST_CHECK(f != boost::ref(ri2));
BOOST_TEST(boost::ref(ri2) != f); BOOST_CHECK(boost::ref(ri2) != f);
BOOST_TEST(!(f != ri2)); BOOST_CHECK(!(f != ri2));
BOOST_TEST(!(f == boost::ref(ri2))); BOOST_CHECK(!(f == boost::ref(ri2)));
BOOST_TEST(!(boost::ref(ri2) == f)); BOOST_CHECK(!(boost::ref(ri2) == f));
# if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) # if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
BOOST_TEST(ri2 == f); BOOST_CHECK(ri2 == f);
BOOST_TEST(!(ri2 != f)); BOOST_CHECK(!(ri2 != f));
# endif # endif
} }
#endif #endif

View File

@ -56,30 +56,30 @@ test_zero_args()
// Default construction // Default construction
func_void_type v1; func_void_type v1;
BOOST_TEST(v1.empty()); BOOST_CHECK(v1.empty());
// Assignment to an empty function // Assignment to an empty function
v1 = five; v1 = five;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
// Invocation of a function // Invocation of a function
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() method // clear() method
v1.clear(); v1.clear();
BOOST_TEST(!v1); BOOST_CHECK(!v1);
// Assignment to an empty function // Assignment to an empty function
v1 = three; v1 = three;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
// Invocation and self-assignment // Invocation and self-assignment
global_int = 0; global_int = 0;
v1 = v1; v1 = v1;
v1(); v1();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v1 = five; v1 = five;
@ -88,61 +88,61 @@ test_zero_args()
global_int = 0; global_int = 0;
v1 = (v1); v1 = (v1);
v1(); v1();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear // clear
v1 = 0; v1 = 0;
BOOST_TEST(v1.empty()); BOOST_CHECK(v1.empty());
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v1 = &write_five; v1 = &write_five;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v1 = &write_three; v1 = &write_three;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment // Assignment
v1 = five; v1 = five;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v1 = write_three; v1 = write_three;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Construction from another function (that is empty) // Construction from another function (that is empty)
v1.clear(); v1.clear();
func_void_type v2(v1); func_void_type v2(v1);
BOOST_TEST(!v2? true : false); BOOST_CHECK(!v2? true : false);
// Assignment to an empty function // Assignment to an empty function
v2 = three; v2 = three;
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v2 = (five); v2 = (five);
@ -150,86 +150,86 @@ test_zero_args()
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
v2.clear(); v2.clear();
BOOST_TEST(v2.empty()); BOOST_CHECK(v2.empty());
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v2 = (&write_five); v2 = (&write_five);
BOOST_TEST(v2? true : false); BOOST_CHECK(v2? true : false);
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v2 = &write_three; v2 = &write_three;
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Swapping // Swapping
v1 = five; v1 = five;
swap(v1, v2); swap(v1, v2);
v2(); v2();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
v1(); v1();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
swap(v1, v2); swap(v1, v2);
v1.clear(); v1.clear();
// Assignment // Assignment
v2 = five; v2 = five;
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v2 = &write_three; v2 = &write_three;
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a function from an empty function // Assignment to a function from an empty function
v2 = v1; v2 = v1;
BOOST_TEST(v2.empty()); BOOST_CHECK(v2.empty());
// Assignment to a function from a function with a functor // Assignment to a function from a function with a functor
v1 = three; v1 = three;
v2 = v1; v2 = v1;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assign to a function from a function with a function // Assign to a function from a function with a function
v2 = &write_five; v2 = &write_five;
v1 = v2; v1 = v2;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Construct a function given another function containing a function // Construct a function given another function containing a function
func_void_type v3(v1); func_void_type v3(v1);
@ -237,20 +237,20 @@ test_zero_args()
// Invocation of a function // Invocation of a function
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() method // clear() method
v3.clear(); v3.clear();
BOOST_TEST(!v3? true : false); BOOST_CHECK(!v3? true : false);
// Assignment to an empty function // Assignment to an empty function
v3 = three; v3 = three;
BOOST_TEST(!v3.empty()); BOOST_CHECK(!v3.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v3 = five; v3 = five;
@ -258,38 +258,38 @@ test_zero_args()
// Invocation // Invocation
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() // clear()
v3.clear(); v3.clear();
BOOST_TEST(v3.empty()); BOOST_CHECK(v3.empty());
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v3 = &write_five; v3 = &write_five;
BOOST_TEST(!v3.empty()); BOOST_CHECK(!v3.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v3 = &write_three; v3 = &write_three;
BOOST_TEST(!v3.empty()); BOOST_CHECK(!v3.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment // Assignment
v3 = five; v3 = five;
BOOST_TEST(!v3.empty()); BOOST_CHECK(!v3.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Construction of a function from a function containing a functor // Construction of a function from a function containing a functor
func_void_type v4(v3); func_void_type v4(v3);
@ -297,20 +297,20 @@ test_zero_args()
// Invocation of a function // Invocation of a function
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() method // clear() method
v4.clear(); v4.clear();
BOOST_TEST(v4.empty()); BOOST_CHECK(v4.empty());
// Assignment to an empty function // Assignment to an empty function
v4 = three; v4 = three;
BOOST_TEST(!v4.empty()); BOOST_CHECK(!v4.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v4 = five; v4 = five;
@ -318,38 +318,38 @@ test_zero_args()
// Invocation // Invocation
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() // clear()
v4.clear(); v4.clear();
BOOST_TEST(v4.empty()); BOOST_CHECK(v4.empty());
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v4 = &write_five; v4 = &write_five;
BOOST_TEST(!v4.empty()); BOOST_CHECK(!v4.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v4 = &write_three; v4 = &write_three;
BOOST_TEST(!v4.empty()); BOOST_CHECK(!v4.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment // Assignment
v4 = five; v4 = five;
BOOST_TEST(!v4.empty()); BOOST_CHECK(!v4.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Construction of a function from a functor // Construction of a function from a functor
func_void_type v5(five); func_void_type v5(five);
@ -357,20 +357,20 @@ test_zero_args()
// Invocation of a function // Invocation of a function
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() method // clear() method
v5.clear(); v5.clear();
BOOST_TEST(v5.empty()); BOOST_CHECK(v5.empty());
// Assignment to an empty function // Assignment to an empty function
v5 = three; v5 = three;
BOOST_TEST(!v5.empty()); BOOST_CHECK(!v5.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v5 = five; v5 = five;
@ -378,38 +378,38 @@ test_zero_args()
// Invocation // Invocation
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() // clear()
v5.clear(); v5.clear();
BOOST_TEST(v5.empty()); BOOST_CHECK(v5.empty());
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v5 = &write_five; v5 = &write_five;
BOOST_TEST(!v5.empty()); BOOST_CHECK(!v5.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v5 = &write_three; v5 = &write_three;
BOOST_TEST(!v5.empty()); BOOST_CHECK(!v5.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment // Assignment
v5 = five; v5 = five;
BOOST_TEST(!v5.empty()); BOOST_CHECK(!v5.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Construction of a function from a function // Construction of a function from a function
func_void_type v6(&write_five); func_void_type v6(&write_five);
@ -417,20 +417,20 @@ test_zero_args()
// Invocation of a function // Invocation of a function
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() method // clear() method
v6.clear(); v6.clear();
BOOST_TEST(v6.empty()); BOOST_CHECK(v6.empty());
// Assignment to an empty function // Assignment to an empty function
v6 = three; v6 = three;
BOOST_TEST(!v6.empty()); BOOST_CHECK(!v6.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v6 = five; v6 = five;
@ -438,38 +438,38 @@ test_zero_args()
// Invocation // Invocation
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() // clear()
v6.clear(); v6.clear();
BOOST_TEST(v6.empty()); BOOST_CHECK(v6.empty());
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v6 = &write_five; v6 = &write_five;
BOOST_TEST(!v6.empty()); BOOST_CHECK(!v6.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v6 = &write_three; v6 = &write_three;
BOOST_TEST(!v6.empty()); BOOST_CHECK(!v6.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment // Assignment
v6 = five; v6 = five;
BOOST_TEST(!v6.empty()); BOOST_CHECK(!v6.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Const vs. non-const // Const vs. non-const
// Initialization for Borland C++ 5.5 // Initialization for Borland C++ 5.5
@ -479,19 +479,19 @@ test_zero_args()
global_int = 0; global_int = 0;
v7(); v7();
BOOST_TEST(global_int == 2); BOOST_CHECK(global_int == 2);
global_int = 0; global_int = 0;
v8(); v8();
BOOST_TEST(global_int == 2); BOOST_CHECK(global_int == 2);
// Test construction from 0 and comparison to 0 // Test construction from 0 and comparison to 0
func_void_type v9(0); func_void_type v9(0);
BOOST_TEST(v9 == 0); BOOST_CHECK(v9 == 0);
# if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x540 || defined(BOOST_STRICT_CONFIG) # if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x540 || defined(BOOST_STRICT_CONFIG)
BOOST_TEST(0 == v9); BOOST_CHECK(0 == v9);
#else #else
BOOST_TEST(v9.empty()); BOOST_CHECK(v9.empty());
#endif #endif
// Test return values // Test return values
@ -501,31 +501,31 @@ test_zero_args()
generate_three_obj gen_three = generate_three_obj(); generate_three_obj gen_three = generate_three_obj();
func_int_type i0(gen_five); func_int_type i0(gen_five);
BOOST_TEST(i0() == 5); BOOST_CHECK(i0() == 5);
i0 = gen_three; i0 = gen_three;
BOOST_TEST(i0() == 3); BOOST_CHECK(i0() == 3);
i0 = &generate_five; i0 = &generate_five;
BOOST_TEST(i0() == 5); BOOST_CHECK(i0() == 5);
i0 = &generate_three; i0 = &generate_three;
BOOST_TEST(i0() == 3); BOOST_CHECK(i0() == 3);
BOOST_TEST(i0? true : false); BOOST_CHECK(i0? true : false);
i0.clear(); i0.clear();
BOOST_TEST(!i0? true : false); BOOST_CHECK(!i0? true : false);
// Test return values with compatible types // Test return values with compatible types
typedef function0<long> func_long_type; typedef function0<long> func_long_type;
func_long_type i1(gen_five); func_long_type i1(gen_five);
BOOST_TEST(i1() == 5); BOOST_CHECK(i1() == 5);
i1 = gen_three; i1 = gen_three;
BOOST_TEST(i1() == 3); BOOST_CHECK(i1() == 3);
i1 = &generate_five; i1 = &generate_five;
BOOST_TEST(i1() == 5); BOOST_CHECK(i1() == 5);
i1 = &generate_three; i1 = &generate_three;
BOOST_TEST(i1() == 3); BOOST_CHECK(i1() == 3);
BOOST_TEST(i1? true : false); BOOST_CHECK(i1? true : false);
i1.clear(); i1.clear();
BOOST_TEST(!i1? true : false); BOOST_CHECK(!i1? true : false);
} }
static void static void
@ -534,45 +534,45 @@ test_one_arg()
negate<int> neg = negate<int>(); // Initialization for Borland C++ 5.5 negate<int> neg = negate<int>(); // Initialization for Borland C++ 5.5
function1<int, int> f1(neg); function1<int, int> f1(neg);
BOOST_TEST(f1(5) == -5); BOOST_CHECK(f1(5) == -5);
function1<string, string> id(&identity_str); function1<string, string> id(&identity_str);
BOOST_TEST(id("str") == "str"); BOOST_CHECK(id("str") == "str");
function1<std::string, const char*> id2(&identity_str); function1<std::string, const char*> id2(&identity_str);
BOOST_TEST(id2("foo") == "foo"); BOOST_CHECK(id2("foo") == "foo");
add_to_obj add_to(5); add_to_obj add_to(5);
function1<int, int> f2(add_to); function1<int, int> f2(add_to);
BOOST_TEST(f2(3) == 8); BOOST_CHECK(f2(3) == 8);
const function1<int, int> cf2(add_to); const function1<int, int> cf2(add_to);
BOOST_TEST(cf2(3) == 8); BOOST_CHECK(cf2(3) == 8);
} }
static void static void
test_two_args() test_two_args()
{ {
function2<string, const string&, const string&> cat(&string_cat); function2<string, const string&, const string&> cat(&string_cat);
BOOST_TEST(cat("str", "ing") == "string"); BOOST_CHECK(cat("str", "ing") == "string");
function2<int, short, short> sum(&sum_ints); function2<int, short, short> sum(&sum_ints);
BOOST_TEST(sum(2, 3) == 5); BOOST_CHECK(sum(2, 3) == 5);
} }
static void static void
test_emptiness() test_emptiness()
{ {
function0<float> f1; function0<float> f1;
BOOST_TEST(f1.empty()); BOOST_CHECK(f1.empty());
function0<float> f2; function0<float> f2;
f2 = f1; f2 = f1;
BOOST_TEST(f2.empty()); BOOST_CHECK(f2.empty());
function0<double> f3; function0<double> f3;
f3 = f2; f3 = f2;
BOOST_TEST(f3.empty()); BOOST_CHECK(f3.empty());
} }
struct X { struct X {
@ -593,18 +593,18 @@ test_member_functions()
X one(1); X one(1);
X five(5); X five(5);
BOOST_TEST(f1(&one) == 2); BOOST_CHECK(f1(&one) == 2);
BOOST_TEST(f1(&five) == 10); BOOST_CHECK(f1(&five) == 10);
boost::function1<int, X*> f1_2; boost::function1<int, X*> f1_2;
f1_2 = &X::twice; f1_2 = &X::twice;
BOOST_TEST(f1_2(&one) == 2); BOOST_CHECK(f1_2(&one) == 2);
BOOST_TEST(f1_2(&five) == 10); BOOST_CHECK(f1_2(&five) == 10);
boost::function2<int, X&, int> f2(&X::plus); boost::function2<int, X&, int> f2(&X::plus);
BOOST_TEST(f2(one, 3) == 4); BOOST_CHECK(f2(one, 3) == 4);
BOOST_TEST(f2(five, 4) == 9); BOOST_CHECK(f2(five, 4) == 9);
} }
struct add_with_throw_on_copy { struct add_with_throw_on_copy {
@ -629,7 +629,7 @@ test_ref()
add_with_throw_on_copy atc; add_with_throw_on_copy atc;
try { try {
boost::function2<int, int, int> f(ref(atc)); boost::function2<int, int, int> f(ref(atc));
BOOST_TEST(f(1, 3) == 4); BOOST_CHECK(f(1, 3) == 4);
} }
catch(std::runtime_error e) { catch(std::runtime_error e) {
BOOST_ERROR("Nonthrowing constructor threw an exception"); BOOST_ERROR("Nonthrowing constructor threw an exception");

View File

@ -56,30 +56,30 @@ test_zero_args()
// Default construction // Default construction
func_void_type v1; func_void_type v1;
BOOST_TEST(v1.empty()); BOOST_CHECK(v1.empty());
// Assignment to an empty function // Assignment to an empty function
v1 = five; v1 = five;
BOOST_TEST(v1 != 0); BOOST_CHECK(v1 != 0);
// Invocation of a function // Invocation of a function
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() method // clear() method
v1.clear(); v1.clear();
BOOST_TEST(v1 == 0); BOOST_CHECK(v1 == 0);
// Assignment to an empty function // Assignment to an empty function
v1 = three; v1 = three;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
// Invocation and self-assignment // Invocation and self-assignment
global_int = 0; global_int = 0;
v1 = v1; v1 = v1;
v1(); v1();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v1 = five; v1 = five;
@ -88,61 +88,61 @@ test_zero_args()
global_int = 0; global_int = 0;
v1 = (v1); v1 = (v1);
v1(); v1();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear // clear
v1 = 0; v1 = 0;
BOOST_TEST(0 == v1); BOOST_CHECK(0 == v1);
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v1 = BOOST_FUNCTION_TARGET_FIX(&) write_five; v1 = BOOST_FUNCTION_TARGET_FIX(&) write_five;
BOOST_TEST(0 != v1); BOOST_CHECK(0 != v1);
// Invocation // Invocation
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v1 = BOOST_FUNCTION_TARGET_FIX(&) write_three; v1 = BOOST_FUNCTION_TARGET_FIX(&) write_three;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment // Assignment
v1 = five; v1 = five;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v1 = &write_three; v1 = &write_three;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Construction from another function (that is empty) // Construction from another function (that is empty)
v1.clear(); v1.clear();
func_void_type v2(v1); func_void_type v2(v1);
BOOST_TEST(!v2? true : false); BOOST_CHECK(!v2? true : false);
// Assignment to an empty function // Assignment to an empty function
v2 = three; v2 = three;
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v2 = (five); v2 = (five);
@ -150,86 +150,86 @@ test_zero_args()
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
v2.clear(); v2.clear();
BOOST_TEST(v2.empty()); BOOST_CHECK(v2.empty());
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v2 = (BOOST_FUNCTION_TARGET_FIX(&) write_five); v2 = (BOOST_FUNCTION_TARGET_FIX(&) write_five);
BOOST_TEST(v2? true : false); BOOST_CHECK(v2? true : false);
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v2 = BOOST_FUNCTION_TARGET_FIX(&) write_three; v2 = BOOST_FUNCTION_TARGET_FIX(&) write_three;
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Swapping // Swapping
v1 = five; v1 = five;
swap(v1, v2); swap(v1, v2);
v2(); v2();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
v1(); v1();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
swap(v1, v2); swap(v1, v2);
v1.clear(); v1.clear();
// Assignment // Assignment
v2 = five; v2 = five;
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v2 = &write_three; v2 = &write_three;
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a function from an empty function // Assignment to a function from an empty function
v2 = v1; v2 = v1;
BOOST_TEST(v2.empty()); BOOST_CHECK(v2.empty());
// Assignment to a function from a function with a functor // Assignment to a function from a function with a functor
v1 = three; v1 = three;
v2 = v1; v2 = v1;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assign to a function from a function with a function // Assign to a function from a function with a function
v2 = BOOST_FUNCTION_TARGET_FIX(&) write_five; v2 = BOOST_FUNCTION_TARGET_FIX(&) write_five;
v1 = v2; v1 = v2;
BOOST_TEST(!v1.empty()); BOOST_CHECK(!v1.empty());
BOOST_TEST(!v2.empty()); BOOST_CHECK(!v2.empty());
global_int = 0; global_int = 0;
v1(); v1();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
global_int = 0; global_int = 0;
v2(); v2();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Construct a function given another function containing a function // Construct a function given another function containing a function
func_void_type v3(v1); func_void_type v3(v1);
@ -237,20 +237,20 @@ test_zero_args()
// Invocation of a function // Invocation of a function
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() method // clear() method
v3.clear(); v3.clear();
BOOST_TEST(!v3? true : false); BOOST_CHECK(!v3? true : false);
// Assignment to an empty function // Assignment to an empty function
v3 = three; v3 = three;
BOOST_TEST(!v3.empty()); BOOST_CHECK(!v3.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v3 = five; v3 = five;
@ -258,38 +258,38 @@ test_zero_args()
// Invocation // Invocation
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() // clear()
v3.clear(); v3.clear();
BOOST_TEST(v3.empty()); BOOST_CHECK(v3.empty());
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v3 = &write_five; v3 = &write_five;
BOOST_TEST(!v3.empty()); BOOST_CHECK(!v3.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v3 = &write_three; v3 = &write_three;
BOOST_TEST(!v3.empty()); BOOST_CHECK(!v3.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment // Assignment
v3 = five; v3 = five;
BOOST_TEST(!v3.empty()); BOOST_CHECK(!v3.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v3(); v3();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Construction of a function from a function containing a functor // Construction of a function from a function containing a functor
func_void_type v4(v3); func_void_type v4(v3);
@ -297,20 +297,20 @@ test_zero_args()
// Invocation of a function // Invocation of a function
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() method // clear() method
v4.clear(); v4.clear();
BOOST_TEST(v4.empty()); BOOST_CHECK(v4.empty());
// Assignment to an empty function // Assignment to an empty function
v4 = three; v4 = three;
BOOST_TEST(!v4.empty()); BOOST_CHECK(!v4.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v4 = five; v4 = five;
@ -318,38 +318,38 @@ test_zero_args()
// Invocation // Invocation
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() // clear()
v4.clear(); v4.clear();
BOOST_TEST(v4.empty()); BOOST_CHECK(v4.empty());
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v4 = &write_five; v4 = &write_five;
BOOST_TEST(!v4.empty()); BOOST_CHECK(!v4.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v4 = &write_three; v4 = &write_three;
BOOST_TEST(!v4.empty()); BOOST_CHECK(!v4.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment // Assignment
v4 = five; v4 = five;
BOOST_TEST(!v4.empty()); BOOST_CHECK(!v4.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v4(); v4();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Construction of a function from a functor // Construction of a function from a functor
func_void_type v5(five); func_void_type v5(five);
@ -357,20 +357,20 @@ test_zero_args()
// Invocation of a function // Invocation of a function
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() method // clear() method
v5.clear(); v5.clear();
BOOST_TEST(v5.empty()); BOOST_CHECK(v5.empty());
// Assignment to an empty function // Assignment to an empty function
v5 = three; v5 = three;
BOOST_TEST(!v5.empty()); BOOST_CHECK(!v5.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v5 = five; v5 = five;
@ -378,38 +378,38 @@ test_zero_args()
// Invocation // Invocation
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() // clear()
v5.clear(); v5.clear();
BOOST_TEST(v5.empty()); BOOST_CHECK(v5.empty());
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v5 = &write_five; v5 = &write_five;
BOOST_TEST(!v5.empty()); BOOST_CHECK(!v5.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v5 = &write_three; v5 = &write_three;
BOOST_TEST(!v5.empty()); BOOST_CHECK(!v5.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment // Assignment
v5 = five; v5 = five;
BOOST_TEST(!v5.empty()); BOOST_CHECK(!v5.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v5(); v5();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Construction of a function from a function // Construction of a function from a function
func_void_type v6(&write_five); func_void_type v6(&write_five);
@ -417,20 +417,20 @@ test_zero_args()
// Invocation of a function // Invocation of a function
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() method // clear() method
v6.clear(); v6.clear();
BOOST_TEST(v6.empty()); BOOST_CHECK(v6.empty());
// Assignment to an empty function // Assignment to an empty function
v6 = three; v6 = three;
BOOST_TEST(!v6.empty()); BOOST_CHECK(!v6.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment to a non-empty function // Assignment to a non-empty function
v6 = five; v6 = five;
@ -438,38 +438,38 @@ test_zero_args()
// Invocation // Invocation
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// clear() // clear()
v6.clear(); v6.clear();
BOOST_TEST(v6.empty()); BOOST_CHECK(v6.empty());
// Assignment to an empty function from a free function // Assignment to an empty function from a free function
v6 = &write_five; v6 = &write_five;
BOOST_TEST(!v6.empty()); BOOST_CHECK(!v6.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Assignment to a non-empty function from a free function // Assignment to a non-empty function from a free function
v6 = &write_three; v6 = &write_three;
BOOST_TEST(!v6.empty()); BOOST_CHECK(!v6.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 3); BOOST_CHECK(global_int == 3);
// Assignment // Assignment
v6 = five; v6 = five;
BOOST_TEST(!v6.empty()); BOOST_CHECK(!v6.empty());
// Invocation // Invocation
global_int = 0; global_int = 0;
v6(); v6();
BOOST_TEST(global_int == 5); BOOST_CHECK(global_int == 5);
// Const vs. non-const // Const vs. non-const
write_const_1_nonconst_2 one_or_two; write_const_1_nonconst_2 one_or_two;
@ -478,16 +478,16 @@ test_zero_args()
global_int = 0; global_int = 0;
v7(); v7();
BOOST_TEST(global_int == 2); BOOST_CHECK(global_int == 2);
global_int = 0; global_int = 0;
v8(); v8();
BOOST_TEST(global_int == 2); BOOST_CHECK(global_int == 2);
// Test construction from 0 and comparison to 0 // Test construction from 0 and comparison to 0
func_void_type v9(0); func_void_type v9(0);
BOOST_TEST(v9 == 0); BOOST_CHECK(v9 == 0);
BOOST_TEST(0 == v9); BOOST_CHECK(0 == v9);
// Test return values // Test return values
typedef function<int ()> func_int_type; typedef function<int ()> func_int_type;
@ -496,31 +496,31 @@ test_zero_args()
func_int_type i0(gen_five); func_int_type i0(gen_five);
BOOST_TEST(i0() == 5); BOOST_CHECK(i0() == 5);
i0 = gen_three; i0 = gen_three;
BOOST_TEST(i0() == 3); BOOST_CHECK(i0() == 3);
i0 = &generate_five; i0 = &generate_five;
BOOST_TEST(i0() == 5); BOOST_CHECK(i0() == 5);
i0 = &generate_three; i0 = &generate_three;
BOOST_TEST(i0() == 3); BOOST_CHECK(i0() == 3);
BOOST_TEST(i0? true : false); BOOST_CHECK(i0? true : false);
i0.clear(); i0.clear();
BOOST_TEST(!i0? true : false); BOOST_CHECK(!i0? true : false);
// Test return values with compatible types // Test return values with compatible types
typedef function<long ()> func_long_type; typedef function<long ()> func_long_type;
func_long_type i1(gen_five); func_long_type i1(gen_five);
BOOST_TEST(i1() == 5); BOOST_CHECK(i1() == 5);
i1 = gen_three; i1 = gen_three;
BOOST_TEST(i1() == 3); BOOST_CHECK(i1() == 3);
i1 = &generate_five; i1 = &generate_five;
BOOST_TEST(i1() == 5); BOOST_CHECK(i1() == 5);
i1 = &generate_three; i1 = &generate_three;
BOOST_TEST(i1() == 3); BOOST_CHECK(i1() == 3);
BOOST_TEST(i1? true : false); BOOST_CHECK(i1? true : false);
i1.clear(); i1.clear();
BOOST_TEST(!i1? true : false); BOOST_CHECK(!i1? true : false);
} }
static void static void
@ -529,45 +529,45 @@ test_one_arg()
negate<int> neg; negate<int> neg;
function<int (int)> f1(neg); function<int (int)> f1(neg);
BOOST_TEST(f1(5) == -5); BOOST_CHECK(f1(5) == -5);
function<string (string)> id(&identity_str); function<string (string)> id(&identity_str);
BOOST_TEST(id("str") == "str"); BOOST_CHECK(id("str") == "str");
function<string (const char*)> id2(&identity_str); function<string (const char*)> id2(&identity_str);
BOOST_TEST(id2("foo") == "foo"); BOOST_CHECK(id2("foo") == "foo");
add_to_obj add_to(5); add_to_obj add_to(5);
function<int (int)> f2(add_to); function<int (int)> f2(add_to);
BOOST_TEST(f2(3) == 8); BOOST_CHECK(f2(3) == 8);
const function<int (int)> cf2(add_to); const function<int (int)> cf2(add_to);
BOOST_TEST(cf2(3) == 8); BOOST_CHECK(cf2(3) == 8);
} }
static void static void
test_two_args() test_two_args()
{ {
function<string (const string&, const string&)> cat(&string_cat); function<string (const string&, const string&)> cat(&string_cat);
BOOST_TEST(cat("str", "ing") == "string"); BOOST_CHECK(cat("str", "ing") == "string");
function<int (short, short)> sum(&sum_ints); function<int (short, short)> sum(&sum_ints);
BOOST_TEST(sum(2, 3) == 5); BOOST_CHECK(sum(2, 3) == 5);
} }
static void static void
test_emptiness() test_emptiness()
{ {
function<float ()> f1; function<float ()> f1;
BOOST_TEST(f1.empty()); BOOST_CHECK(f1.empty());
function<float ()> f2; function<float ()> f2;
f2 = f1; f2 = f1;
BOOST_TEST(f2.empty()); BOOST_CHECK(f2.empty());
function<double ()> f3; function<double ()> f3;
f3 = f2; f3 = f2;
BOOST_TEST(f3.empty()); BOOST_CHECK(f3.empty());
} }
struct X { struct X {
@ -587,18 +587,18 @@ test_member_functions()
X one(1); X one(1);
X five(5); X five(5);
BOOST_TEST(f1(&one) == 2); BOOST_CHECK(f1(&one) == 2);
BOOST_TEST(f1(&five) == 10); BOOST_CHECK(f1(&five) == 10);
boost::function<int (X*)> f1_2; boost::function<int (X*)> f1_2;
f1_2 = &X::twice; f1_2 = &X::twice;
BOOST_TEST(f1_2(&one) == 2); BOOST_CHECK(f1_2(&one) == 2);
BOOST_TEST(f1_2(&five) == 10); BOOST_CHECK(f1_2(&five) == 10);
boost::function<int (X&, int)> f2(&X::plus); boost::function<int (X&, int)> f2(&X::plus);
BOOST_TEST(f2(one, 3) == 4); BOOST_CHECK(f2(one, 3) == 4);
BOOST_TEST(f2(five, 4) == 9); BOOST_CHECK(f2(five, 4) == 9);
} }
struct add_with_throw_on_copy { struct add_with_throw_on_copy {
@ -623,7 +623,7 @@ test_ref()
add_with_throw_on_copy atc; add_with_throw_on_copy atc;
try { try {
boost::function<int (int, int)> f(ref(atc)); boost::function<int (int, int)> f(ref(atc));
BOOST_TEST(f(1, 3) == 4); BOOST_CHECK(f(1, 3) == 4);
} }
catch(runtime_error e) { catch(runtime_error e) {
BOOST_ERROR("Nonthrowing constructor threw an exception"); BOOST_ERROR("Nonthrowing constructor threw an exception");
@ -671,8 +671,8 @@ static void test_allocator()
boost::function<int (int, int), counting_allocator<int> > f; boost::function<int (int, int), counting_allocator<int> > f;
f = plus<int>(); f = plus<int>();
f.clear(); f.clear();
BOOST_TEST(alloc_count == 1); BOOST_CHECK(alloc_count == 1);
BOOST_TEST(dealloc_count == 1); BOOST_CHECK(dealloc_count == 1);
alloc_count = 0; alloc_count = 0;
dealloc_count = 0; dealloc_count = 0;
@ -684,8 +684,8 @@ static void test_allocator()
dealloc_count = 0; dealloc_count = 0;
fv = DoNothing(); fv = DoNothing();
fv.clear(); fv.clear();
BOOST_TEST(alloc_count == 1); BOOST_CHECK(alloc_count == 1);
BOOST_TEST(dealloc_count == 1); BOOST_CHECK(dealloc_count == 1);
alloc_count = 0; alloc_count = 0;
dealloc_count = 0; dealloc_count = 0;
@ -699,7 +699,7 @@ static void test_exception()
boost::function<int (int, int)> f; boost::function<int (int, int)> f;
try { try {
f(5, 4); f(5, 4);
BOOST_TEST(false); BOOST_CHECK(false);
} }
catch(boost::bad_function_call) { catch(boost::bad_function_call) {
// okay // okay