diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 93d16b4..39408eb 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -7,69 +7,31 @@ # For more information, see http://www.boost.org/ -project - : requirements msvc:on - : source-location $(BOOST_ROOT) - ; - -# bring in rules for testing import testing ; -{ - - test-suite function - : - [ run libs/function/test/function_test.cpp : : : : lib_function_test ] - - [ run libs/function/test/function_test.cpp : : : off : lib_function_test_no_rtti ] - - [ 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/stateless_test.cpp ../../../libs/test/build//boost_test_exec_monitor : : : : ] - - [ run libs/function/test/lambda_test.cpp ../../../libs/test/build//boost_test_exec_monitor : : : : ] - - [ compile-fail libs/function/test/function_test_fail1.cpp : : : : ] - - [ compile-fail libs/function/test/function_test_fail2.cpp : : : : ] - - [ compile libs/function/test/function_30.cpp : : : : ] - - [ compile libs/function/test/function_30_repeat.cpp : : : : ] - - [ run libs/function/test/function_arith_cxx98.cpp : : : : ] - - [ run libs/function/test/function_arith_portable.cpp : : : : ] - - [ run libs/function/test/sum_avg_cxx98.cpp : : : : ] - - [ run libs/function/test/sum_avg_portable.cpp : : : : ] - - [ run libs/function/test/mem_fun_cxx98.cpp : : : : ] - - [ run libs/function/test/mem_fun_portable.cpp : : : : ] - - [ run libs/function/test/std_bind_cxx98.cpp : : : : ] - - [ run libs/function/test/std_bind_portable.cpp : : : : ] - - [ run libs/function/test/function_ref_cxx98.cpp : : : : ] - - [ run libs/function/test/function_ref_portable.cpp : : : : ] - - [ run libs/function/test/contains_test.cpp : : : : ] - - [ run libs/function/test/contains2_test.cpp : : : : ] - - [ run libs/function/test/nothrow_swap.cpp : : : : ] - - [ run libs/function/test/rvalues_test.cpp : : : : ] - - [ compile libs/function/test/function_typeof_test.cpp ] - - [ run libs/function/test/result_arg_types_test.cpp ] - ; -} - +run function_test.cpp ; +run function_test.cpp : : : off gcc-4.4.7,0x:no : function_test_no_rtti ; +run function_n_test.cpp ; +run allocator_test.cpp ; +run stateless_test.cpp ; +run lambda_test.cpp ; +compile-fail function_test_fail1.cpp ; +compile-fail function_test_fail2.cpp ; +compile function_30.cpp ; +compile function_30_repeat.cpp ; +run function_arith_cxx98.cpp ; +run function_arith_portable.cpp ; +run sum_avg_cxx98.cpp ; +run sum_avg_portable.cpp ; +run mem_fun_cxx98.cpp ; +run mem_fun_portable.cpp ; +run std_bind_cxx98.cpp ; +run std_bind_portable.cpp ; +run function_ref_cxx98.cpp ; +run function_ref_portable.cpp ; +run contains_test.cpp ; +run contains2_test.cpp ; +run nothrow_swap.cpp ; +run rvalues_test.cpp ; +compile function_typeof_test.cpp ; +run result_arg_types_test.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(); }