diff --git a/test/allocator_test.cpp b/test/allocator_test.cpp index 9864dfe..7e12d48 100644 --- a/test/allocator_test.cpp +++ b/test/allocator_test.cpp @@ -41,11 +41,20 @@ struct counting_allocator : public std::allocator } }; +struct plus_int +{ + int operator()(int x, int y) const { return x + y; } + + int unused_state_data; +}; + static int do_minus(int x, int y) { return x-y; } struct DoNothing { void operator()() const {} + + int unused_state_data; }; static void do_nothing() {} @@ -54,7 +63,7 @@ int test_main(int, char*[]) { function2 > f; - f = plus(); + f = plus_int(); f.clear(); BOOST_CHECK(alloc_count == 1); BOOST_CHECK(dealloc_count == 1); @@ -63,6 +72,8 @@ test_main(int, char*[]) dealloc_count = 0; f = &do_minus; f.clear(); + BOOST_CHECK(alloc_count == 0); + BOOST_CHECK(dealloc_count == 0); function0 > fv; alloc_count = 0; @@ -76,6 +87,8 @@ test_main(int, char*[]) dealloc_count = 0; fv = &do_nothing; fv.clear(); + BOOST_CHECK(alloc_count == 0); + BOOST_CHECK(dealloc_count == 0); return 0; } diff --git a/test/function_test.cpp b/test/function_test.cpp index f8a9227..47fdba4 100644 --- a/test/function_test.cpp +++ b/test/function_test.cpp @@ -630,70 +630,6 @@ test_ref() } } -static int alloc_count = 0; -static int dealloc_count = 0; - -template -struct counting_allocator : public allocator -{ - template - struct rebind - { - typedef counting_allocator other; - }; - - - T* allocate(size_t n) - { - alloc_count++; - return allocator::allocate(n); - } - - void deallocate(T* p, size_t n) - { - dealloc_count++; - allocator::deallocate(p, n); - } -}; - -static int do_minus(int x, int y) { return x-y; } - -struct DoNothing -{ - void operator()() const {} -}; - -static void do_nothing() {} - -static void test_allocator() -{ -#ifndef BOOST_NO_STD_ALLOCATOR - boost::function > f; - f = plus(); - f.clear(); - BOOST_CHECK(alloc_count == 1); - BOOST_CHECK(dealloc_count == 1); - - alloc_count = 0; - dealloc_count = 0; - f = &do_minus; - f.clear(); - - boost::function > fv; - alloc_count = 0; - dealloc_count = 0; - fv = DoNothing(); - fv.clear(); - BOOST_CHECK(alloc_count == 1); - BOOST_CHECK(dealloc_count == 1); - - alloc_count = 0; - dealloc_count = 0; - fv = &do_nothing; - fv.clear(); -#endif // ndef BOOST_NO_STD_ALLOCATOR -} - static void test_exception() { boost::function f; @@ -739,7 +675,6 @@ int test_main(int, char* []) test_emptiness(); test_member_functions(); test_ref(); - test_allocator(); test_exception(); test_implicit(); test_call();