mirror of
https://github.com/boostorg/lambda.git
synced 2026-01-21 04:52:25 +00:00
Compare commits
14 Commits
boost-1.32
...
boost-1.34
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1543b68314 | ||
|
|
b112fb9254 | ||
|
|
13ec0c5bbc | ||
|
|
29ab5a2814 | ||
|
|
a0cfe43611 | ||
|
|
fe858cf734 | ||
|
|
b3120233dc | ||
|
|
24e8602cf1 | ||
|
|
7f77f987c1 | ||
|
|
d854239945 | ||
|
|
4aef261258 | ||
|
|
6b67606f40 | ||
|
|
b0ce56c74f | ||
|
|
9e45d49139 |
@@ -3,6 +3,10 @@
|
||||
<meta http-equiv="refresh" content="0; URL=../../../doc/html/lambda.html">
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to <a href="../../../doc/html/lambda.html">www.boost.org/doc/html/lambda.html</a>
|
||||
Automatic redirection failed, please go to <a href="../../../doc/html/lambda.html">www.boost.org/doc/html/lambda.html</a> <hr>
|
||||
<p>© Copyright Beman Dawes, 2001</p>
|
||||
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file <a href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
|
||||
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -165,8 +165,8 @@ The STL contains predefined function objects for some common cases (such as <lit
|
||||
As an example, one possible implementation for the standard <literal>plus</literal> template is:
|
||||
|
||||
<programlisting>
|
||||
<![CDATA[template <class T> : public binary_function<T, T, T>
|
||||
struct plus {
|
||||
<![CDATA[template <class T>
|
||||
struct plus : public binary_function<T, T, T> {
|
||||
T operator()(const T& i, const T& j) const {
|
||||
return i + j;
|
||||
}
|
||||
@@ -2640,6 +2640,7 @@ which require that the argument types are references.
|
||||
<row><entry><literal><![CDATA[&]]></literal></entry><entry><literal><![CDATA[other_action<address_of_action>]]></literal></entry></row>
|
||||
<row><entry><literal><![CDATA[*]]></literal></entry><entry><literal><![CDATA[other_action<contents_of_action>]]></literal></entry></row>
|
||||
<row><entry><literal><![CDATA[,]]></literal></entry><entry><literal><![CDATA[other_action<comma_action>]]></literal></entry></row>
|
||||
<row><entry><literal><![CDATA[->*]]></literal></entry><entry><literal><![CDATA[other_action<member_pointer_action>]]></literal></entry></row>
|
||||
|
||||
</tbody>
|
||||
</tgroup>
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
|
||||
typedef T element_t;
|
||||
|
||||
// take all parameters as const rererences. Note that non-const references
|
||||
// take all parameters as const references. Note that non-const references
|
||||
// stay as they are.
|
||||
typedef typename boost::add_reference<
|
||||
typename boost::add_const<T>::type
|
||||
@@ -317,7 +317,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// These specializatoins provide a shorter notation to define actions.
|
||||
// These specializations provide a shorter notation to define actions.
|
||||
// These lambda_functor_base instances take care of the recursive evaluation
|
||||
// of the arguments and pass the evaluated arguments to the apply function
|
||||
// of an action class. To make action X work with these classes, one must
|
||||
|
||||
@@ -65,7 +65,7 @@ void do_nothing(A1&, A2&, A3&, A4&) {}
|
||||
} // lambda
|
||||
} // boost
|
||||
|
||||
// prevent the warnings from unused argumetns
|
||||
// prevent the warnings from unused arguments
|
||||
#define CALL_USE_ARGS \
|
||||
::boost::lambda::detail::do_nothing(a, b, c, env)
|
||||
|
||||
|
||||
@@ -858,9 +858,13 @@ struct return_type_2<other_action<subscript_action>, A, B> {
|
||||
} // namespace boost
|
||||
|
||||
|
||||
namespace std {
|
||||
template <class Char, class Traits, class Allocator> class basic_string;
|
||||
}
|
||||
// Forward declarations are incompatible with the libstdc++ debug mode.
|
||||
#if BOOST_WORKAROUND(__GNUC__, >= 3) && defined(_GLIBCXX_DEBUG)
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <deque>
|
||||
#else
|
||||
|
||||
// The GCC 2.95.x uses a non-conformant deque
|
||||
#if BOOST_WORKAROUND(__GNUC__, == 2) && __GNUC_MINOR__ <= 96
|
||||
@@ -873,12 +877,8 @@ namespace std {
|
||||
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__GNUC__, == 3) && __GNUC_MINOR__ >=4
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#else
|
||||
|
||||
namespace std {
|
||||
template <class Char, class Traits, class Allocator> class basic_string;
|
||||
template <class T, class Allocator> class vector;
|
||||
template <class Key, class T, class Cmp, class Allocator> class map;
|
||||
template <class Key, class T, class Cmp, class Allocator> class multimap;
|
||||
|
||||
@@ -48,7 +48,7 @@ struct try_catch_action {};
|
||||
struct throw_new_action {};
|
||||
struct rethrow_action {};
|
||||
|
||||
template<class ThrowType> class throw_action;
|
||||
template<class ThrowType> struct throw_action;
|
||||
|
||||
template<>
|
||||
struct throw_action<rethrow_action> {
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
<meta http-equiv="refresh" content="0; URL=../../doc/html/lambda.html">
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to <a href="../../doc/html/lambda.html">www.boost.org/doc/html/lambda.html</a>
|
||||
Automatic redirection failed, please go to <a href="../../doc/html/lambda.html">www.boost.org/doc/html/lambda.html</a> <hr>
|
||||
<p>© Copyright Beman Dawes, 2001</p>
|
||||
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
|
||||
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||
</body>
|
||||
</html>
|
||||
59
test/Jamfile
59
test/Jamfile
@@ -1,59 +0,0 @@
|
||||
# Lambda library
|
||||
|
||||
# Copyright (C) 2001-2003 Jaakko Järvi
|
||||
|
||||
# Use, modification and distribution is subject to the Boost Software License,
|
||||
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# For more information, see http://www.boost.org/
|
||||
|
||||
|
||||
subproject libs/lambda/test ;
|
||||
|
||||
# bring in rules for testing
|
||||
SEARCH on testing.jam = $(BOOST_BUILD_PATH) ;
|
||||
include testing.jam ;
|
||||
|
||||
# Make tests run by default.
|
||||
DEPENDS all : test ;
|
||||
|
||||
{
|
||||
# look in BOOST_ROOT for sources first, just in this Jamfile
|
||||
local SEARCH_SOURCE = $(BOOST_ROOT) $(SEARCH_SOURCE) ;
|
||||
|
||||
test-suite lambda
|
||||
:
|
||||
[ run libs/lambda/test/algorithm_test.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/bind_tests_simple.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/bind_tests_advanced.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/bind_tests_simple_f_refs.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/bll_and_function.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/cast_test.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/constructor_tests.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/control_structures.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/exception_test.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/extending_rt_traits.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/is_instance_of_test.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/member_pointer_test.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/operator_tests_simple.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/phoenix_control_structures.cpp : : : : ]
|
||||
|
||||
[ run libs/lambda/test/switch_construct.cpp : : : : ]
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
BOOST = ../../..
|
||||
|
||||
CXX = gcc
|
||||
EXTRAFLAGS = -pedantic -Wno-long-long -ftemplate-depth-50
|
||||
CXX = g++
|
||||
EXTRAFLAGS = -pedantic -Wno-long-long -Wno-long-double -ftemplate-depth-50
|
||||
LIBS = -lstdc++
|
||||
|
||||
#CXX = KCC
|
||||
|
||||
@@ -41,7 +41,7 @@ void test_foreach() {
|
||||
bind(ll::for_each(), _1, _1 + 20,
|
||||
protect((sum += _1))));
|
||||
|
||||
BOOST_TEST(sum == (199 + 1)/ 2 * 199);
|
||||
BOOST_CHECK(sum == (199 + 1)/ 2 * 199);
|
||||
}
|
||||
|
||||
// More tests needed (for all algorithms)
|
||||
|
||||
@@ -60,16 +60,16 @@ void test_nested_binds()
|
||||
bool condition;
|
||||
|
||||
condition = true;
|
||||
BOOST_TEST(bind(bind(&sum_or_product, _1), 1, 2)(condition)==3);
|
||||
BOOST_TEST(bind(bind(&sum_or_product, _1), _2, _3)(condition, j, k)==5);
|
||||
BOOST_CHECK(bind(bind(&sum_or_product, _1), 1, 2)(condition)==3);
|
||||
BOOST_CHECK(bind(bind(&sum_or_product, _1), _2, _3)(condition, j, k)==5);
|
||||
|
||||
condition = false;
|
||||
BOOST_TEST(bind(bind(&sum_or_product, _1), 1, 2)(condition)==2);
|
||||
BOOST_TEST(bind(bind(&sum_or_product, _1), _2, _3)(condition, j, k)==6);
|
||||
BOOST_CHECK(bind(bind(&sum_or_product, _1), 1, 2)(condition)==2);
|
||||
BOOST_CHECK(bind(bind(&sum_or_product, _1), _2, _3)(condition, j, k)==6);
|
||||
|
||||
|
||||
which_one wo;
|
||||
BOOST_TEST(bind(bind(bind(wo), _1), _2, _3)(condition, j, k)==6);
|
||||
BOOST_CHECK(bind(bind(bind(wo), _1), _2, _3)(condition, j, k)==6);
|
||||
|
||||
|
||||
return;
|
||||
@@ -109,14 +109,14 @@ void test_unlambda() {
|
||||
|
||||
int i = 1;
|
||||
|
||||
BOOST_TEST(unlambda(_1 + _2)(i, i) == 2);
|
||||
BOOST_TEST(unlambda(++var(i))() == 2);
|
||||
BOOST_TEST(call_with_100(_1 + 1) == 101);
|
||||
BOOST_CHECK(unlambda(_1 + _2)(i, i) == 2);
|
||||
BOOST_CHECK(unlambda(++var(i))() == 2);
|
||||
BOOST_CHECK(call_with_100(_1 + 1) == 101);
|
||||
|
||||
|
||||
BOOST_TEST(call_with_101(_1 + 1) == 102);
|
||||
BOOST_CHECK(call_with_101(_1 + 1) == 102);
|
||||
|
||||
BOOST_TEST(call_with_100(bind(std_functor(std::bind1st(std::plus<int>(), 1)), _1)) == 101);
|
||||
BOOST_CHECK(call_with_100(bind(std_functor(std::bind1st(std::plus<int>(), 1)), _1)) == 101);
|
||||
|
||||
// std_functor insturcts LL that the functor defines a result_type typedef
|
||||
// rather than a sig template.
|
||||
@@ -200,7 +200,7 @@ void test_protect()
|
||||
bind(ll::for_each(), _1, _1 + 5,
|
||||
protect(sum += _1))
|
||||
);
|
||||
BOOST_TEST(sum == (1+15)*15/2);
|
||||
BOOST_CHECK(sum == (1+15)*15/2);
|
||||
|
||||
sum = 0;
|
||||
|
||||
@@ -208,17 +208,17 @@ void test_protect()
|
||||
bind(ll::for_each(), _1, _1 + 5,
|
||||
sum += 1 + protect(_1)) // add element count
|
||||
);
|
||||
BOOST_TEST(sum == (1+15)*15/2 + 15);
|
||||
BOOST_CHECK(sum == (1+15)*15/2 + 15);
|
||||
|
||||
(1 + protect(_1))(sum);
|
||||
|
||||
int k = 0;
|
||||
((k += constant(1)) += protect(constant(2)))();
|
||||
BOOST_TEST(k==1);
|
||||
BOOST_CHECK(k==1);
|
||||
|
||||
k = 0;
|
||||
((k += constant(1)) += protect(constant(2)))()();
|
||||
BOOST_TEST(k==3);
|
||||
BOOST_CHECK(k==3);
|
||||
|
||||
// note, the following doesn't work:
|
||||
|
||||
@@ -276,10 +276,10 @@ void test_lambda_functors_as_arguments_to_lambda_functors() {
|
||||
// sum_0() + 7, but rather
|
||||
// bind(sum_0) + 7, which results in another lambda functor
|
||||
// (lambda functor + int) and can be called again
|
||||
BOOST_TEST((_1 + _2)(bind(&sum_0), make_const(7))() == 7);
|
||||
BOOST_CHECK((_1 + _2)(bind(&sum_0), make_const(7))() == 7);
|
||||
|
||||
int i = 3, j = 12;
|
||||
BOOST_TEST((_1 - _2)(_2, _1)(i, j) == j - i);
|
||||
BOOST_CHECK((_1 - _2)(_2, _1)(i, j) == j - i);
|
||||
|
||||
// also, note that lambda functor are no special case for bind if received
|
||||
// as a parameter. In oder to be bindable, the functor must
|
||||
@@ -292,12 +292,12 @@ void test_lambda_functors_as_arguments_to_lambda_functors() {
|
||||
int a = 5, b = 6;
|
||||
|
||||
// Let type deduction find out the return type
|
||||
BOOST_TEST(bind(_1, _2, _3)(unlambda(_1 + _2), a, b) == 11);
|
||||
BOOST_CHECK(bind(_1, _2, _3)(unlambda(_1 + _2), a, b) == 11);
|
||||
|
||||
//specify it yourself:
|
||||
BOOST_TEST(bind(_1, _2, _3)(ret<int>(_1 + _2), a, b) == 11);
|
||||
BOOST_TEST(ret<int>(bind(_1, _2, _3))(_1 + _2, a, b) == 11);
|
||||
BOOST_TEST(bind<int>(_1, _2, _3)(_1 + _2, a, b) == 11);
|
||||
BOOST_CHECK(bind(_1, _2, _3)(ret<int>(_1 + _2), a, b) == 11);
|
||||
BOOST_CHECK(ret<int>(bind(_1, _2, _3))(_1 + _2, a, b) == 11);
|
||||
BOOST_CHECK(bind<int>(_1, _2, _3)(_1 + _2, a, b) == 11);
|
||||
|
||||
bind(_1,1.0)(_1+_1);
|
||||
return;
|
||||
@@ -310,10 +310,10 @@ void test_const_parameters() {
|
||||
// (_1 + _2)(1, 2); // this would fail,
|
||||
|
||||
// Either make arguments const:
|
||||
BOOST_TEST((_1 + _2)(make_const(1), make_const(2)) == 3);
|
||||
BOOST_CHECK((_1 + _2)(make_const(1), make_const(2)) == 3);
|
||||
|
||||
// Or use const_parameters:
|
||||
BOOST_TEST(const_parameters(_1 + _2)(1, 2) == 3);
|
||||
BOOST_CHECK(const_parameters(_1 + _2)(1, 2) == 3);
|
||||
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ void test_rvalue_arguments()
|
||||
{
|
||||
// Not quite working yet.
|
||||
// Problems with visual 7.1
|
||||
// BOOST_TEST((_1 + _2)(1, 2) == 3);
|
||||
// BOOST_CHECK((_1 + _2)(1, 2) == 3);
|
||||
}
|
||||
|
||||
void test_break_const()
|
||||
@@ -348,7 +348,7 @@ void test_break_const()
|
||||
// OLD COMMENT: (_1 += _2)(i, 2) // fails, 2 is a non-const rvalue
|
||||
// OLD COMMENT: const_parameters(_1 += _2)(i, 2) // fails, side-effect to i
|
||||
break_const(_1 += _2)(i, 2); // ok
|
||||
BOOST_TEST(i == 3);
|
||||
BOOST_CHECK(i == 3);
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
|
||||
@@ -65,18 +65,18 @@ void test_member_functions()
|
||||
|
||||
|
||||
|
||||
BOOST_TEST(bind(&A::add, ref(a), _1)(i) == 11);
|
||||
BOOST_TEST(bind(&A::add, &a, _1)(i) == 11);
|
||||
BOOST_TEST(bind(&A::add, _1, 1)(a) == 11);
|
||||
BOOST_TEST(bind(&A::add, _1, 1)(make_const(&a)) == 11);
|
||||
BOOST_CHECK(bind(&A::add, ref(a), _1)(i) == 11);
|
||||
BOOST_CHECK(bind(&A::add, &a, _1)(i) == 11);
|
||||
BOOST_CHECK(bind(&A::add, _1, 1)(a) == 11);
|
||||
BOOST_CHECK(bind(&A::add, _1, 1)(make_const(&a)) == 11);
|
||||
|
||||
BOOST_TEST(bind(&A::add2, _1, 1, 1)(a) == 12);
|
||||
BOOST_TEST(bind(&A::add3, _1, 1, 1, 1)(a) == 13);
|
||||
BOOST_TEST(bind(&A::add4, _1, 1, 1, 1, 1)(a) == 14);
|
||||
BOOST_TEST(bind(&A::add5, _1, 1, 1, 1, 1, 1)(a) == 15);
|
||||
BOOST_TEST(bind(&A::add6, _1, 1, 1, 1, 1, 1, 1)(a) == 16);
|
||||
BOOST_TEST(bind(&A::add7, _1, 1, 1, 1, 1, 1, 1, 1)(a) == 17);
|
||||
BOOST_TEST(bind(&A::add8, _1, 1, 1, 1, 1, 1, 1, 1, 1)(a) == 18);
|
||||
BOOST_CHECK(bind(&A::add2, _1, 1, 1)(a) == 12);
|
||||
BOOST_CHECK(bind(&A::add3, _1, 1, 1, 1)(a) == 13);
|
||||
BOOST_CHECK(bind(&A::add4, _1, 1, 1, 1, 1)(a) == 14);
|
||||
BOOST_CHECK(bind(&A::add5, _1, 1, 1, 1, 1, 1)(a) == 15);
|
||||
BOOST_CHECK(bind(&A::add6, _1, 1, 1, 1, 1, 1, 1)(a) == 16);
|
||||
BOOST_CHECK(bind(&A::add7, _1, 1, 1, 1, 1, 1, 1, 1)(a) == 17);
|
||||
BOOST_CHECK(bind(&A::add8, _1, 1, 1, 1, 1, 1, 1, 1, 1)(a) == 18);
|
||||
|
||||
// This should fail, as lambda functors store arguments as const
|
||||
// bind(&A::add, a, _1);
|
||||
@@ -88,56 +88,56 @@ int test_main(int, char *[]) {
|
||||
int result;
|
||||
|
||||
// bind all parameters
|
||||
BOOST_TEST(bind(&sum_of_args_0)()==0);
|
||||
BOOST_TEST(bind(&sum_of_args_1, 1)()==1);
|
||||
BOOST_TEST(bind(&sum_of_args_2, 1, 2)()==3);
|
||||
BOOST_TEST(bind(&sum_of_args_3, 1, 2, 3)()==6);
|
||||
BOOST_TEST(bind(&sum_of_args_4, 1, 2, 3, 4)()==10);
|
||||
BOOST_TEST(bind(&sum_of_args_5, 1, 2, 3, 4, 5)()==15);
|
||||
BOOST_TEST(bind(&sum_of_args_6, 1, 2, 3, 4, 5, 6)()==21);
|
||||
BOOST_TEST(bind(&sum_of_args_7, 1, 2, 3, 4, 5, 6, 7)()==28);
|
||||
BOOST_TEST(bind(&sum_of_args_8, 1, 2, 3, 4, 5, 6, 7, 8)()==36);
|
||||
BOOST_TEST(bind(&sum_of_args_9, 1, 2, 3, 4, 5, 6, 7, 8, 9)()==45);
|
||||
BOOST_CHECK(bind(&sum_of_args_0)()==0);
|
||||
BOOST_CHECK(bind(&sum_of_args_1, 1)()==1);
|
||||
BOOST_CHECK(bind(&sum_of_args_2, 1, 2)()==3);
|
||||
BOOST_CHECK(bind(&sum_of_args_3, 1, 2, 3)()==6);
|
||||
BOOST_CHECK(bind(&sum_of_args_4, 1, 2, 3, 4)()==10);
|
||||
BOOST_CHECK(bind(&sum_of_args_5, 1, 2, 3, 4, 5)()==15);
|
||||
BOOST_CHECK(bind(&sum_of_args_6, 1, 2, 3, 4, 5, 6)()==21);
|
||||
BOOST_CHECK(bind(&sum_of_args_7, 1, 2, 3, 4, 5, 6, 7)()==28);
|
||||
BOOST_CHECK(bind(&sum_of_args_8, 1, 2, 3, 4, 5, 6, 7, 8)()==36);
|
||||
BOOST_CHECK(bind(&sum_of_args_9, 1, 2, 3, 4, 5, 6, 7, 8, 9)()==45);
|
||||
|
||||
// first parameter open
|
||||
BOOST_TEST(bind(&sum_of_args_0)()==0);
|
||||
BOOST_TEST(bind(&sum_of_args_1, _1)(i)==1);
|
||||
BOOST_TEST(bind(&sum_of_args_2, _1, 2)(i)==3);
|
||||
BOOST_TEST(bind(&sum_of_args_3, _1, 2, 3)(i)==6);
|
||||
BOOST_TEST(bind(&sum_of_args_4, _1, 2, 3, 4)(i)==10);
|
||||
BOOST_TEST(bind(&sum_of_args_5, _1, 2, 3, 4, 5)(i)==15);
|
||||
BOOST_TEST(bind(&sum_of_args_6, _1, 2, 3, 4, 5, 6)(i)==21);
|
||||
BOOST_TEST(bind(&sum_of_args_7, _1, 2, 3, 4, 5, 6, 7)(i)==28);
|
||||
BOOST_TEST(bind(&sum_of_args_8, _1, 2, 3, 4, 5, 6, 7, 8)(i)==36);
|
||||
BOOST_TEST(bind(&sum_of_args_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i)==45);
|
||||
BOOST_CHECK(bind(&sum_of_args_0)()==0);
|
||||
BOOST_CHECK(bind(&sum_of_args_1, _1)(i)==1);
|
||||
BOOST_CHECK(bind(&sum_of_args_2, _1, 2)(i)==3);
|
||||
BOOST_CHECK(bind(&sum_of_args_3, _1, 2, 3)(i)==6);
|
||||
BOOST_CHECK(bind(&sum_of_args_4, _1, 2, 3, 4)(i)==10);
|
||||
BOOST_CHECK(bind(&sum_of_args_5, _1, 2, 3, 4, 5)(i)==15);
|
||||
BOOST_CHECK(bind(&sum_of_args_6, _1, 2, 3, 4, 5, 6)(i)==21);
|
||||
BOOST_CHECK(bind(&sum_of_args_7, _1, 2, 3, 4, 5, 6, 7)(i)==28);
|
||||
BOOST_CHECK(bind(&sum_of_args_8, _1, 2, 3, 4, 5, 6, 7, 8)(i)==36);
|
||||
BOOST_CHECK(bind(&sum_of_args_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i)==45);
|
||||
|
||||
// two open arguments
|
||||
BOOST_TEST(bind(&sum_of_args_0)()==0);
|
||||
BOOST_TEST(bind(&sum_of_args_1, _1)(i)==1);
|
||||
BOOST_TEST(bind(&sum_of_args_2, _1, _2)(i, j)==3);
|
||||
BOOST_TEST(bind(&sum_of_args_3, _1, _2, 3)(i, j)==6);
|
||||
BOOST_TEST(bind(&sum_of_args_4, _1, _2, 3, 4)(i, j)==10);
|
||||
BOOST_TEST(bind(&sum_of_args_5, _1, _2, 3, 4, 5)(i, j)==15);
|
||||
BOOST_TEST(bind(&sum_of_args_6, _1, _2, 3, 4, 5, 6)(i, j)==21);
|
||||
BOOST_TEST(bind(&sum_of_args_7, _1, _2, 3, 4, 5, 6, 7)(i, j)==28);
|
||||
BOOST_TEST(bind(&sum_of_args_8, _1, _2, 3, 4, 5, 6, 7, 8)(i, j)==36);
|
||||
BOOST_TEST(bind(&sum_of_args_9, _1, _2, 3, 4, 5, 6, 7, 8, 9)(i, j)==45);
|
||||
BOOST_CHECK(bind(&sum_of_args_0)()==0);
|
||||
BOOST_CHECK(bind(&sum_of_args_1, _1)(i)==1);
|
||||
BOOST_CHECK(bind(&sum_of_args_2, _1, _2)(i, j)==3);
|
||||
BOOST_CHECK(bind(&sum_of_args_3, _1, _2, 3)(i, j)==6);
|
||||
BOOST_CHECK(bind(&sum_of_args_4, _1, _2, 3, 4)(i, j)==10);
|
||||
BOOST_CHECK(bind(&sum_of_args_5, _1, _2, 3, 4, 5)(i, j)==15);
|
||||
BOOST_CHECK(bind(&sum_of_args_6, _1, _2, 3, 4, 5, 6)(i, j)==21);
|
||||
BOOST_CHECK(bind(&sum_of_args_7, _1, _2, 3, 4, 5, 6, 7)(i, j)==28);
|
||||
BOOST_CHECK(bind(&sum_of_args_8, _1, _2, 3, 4, 5, 6, 7, 8)(i, j)==36);
|
||||
BOOST_CHECK(bind(&sum_of_args_9, _1, _2, 3, 4, 5, 6, 7, 8, 9)(i, j)==45);
|
||||
|
||||
// three open arguments
|
||||
BOOST_TEST(bind(&sum_of_args_0)()==0);
|
||||
BOOST_TEST(bind(&sum_of_args_1, _1)(i)==1);
|
||||
BOOST_TEST(bind(&sum_of_args_2, _1, _2)(i, j)==3);
|
||||
BOOST_TEST(bind(&sum_of_args_3, _1, _2, _3)(i, j, k)==6);
|
||||
BOOST_TEST(bind(&sum_of_args_4, _1, _2, _3, 4)(i, j, k)==10);
|
||||
BOOST_TEST(bind(&sum_of_args_5, _1, _2, _3, 4, 5)(i, j, k)==15);
|
||||
BOOST_TEST(bind(&sum_of_args_6, _1, _2, _3, 4, 5, 6)(i, j, k)==21);
|
||||
BOOST_TEST(bind(&sum_of_args_7, _1, _2, _3, 4, 5, 6, 7)(i, j, k)==28);
|
||||
BOOST_TEST(bind(&sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8)(i, j, k)==36);
|
||||
BOOST_TEST(bind(&sum_of_args_9, _1, _2, _3, 4, 5, 6, 7, 8, 9)(i, j, k)==45);
|
||||
BOOST_CHECK(bind(&sum_of_args_0)()==0);
|
||||
BOOST_CHECK(bind(&sum_of_args_1, _1)(i)==1);
|
||||
BOOST_CHECK(bind(&sum_of_args_2, _1, _2)(i, j)==3);
|
||||
BOOST_CHECK(bind(&sum_of_args_3, _1, _2, _3)(i, j, k)==6);
|
||||
BOOST_CHECK(bind(&sum_of_args_4, _1, _2, _3, 4)(i, j, k)==10);
|
||||
BOOST_CHECK(bind(&sum_of_args_5, _1, _2, _3, 4, 5)(i, j, k)==15);
|
||||
BOOST_CHECK(bind(&sum_of_args_6, _1, _2, _3, 4, 5, 6)(i, j, k)==21);
|
||||
BOOST_CHECK(bind(&sum_of_args_7, _1, _2, _3, 4, 5, 6, 7)(i, j, k)==28);
|
||||
BOOST_CHECK(bind(&sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8)(i, j, k)==36);
|
||||
BOOST_CHECK(bind(&sum_of_args_9, _1, _2, _3, 4, 5, 6, 7, 8, 9)(i, j, k)==45);
|
||||
|
||||
// function compositions with bind
|
||||
BOOST_TEST(bind(&sum_of_args_3, bind(&sum_of_args_2, _1, 2), 2, 3)(i)==8);
|
||||
BOOST_TEST(
|
||||
BOOST_CHECK(bind(&sum_of_args_3, bind(&sum_of_args_2, _1, 2), 2, 3)(i)==8);
|
||||
BOOST_CHECK(
|
||||
bind(&sum_of_args_9,
|
||||
bind(&sum_of_args_0), // 0
|
||||
bind(&sum_of_args_1, _1), // 1
|
||||
@@ -163,7 +163,7 @@ int test_main(int, char *[]) {
|
||||
_3,
|
||||
4)
|
||||
)(i, j, k);
|
||||
BOOST_TEST(result == 12);
|
||||
BOOST_CHECK(result == 12);
|
||||
|
||||
test_member_functions();
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@ void test_member_functions()
|
||||
A a(10);
|
||||
int i = 1;
|
||||
|
||||
BOOST_TEST(bind(&A::add, ref(a), _1)(i) == 11);
|
||||
BOOST_TEST(bind(&A::add, &a, _1)(i) == 11);
|
||||
BOOST_TEST(bind(&A::add, _1, 1)(a) == 11);
|
||||
BOOST_TEST(bind(&A::add, _1, 1)(make_const(&a)) == 11);
|
||||
BOOST_CHECK(bind(&A::add, ref(a), _1)(i) == 11);
|
||||
BOOST_CHECK(bind(&A::add, &a, _1)(i) == 11);
|
||||
BOOST_CHECK(bind(&A::add, _1, 1)(a) == 11);
|
||||
BOOST_CHECK(bind(&A::add, _1, 1)(make_const(&a)) == 11);
|
||||
|
||||
// This should fail, as lambda functors store arguments as const
|
||||
// bind(&A::add, a, _1);
|
||||
@@ -66,56 +66,56 @@ int test_main(int, char *[]) {
|
||||
|
||||
|
||||
// bind all parameters
|
||||
BOOST_TEST(bind(sum_of_args_0)()==0);
|
||||
BOOST_TEST(bind(sum_of_args_1, 1)()==1);
|
||||
BOOST_TEST(bind(sum_of_args_2, 1, 2)()==3);
|
||||
BOOST_TEST(bind(sum_of_args_3, 1, 2, 3)()==6);
|
||||
BOOST_TEST(bind(sum_of_args_4, 1, 2, 3, 4)()==10);
|
||||
BOOST_TEST(bind(sum_of_args_5, 1, 2, 3, 4, 5)()==15);
|
||||
BOOST_TEST(bind(sum_of_args_6, 1, 2, 3, 4, 5, 6)()==21);
|
||||
BOOST_TEST(bind(sum_of_args_7, 1, 2, 3, 4, 5, 6, 7)()==28);
|
||||
BOOST_TEST(bind(sum_of_args_8, 1, 2, 3, 4, 5, 6, 7, 8)()==36);
|
||||
BOOST_TEST(bind(sum_of_args_9, 1, 2, 3, 4, 5, 6, 7, 8, 9)()==45);
|
||||
BOOST_CHECK(bind(sum_of_args_0)()==0);
|
||||
BOOST_CHECK(bind(sum_of_args_1, 1)()==1);
|
||||
BOOST_CHECK(bind(sum_of_args_2, 1, 2)()==3);
|
||||
BOOST_CHECK(bind(sum_of_args_3, 1, 2, 3)()==6);
|
||||
BOOST_CHECK(bind(sum_of_args_4, 1, 2, 3, 4)()==10);
|
||||
BOOST_CHECK(bind(sum_of_args_5, 1, 2, 3, 4, 5)()==15);
|
||||
BOOST_CHECK(bind(sum_of_args_6, 1, 2, 3, 4, 5, 6)()==21);
|
||||
BOOST_CHECK(bind(sum_of_args_7, 1, 2, 3, 4, 5, 6, 7)()==28);
|
||||
BOOST_CHECK(bind(sum_of_args_8, 1, 2, 3, 4, 5, 6, 7, 8)()==36);
|
||||
BOOST_CHECK(bind(sum_of_args_9, 1, 2, 3, 4, 5, 6, 7, 8, 9)()==45);
|
||||
|
||||
// first parameter open
|
||||
BOOST_TEST(bind(sum_of_args_0)()==0);
|
||||
BOOST_TEST(bind(sum_of_args_1, _1)(i)==1);
|
||||
BOOST_TEST(bind(sum_of_args_2, _1, 2)(i)==3);
|
||||
BOOST_TEST(bind(sum_of_args_3, _1, 2, 3)(i)==6);
|
||||
BOOST_TEST(bind(sum_of_args_4, _1, 2, 3, 4)(i)==10);
|
||||
BOOST_TEST(bind(sum_of_args_5, _1, 2, 3, 4, 5)(i)==15);
|
||||
BOOST_TEST(bind(sum_of_args_6, _1, 2, 3, 4, 5, 6)(i)==21);
|
||||
BOOST_TEST(bind(sum_of_args_7, _1, 2, 3, 4, 5, 6, 7)(i)==28);
|
||||
BOOST_TEST(bind(sum_of_args_8, _1, 2, 3, 4, 5, 6, 7, 8)(i)==36);
|
||||
BOOST_TEST(bind(sum_of_args_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i)==45);
|
||||
BOOST_CHECK(bind(sum_of_args_0)()==0);
|
||||
BOOST_CHECK(bind(sum_of_args_1, _1)(i)==1);
|
||||
BOOST_CHECK(bind(sum_of_args_2, _1, 2)(i)==3);
|
||||
BOOST_CHECK(bind(sum_of_args_3, _1, 2, 3)(i)==6);
|
||||
BOOST_CHECK(bind(sum_of_args_4, _1, 2, 3, 4)(i)==10);
|
||||
BOOST_CHECK(bind(sum_of_args_5, _1, 2, 3, 4, 5)(i)==15);
|
||||
BOOST_CHECK(bind(sum_of_args_6, _1, 2, 3, 4, 5, 6)(i)==21);
|
||||
BOOST_CHECK(bind(sum_of_args_7, _1, 2, 3, 4, 5, 6, 7)(i)==28);
|
||||
BOOST_CHECK(bind(sum_of_args_8, _1, 2, 3, 4, 5, 6, 7, 8)(i)==36);
|
||||
BOOST_CHECK(bind(sum_of_args_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i)==45);
|
||||
|
||||
// two open arguments
|
||||
BOOST_TEST(bind(sum_of_args_0)()==0);
|
||||
BOOST_TEST(bind(sum_of_args_1, _1)(i)==1);
|
||||
BOOST_TEST(bind(sum_of_args_2, _1, _2)(i, j)==3);
|
||||
BOOST_TEST(bind(sum_of_args_3, _1, _2, 3)(i, j)==6);
|
||||
BOOST_TEST(bind(sum_of_args_4, _1, _2, 3, 4)(i, j)==10);
|
||||
BOOST_TEST(bind(sum_of_args_5, _1, _2, 3, 4, 5)(i, j)==15);
|
||||
BOOST_TEST(bind(sum_of_args_6, _1, _2, 3, 4, 5, 6)(i, j)==21);
|
||||
BOOST_TEST(bind(sum_of_args_7, _1, _2, 3, 4, 5, 6, 7)(i, j)==28);
|
||||
BOOST_TEST(bind(sum_of_args_8, _1, _2, 3, 4, 5, 6, 7, 8)(i, j)==36);
|
||||
BOOST_TEST(bind(sum_of_args_9, _1, _2, 3, 4, 5, 6, 7, 8, 9)(i, j)==45);
|
||||
BOOST_CHECK(bind(sum_of_args_0)()==0);
|
||||
BOOST_CHECK(bind(sum_of_args_1, _1)(i)==1);
|
||||
BOOST_CHECK(bind(sum_of_args_2, _1, _2)(i, j)==3);
|
||||
BOOST_CHECK(bind(sum_of_args_3, _1, _2, 3)(i, j)==6);
|
||||
BOOST_CHECK(bind(sum_of_args_4, _1, _2, 3, 4)(i, j)==10);
|
||||
BOOST_CHECK(bind(sum_of_args_5, _1, _2, 3, 4, 5)(i, j)==15);
|
||||
BOOST_CHECK(bind(sum_of_args_6, _1, _2, 3, 4, 5, 6)(i, j)==21);
|
||||
BOOST_CHECK(bind(sum_of_args_7, _1, _2, 3, 4, 5, 6, 7)(i, j)==28);
|
||||
BOOST_CHECK(bind(sum_of_args_8, _1, _2, 3, 4, 5, 6, 7, 8)(i, j)==36);
|
||||
BOOST_CHECK(bind(sum_of_args_9, _1, _2, 3, 4, 5, 6, 7, 8, 9)(i, j)==45);
|
||||
|
||||
// three open arguments
|
||||
BOOST_TEST(bind(sum_of_args_0)()==0);
|
||||
BOOST_TEST(bind(sum_of_args_1, _1)(i)==1);
|
||||
BOOST_TEST(bind(sum_of_args_2, _1, _2)(i, j)==3);
|
||||
BOOST_TEST(bind(sum_of_args_3, _1, _2, _3)(i, j, k)==6);
|
||||
BOOST_TEST(bind(sum_of_args_4, _1, _2, _3, 4)(i, j, k)==10);
|
||||
BOOST_TEST(bind(sum_of_args_5, _1, _2, _3, 4, 5)(i, j, k)==15);
|
||||
BOOST_TEST(bind(sum_of_args_6, _1, _2, _3, 4, 5, 6)(i, j, k)==21);
|
||||
BOOST_TEST(bind(sum_of_args_7, _1, _2, _3, 4, 5, 6, 7)(i, j, k)==28);
|
||||
BOOST_TEST(bind(sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8)(i, j, k)==36);
|
||||
BOOST_TEST(bind(sum_of_args_9, _1, _2, _3, 4, 5, 6, 7, 8, 9)(i, j, k)==45);
|
||||
BOOST_CHECK(bind(sum_of_args_0)()==0);
|
||||
BOOST_CHECK(bind(sum_of_args_1, _1)(i)==1);
|
||||
BOOST_CHECK(bind(sum_of_args_2, _1, _2)(i, j)==3);
|
||||
BOOST_CHECK(bind(sum_of_args_3, _1, _2, _3)(i, j, k)==6);
|
||||
BOOST_CHECK(bind(sum_of_args_4, _1, _2, _3, 4)(i, j, k)==10);
|
||||
BOOST_CHECK(bind(sum_of_args_5, _1, _2, _3, 4, 5)(i, j, k)==15);
|
||||
BOOST_CHECK(bind(sum_of_args_6, _1, _2, _3, 4, 5, 6)(i, j, k)==21);
|
||||
BOOST_CHECK(bind(sum_of_args_7, _1, _2, _3, 4, 5, 6, 7)(i, j, k)==28);
|
||||
BOOST_CHECK(bind(sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8)(i, j, k)==36);
|
||||
BOOST_CHECK(bind(sum_of_args_9, _1, _2, _3, 4, 5, 6, 7, 8, 9)(i, j, k)==45);
|
||||
|
||||
// function compositions with bind
|
||||
BOOST_TEST(bind(sum_of_args_3, bind(sum_of_args_2, _1, 2), 2, 3)(i)==8);
|
||||
BOOST_TEST(
|
||||
BOOST_CHECK(bind(sum_of_args_3, bind(sum_of_args_2, _1, 2), 2, 3)(i)==8);
|
||||
BOOST_CHECK(
|
||||
bind(sum_of_args_9,
|
||||
bind(sum_of_args_0), // 0
|
||||
bind(sum_of_args_1, _1), // 1
|
||||
@@ -141,7 +141,7 @@ int test_main(int, char *[]) {
|
||||
_3,
|
||||
4)
|
||||
)(i, j, k);
|
||||
BOOST_TEST(result == 12);
|
||||
BOOST_CHECK(result == 12);
|
||||
|
||||
test_member_functions();
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ void test_function() {
|
||||
boost::function<int (int, int)> f;
|
||||
f = _1 + _2;
|
||||
|
||||
BOOST_TEST(f(1, 2)== 3);
|
||||
BOOST_CHECK(f(1, 2)== 3);
|
||||
|
||||
int i=1; int j=2;
|
||||
boost::function<int& (int&, int)> g = _1 += _2;
|
||||
g(i, j);
|
||||
BOOST_TEST(i==3);
|
||||
BOOST_CHECK(i==3);
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ void test_function() {
|
||||
*sum = 0;
|
||||
boost::function<int& (int)> counter = *sum += _1;
|
||||
counter(5); // ok, sum* = 5;
|
||||
BOOST_TEST(*sum == 5);
|
||||
BOOST_CHECK(*sum == 5);
|
||||
delete sum;
|
||||
|
||||
// The next statement would lead to a dangling reference
|
||||
|
||||
@@ -53,46 +53,46 @@ void do_test() {
|
||||
(var(b) = ll_static_cast<base *>(p_derived))();
|
||||
(var(d) = ll_static_cast<derived *>(b))();
|
||||
|
||||
BOOST_TEST(b->class_name() == "derived");
|
||||
BOOST_TEST(d->class_name() == "derived");
|
||||
BOOST_CHECK(b->class_name() == "derived");
|
||||
BOOST_CHECK(d->class_name() == "derived");
|
||||
|
||||
(var(b) = ll_dynamic_cast<derived *>(b))();
|
||||
BOOST_TEST(b != 0);
|
||||
BOOST_TEST(b->class_name() == "derived");
|
||||
BOOST_CHECK(b != 0);
|
||||
BOOST_CHECK(b->class_name() == "derived");
|
||||
|
||||
(var(d) = ll_dynamic_cast<derived *>(p_base))();
|
||||
BOOST_TEST(d == 0);
|
||||
BOOST_CHECK(d == 0);
|
||||
|
||||
|
||||
|
||||
const derived* p_const_derived = p_derived;
|
||||
|
||||
BOOST_TEST(p_const_derived->class_name() == "const derived");
|
||||
BOOST_CHECK(p_const_derived->class_name() == "const derived");
|
||||
(var(d) = ll_const_cast<derived *>(p_const_derived))();
|
||||
BOOST_TEST(d->class_name() == "derived");
|
||||
BOOST_CHECK(d->class_name() == "derived");
|
||||
|
||||
int i = 10;
|
||||
char* cp = reinterpret_cast<char*>(&i);
|
||||
|
||||
int* ip;
|
||||
(var(ip) = ll_reinterpret_cast<int *>(cp))();
|
||||
BOOST_TEST(*ip == 10);
|
||||
BOOST_CHECK(*ip == 10);
|
||||
|
||||
|
||||
// typeid
|
||||
|
||||
BOOST_TEST(string(ll_typeid(d)().name()) == string(typeid(d).name()));
|
||||
BOOST_CHECK(string(ll_typeid(d)().name()) == string(typeid(d).name()));
|
||||
|
||||
|
||||
// sizeof
|
||||
|
||||
BOOST_TEST(ll_sizeof(_1)(p_derived) == sizeof(p_derived));
|
||||
BOOST_TEST(ll_sizeof(_1)(*p_derived) == sizeof(*p_derived));
|
||||
BOOST_TEST(ll_sizeof(_1)(p_base) == sizeof(p_base));
|
||||
BOOST_TEST(ll_sizeof(_1)(*p_base) == sizeof(*p_base));
|
||||
BOOST_CHECK(ll_sizeof(_1)(p_derived) == sizeof(p_derived));
|
||||
BOOST_CHECK(ll_sizeof(_1)(*p_derived) == sizeof(*p_derived));
|
||||
BOOST_CHECK(ll_sizeof(_1)(p_base) == sizeof(p_base));
|
||||
BOOST_CHECK(ll_sizeof(_1)(*p_base) == sizeof(*p_base));
|
||||
|
||||
int an_array[100];
|
||||
BOOST_TEST(ll_sizeof(_1)(an_array) == 100 * sizeof(int));
|
||||
BOOST_CHECK(ll_sizeof(_1)(an_array) == 100 * sizeof(int));
|
||||
|
||||
delete p_derived;
|
||||
delete p_base;
|
||||
|
||||
@@ -45,63 +45,63 @@ void constructor_all_lengths()
|
||||
bind(constructor<tuple<int> >(),
|
||||
1)()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
bind(constructor<tuple<int, int> >(),
|
||||
1, 2)()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
bind(constructor<tuple<int, int, int> >(),
|
||||
1, 2, 3)()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
bind(constructor<tuple<int, int, int, int> >(),
|
||||
1, 2, 3, 4)()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
bind(constructor<tuple<int, int, int, int, int> >(),
|
||||
1, 2, 3, 4, 5)()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
bind(constructor<tuple<int, int, int, int, int, int> >(),
|
||||
1, 2, 3, 4, 5, 6)()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
bind(constructor<tuple<int, int, int, int, int, int, int> >(),
|
||||
1, 2, 3, 4, 5, 6, 7)()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
bind(constructor<tuple<int, int, int, int, int, int, int, int> >(),
|
||||
1, 2, 3, 4, 5, 6, 7, 8)()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
bind(constructor<tuple<int, int, int, int, int, int, int, int, int> >(),
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9)()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
}
|
||||
|
||||
@@ -113,63 +113,63 @@ void new_ptr_all_lengths()
|
||||
*(bind(new_ptr<tuple<int> >(),
|
||||
1))()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
*(bind(new_ptr<tuple<int, int> >(),
|
||||
1, 2))()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
*(bind(new_ptr<tuple<int, int, int> >(),
|
||||
1, 2, 3))()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
*(bind(new_ptr<tuple<int, int, int, int> >(),
|
||||
1, 2, 3, 4))()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
*(bind(new_ptr<tuple<int, int, int, int, int> >(),
|
||||
1, 2, 3, 4, 5))()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
*(bind(new_ptr<tuple<int, int, int, int, int, int> >(),
|
||||
1, 2, 3, 4, 5, 6))()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
*(bind(new_ptr<tuple<int, int, int, int, int, int, int> >(),
|
||||
1, 2, 3, 4, 5, 6, 7))()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
*(bind(new_ptr<tuple<int, int, int, int, int, int, int, int> >(),
|
||||
1, 2, 3, 4, 5, 6, 7, 8))()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
ok = check_tuple(
|
||||
1,
|
||||
*(bind(new_ptr<tuple<int, int, int, int, int, int, int, int, int> >(),
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9))()
|
||||
);
|
||||
BOOST_TEST(ok);
|
||||
BOOST_CHECK(ok);
|
||||
|
||||
}
|
||||
|
||||
@@ -186,14 +186,14 @@ void test_destructor ()
|
||||
bool flag;
|
||||
|
||||
is_destructor_called* idc = new(space) is_destructor_called(flag);
|
||||
BOOST_TEST(flag == false);
|
||||
BOOST_CHECK(flag == false);
|
||||
bind(destructor(), _1)(idc);
|
||||
BOOST_TEST(flag == true);
|
||||
BOOST_CHECK(flag == true);
|
||||
|
||||
idc = new(space) is_destructor_called(flag);
|
||||
BOOST_TEST(flag == false);
|
||||
BOOST_CHECK(flag == false);
|
||||
bind(destructor(), _1)(*idc);
|
||||
BOOST_TEST(flag == true);
|
||||
BOOST_CHECK(flag == true);
|
||||
}
|
||||
|
||||
|
||||
@@ -212,14 +212,14 @@ void test_news_and_deletes ()
|
||||
int count_errors = 0;
|
||||
|
||||
for_each(i, i+10, (*_1 == 2) || ++var(count_errors));
|
||||
BOOST_TEST(count_errors == 0);
|
||||
BOOST_CHECK(count_errors == 0);
|
||||
|
||||
|
||||
count_deletes* ct[10];
|
||||
for_each(ct, ct+10, _1 = bind(new_ptr<count_deletes>()));
|
||||
count_deletes::count = 0;
|
||||
for_each(ct, ct+10, bind(delete_ptr(), _1));
|
||||
BOOST_TEST(count_deletes::count == 10);
|
||||
BOOST_CHECK(count_deletes::count == 10);
|
||||
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ void test_array_new_and_delete()
|
||||
count_deletes::count = 0;
|
||||
|
||||
bind(delete_array(), _1)(c);
|
||||
BOOST_TEST(count_deletes::count == 5);
|
||||
BOOST_CHECK(count_deletes::count == 5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,41 +50,41 @@ void simple_loops() {
|
||||
int i;
|
||||
int arithmetic_series = 0;
|
||||
for_loop(_1 = 0, _1 < 10, _1++, arithmetic_series += _1)(i);
|
||||
BOOST_TEST(arithmetic_series == 45);
|
||||
BOOST_CHECK(arithmetic_series == 45);
|
||||
|
||||
// no body case
|
||||
for_loop(boost::lambda::var(i) = 0, boost::lambda::var(i) < 100, ++boost::lambda::var(i))();
|
||||
BOOST_TEST(i == 100);
|
||||
BOOST_CHECK(i == 100);
|
||||
|
||||
// while loops -------------------------------------------------------
|
||||
int a = 0, b = 0, c = 0;
|
||||
|
||||
while_loop((_1 + _2) >= (_1 * _2), (++_1, ++_2, ++_3))(a, b, c);
|
||||
BOOST_TEST(c == 3);
|
||||
BOOST_CHECK(c == 3);
|
||||
|
||||
int count;
|
||||
count = 0; i = 0;
|
||||
while_loop(_1++ < 10, ++boost::lambda::var(count))(i);
|
||||
BOOST_TEST(count == 10);
|
||||
BOOST_CHECK(count == 10);
|
||||
|
||||
// note that the first parameter of do_while_loop is the condition
|
||||
count = 0; i = 0;
|
||||
do_while_loop(_1++ < 10, ++boost::lambda::var(count))(i);
|
||||
BOOST_TEST(count == 11);
|
||||
BOOST_CHECK(count == 11);
|
||||
|
||||
a = 0;
|
||||
do_while_loop(constant(false), _1++)(a);
|
||||
BOOST_TEST(a == 1);
|
||||
BOOST_CHECK(a == 1);
|
||||
|
||||
// no body cases
|
||||
a = 40; b = 30;
|
||||
while_loop(--_1 > _2)(a, b);
|
||||
BOOST_TEST(a == b);
|
||||
BOOST_CHECK(a == b);
|
||||
|
||||
// (the no body case for do_while_loop is pretty redundant)
|
||||
a = 40; b = 30;
|
||||
do_while_loop(--_1 > _2)(a, b);
|
||||
BOOST_TEST(a == b);
|
||||
BOOST_CHECK(a == b);
|
||||
|
||||
|
||||
}
|
||||
@@ -93,25 +93,25 @@ void simple_ifs () {
|
||||
|
||||
int value = 42;
|
||||
if_then(_1 < 0, _1 = 0)(value);
|
||||
BOOST_TEST(value == 42);
|
||||
BOOST_CHECK(value == 42);
|
||||
|
||||
value = -42;
|
||||
if_then(_1 < 0, _1 = -_1)(value);
|
||||
BOOST_TEST(value == 42);
|
||||
BOOST_CHECK(value == 42);
|
||||
|
||||
int min;
|
||||
if_then_else(_1 < _2, boost::lambda::var(min) = _1, boost::lambda::var(min) = _2)
|
||||
(make_const(1), make_const(2));
|
||||
BOOST_TEST(min == 1);
|
||||
BOOST_CHECK(min == 1);
|
||||
|
||||
if_then_else(_1 < _2, boost::lambda::var(min) = _1, boost::lambda::var(min) = _2)
|
||||
(make_const(5), make_const(3));
|
||||
BOOST_TEST(min == 3);
|
||||
BOOST_CHECK(min == 3);
|
||||
|
||||
int x, y;
|
||||
x = -1; y = 1;
|
||||
BOOST_TEST(if_then_else_return(_1 < _2, _2, _1)(x, y) == (std::max)(x ,y));
|
||||
BOOST_TEST(if_then_else_return(_1 < _2, _2, _1)(y, x) == (std::max)(x ,y));
|
||||
BOOST_CHECK(if_then_else_return(_1 < _2, _2, _1)(x, y) == (std::max)(x ,y));
|
||||
BOOST_CHECK(if_then_else_return(_1 < _2, _2, _1)(y, x) == (std::max)(x ,y));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 1);
|
||||
BOOST_CHECK(ecount == 1);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=2; i++)
|
||||
@@ -113,7 +113,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 2);
|
||||
BOOST_CHECK(ecount == 2);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=3; i++)
|
||||
@@ -131,7 +131,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 3);
|
||||
BOOST_CHECK(ecount == 3);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=4; i++)
|
||||
@@ -152,7 +152,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 4);
|
||||
BOOST_CHECK(ecount == 4);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=5; i++)
|
||||
@@ -176,7 +176,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 5);
|
||||
BOOST_CHECK(ecount == 5);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=6; i++)
|
||||
@@ -203,7 +203,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 6);
|
||||
BOOST_CHECK(ecount == 6);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=7; i++)
|
||||
@@ -233,7 +233,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 7);
|
||||
BOOST_CHECK(ecount == 7);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=8; i++)
|
||||
@@ -266,7 +266,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 8);
|
||||
BOOST_CHECK(ecount == 8);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=9; i++)
|
||||
@@ -302,7 +302,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 9);
|
||||
BOOST_CHECK(ecount == 9);
|
||||
|
||||
|
||||
// with catch(...) blocks
|
||||
@@ -317,7 +317,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 1);
|
||||
BOOST_CHECK(ecount == 1);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=2; i++)
|
||||
@@ -332,7 +332,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 2);
|
||||
BOOST_CHECK(ecount == 2);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=3; i++)
|
||||
@@ -350,7 +350,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 3);
|
||||
BOOST_CHECK(ecount == 3);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=4; i++)
|
||||
@@ -371,7 +371,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 4);
|
||||
BOOST_CHECK(ecount == 4);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=5; i++)
|
||||
@@ -395,7 +395,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 5);
|
||||
BOOST_CHECK(ecount == 5);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=6; i++)
|
||||
@@ -422,7 +422,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 6);
|
||||
BOOST_CHECK(ecount == 6);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=7; i++)
|
||||
@@ -452,7 +452,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 7);
|
||||
BOOST_CHECK(ecount == 7);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=8; i++)
|
||||
@@ -485,7 +485,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 8);
|
||||
BOOST_CHECK(ecount == 8);
|
||||
|
||||
ecount = 0;
|
||||
for(int i=1; i<=9; i++)
|
||||
@@ -521,7 +521,7 @@ void test_different_number_of_catch_blocks() {
|
||||
)
|
||||
)(i);
|
||||
}
|
||||
BOOST_TEST(ecount == 9);
|
||||
BOOST_CHECK(ecount == 9);
|
||||
}
|
||||
|
||||
void test_empty_catch_blocks() {
|
||||
@@ -551,7 +551,7 @@ void return_type_matching() {
|
||||
|
||||
int i = 1;
|
||||
|
||||
BOOST_TEST(
|
||||
BOOST_CHECK(
|
||||
|
||||
try_catch(
|
||||
_1 + 1,
|
||||
@@ -575,14 +575,14 @@ void return_type_matching() {
|
||||
make_void(_1 += 1),
|
||||
catch_exception<char>(_e) // since try is void, catch can return anything
|
||||
)(i);
|
||||
BOOST_TEST(i == 2);
|
||||
BOOST_CHECK(i == 2);
|
||||
|
||||
try_catch(
|
||||
(_1 += 1, throw_exception('a')),
|
||||
catch_exception<char>(_e) // since try throws, it is void,
|
||||
// so catch can return anything
|
||||
)(i);
|
||||
BOOST_TEST(i == 3);
|
||||
BOOST_CHECK(i == 3);
|
||||
|
||||
char a = 'a';
|
||||
try_catch(
|
||||
@@ -592,7 +592,7 @@ void return_type_matching() {
|
||||
),
|
||||
catch_exception<char>( _1 = _e )
|
||||
)(a);
|
||||
BOOST_TEST(a == 'b');
|
||||
BOOST_CHECK(a == 'b');
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
@@ -605,11 +605,11 @@ int test_main(int, char *[]) {
|
||||
}
|
||||
catch (int x)
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
BOOST_CHECK(false);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
BOOST_CHECK(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ void test_unary_operators()
|
||||
ok((&_1)(a));
|
||||
ok((*_1)(a));
|
||||
|
||||
BOOST_TEST((*_1)(make_const(&i)) == 1);
|
||||
BOOST_CHECK((*_1)(make_const(&i)) == 1);
|
||||
}
|
||||
|
||||
class X {};
|
||||
|
||||
@@ -53,25 +53,25 @@ using boost::lambda::is_instance_of_3;
|
||||
using boost::lambda::is_instance_of_4;
|
||||
|
||||
|
||||
BOOST_TEST((is_instance_of_1<B1, A1>::value == true));
|
||||
BOOST_TEST((is_instance_of_1<A1<float>, A1>::value == true));
|
||||
BOOST_TEST((is_instance_of_1<int, A1>::value == false));
|
||||
BOOST_TEST((is_instance_of_1<C1, A1>::value == false));
|
||||
BOOST_CHECK((is_instance_of_1<B1, A1>::value == true));
|
||||
BOOST_CHECK((is_instance_of_1<A1<float>, A1>::value == true));
|
||||
BOOST_CHECK((is_instance_of_1<int, A1>::value == false));
|
||||
BOOST_CHECK((is_instance_of_1<C1, A1>::value == false));
|
||||
|
||||
BOOST_TEST((is_instance_of_2<B2, A2>::value == true));
|
||||
BOOST_TEST((is_instance_of_2<A2<int, float>, A2>::value == true));
|
||||
BOOST_TEST((is_instance_of_2<int, A2>::value == false));
|
||||
BOOST_TEST((is_instance_of_2<C2, A2>::value == false));
|
||||
BOOST_CHECK((is_instance_of_2<B2, A2>::value == true));
|
||||
BOOST_CHECK((is_instance_of_2<A2<int, float>, A2>::value == true));
|
||||
BOOST_CHECK((is_instance_of_2<int, A2>::value == false));
|
||||
BOOST_CHECK((is_instance_of_2<C2, A2>::value == false));
|
||||
|
||||
BOOST_TEST((is_instance_of_3<B3, A3>::value == true));
|
||||
BOOST_TEST((is_instance_of_3<A3<int, float, char>, A3>::value == true));
|
||||
BOOST_TEST((is_instance_of_3<int, A3>::value == false));
|
||||
BOOST_TEST((is_instance_of_3<C3, A3>::value == false));
|
||||
BOOST_CHECK((is_instance_of_3<B3, A3>::value == true));
|
||||
BOOST_CHECK((is_instance_of_3<A3<int, float, char>, A3>::value == true));
|
||||
BOOST_CHECK((is_instance_of_3<int, A3>::value == false));
|
||||
BOOST_CHECK((is_instance_of_3<C3, A3>::value == false));
|
||||
|
||||
BOOST_TEST((is_instance_of_4<B4, A4>::value == true));
|
||||
BOOST_TEST((is_instance_of_4<A4<int, float, char, double>, A4>::value == true));
|
||||
BOOST_TEST((is_instance_of_4<int, A4>::value == false));
|
||||
BOOST_TEST((is_instance_of_4<C4, A4>::value == false));
|
||||
BOOST_CHECK((is_instance_of_4<B4, A4>::value == true));
|
||||
BOOST_CHECK((is_instance_of_4<A4<int, float, char, double>, A4>::value == true));
|
||||
BOOST_CHECK((is_instance_of_4<int, A4>::value == false));
|
||||
BOOST_CHECK((is_instance_of_4<C4, A4>::value == false));
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -50,65 +50,65 @@ void pointer_to_data_member_tests() {
|
||||
// int i = 0;
|
||||
my_struct *y = &x;
|
||||
|
||||
BOOST_TEST((_1 ->* &my_struct::mem)(y) == 3);
|
||||
BOOST_CHECK((_1 ->* &my_struct::mem)(y) == 3);
|
||||
|
||||
(_1 ->* &my_struct::mem)(y) = 4;
|
||||
BOOST_TEST(x.mem == 4);
|
||||
BOOST_CHECK(x.mem == 4);
|
||||
|
||||
((_1 ->* &my_struct::mem) = 5)(y);
|
||||
BOOST_TEST(x.mem == 5);
|
||||
BOOST_CHECK(x.mem == 5);
|
||||
|
||||
// &my_struct::mem is a temporary, must be constified
|
||||
((y ->* _1) = 6)(make_const(&my_struct::mem));
|
||||
BOOST_TEST(x.mem == 6);
|
||||
BOOST_CHECK(x.mem == 6);
|
||||
|
||||
((_1 ->* _2) = 7)(y, make_const(&my_struct::mem));
|
||||
BOOST_TEST(x.mem == 7);
|
||||
BOOST_CHECK(x.mem == 7);
|
||||
|
||||
}
|
||||
|
||||
void pointer_to_member_function_tests() {
|
||||
|
||||
my_struct *y = new my_struct(1);
|
||||
BOOST_TEST( (_1 ->* &my_struct::foo)(y)() == (y->mem));
|
||||
BOOST_TEST( (_1 ->* &my_struct::fooc)(y)() == (y->mem));
|
||||
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo))() == (y->mem));
|
||||
BOOST_TEST( (y ->* _1)(make_const(&my_struct::fooc))() == (y->mem));
|
||||
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo))() == (y->mem));
|
||||
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::fooc))() == (y->mem));
|
||||
BOOST_CHECK( (_1 ->* &my_struct::foo)(y)() == (y->mem));
|
||||
BOOST_CHECK( (_1 ->* &my_struct::fooc)(y)() == (y->mem));
|
||||
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo))() == (y->mem));
|
||||
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::fooc))() == (y->mem));
|
||||
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo))() == (y->mem));
|
||||
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::fooc))() == (y->mem));
|
||||
|
||||
BOOST_TEST( (_1 ->* &my_struct::foo1)(y)(1) == (y->mem+1));
|
||||
BOOST_TEST( (_1 ->* &my_struct::foo1c)(y)(1) == (y->mem+1));
|
||||
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo1))(1) == (y->mem+1));
|
||||
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo1c))(1) == (y->mem+1));
|
||||
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo1))(1) == (y->mem+1));
|
||||
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo1c))(1) == (y->mem+1));
|
||||
BOOST_CHECK( (_1 ->* &my_struct::foo1)(y)(1) == (y->mem+1));
|
||||
BOOST_CHECK( (_1 ->* &my_struct::foo1c)(y)(1) == (y->mem+1));
|
||||
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo1))(1) == (y->mem+1));
|
||||
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo1c))(1) == (y->mem+1));
|
||||
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo1))(1) == (y->mem+1));
|
||||
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo1c))(1) == (y->mem+1));
|
||||
|
||||
BOOST_TEST( (_1 ->* &my_struct::foo2)(y)(1,2) == (y->mem+1+2));
|
||||
BOOST_TEST( (_1 ->* &my_struct::foo2c)(y)(1,2) == (y->mem+1+2));
|
||||
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo2))(1,2) == (y->mem+1+2));
|
||||
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo2c))(1,2) == (y->mem+1+2));
|
||||
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo2))(1,2) == (y->mem+1+2));
|
||||
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo2c))(1,2) == (y->mem+1+2));
|
||||
BOOST_CHECK( (_1 ->* &my_struct::foo2)(y)(1,2) == (y->mem+1+2));
|
||||
BOOST_CHECK( (_1 ->* &my_struct::foo2c)(y)(1,2) == (y->mem+1+2));
|
||||
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo2))(1,2) == (y->mem+1+2));
|
||||
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo2c))(1,2) == (y->mem+1+2));
|
||||
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo2))(1,2) == (y->mem+1+2));
|
||||
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo2c))(1,2) == (y->mem+1+2));
|
||||
|
||||
BOOST_TEST( (_1 ->* &my_struct::foo3)(y)(1,2,3) == (y->mem+1+2+3));
|
||||
BOOST_TEST( (_1 ->* &my_struct::foo3c)(y)(1,2,3) == (y->mem+1+2+3));
|
||||
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo3))(1,2,3) == (y->mem+1+2+3));
|
||||
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo3c))(1,2,3) == (y->mem+1+2+3));
|
||||
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo3))(1,2,3) == (y->mem+1+2+3));
|
||||
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo3c))(1,2,3) == (y->mem+1+2+3));
|
||||
BOOST_CHECK( (_1 ->* &my_struct::foo3)(y)(1,2,3) == (y->mem+1+2+3));
|
||||
BOOST_CHECK( (_1 ->* &my_struct::foo3c)(y)(1,2,3) == (y->mem+1+2+3));
|
||||
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo3))(1,2,3) == (y->mem+1+2+3));
|
||||
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo3c))(1,2,3) == (y->mem+1+2+3));
|
||||
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo3))(1,2,3) == (y->mem+1+2+3));
|
||||
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo3c))(1,2,3) == (y->mem+1+2+3));
|
||||
|
||||
BOOST_TEST( (_1 ->* &my_struct::foo4)(y)(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
BOOST_TEST( (_1 ->* &my_struct::foo4c)(y)(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo4))(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo4c))(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo4))(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo4c))(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
BOOST_CHECK( (_1 ->* &my_struct::foo4)(y)(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
BOOST_CHECK( (_1 ->* &my_struct::foo4c)(y)(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo4))(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo4c))(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo4))(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo4c))(1,2,3,4) == (y->mem+1+2+3+4));
|
||||
|
||||
|
||||
|
||||
// member functions with default values do not work (inherent language issue)
|
||||
// BOOST_TEST( (_1 ->* &my_struct::foo3default)(y)() == (y->mem+1+2+3));
|
||||
// BOOST_CHECK( (_1 ->* &my_struct::foo3default)(y)() == (y->mem+1+2+3));
|
||||
|
||||
}
|
||||
|
||||
@@ -163,21 +163,21 @@ void test_overloaded_pointer_to_member()
|
||||
A a; B b;
|
||||
|
||||
// this won't work, can't deduce the return type
|
||||
// BOOST_TEST((_1->*_2)(a, b) == false);
|
||||
// BOOST_CHECK((_1->*_2)(a, b) == false);
|
||||
|
||||
// ret<bool> gives the return type
|
||||
BOOST_TEST(ret<bool>(_1->*_2)(a, b) == false);
|
||||
BOOST_TEST(ret<bool>(a->*_1)(b) == false);
|
||||
BOOST_TEST(ret<bool>(_1->*b)(a) == false);
|
||||
BOOST_TEST((ret<bool>((var(a))->*b))() == false);
|
||||
BOOST_TEST((ret<bool>((var(a))->*var(b)))() == false);
|
||||
BOOST_CHECK(ret<bool>(_1->*_2)(a, b) == false);
|
||||
BOOST_CHECK(ret<bool>(a->*_1)(b) == false);
|
||||
BOOST_CHECK(ret<bool>(_1->*b)(a) == false);
|
||||
BOOST_CHECK((ret<bool>((var(a))->*b))() == false);
|
||||
BOOST_CHECK((ret<bool>((var(a))->*var(b)))() == false);
|
||||
|
||||
|
||||
// this is ok without ret<bool> due to the return_type_2 spcialization above
|
||||
BOOST_TEST((_1->*_2)(b, a) == true);
|
||||
BOOST_TEST((b->*_1)(a) == true);
|
||||
BOOST_TEST((_1->*a)(b) == true);
|
||||
BOOST_TEST((var(b)->*a)() == true);
|
||||
BOOST_CHECK((_1->*_2)(b, a) == true);
|
||||
BOOST_CHECK((b->*_1)(a) == true);
|
||||
BOOST_CHECK((_1->*a)(b) == true);
|
||||
BOOST_CHECK((var(b)->*a)() == true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ void cout_tests()
|
||||
|
||||
(os << constant("FOO"))();
|
||||
|
||||
BOOST_TEST(os.str() == std::string("10FOO"));
|
||||
BOOST_CHECK(os.str() == std::string("10FOO"));
|
||||
|
||||
|
||||
istringstream is("ABC 1");
|
||||
@@ -57,21 +57,21 @@ void cout_tests()
|
||||
is >> s;
|
||||
is >> k;
|
||||
|
||||
BOOST_TEST(s == std::string("ABC"));
|
||||
BOOST_TEST(k == 1);
|
||||
BOOST_CHECK(s == std::string("ABC"));
|
||||
BOOST_CHECK(k == 1);
|
||||
// test for constant, constant_ref and var
|
||||
i = 5;
|
||||
constant_type<int>::type ci(constant(i));
|
||||
var_type<int>::type vi(var(i));
|
||||
|
||||
(vi = _1)(make_const(100));
|
||||
BOOST_TEST((ci)() == 5);
|
||||
BOOST_TEST(i == 100);
|
||||
BOOST_CHECK((ci)() == 5);
|
||||
BOOST_CHECK(i == 100);
|
||||
|
||||
int a;
|
||||
constant_ref_type<int>::type cr(constant_ref(i));
|
||||
(++vi, var(a) = cr)();
|
||||
BOOST_TEST(i == 101);
|
||||
BOOST_CHECK(i == 101);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -81,17 +81,17 @@ void arithmetic_operators() {
|
||||
using namespace std;
|
||||
using namespace boost::lambda;
|
||||
|
||||
BOOST_TEST((_1 + 1)(i)==2);
|
||||
BOOST_TEST(((_1 + 1) * _2)(i, j)==4);
|
||||
BOOST_TEST((_1 - 1)(i)==0);
|
||||
BOOST_CHECK((_1 + 1)(i)==2);
|
||||
BOOST_CHECK(((_1 + 1) * _2)(i, j)==4);
|
||||
BOOST_CHECK((_1 - 1)(i)==0);
|
||||
|
||||
BOOST_TEST((_1 * 2)(j)==4);
|
||||
BOOST_TEST((_1 / 2)(j)==1);
|
||||
BOOST_CHECK((_1 * 2)(j)==4);
|
||||
BOOST_CHECK((_1 / 2)(j)==1);
|
||||
|
||||
BOOST_TEST((_1 % 2)(k)==1);
|
||||
BOOST_CHECK((_1 % 2)(k)==1);
|
||||
|
||||
BOOST_TEST((-_1)(i) == -1);
|
||||
BOOST_TEST((+_1)(i) == 1);
|
||||
BOOST_CHECK((-_1)(i) == -1);
|
||||
BOOST_CHECK((+_1)(i) == 1);
|
||||
|
||||
// test that unary plus really does something
|
||||
unary_plus_tester u;
|
||||
@@ -101,95 +101,95 @@ void arithmetic_operators() {
|
||||
void bitwise_operators() {
|
||||
unsigned int ui = 2;
|
||||
|
||||
BOOST_TEST((_1 << 1)(ui)==(2 << 1));
|
||||
BOOST_TEST((_1 >> 1)(ui)==(2 >> 1));
|
||||
BOOST_CHECK((_1 << 1)(ui)==(2 << 1));
|
||||
BOOST_CHECK((_1 >> 1)(ui)==(2 >> 1));
|
||||
|
||||
BOOST_TEST((_1 & 1)(ui)==(2 & 1));
|
||||
BOOST_TEST((_1 | 1)(ui)==(2 | 1));
|
||||
BOOST_TEST((_1 ^ 1)(ui)==(2 ^ 1));
|
||||
BOOST_TEST((~_1)(ui)==~2u);
|
||||
BOOST_CHECK((_1 & 1)(ui)==(2 & 1));
|
||||
BOOST_CHECK((_1 | 1)(ui)==(2 | 1));
|
||||
BOOST_CHECK((_1 ^ 1)(ui)==(2 ^ 1));
|
||||
BOOST_CHECK((~_1)(ui)==~2u);
|
||||
}
|
||||
|
||||
void comparison_operators() {
|
||||
int i = 0, j = 1;
|
||||
|
||||
BOOST_TEST((_1 < _2)(i, j) == true);
|
||||
BOOST_TEST((_1 <= _2)(i, j) == true);
|
||||
BOOST_TEST((_1 == _2)(i, j) == false);
|
||||
BOOST_TEST((_1 != _2)(i, j) == true);
|
||||
BOOST_TEST((_1 > _2)(i, j) == false);
|
||||
BOOST_TEST((_1 >= _2)(i, j) == false);
|
||||
BOOST_CHECK((_1 < _2)(i, j) == true);
|
||||
BOOST_CHECK((_1 <= _2)(i, j) == true);
|
||||
BOOST_CHECK((_1 == _2)(i, j) == false);
|
||||
BOOST_CHECK((_1 != _2)(i, j) == true);
|
||||
BOOST_CHECK((_1 > _2)(i, j) == false);
|
||||
BOOST_CHECK((_1 >= _2)(i, j) == false);
|
||||
|
||||
BOOST_TEST((!(_1 < _2))(i, j) == false);
|
||||
BOOST_TEST((!(_1 <= _2))(i, j) == false);
|
||||
BOOST_TEST((!(_1 == _2))(i, j) == true);
|
||||
BOOST_TEST((!(_1 != _2))(i, j) == false);
|
||||
BOOST_TEST((!(_1 > _2))(i, j) == true);
|
||||
BOOST_TEST((!(_1 >= _2))(i, j) == true);
|
||||
BOOST_CHECK((!(_1 < _2))(i, j) == false);
|
||||
BOOST_CHECK((!(_1 <= _2))(i, j) == false);
|
||||
BOOST_CHECK((!(_1 == _2))(i, j) == true);
|
||||
BOOST_CHECK((!(_1 != _2))(i, j) == false);
|
||||
BOOST_CHECK((!(_1 > _2))(i, j) == true);
|
||||
BOOST_CHECK((!(_1 >= _2))(i, j) == true);
|
||||
}
|
||||
|
||||
void logical_operators() {
|
||||
|
||||
bool t = true, f = false;
|
||||
BOOST_TEST((_1 && _2)(t, t) == true);
|
||||
BOOST_TEST((_1 && _2)(t, f) == false);
|
||||
BOOST_TEST((_1 && _2)(f, t) == false);
|
||||
BOOST_TEST((_1 && _2)(f, f) == false);
|
||||
BOOST_CHECK((_1 && _2)(t, t) == true);
|
||||
BOOST_CHECK((_1 && _2)(t, f) == false);
|
||||
BOOST_CHECK((_1 && _2)(f, t) == false);
|
||||
BOOST_CHECK((_1 && _2)(f, f) == false);
|
||||
|
||||
BOOST_TEST((_1 || _2)(t, t) == true);
|
||||
BOOST_TEST((_1 || _2)(t, f) == true);
|
||||
BOOST_TEST((_1 || _2)(f, t) == true);
|
||||
BOOST_TEST((_1 || _2)(f, f) == false);
|
||||
BOOST_CHECK((_1 || _2)(t, t) == true);
|
||||
BOOST_CHECK((_1 || _2)(t, f) == true);
|
||||
BOOST_CHECK((_1 || _2)(f, t) == true);
|
||||
BOOST_CHECK((_1 || _2)(f, f) == false);
|
||||
|
||||
BOOST_TEST((!_1)(t) == false);
|
||||
BOOST_TEST((!_1)(f) == true);
|
||||
BOOST_CHECK((!_1)(t) == false);
|
||||
BOOST_CHECK((!_1)(f) == true);
|
||||
|
||||
// test short circuiting
|
||||
int i=0;
|
||||
|
||||
(false && ++_1)(i);
|
||||
BOOST_TEST(i==0);
|
||||
BOOST_CHECK(i==0);
|
||||
i = 0;
|
||||
|
||||
(true && ++_1)(i);
|
||||
BOOST_TEST(i==1);
|
||||
BOOST_CHECK(i==1);
|
||||
i = 0;
|
||||
|
||||
(false || ++_1)(i);
|
||||
BOOST_TEST(i==1);
|
||||
BOOST_CHECK(i==1);
|
||||
i = 0;
|
||||
|
||||
(true || ++_1)(i);
|
||||
BOOST_TEST(i==0);
|
||||
BOOST_CHECK(i==0);
|
||||
i = 0;
|
||||
}
|
||||
|
||||
void unary_incs_and_decs() {
|
||||
int i = 0;
|
||||
|
||||
BOOST_TEST(_1++(i) == 0);
|
||||
BOOST_TEST(i == 1);
|
||||
BOOST_CHECK(_1++(i) == 0);
|
||||
BOOST_CHECK(i == 1);
|
||||
i = 0;
|
||||
|
||||
BOOST_TEST(_1--(i) == 0);
|
||||
BOOST_TEST(i == -1);
|
||||
BOOST_CHECK(_1--(i) == 0);
|
||||
BOOST_CHECK(i == -1);
|
||||
i = 0;
|
||||
|
||||
BOOST_TEST((++_1)(i) == 1);
|
||||
BOOST_TEST(i == 1);
|
||||
BOOST_CHECK((++_1)(i) == 1);
|
||||
BOOST_CHECK(i == 1);
|
||||
i = 0;
|
||||
|
||||
BOOST_TEST((--_1)(i) == -1);
|
||||
BOOST_TEST(i == -1);
|
||||
BOOST_CHECK((--_1)(i) == -1);
|
||||
BOOST_CHECK(i == -1);
|
||||
i = 0;
|
||||
|
||||
// the result of prefix -- and ++ are lvalues
|
||||
(++_1)(i) = 10;
|
||||
BOOST_TEST(i==10);
|
||||
BOOST_CHECK(i==10);
|
||||
i = 0;
|
||||
|
||||
(--_1)(i) = 10;
|
||||
BOOST_TEST(i==10);
|
||||
BOOST_CHECK(i==10);
|
||||
i = 0;
|
||||
}
|
||||
|
||||
@@ -199,77 +199,77 @@ void compound_operators() {
|
||||
|
||||
// normal variable as the left operand
|
||||
(i += _1)(make_const(1));
|
||||
BOOST_TEST(i == 2);
|
||||
BOOST_CHECK(i == 2);
|
||||
|
||||
(i -= _1)(make_const(1));
|
||||
BOOST_TEST(i == 1);
|
||||
BOOST_CHECK(i == 1);
|
||||
|
||||
(i *= _1)(make_const(10));
|
||||
BOOST_TEST(i == 10);
|
||||
BOOST_CHECK(i == 10);
|
||||
|
||||
(i /= _1)(make_const(2));
|
||||
BOOST_TEST(i == 5);
|
||||
BOOST_CHECK(i == 5);
|
||||
|
||||
(i %= _1)(make_const(2));
|
||||
BOOST_TEST(i == 1);
|
||||
BOOST_CHECK(i == 1);
|
||||
|
||||
// lambda expression as a left operand
|
||||
(_1 += 1)(i);
|
||||
BOOST_TEST(i == 2);
|
||||
BOOST_CHECK(i == 2);
|
||||
|
||||
(_1 -= 1)(i);
|
||||
BOOST_TEST(i == 1);
|
||||
BOOST_CHECK(i == 1);
|
||||
|
||||
(_1 *= 10)(i);
|
||||
BOOST_TEST(i == 10);
|
||||
BOOST_CHECK(i == 10);
|
||||
|
||||
(_1 /= 2)(i);
|
||||
BOOST_TEST(i == 5);
|
||||
BOOST_CHECK(i == 5);
|
||||
|
||||
(_1 %= 2)(i);
|
||||
BOOST_TEST(i == 1);
|
||||
BOOST_CHECK(i == 1);
|
||||
|
||||
// shifts
|
||||
unsigned int ui = 2;
|
||||
(_1 <<= 1)(ui);
|
||||
BOOST_TEST(ui==(2 << 1));
|
||||
BOOST_CHECK(ui==(2 << 1));
|
||||
|
||||
ui = 2;
|
||||
(_1 >>= 1)(ui);
|
||||
BOOST_TEST(ui==(2 >> 1));
|
||||
BOOST_CHECK(ui==(2 >> 1));
|
||||
|
||||
ui = 2;
|
||||
(ui <<= _1)(make_const(1));
|
||||
BOOST_TEST(ui==(2 << 1));
|
||||
BOOST_CHECK(ui==(2 << 1));
|
||||
|
||||
ui = 2;
|
||||
(ui >>= _1)(make_const(1));
|
||||
BOOST_TEST(ui==(2 >> 1));
|
||||
BOOST_CHECK(ui==(2 >> 1));
|
||||
|
||||
// and, or, xor
|
||||
ui = 2;
|
||||
(_1 &= 1)(ui);
|
||||
BOOST_TEST(ui==(2 & 1));
|
||||
BOOST_CHECK(ui==(2 & 1));
|
||||
|
||||
ui = 2;
|
||||
(_1 |= 1)(ui);
|
||||
BOOST_TEST(ui==(2 | 1));
|
||||
BOOST_CHECK(ui==(2 | 1));
|
||||
|
||||
ui = 2;
|
||||
(_1 ^= 1)(ui);
|
||||
BOOST_TEST(ui==(2 ^ 1));
|
||||
BOOST_CHECK(ui==(2 ^ 1));
|
||||
|
||||
ui = 2;
|
||||
(ui &= _1)(make_const(1));
|
||||
BOOST_TEST(ui==(2 & 1));
|
||||
BOOST_CHECK(ui==(2 & 1));
|
||||
|
||||
ui = 2;
|
||||
(ui |= _1)(make_const(1));
|
||||
BOOST_TEST(ui==(2 | 1));
|
||||
BOOST_CHECK(ui==(2 | 1));
|
||||
|
||||
ui = 2;
|
||||
(ui ^= _1)(make_const(1));
|
||||
BOOST_TEST(ui==(2 ^ 1));
|
||||
BOOST_CHECK(ui==(2 ^ 1));
|
||||
|
||||
}
|
||||
|
||||
@@ -283,24 +283,24 @@ void assignment_and_subscript() {
|
||||
string s;
|
||||
|
||||
(_1 = "one")(s);
|
||||
BOOST_TEST(s == string("one"));
|
||||
BOOST_CHECK(s == string("one"));
|
||||
|
||||
(var(s) = "two")();
|
||||
BOOST_TEST(s == string("two"));
|
||||
BOOST_CHECK(s == string("two"));
|
||||
|
||||
BOOST_TEST((var(s)[_1])(make_const(2)) == 'o');
|
||||
BOOST_TEST((_1[2])(s) == 'o');
|
||||
BOOST_TEST((_1[_2])(s, make_const(2)) == 'o');
|
||||
BOOST_CHECK((var(s)[_1])(make_const(2)) == 'o');
|
||||
BOOST_CHECK((_1[2])(s) == 'o');
|
||||
BOOST_CHECK((_1[_2])(s, make_const(2)) == 'o');
|
||||
|
||||
// subscript returns lvalue
|
||||
(var(s)[_1])(make_const(1)) = 'o';
|
||||
BOOST_TEST(s == "too");
|
||||
BOOST_CHECK(s == "too");
|
||||
|
||||
(_1[1])(s) = 'a';
|
||||
BOOST_TEST(s == "tao");
|
||||
BOOST_CHECK(s == "tao");
|
||||
|
||||
(_1[_2])(s, make_const(0)) = 'm';
|
||||
BOOST_TEST(s == "mao");
|
||||
BOOST_CHECK(s == "mao");
|
||||
|
||||
// TODO: tests for vector, set, map, multimap
|
||||
}
|
||||
@@ -311,14 +311,14 @@ void address_of_and_dereference() {
|
||||
|
||||
A a; int i = 42;
|
||||
|
||||
BOOST_TEST((&_1)(a) == &a);
|
||||
BOOST_TEST((*&_1)(i) == 42);
|
||||
BOOST_CHECK((&_1)(a) == &a);
|
||||
BOOST_CHECK((*&_1)(i) == 42);
|
||||
|
||||
std::vector<int> vi; vi.push_back(1);
|
||||
std::vector<int>::iterator it = vi.begin();
|
||||
|
||||
(*_1 = 7)(it);
|
||||
BOOST_TEST(vi[0] == 7);
|
||||
BOOST_CHECK(vi[0] == 7);
|
||||
|
||||
// TODO: Add tests for more complex iterator types
|
||||
}
|
||||
@@ -328,7 +328,7 @@ void address_of_and_dereference() {
|
||||
void comma() {
|
||||
|
||||
int i = 100;
|
||||
BOOST_TEST((_1 = 10, 2 * _1)(i) == 20);
|
||||
BOOST_CHECK((_1 = 10, 2 * _1)(i) == 20);
|
||||
|
||||
// TODO: that the return type is the exact type of the right argument
|
||||
// (that r/l valueness is preserved)
|
||||
@@ -347,32 +347,32 @@ void pointer_arithmetic() {
|
||||
|
||||
|
||||
// non-const array
|
||||
BOOST_TEST((*(_1 + 1))(ia) == 2);
|
||||
BOOST_CHECK((*(_1 + 1))(ia) == 2);
|
||||
|
||||
// non-const pointer
|
||||
BOOST_TEST((*(_1 + 1))(ip) == 2);
|
||||
BOOST_CHECK((*(_1 + 1))(ip) == 2);
|
||||
|
||||
BOOST_TEST((*(_1 - 1))(ia_last) == 3);
|
||||
BOOST_CHECK((*(_1 - 1))(ia_last) == 3);
|
||||
|
||||
// const array
|
||||
BOOST_TEST((*(_1 + 1))(cia) == 2);
|
||||
BOOST_CHECK((*(_1 + 1))(cia) == 2);
|
||||
// const pointer
|
||||
BOOST_TEST((*(_1 + 1))(cip) == 2);
|
||||
BOOST_TEST((*(_1 - 1))(cia_last) == 3);
|
||||
BOOST_CHECK((*(_1 + 1))(cip) == 2);
|
||||
BOOST_CHECK((*(_1 - 1))(cia_last) == 3);
|
||||
|
||||
// pointer arithmetic should not make non-consts const
|
||||
(*(_1 + 2))(ia) = 0;
|
||||
(*(_1 + 3))(ip) = 0;
|
||||
|
||||
BOOST_TEST(ia[2] == 0);
|
||||
BOOST_TEST(ia[3] == 0);
|
||||
BOOST_CHECK(ia[2] == 0);
|
||||
BOOST_CHECK(ia[3] == 0);
|
||||
|
||||
// pointer - pointer
|
||||
BOOST_TEST((_1 - _2)(ia_last, ia) == 3);
|
||||
BOOST_TEST((_1 - _2)(cia_last, cia) == 3);
|
||||
BOOST_TEST((ia_last - _1)(ia) == 3);
|
||||
BOOST_TEST((cia_last - _1)(cia) == 3);
|
||||
BOOST_TEST((cia_last - _1)(cip) == 3);
|
||||
BOOST_CHECK((_1 - _2)(ia_last, ia) == 3);
|
||||
BOOST_CHECK((_1 - _2)(cia_last, cia) == 3);
|
||||
BOOST_CHECK((ia_last - _1)(ia) == 3);
|
||||
BOOST_CHECK((cia_last - _1)(cia) == 3);
|
||||
BOOST_CHECK((cia_last - _1)(cip) == 3);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ int test_main(int, char *[]) {
|
||||
]
|
||||
);
|
||||
|
||||
BOOST_TEST(sum == 4+5+6+7+8);
|
||||
BOOST_CHECK(sum == 4+5+6+7+8);
|
||||
|
||||
int gt = 0, eq = 0, lt = 0;
|
||||
//////////////////////////////////
|
||||
@@ -82,9 +82,9 @@ int test_main(int, char *[]) {
|
||||
]
|
||||
);
|
||||
|
||||
BOOST_TEST(lt==4);
|
||||
BOOST_TEST(eq==1);
|
||||
BOOST_TEST(gt==5);
|
||||
BOOST_CHECK(lt==4);
|
||||
BOOST_CHECK(eq==1);
|
||||
BOOST_CHECK(gt==5);
|
||||
|
||||
vector<int> t = v;
|
||||
|
||||
@@ -101,8 +101,8 @@ int test_main(int, char *[]) {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(counta == 55);
|
||||
BOOST_TEST(countb == 10);
|
||||
BOOST_CHECK(counta == 55);
|
||||
BOOST_CHECK(countb == 10);
|
||||
|
||||
|
||||
v = t;
|
||||
@@ -120,8 +120,8 @@ int test_main(int, char *[]) {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(counta == (2+11)*10/2);
|
||||
BOOST_TEST(countb == 10);
|
||||
BOOST_CHECK(counta == (2+11)*10/2);
|
||||
BOOST_CHECK(countb == 10);
|
||||
|
||||
|
||||
v = t;
|
||||
@@ -138,8 +138,8 @@ int test_main(int, char *[]) {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(counta == (1+10)*10/2);
|
||||
BOOST_TEST(countb == 10);
|
||||
BOOST_CHECK(counta == (1+10)*10/2);
|
||||
BOOST_CHECK(countb == 10);
|
||||
|
||||
v = t;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ void do_switch_no_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 0));
|
||||
BOOST_CHECK(check(w, 0));
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -75,7 +75,7 @@ void do_switch_no_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 1));
|
||||
BOOST_CHECK(check(w, 1));
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -88,7 +88,7 @@ void do_switch_no_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 2));
|
||||
BOOST_CHECK(check(w, 2));
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -102,7 +102,7 @@ void do_switch_no_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 3));
|
||||
BOOST_CHECK(check(w, 3));
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -117,7 +117,7 @@ void do_switch_no_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 4));
|
||||
BOOST_CHECK(check(w, 4));
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -133,7 +133,7 @@ void do_switch_no_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 5));
|
||||
BOOST_CHECK(check(w, 5));
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -150,7 +150,7 @@ void do_switch_no_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 6));
|
||||
BOOST_CHECK(check(w, 6));
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -168,7 +168,7 @@ void do_switch_no_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 7));
|
||||
BOOST_CHECK(check(w, 7));
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -187,7 +187,7 @@ void do_switch_no_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 8));
|
||||
BOOST_CHECK(check(w, 8));
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
}
|
||||
@@ -216,8 +216,8 @@ void do_switch_yes_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, -1));
|
||||
BOOST_TEST(default_count == 10);
|
||||
BOOST_CHECK(check(w, -1));
|
||||
BOOST_CHECK(default_count == 10);
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -230,8 +230,8 @@ void do_switch_yes_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 0));
|
||||
BOOST_TEST(default_count == 9);
|
||||
BOOST_CHECK(check(w, 0));
|
||||
BOOST_CHECK(default_count == 9);
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -245,8 +245,8 @@ void do_switch_yes_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 1));
|
||||
BOOST_TEST(default_count == 8);
|
||||
BOOST_CHECK(check(w, 1));
|
||||
BOOST_CHECK(default_count == 8);
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -261,8 +261,8 @@ void do_switch_yes_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 2));
|
||||
BOOST_TEST(default_count == 7);
|
||||
BOOST_CHECK(check(w, 2));
|
||||
BOOST_CHECK(default_count == 7);
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -278,8 +278,8 @@ void do_switch_yes_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 3));
|
||||
BOOST_TEST(default_count == 6);
|
||||
BOOST_CHECK(check(w, 3));
|
||||
BOOST_CHECK(default_count == 6);
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -296,8 +296,8 @@ void do_switch_yes_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 4));
|
||||
BOOST_TEST(default_count == 5);
|
||||
BOOST_CHECK(check(w, 4));
|
||||
BOOST_CHECK(default_count == 5);
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -315,8 +315,8 @@ void do_switch_yes_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 5));
|
||||
BOOST_TEST(default_count == 4);
|
||||
BOOST_CHECK(check(w, 5));
|
||||
BOOST_CHECK(default_count == 4);
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -335,8 +335,8 @@ void do_switch_yes_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 6));
|
||||
BOOST_TEST(default_count == 3);
|
||||
BOOST_CHECK(check(w, 6));
|
||||
BOOST_CHECK(default_count == 3);
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
// ---
|
||||
@@ -356,8 +356,8 @@ void do_switch_yes_defaults_tests() {
|
||||
)
|
||||
);
|
||||
|
||||
BOOST_TEST(check(w, 7));
|
||||
BOOST_TEST(default_count == 2);
|
||||
BOOST_CHECK(check(w, 7));
|
||||
BOOST_CHECK(default_count == 2);
|
||||
std::fill_n(w.begin(), 10, 0);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user