mirror of
https://github.com/boostorg/local_function.git
synced 2026-01-27 19:02:16 +00:00
Added test for sequence syntax (to run with and without variadic macro support) and disabled variadic syntax test when variadic macros are not supported.
Updated docs. [SVN r77078]
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
// Home at http://www.boost.org/libs/local_function
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifndef BOOST_NO_VARIADIC_MACROS
|
||||
|
||||
#include <boost/local_function.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#define BOOST_TEST_MODULE TestReturnAssign
|
||||
@@ -12,8 +15,8 @@
|
||||
#include <iostream>
|
||||
|
||||
//[return_assign
|
||||
void call1(boost::function<int (int) > f) { BOOST_CHECK( f(1) == 5 ); }
|
||||
void call0(boost::function<int (void)> f) { BOOST_CHECK( f() == 5 ); }
|
||||
void call1(boost::function<int (int) > f) { BOOST_CHECK(f(1) == 5); }
|
||||
void call0(boost::function<int (void)> f) { BOOST_CHECK(f() == 5); }
|
||||
|
||||
boost::function<int (int, int)> linear(const int& slope) {
|
||||
int BOOST_LOCAL_FUNCTION(const bind& slope,
|
||||
@@ -22,7 +25,7 @@ boost::function<int (int, int)> linear(const int& slope) {
|
||||
} BOOST_LOCAL_FUNCTION_NAME(lin)
|
||||
|
||||
boost::function<int (int, int)> f = lin; // Assign to local variable.
|
||||
BOOST_CHECK( f(1, 2) == 5 );
|
||||
BOOST_CHECK(f(1, 2) == 5);
|
||||
|
||||
call1(lin); // Pass to other functions.
|
||||
call0(lin);
|
||||
@@ -32,11 +35,17 @@ boost::function<int (int, int)> linear(const int& slope) {
|
||||
|
||||
void call(void) {
|
||||
boost::function<int (int, int)> f = linear(2);
|
||||
BOOST_CHECK( f(1, 2) == 5 );
|
||||
BOOST_CHECK(f(1, 2) == 5);
|
||||
}
|
||||
//]
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_return_assign ) {
|
||||
BOOST_AUTO_TEST_CASE(test_return_assign) {
|
||||
call();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(void) { return 0; } // Trivial test.
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user