mirror of
https://github.com/boostorg/function.git
synced 2025-07-22 17:07:14 +02:00
allocator_test.cpp:
function_test.cpp: - Test out the new function syntax [SVN r14532]
This commit is contained in:
@ -84,5 +84,14 @@ test_main(int, char*[])
|
||||
fv = &do_nothing;
|
||||
fv.clear();
|
||||
|
||||
function<int (int, int), empty_function_policy, empty_function_mixin,
|
||||
counting_allocator<int> > f2;
|
||||
alloc_count = 0;
|
||||
dealloc_count = 0;
|
||||
f2 = plus<int>();
|
||||
f2.clear();
|
||||
BOOST_TEST(alloc_count == 1);
|
||||
BOOST_TEST(dealloc_count == 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -632,6 +632,28 @@ test_ref()
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_new_syntax()
|
||||
{
|
||||
write_five_obj five;
|
||||
function<void()> v2;
|
||||
|
||||
// Assignment
|
||||
v2 = five;
|
||||
BOOST_TEST(!v2.empty());
|
||||
|
||||
// Invocation
|
||||
global_int = 0;
|
||||
v2();
|
||||
|
||||
BOOST_TEST(global_int == 5);
|
||||
function<string (const string& x, const string& y)> cat(&string_cat);
|
||||
BOOST_TEST(cat("str", "ing") == "string");
|
||||
|
||||
function<int (short lhs, short rhs)> sum(&sum_ints);
|
||||
BOOST_TEST(sum(2, 3) == 5);
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_zero_args();
|
||||
@ -640,6 +662,7 @@ int test_main(int, char* [])
|
||||
test_emptiness();
|
||||
test_member_functions();
|
||||
test_ref();
|
||||
test_new_syntax();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user