diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 93d16b4..d77a624 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -25,11 +25,11 @@ import testing ; [ run libs/function/test/function_n_test.cpp : : : : ] - [ run libs/function/test/allocator_test.cpp ../../../libs/test/build//boost_test_exec_monitor : : : : ] + [ run libs/function/test/allocator_test.cpp ] - [ run libs/function/test/stateless_test.cpp ../../../libs/test/build//boost_test_exec_monitor : : : : ] + [ run libs/function/test/stateless_test.cpp ] - [ run libs/function/test/lambda_test.cpp ../../../libs/test/build//boost_test_exec_monitor : : : : ] + [ run libs/function/test/lambda_test.cpp ] [ compile-fail libs/function/test/function_test_fail1.cpp : : : : ] diff --git a/test/allocator_test.cpp b/test/allocator_test.cpp index 3643b2b..a09f067 100644 --- a/test/allocator_test.cpp +++ b/test/allocator_test.cpp @@ -7,10 +7,10 @@ // For more information, see http://www.boost.org -#include +#include +#include #include #include -#include using namespace std; using namespace boost; @@ -74,20 +74,19 @@ struct DoNothing: base static void do_nothing() {} -int -test_main(int, char*[]) +int main() { function2 f; f.assign( plus_int(), counting_allocator() ); f.clear(); - BOOST_CHECK(alloc_count == 1); - BOOST_CHECK(dealloc_count == 1); + BOOST_TEST_EQ( alloc_count, 1 ); + BOOST_TEST_EQ( dealloc_count, 1 ); alloc_count = 0; dealloc_count = 0; f.assign( plus_int(), counting_allocator() ); f.clear(); - BOOST_CHECK(alloc_count == 0); - BOOST_CHECK(dealloc_count == 0); + BOOST_TEST_EQ( alloc_count, 0 ); + BOOST_TEST_EQ( dealloc_count, 0 ); f.assign( plus_int(), std::allocator() ); f.clear(); f.assign( plus_int(), std::allocator() ); @@ -97,8 +96,8 @@ test_main(int, char*[]) dealloc_count = 0; f.assign( &do_minus, counting_allocator() ); f.clear(); - BOOST_CHECK(alloc_count == 0); - BOOST_CHECK(dealloc_count == 0); + BOOST_TEST_EQ( alloc_count, 0 ); + BOOST_TEST_EQ( dealloc_count, 0 ); f.assign( &do_minus, std::allocator() ); f.clear(); @@ -107,14 +106,14 @@ test_main(int, char*[]) dealloc_count = 0; fv.assign( DoNothing(), counting_allocator() ); fv.clear(); - BOOST_CHECK(alloc_count == 1); - BOOST_CHECK(dealloc_count == 1); + BOOST_TEST_EQ( alloc_count, 1 ); + BOOST_TEST_EQ( dealloc_count, 1 ); alloc_count = 0; dealloc_count = 0; fv.assign( DoNothing(), counting_allocator() ); fv.clear(); - BOOST_CHECK(alloc_count == 0); - BOOST_CHECK(dealloc_count == 0); + BOOST_TEST_EQ( alloc_count, 0 ); + BOOST_TEST_EQ( dealloc_count, 0 ); fv.assign( DoNothing(), std::allocator() ); fv.clear(); fv.assign( DoNothing(), std::allocator() ); @@ -124,8 +123,8 @@ test_main(int, char*[]) dealloc_count = 0; fv.assign( &do_nothing, counting_allocator() ); fv.clear(); - BOOST_CHECK(alloc_count == 0); - BOOST_CHECK(dealloc_count == 0); + BOOST_TEST_EQ( alloc_count, 0 ); + BOOST_TEST_EQ( dealloc_count, 0 ); fv.assign( &do_nothing, std::allocator() ); fv.clear(); @@ -133,5 +132,5 @@ test_main(int, char*[]) fv.assign(&do_nothing, std::allocator() ); fv2.assign(fv, std::allocator() ); - return 0; + return boost::report_errors(); } diff --git a/test/lambda_test.cpp b/test/lambda_test.cpp index 2abca54..7def0fa 100644 --- a/test/lambda_test.cpp +++ b/test/lambda_test.cpp @@ -7,13 +7,13 @@ // For more information, see http://www.boost.org +#include +#include +#include +#include #include #include -#include -#include -#include -#include static unsigned func_impl(int arg1, bool arg2, double arg3) @@ -22,17 +22,19 @@ func_impl(int arg1, bool arg2, double arg3) return abs (static_cast((arg2 ? arg1 : 2 * arg1) * arg3)); } -int test_main(int, char*[]) +int main() { using boost::function; using namespace boost::lambda; function f1 = bind(func_impl, 15, _1, _2); + BOOST_TEST_EQ( f1(true, 2.0), 30 ); + function f2 = boost::lambda::bind(f1, false, _1); + BOOST_TEST_EQ( f2(2.0), 60 ); + function f3 = boost::lambda::bind(f2, 4.0); + BOOST_TEST_EQ( f3(), 120 ); - f3(); - - return 0; + return boost::report_errors(); } - diff --git a/test/stateless_test.cpp b/test/stateless_test.cpp index 3bc9e45..5ec1b84 100644 --- a/test/stateless_test.cpp +++ b/test/stateless_test.cpp @@ -7,16 +7,18 @@ // For more information, see http://www.boost.org -#include #include +#include #include +#include struct stateless_integer_add { int operator()(int x, int y) const { return x+y; } - void* operator new(std::size_t) + void* operator new(std::size_t n) { - throw std::runtime_error("Cannot allocate a stateless_integer_add"); + BOOST_ERROR( "stateless_integer_add incorrectly allocated" ); + return ::operator new( n ); } void* operator new(std::size_t, void* p) @@ -24,15 +26,17 @@ struct stateless_integer_add { return p; } - void operator delete(void*) throw() + void operator delete(void* p) throw() { + BOOST_ERROR( "stateless_integer_add incorrectly deallocated" ); + return ::operator delete( p ); } }; -int test_main(int, char*[]) +int main() { boost::function2 f; f = stateless_integer_add(); - return 0; + return boost::report_errors(); }