diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index ec0db4f..0141afe 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -7,8 +7,7 @@ import testing ; -project : requirements /boost//unit_test_framework ; - +run add_cxx11_lambda.cpp ; run add_global_functor.cpp ; run add_local_functor.cpp ; run add_phoenix.cpp ; @@ -17,12 +16,12 @@ run const_block.cpp ; compile-fail const_block_error.cpp : debug : ; run const_block_error.cpp : release : ; -run expensive_copy_lambda.cpp ; +run expensive_copy_cxx11_lambda.cpp ; run expensive_copy_local_function.cpp ; run gcc_access.cpp ; run gcc_lambda.cpp ; -run gcc_lambda_cxx11.cpp ; +run gcc_cxx11_lambda.cpp ; run gcc_square.cpp ; run gcc_store.cpp ; @@ -32,7 +31,7 @@ run impl_tparam_tricks.cpp ; run n2529_this.cpp ; run n2550_find_if.cpp ; -compile-fail noncopyable_lambda_error.cpp ; +compile-fail noncopyable_cxx11_lambda_error.cpp ; run noncopyable_local_function.cpp ; run phoenix_factorial.cpp ; @@ -44,7 +43,7 @@ exe profile_global_functor : profile_global_functor.cpp /boost/system//boost_system static ; -exe profile_lambda : profile_lambda.cpp +exe profile_cxx11_lambda : profile_cxx11_lambda.cpp : /boost/chrono//boost_chrono /boost/system//boost_system static diff --git a/test/add_lambda.cpp b/example/add_cxx11_lambda.cpp similarity index 67% rename from test/add_lambda.cpp rename to example/add_cxx11_lambda.cpp index 8ff2070..d7085bb 100644 --- a/test/add_lambda.cpp +++ b/example/add_cxx11_lambda.cpp @@ -6,15 +6,15 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_LAMBDAS +#ifdef BOOST_NO_LAMBDAS +# error "lambda functions required" +#else -#define BOOST_TEST_MODULE TestAddLambda -#include +#include #include -BOOST_AUTO_TEST_CASE( test_add_lambda ) -//[add_lambda -{ // Some local scope. +//[add_cxx11_lambda +int main(void) { // Some local scope. int sum = 0, factor = 10; // Variables in scope to bind. auto add = [factor, &sum](int num) { // C++11 only. @@ -25,13 +25,10 @@ BOOST_AUTO_TEST_CASE( test_add_lambda ) int nums[] = {2, 3}; std::for_each(nums, nums + 2, add); // Pass it to an algorithm. - BOOST_CHECK(sum == 60); // Assert final summation value. + BOOST_TEST(sum == 60); // Assert final summation value. + return boost::report_errors(); } //] -#else - -int main(void) { return 0; } // Trivial test. - #endif diff --git a/example/add_global_functor.cpp b/example/add_global_functor.cpp index 00773a8..4ef2554 100644 --- a/example/add_global_functor.cpp +++ b/example/add_global_functor.cpp @@ -5,8 +5,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // Home at http://www.boost.org/libs/local_function -#define BOOST_TEST_MODULE TestAddGlobalFunctor -#include +#include #include //[add_global_functor @@ -22,7 +21,7 @@ private: // Unfortunately, cannot bind so repeat variable types. const int factor; // Make `factor` constant. }; -BOOST_AUTO_TEST_CASE(test_add_global_functor) { +int main(void) { int sum = 0, factor = 10; global_add add(sum, factor); @@ -31,7 +30,8 @@ BOOST_AUTO_TEST_CASE(test_add_global_functor) { int nums[] = {2, 3}; std::for_each(nums, nums + 2, add); // Passed as template parameter. - BOOST_CHECK(sum == 60); + BOOST_TEST(sum == 60); + return boost::report_errors(); } //] diff --git a/example/add_local_functor.cpp b/example/add_local_functor.cpp index cf0d514..2938d69 100644 --- a/example/add_local_functor.cpp +++ b/example/add_local_functor.cpp @@ -5,12 +5,10 @@ // http://www.boost.org/LICENSE_1_0.txt) // Home at http://www.boost.org/libs/local_function -#define BOOST_TEST_MODULE TestAddLocalFunctor -#include +#include -BOOST_AUTO_TEST_CASE(test_add_local_functor) //[add_local_functor -{ +int main(void) { int sum = 0, factor = 10; struct local_add { // Unfortunately, boilerplate code to program the class. @@ -29,7 +27,8 @@ BOOST_AUTO_TEST_CASE(test_add_local_functor) // Unfortunately, cannot pass as template parameter to `std::for_each`. for(size_t i = 0; i < 2; ++i) add(nums[i]); - BOOST_CHECK(sum == 60); + BOOST_TEST(sum == 60); + return boost::report_errors(); } //] diff --git a/example/add_phoenix.cpp b/example/add_phoenix.cpp index 3c39f01..10b5342 100644 --- a/example/add_phoenix.cpp +++ b/example/add_phoenix.cpp @@ -6,14 +6,12 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestAddPhoenix -#include +#include #include #include -BOOST_AUTO_TEST_CASE(test_add_phoenix) //[add_phoenix -{ +int main(void) { using boost::phoenix::let; using boost::phoenix::local_names::_f; using boost::phoenix::cref; @@ -29,7 +27,8 @@ BOOST_AUTO_TEST_CASE(test_add_phoenix) ref(sum) += _f * _1, _1 // Access `sum` by reference. ]); - BOOST_CHECK(sum == 60); + BOOST_TEST(sum == 60); + return boost::report_errors(); } //] diff --git a/example/chrono.py b/example/chrono.py index 0766821..84d6dfb 100755 --- a/example/chrono.py +++ b/example/chrono.py @@ -9,7 +9,10 @@ import sys import time import os -# Usage: python crono.py COMMAND [COMMAND_OPTIONS] +if len(sys.argv) < 2: + print "Usage: python " + sys.argv[0] + " COMMAND [COMMAND_OPTIONS]" + print "Measure run-time of executing the specified command." + exit(1) cmd = "" for arg in sys.argv[1:]: cmd += str(arg) + " " diff --git a/example/const_block.hpp b/example/const_block.hpp index 824fb01..67b9e77 100644 --- a/example/const_block.hpp +++ b/example/const_block.hpp @@ -17,7 +17,6 @@ #include #include #include -#include // PRIVATE // @@ -34,8 +33,8 @@ ) #define CONST_BLOCK_END_(id) \ - BOOST_LOCAL_FUNCTION_NAME(BOOST_PP_CAT(const_assert_, id)) \ - BOOST_PP_CAT(const_assert_, id)(); /* call local function immediately */ + BOOST_LOCAL_FUNCTION_NAME(BOOST_PP_CAT(const_block_, id)) \ + BOOST_PP_CAT(const_block_, id)(); /* call local function immediately */ // PUBLIC // diff --git a/example/expensive_copy_lambda.cpp b/example/expensive_copy_cxx11_lambda.cpp similarity index 71% rename from example/expensive_copy_lambda.cpp rename to example/expensive_copy_cxx11_lambda.cpp index 7169ebe..741b16f 100644 --- a/example/expensive_copy_lambda.cpp +++ b/example/expensive_copy_cxx11_lambda.cpp @@ -6,16 +6,18 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_LAMBDAS +#ifdef BOOST_NO_LAMBDAS +# error "lambda functions required" +#else #include #include -//[expensive_copy_lambda +//[expensive_copy_cxx11_lambda struct n { int i; n(int _i): i(_i) {} - n(n const& x): i(x.i) { // Some time consuming copy. + n(n const& x): i(x.i) { // Some time consuming copy operation. for (unsigned i = 0; i < 10000; ++i) std::cout << '.'; } }; @@ -24,7 +26,7 @@ int main(void) { n x(-1); auto f = [x]() { // Problem: Expensive copy, but if bind - assert( x.i == -1); // by `&x` then `x` is not constant. + assert(x.i == -1); // by `&x` then `x` is not constant. }; f(); @@ -32,9 +34,5 @@ int main(void) { } //] -#else // NO_LAMBDAS - -int main(void) { return 0; } // Trivial test. - #endif // NO_LAMBDAS diff --git a/example/expensive_copy_local_function.cpp b/example/expensive_copy_local_function.cpp index d732533..5dfde05 100644 --- a/example/expensive_copy_local_function.cpp +++ b/example/expensive_copy_local_function.cpp @@ -13,7 +13,7 @@ struct n { int i; n(int _i): i(_i) {} - n(n const& x): i(x.i) { // Some time consuming copy. + n(n const& x): i(x.i) { // Some time consuming copy operation. for (unsigned i = 0; i < 10000; ++i) std::cout << '.'; } }; @@ -21,8 +21,8 @@ struct n { int main(void) { n x(-1); - void BOOST_LOCAL_FUNCTION(const bind& x) { // OK: No copy - assert( x.i == -1 ); // and constant. + void BOOST_LOCAL_FUNCTION(const bind& x) { // OK: No copy expensive + assert(x.i == -1); // copy but constant. } BOOST_LOCAL_FUNCTION_NAME(f) f(); diff --git a/example/gcc_access.cpp b/example/gcc_access.cpp index 4515d6b..0b0e171 100644 --- a/example/gcc_access.cpp +++ b/example/gcc_access.cpp @@ -6,18 +6,18 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestGccAccess -#include +#include -BOOST_AUTO_TEST_CASE(test_gcc_access) { +int main(void) { int nums[] = {1, 2, 3}; int offset = -1; int BOOST_LOCAL_FUNCTION(const bind offset, int* array, int index) { return array[index + offset]; } BOOST_LOCAL_FUNCTION_NAME(access) - BOOST_CHECK(access(nums, 1) == 1); - BOOST_CHECK(access(nums, 2) == 2); - BOOST_CHECK(access(nums, 3) == 3); + BOOST_TEST(access(nums, 1) == 1); + BOOST_TEST(access(nums, 2) == 2); + BOOST_TEST(access(nums, 3) == 3); + return boost::report_errors(); } diff --git a/example/gcc_lambda_cxx11.cpp b/example/gcc_cxx11_lambda.cpp similarity index 63% rename from example/gcc_lambda_cxx11.cpp rename to example/gcc_cxx11_lambda.cpp index d5a76e1..90c4a7e 100644 --- a/example/gcc_lambda_cxx11.cpp +++ b/example/gcc_cxx11_lambda.cpp @@ -6,14 +6,15 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_LAMBDAS +#ifdef BOOST_NO_LAMBDAS +# error "lambda functions required" +#else -#define BOOST_TEST_MODULE TestGccLambdaCxx11 -#include +#include #include -BOOST_AUTO_TEST_CASE(test_gcc_lambda_cxx11) { - //[gcc_lambda_cxx11 +int main(void) { + //[gcc_cxx11_lambda int val = 2; int nums[] = {1, 2, 3}; int* end = nums + 3; @@ -25,13 +26,10 @@ BOOST_AUTO_TEST_CASE(test_gcc_lambda_cxx11) { ); //] - BOOST_CHECK(iter != end); - BOOST_CHECK(*iter == val); + BOOST_TEST(iter != end); + BOOST_TEST(*iter == val); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // LAMBDAS diff --git a/example/gcc_lambda.cpp b/example/gcc_lambda.cpp index 65fac57..7f33bd6 100644 --- a/example/gcc_lambda.cpp +++ b/example/gcc_lambda.cpp @@ -6,14 +6,15 @@ // Home at http://www.boost.org/libs/local_function #include -#if defined(__GCC__) || !defined(BOOST_NO_LAMBDAS) +#ifndef __GNUC__ +# error "GCC compiler required (uses non-standard GCC statement expressions)" +#else #include "gcc_lambda.hpp" -#define BOOST_TEST_MODULE TestGccLambda -#include +#include #include -BOOST_AUTO_TEST_CASE(test_gcc_lambda) { +int main(void) { //[gcc_lambda int val = 2; int nums[] = {1, 2, 3}; @@ -26,13 +27,10 @@ BOOST_AUTO_TEST_CASE(test_gcc_lambda) { ); //] - BOOST_CHECK(iter != end); - BOOST_CHECK(*iter == val); + BOOST_TEST(iter != end); + BOOST_TEST(*iter == val); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // GCC diff --git a/example/gcc_square.cpp b/example/gcc_square.cpp index d525994..6bd16e8 100644 --- a/example/gcc_square.cpp +++ b/example/gcc_square.cpp @@ -6,8 +6,7 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestGccSquare -#include +#include int add_square(int a, int b) { int BOOST_LOCAL_FUNCTION(int z) { @@ -17,7 +16,8 @@ int add_square(int a, int b) { return square(a) + square(b); } -BOOST_AUTO_TEST_CASE(test_gcc_square) { - BOOST_CHECK(add_square(2, 4) == 20); +int main(void) { + BOOST_TEST(add_square(2, 4) == 20); + return boost::report_errors(); } diff --git a/example/gcc_store.cpp b/example/gcc_store.cpp index 7c0d757..57b68ad 100644 --- a/example/gcc_store.cpp +++ b/example/gcc_store.cpp @@ -7,8 +7,7 @@ #include #include -#define BOOST_TEST_MODULE TestGccStore -#include +#include void intermediate(boost::function store_func, int size) { store_func(size - 1, -1); @@ -22,12 +21,13 @@ void hack(int* array, int size) { intermediate(store, size); } -BOOST_AUTO_TEST_CASE(test_gcc_store) { +int main(void) { int nums[] = {1, 2, 3}; hack(nums, 3); - BOOST_CHECK(nums[0] == 1); - BOOST_CHECK(nums[1] == 2); - BOOST_CHECK(nums[2] == -1); + BOOST_TEST(nums[0] == 1); + BOOST_TEST(nums[1] == 2); + BOOST_TEST(nums[2] == -1); + return boost::report_errors(); } diff --git a/example/impl_pp_keyword.cpp b/example/impl_pp_keyword.cpp index 3d6f2be..7a03ae7 100644 --- a/example/impl_pp_keyword.cpp +++ b/example/impl_pp_keyword.cpp @@ -9,8 +9,7 @@ #include #include #include -#define BOOST_TEST_MODULE TestImplPpKeyword -#include +#include // Expand to 1 if space-separated tokens end with `this_`, 0 otherwise. #define IS_THIS_BACK(tokens) \ @@ -20,9 +19,10 @@ tokens \ ))) -BOOST_AUTO_TEST_CASE(test_impl_pp_keyword) { - BOOST_CHECK(IS_THIS_BACK(const bind this_) == 1); - BOOST_CHECK(IS_THIS_BACK(const bind& x) == 0); +int main(void) { + BOOST_TEST(IS_THIS_BACK(const bind this_) == 1); + BOOST_TEST(IS_THIS_BACK(const bind& x) == 0); + return boost::report_errors(); } //] diff --git a/example/impl_tparam_tricks.cpp b/example/impl_tparam_tricks.cpp index 4cbaa38..e51de7c 100644 --- a/example/impl_tparam_tricks.cpp +++ b/example/impl_tparam_tricks.cpp @@ -6,8 +6,7 @@ // Home at http://www.boost.org/libs/local_function //[impl_tparam_tricks -#define BOOST_TEST_MODULE TestImplTparamTricks -#include +#include #include #include @@ -34,7 +33,7 @@ private: interface* func_; }; -BOOST_AUTO_TEST_CASE(test_impl_tparam_tricks) { +int main(void) { int sum = 0, factor = 10; // Local class for local function. @@ -66,7 +65,8 @@ BOOST_AUTO_TEST_CASE(test_impl_tparam_tricks) { std::for_each(v.begin(), v.end(), add_casting); // OK. std::for_each(v.begin(), v.end(), add_virtual); // OK. - BOOST_CHECK(sum == 200); + BOOST_TEST(sum == 200); + return boost::report_errors(); } //] diff --git a/example/n2529_this.cpp b/example/n2529_this.cpp index f869af5..741cf92 100644 --- a/example/n2529_this.cpp +++ b/example/n2529_this.cpp @@ -6,8 +6,7 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestN2529This -#include +#include #include #include @@ -25,7 +24,7 @@ struct v { } }; -BOOST_AUTO_TEST_CASE(test_n2529_this) { +int main(void) { std::vector n(3); n[0] = 1; n[1] = 2; n[2] = 3; @@ -35,8 +34,9 @@ BOOST_AUTO_TEST_CASE(test_n2529_this) { v vn(n); vn.change_sign_all(i); - BOOST_CHECK(vn.nums.at(0) == -1); - BOOST_CHECK(vn.nums.at(1) == 2); - BOOST_CHECK(vn.nums.at(2) == -3); + BOOST_TEST(vn.nums.at(0) == -1); + BOOST_TEST(vn.nums.at(1) == 2); + BOOST_TEST(vn.nums.at(2) == -3); + return boost::report_errors(); } diff --git a/example/n2550_find_if.cpp b/example/n2550_find_if.cpp index 4add9cb..f3c2fc0 100644 --- a/example/n2550_find_if.cpp +++ b/example/n2550_find_if.cpp @@ -6,8 +6,7 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestN2550FindIf -#include +#include #include #include @@ -16,7 +15,7 @@ struct employee { explicit employee(const int& a_salary): salary(a_salary) {} }; -BOOST_AUTO_TEST_CASE(test_n2550_find_if) { +int main(void) { std::vector employees; employees.push_back(employee(85000)); employees.push_back(employee(100000)); @@ -35,7 +34,8 @@ BOOST_AUTO_TEST_CASE(test_n2550_find_if) { std::vector::iterator i = std::find_if( employees.begin(), employees.end(), between); - BOOST_CHECK(i != employees.end()); - BOOST_CHECK(i->salary >= min_salary && i->salary < u_limit); + BOOST_TEST(i != employees.end()); + BOOST_TEST(i->salary >= min_salary && i->salary < u_limit); + return boost::report_errors(); } diff --git a/example/noncopyable_lambda_error.cpp b/example/noncopyable_cxx11_lambda_error.cpp similarity index 68% rename from example/noncopyable_lambda_error.cpp rename to example/noncopyable_cxx11_lambda_error.cpp index 4e87aed..79499dc 100644 --- a/example/noncopyable_lambda_error.cpp +++ b/example/noncopyable_cxx11_lambda_error.cpp @@ -6,7 +6,9 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_LAMBDAS +#ifdef BOOST_NO_LAMBDAS +# error "lambda functions required" +#else #include #include @@ -20,8 +22,8 @@ struct n: boost::noncopyable { int main(void) { n x(-1); - auto f = [x](void) { // Error: x is non-copyable, but if - assert( x.i == -1 ); // bind `&x` then `x` is not constant. + auto f = [x](void) { // Error: x is non-copyable, but if + assert(x.i == -1); // bind `&x` then `x` is not constant. }; f(); @@ -29,9 +31,5 @@ int main(void) { } //] -#else // NO_LAMBDAS - -#error "Trivial failure." - -#endif // NO_LAMBDAS +#endif // LAMBDAS diff --git a/example/noncopyable_local_function.cpp b/example/noncopyable_local_function.cpp index 9f76afb..8a3e720 100644 --- a/example/noncopyable_local_function.cpp +++ b/example/noncopyable_local_function.cpp @@ -19,7 +19,7 @@ int main() { n x(-1); void BOOST_LOCAL_FUNCTION(const bind& x) { // OK: No copy - assert( x.i == -1 ); // and constant. + assert(x.i == -1); // and constant. } BOOST_LOCAL_FUNCTION_NAME(f) f(); diff --git a/example/phoenix_factorial.cpp b/example/phoenix_factorial.cpp index b1a89a7..bdc8306 100644 --- a/example/phoenix_factorial.cpp +++ b/example/phoenix_factorial.cpp @@ -7,8 +7,7 @@ #include #include -#define BOOST_TEST_MODULE TestPhoenixFactorial -#include +#include //[phoenix_factorial struct factorial_impl { // Phoenix function from global functor. @@ -27,14 +26,15 @@ struct factorial_impl { // Phoenix function from global functor. } }; -BOOST_AUTO_TEST_CASE(test_phoenix_factorial) { +int main(void) { using boost::phoenix::arg_names::arg1; boost::phoenix::function factorial; int i = 4; - BOOST_CHECK(factorial(i)() == 24); // Call. - BOOST_CHECK(factorial(arg1)(i) == 24); // Lazy call. + BOOST_TEST(factorial(i)() == 24); // Call. + BOOST_TEST(factorial(arg1)(i) == 24); // Lazy call. + return boost::report_errors(); } //] diff --git a/example/phoenix_factorial_local.cpp b/example/phoenix_factorial_local.cpp index dade5f0..c52c094 100644 --- a/example/phoenix_factorial_local.cpp +++ b/example/phoenix_factorial_local.cpp @@ -9,11 +9,10 @@ #include #include #include -#define BOOST_TEST_MODULE TestPhoenixFactorialLocal -#include +#include //[phoenix_factorial_local -BOOST_AUTO_TEST_CASE(test_phoenix_factorial_local) { +int main(void) { using boost::phoenix::arg_names::arg1; int BOOST_LOCAL_FUNCTION(int n) { // Unfortunately, monomorphic. @@ -24,8 +23,9 @@ BOOST_AUTO_TEST_CASE(test_phoenix_factorial_local) { factorial(factorial_impl); // Phoenix function from local function. int i = 4; - BOOST_CHECK(factorial(i)() == 24); // Call. - BOOST_CHECK(factorial(arg1)(i) == 24); // Lazy call. + BOOST_TEST(factorial(i)() == 24); // Call. + BOOST_TEST(factorial(arg1)(i) == 24); // Lazy call. + return boost::report_errors(); } //] diff --git a/example/profile_lambda.cpp b/example/profile_cxx11_lambda.cpp similarity index 90% rename from example/profile_lambda.cpp rename to example/profile_cxx11_lambda.cpp index a30ef8c..c07ee08 100644 --- a/example/profile_lambda.cpp +++ b/example/profile_cxx11_lambda.cpp @@ -6,7 +6,9 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_LAMBDAS +#ifdef BOOST_NO_LAMBDAS +# error "lambda functions required" +#else #include #include @@ -38,9 +40,5 @@ int main(int argc, char* argv[]) { return 0; } -#else // NO_LAMBDAS - -int main(void) { return 0; } // Trivial program. - -#endif // NO_LAMBDAS +#endif // LAMBDAS diff --git a/example/profile_legend_lambda.png b/example/profile_legend_cxx11_lambda.png similarity index 100% rename from example/profile_legend_lambda.png rename to example/profile_legend_cxx11_lambda.png diff --git a/example/scope_exit.cpp b/example/scope_exit.cpp index 1600545..607bf6b 100644 --- a/example/scope_exit.cpp +++ b/example/scope_exit.cpp @@ -10,13 +10,11 @@ #include #include #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() -#define BOOST_TEST_MODULE TestScopeExit -#include +#include #include #include #include -class person; BOOST_TYPEOF_REGISTER_TYPE(person) class person { friend class world; public: @@ -32,8 +30,8 @@ private: id_t id_; evolution_t evolution_; }; +BOOST_TYPEOF_REGISTER_TYPE(person) -class world; BOOST_TYPEOF_REGISTER_TYPE(world) class world { public: typedef unsigned int id_t; @@ -53,6 +51,7 @@ private: id_t next_id_; std::vector persons_; }; +BOOST_TYPEOF_REGISTER_TYPE(world) void world::add_person(person const& a_person) { persons_.push_back(a_person); @@ -87,17 +86,17 @@ void world::add_person(person const& a_person) { checkpoint = ++p.evolution_; } -BOOST_AUTO_TEST_CASE(test_scope_exit) { +int main(void) { person adam, eva; std::ostringstream oss; oss << adam; std::cout << oss.str() << std::endl; - BOOST_CHECK(oss.str() == "person(0, 0)"); + BOOST_TEST(oss.str() == "person(0, 0)"); oss.str(""); oss << eva; std::cout << oss.str() << std::endl; - BOOST_CHECK(oss.str() == "person(0, 0)"); + BOOST_TEST(oss.str() == "person(0, 0)"); world w; w.add_person(adam); @@ -105,6 +104,7 @@ BOOST_AUTO_TEST_CASE(test_scope_exit) { oss.str(""); oss << w; std::cout << oss.str() << std::endl; - BOOST_CHECK(oss.str() == "world(3, { person(1, 2), person(2, 2), })"); + BOOST_TEST(oss.str() == "world(3, { person(1, 2), person(2, 2), })"); + return boost::report_errors(); } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ef4025a..e3038d2 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -7,55 +7,42 @@ import testing ; -project : requirements /boost//unit_test_framework ; - -# Run variadic and sequence syntax (also forcing no variadic macros). -rule run-vaseq ( file_name ) +rule vaseq ( command target ) { - run $(file_name).cpp ; - run $(file_name)_seq.cpp ; - run $(file_name)_seq.cpp : : : BOOST_NO_VARIADIC_MACROS : - $(file_name)_seq_nova : ; + $(command) $(target).cpp ; + $(command) $(target)_seq.cpp ; + $(command) $(target)_seq_nova.cpp ; } -# Compile-fail variadic and sequence syntax (also forcing no variadic macros). -rule compile-fail-vaseq ( file_name ) -{ - compile-fail $(file_name).cpp ; - compile-fail $(file_name)_seq.cpp ; - compile-fail $(file_name)_seq.cpp : BOOST_NO_VARIADIC_MACROS : - $(file_name)_seq_nova ; -} +vaseq run add ; +vaseq run add_classifiers ; +vaseq run add_default ; +vaseq run add_except ; +vaseq run add_inline ; +vaseq run add_params_only ; +vaseq run add_template ; +vaseq run add_this ; +vaseq run add_typed ; +vaseq run add_with_default ; +vaseq run all_decl ; +vaseq run factorial ; +vaseq run goto ; +vaseq compile-fail goto_error ; +vaseq run macro_commas ; +vaseq run nesting ; +vaseq run operator ; +vaseq compile-fail operator_error ; +vaseq run overload ; +vaseq run return_assign ; +vaseq run return_derivative ; +vaseq run return_inc ; +vaseq run return_setget ; +vaseq run return_this ; +vaseq run same_line ; +vaseq run transform ; +vaseq run typeof ; +vaseq run typeof_template ; -run-vaseq add ; -run-vaseq add_classifiers ; -run-vaseq add_default ; -run-vaseq add_except ; -run-vaseq add_inline ; -run add_lambda.cpp ; -run-vaseq add_params_only ; -run-vaseq add_template ; -run-vaseq add_this ; -run-vaseq add_typed ; -run-vaseq add_with_default ; -run-vaseq all_decl ; -run-vaseq factorial ; -run-vaseq goto ; -compile-fail-vaseq goto_error ; -run-vaseq macro_commas ; -run-vaseq nesting ; -run-vaseq operator ; -compile-fail-vaseq operator_error ; -run-vaseq overload ; -run-vaseq return_assign ; -run-vaseq return_derivative ; -run-vaseq return_inc ; -run-vaseq return_setget ; -run-vaseq return_this ; -run-vaseq same_line ; run ten_void.cpp ; -run ten_void.cpp : : : BOOST_NO_VARIADIC_MACROS : ten_void_nova : ; -run-vaseq transform ; -run-vaseq typeof ; -run-vaseq typeof_template ; +run ten_void_nova.cpp ; diff --git a/test/add.cpp b/test/add.cpp index b9c7c4b..de39687 100644 --- a/test/add.cpp +++ b/test/add.cpp @@ -6,16 +6,16 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestAdd -#include +#include #include -BOOST_AUTO_TEST_CASE(test_add) //[add -{ // Some local scope. +int main(void) { // Some local scope. int sum = 0, factor = 10; // Variables in scope to bind. void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum, int num) { @@ -26,13 +26,10 @@ BOOST_AUTO_TEST_CASE(test_add) int nums[] = {2, 3}; std::for_each(nums, nums + 2, add); // Pass it to an algorithm. - BOOST_CHECK(sum == 60); // Assert final summation value. + BOOST_TEST(sum == 60); // Assert final summation value. + return boost::report_errors(); } //] -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/add_classifiers.cpp b/test/add_classifiers.cpp index 3f53258..758e2c5 100644 --- a/test/add_classifiers.cpp +++ b/test/add_classifiers.cpp @@ -6,25 +6,25 @@ // Home at http://www.boost.org/libs/local_function #include -#if defined(BOOST_NO_AUTO_DECLARATIONS) && !defined(BOOST_NO_VARIADIC_MACROS) +#if !defined(BOOST_NO_AUTO_DECLARATIONS) +# error "auto-declarations not allowed (using `auto` as storage classifier)" +#elif defined(BOOST_NO_VARIADIC_MACROS) +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestAddClassifiers -#include +#include -BOOST_AUTO_TEST_CASE(test_add_classifiers) { +int main(void) { //[add_classifiers int BOOST_LOCAL_FUNCTION(auto int x, register int y) { // Classifiers. return x + y; } BOOST_LOCAL_FUNCTION_NAME(add) //] - BOOST_CHECK(add(1, 2) == 3); + BOOST_TEST(add(1, 2) == 3); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // AUTO_DECLARATIONS && VARIADIC_MACROS diff --git a/test/add_classifiers_seq.cpp b/test/add_classifiers_seq.cpp index ed1fe0f..4249d28 100644 --- a/test/add_classifiers_seq.cpp +++ b/test/add_classifiers_seq.cpp @@ -6,23 +6,21 @@ // Home at http://www.boost.org/libs/local_function #include -#ifdef BOOST_NO_AUTO_DECLARATIONS +#ifndef BOOST_NO_AUTO_DECLARATIONS +# error "auto-declarations not allowed (using `auto` as storage classifier)" +#else #include -#define BOOST_TEST_MODULE TestAddClassifiersSeq -#include +#include -BOOST_AUTO_TEST_CASE(test_add_classifiers_seq) { +int main(void) { int BOOST_LOCAL_FUNCTION( (auto int x) (register int y) ) { return x + y; } BOOST_LOCAL_FUNCTION_NAME(add) - BOOST_CHECK(add(1, 2) == 3); + BOOST_TEST(add(1, 2) == 3); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // AUTO_DECLARATIONS diff --git a/test/add_classifiers_seq_nova.cpp b/test/add_classifiers_seq_nova.cpp new file mode 100644 index 0000000..3462584 --- /dev/null +++ b/test/add_classifiers_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "add_classifiers_seq.cpp" + diff --git a/test/add_default.cpp b/test/add_default.cpp index a2962a7..902855f 100644 --- a/test/add_default.cpp +++ b/test/add_default.cpp @@ -6,25 +6,23 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestAddDefault -#include +#include -BOOST_AUTO_TEST_CASE(test_add_default) { +int main(void) { //[add_default - int BOOST_LOCAL_FUNCTION(int x, int y, default 2) { // Default. + int BOOST_LOCAL_FUNCTION(int x, int y, default 2) { // Default parameter. return x + y; } BOOST_LOCAL_FUNCTION_NAME(add) - BOOST_CHECK(add(1) == 3); + BOOST_TEST(add(1) == 3); //] + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/add_default_seq.cpp b/test/add_default_seq.cpp index 4b3a2a1..8130a90 100644 --- a/test/add_default_seq.cpp +++ b/test/add_default_seq.cpp @@ -6,14 +6,14 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestAddDefaultSeq -#include +#include -BOOST_AUTO_TEST_CASE(test_add_default_seq) { +int main(void) { int BOOST_LOCAL_FUNCTION( (int x) (int y)(default 2) ) { return x + y; } BOOST_LOCAL_FUNCTION_NAME(add) - BOOST_CHECK(add(1) == 3); + BOOST_TEST(add(1) == 3); + return boost::report_errors(); } diff --git a/test/add_default_seq_nova.cpp b/test/add_default_seq_nova.cpp new file mode 100644 index 0000000..92e4ea7 --- /dev/null +++ b/test/add_default_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "add_default_seq.cpp" + diff --git a/test/add_except.cpp b/test/add_except.cpp index 3fdd826..8cd82fe 100644 --- a/test/add_except.cpp +++ b/test/add_except.cpp @@ -6,13 +6,14 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestAddExcept -#include +#include -BOOST_AUTO_TEST_CASE(test_except) { +int main(void) { //[add_except double sum = 0.0; int factor = 10; @@ -25,12 +26,9 @@ BOOST_AUTO_TEST_CASE(test_except) { add(100); //] - BOOST_CHECK(sum == 1000); + BOOST_TEST(sum == 1000); + return boost::report_errors(); } -#else - -int main(void) { return 0; } - -#endif +#endif // VARIADIC_MACROS diff --git a/test/add_except_seq.cpp b/test/add_except_seq.cpp index 4b9cafb..be1d186 100644 --- a/test/add_except_seq.cpp +++ b/test/add_except_seq.cpp @@ -6,10 +6,9 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestAddExceptSeq -#include +#include -BOOST_AUTO_TEST_CASE(test_except_seq) { +int main(void) { double sum = 0.0; int factor = 10; @@ -20,6 +19,7 @@ BOOST_AUTO_TEST_CASE(test_except_seq) { add(100); - BOOST_CHECK(sum == 1000); + BOOST_TEST(sum == 1000); + return boost::report_errors(); } diff --git a/test/add_except_seq_nova.cpp b/test/add_except_seq_nova.cpp new file mode 100644 index 0000000..44f53a2 --- /dev/null +++ b/test/add_except_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "add_except_seq.cpp" + diff --git a/test/add_inline.cpp b/test/add_inline.cpp index bd86f61..5777b58 100644 --- a/test/add_inline.cpp +++ b/test/add_inline.cpp @@ -6,15 +6,16 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestAddInline -#include +#include #include #include -BOOST_AUTO_TEST_CASE(test_add_inline) { +int main(void) { //[add_inline int sum = 0, factor = 10; @@ -28,12 +29,9 @@ BOOST_AUTO_TEST_CASE(test_add_inline) { for(size_t i = 0; i < v.size(); ++i) add(v[i]); // Cannot use for_each. //] - BOOST_CHECK(sum == 1000); + BOOST_TEST(sum == 1000); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/add_inline_seq.cpp b/test/add_inline_seq.cpp index 00f9516..7802621 100644 --- a/test/add_inline_seq.cpp +++ b/test/add_inline_seq.cpp @@ -6,12 +6,11 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestAddInlineSeq -#include +#include #include #include -BOOST_AUTO_TEST_CASE(test_add_inline_seq) { +int main(void) { int sum = 0, factor = 10; void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) { @@ -23,6 +22,7 @@ BOOST_AUTO_TEST_CASE(test_add_inline_seq) { for(size_t i = 0; i < v.size(); ++i) add(v[i]); - BOOST_CHECK(sum == 1000); + BOOST_TEST(sum == 1000); + return boost::report_errors(); } diff --git a/test/add_inline_seq_nova.cpp b/test/add_inline_seq_nova.cpp new file mode 100644 index 0000000..e040ad6 --- /dev/null +++ b/test/add_inline_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "add_inline_seq.cpp" + diff --git a/test/add_params_only.cpp b/test/add_params_only.cpp index d613994..08e48c8 100644 --- a/test/add_params_only.cpp +++ b/test/add_params_only.cpp @@ -6,25 +6,23 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestAddParamsOnly -#include +#include -BOOST_AUTO_TEST_CASE(test_add_params_only) { +int main(void) { //[add_params_only int BOOST_LOCAL_FUNCTION(int x, int y) { // Local function. return x + y; } BOOST_LOCAL_FUNCTION_NAME(add) - BOOST_CHECK(add(1, 2) == 3); // Local function call. + BOOST_TEST(add(1, 2) == 3); // Local function call. //] + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/add_params_only_seq.cpp b/test/add_params_only_seq.cpp index a1e55d2..565d5ff 100644 --- a/test/add_params_only_seq.cpp +++ b/test/add_params_only_seq.cpp @@ -6,14 +6,14 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestAddParamsOnlySeq -#include +#include -BOOST_AUTO_TEST_CASE(test_add_params_only_seq) { +int main(void) { int BOOST_LOCAL_FUNCTION( (int x) (int y) ) { return x + y; } BOOST_LOCAL_FUNCTION_NAME(add) - BOOST_CHECK(add(1, 2) == 3); + BOOST_TEST(add(1, 2) == 3); + return boost::report_errors(); } diff --git a/test/add_params_only_seq_nova.cpp b/test/add_params_only_seq_nova.cpp new file mode 100644 index 0000000..7123aae --- /dev/null +++ b/test/add_params_only_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "add_params_only_seq.cpp" + diff --git a/test/add_seq.cpp b/test/add_seq.cpp index 8b38026..d04819b 100644 --- a/test/add_seq.cpp +++ b/test/add_seq.cpp @@ -6,13 +6,11 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestAddSeq -#include +#include #include -BOOST_AUTO_TEST_CASE(test_add_seq) //[add_seq -{ +int main(void) { int sum = 0, factor = 10; void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) { @@ -23,7 +21,8 @@ BOOST_AUTO_TEST_CASE(test_add_seq) int nums[] = {2, 3}; std::for_each(nums, nums + 2, add); - BOOST_CHECK(sum == 60); + BOOST_TEST(sum == 60); + return boost::report_errors(); } //] diff --git a/test/add_seq_nova.cpp b/test/add_seq_nova.cpp new file mode 100644 index 0000000..ce0c279 --- /dev/null +++ b/test/add_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "add_seq.cpp" + diff --git a/test/add_template.cpp b/test/add_template.cpp index db21166..3f9425c 100644 --- a/test/add_template.cpp +++ b/test/add_template.cpp @@ -6,11 +6,12 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestAddTemplate -#include +#include #include //[add_template @@ -31,13 +32,10 @@ T total(const T& x, const T& y, const T& z) { } //] -BOOST_AUTO_TEST_CASE(test_add_template) { - BOOST_CHECK(total(1, 2, 3) == 60); +int main(void) { + BOOST_TEST(total(1, 2, 3) == 60); + return boost::report_errors(); } -#else - -int main(void) { return 0; } - -#endif +#endif // VARIADIC_MACROS diff --git a/test/add_template_seq.cpp b/test/add_template_seq.cpp index 205922c..8e89347 100644 --- a/test/add_template_seq.cpp +++ b/test/add_template_seq.cpp @@ -6,8 +6,7 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestAddTemplateSeq -#include +#include #include template @@ -25,7 +24,8 @@ T total(const T& x, const T& y, const T& z) { return sum; } -BOOST_AUTO_TEST_CASE(test_add_template_seq) { - BOOST_CHECK(total(1, 2, 3) == 60); +int main(void) { + BOOST_TEST(total(1, 2, 3) == 60); + return boost::report_errors(); } diff --git a/test/add_template_seq_nova.cpp b/test/add_template_seq_nova.cpp new file mode 100644 index 0000000..9c02384 --- /dev/null +++ b/test/add_template_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "add_template_seq.cpp" + diff --git a/test/add_this.cpp b/test/add_this.cpp index ed4669c..53dee3e 100644 --- a/test/add_this.cpp +++ b/test/add_this.cpp @@ -6,11 +6,12 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestAddThis -#include +#include #include #include @@ -33,16 +34,13 @@ private: }; //] -BOOST_AUTO_TEST_CASE(test_add_this) { +int main(void) { std::vector v(3); v[0] = 1; v[1] = 2; v[2] = 3; - BOOST_CHECK(adder().sum(v) == 60); + BOOST_TEST(adder().sum(v) == 60); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/add_this_seq.cpp b/test/add_this_seq.cpp index a141ac0..633d1b9 100644 --- a/test/add_this_seq.cpp +++ b/test/add_this_seq.cpp @@ -6,8 +6,7 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestAddThisSeq -#include +#include #include #include @@ -29,10 +28,11 @@ private: int sum_; }; -BOOST_AUTO_TEST_CASE(test_add_this_seq) { +int main(void) { std::vector v(3); v[0] = 1; v[1] = 2; v[2] = 3; - BOOST_CHECK(adder().sum(v) == 60); + BOOST_TEST(adder().sum(v) == 60); + return boost::report_errors(); } diff --git a/test/add_this_seq_nova.cpp b/test/add_this_seq_nova.cpp new file mode 100644 index 0000000..e015739 --- /dev/null +++ b/test/add_this_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "add_this_seq.cpp" + diff --git a/test/add_typed.cpp b/test/add_typed.cpp index 303c95f..9172315 100644 --- a/test/add_typed.cpp +++ b/test/add_typed.cpp @@ -6,11 +6,12 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestAddTyped -#include +#include #include #include @@ -34,16 +35,13 @@ private: }; //] -BOOST_AUTO_TEST_CASE(test_add_typed) { +int main(void) { std::vector v(3); v[0] = 1; v[1] = 2; v[2] = 3; - BOOST_CHECK(adder().sum(v) == 60); + BOOST_TEST(adder().sum(v) == 60); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/add_typed_seq.cpp b/test/add_typed_seq.cpp index 51ecea2..6e9e370 100644 --- a/test/add_typed_seq.cpp +++ b/test/add_typed_seq.cpp @@ -6,8 +6,7 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestAddTypedSeq -#include +#include #include #include @@ -28,10 +27,11 @@ private: int sum_; }; -BOOST_AUTO_TEST_CASE(test_add_typed_seq) { +int main(void) { std::vector v(3); v[0] = 1; v[1] = 2; v[2] = 3; - BOOST_CHECK(adder().sum(v) == 60); + BOOST_TEST(adder().sum(v) == 60); + return boost::report_errors(); } diff --git a/test/add_typed_seq_nova.cpp b/test/add_typed_seq_nova.cpp new file mode 100644 index 0000000..0cdb356 --- /dev/null +++ b/test/add_typed_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "add_typed_seq.cpp" + diff --git a/test/add_with_default.cpp b/test/add_with_default.cpp index 9fc354f..fc3e446 100644 --- a/test/add_with_default.cpp +++ b/test/add_with_default.cpp @@ -6,29 +6,27 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestAddWithDefault -#include +#include //[add_with_default_macro #define WITH_DEFAULT , default //] -BOOST_AUTO_TEST_CASE(test_add_with_default) { +int main(void) { //[add_with_default int BOOST_LOCAL_FUNCTION(int x, int y WITH_DEFAULT 2) { // Default. return x + y; } BOOST_LOCAL_FUNCTION_NAME(add) - BOOST_CHECK(add(1) == 3); + BOOST_TEST(add(1) == 3); //] + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/add_with_default_seq.cpp b/test/add_with_default_seq.cpp index 36fc62b..1513af0 100644 --- a/test/add_with_default_seq.cpp +++ b/test/add_with_default_seq.cpp @@ -6,16 +6,16 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestAddWithDefaultSeq -#include +#include #define WITH_DEFAULT )(default -BOOST_AUTO_TEST_CASE(test_add_with_default_seq) { +int main(void) { int BOOST_LOCAL_FUNCTION( (int x) (int y WITH_DEFAULT 2) ) { return x + y; } BOOST_LOCAL_FUNCTION_NAME(add) - BOOST_CHECK(add(1) == 3); + BOOST_TEST(add(1) == 3); + return boost::report_errors(); } diff --git a/test/add_with_default_seq_nova.cpp b/test/add_with_default_seq_nova.cpp new file mode 100644 index 0000000..d7149cc --- /dev/null +++ b/test/add_with_default_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "add_with_default_seq.cpp" + diff --git a/test/all_decl.cpp b/test/all_decl.cpp index 98e585c..cda2292 100644 --- a/test/all_decl.cpp +++ b/test/all_decl.cpp @@ -6,7 +6,9 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include @@ -166,9 +168,5 @@ int main(void) { return 0; } -#else - -int main(void) { return 0; } - -#endif +#endif // VARIADIC_MACROS diff --git a/test/all_decl_seq_nova.cpp b/test/all_decl_seq_nova.cpp new file mode 100644 index 0000000..8333b28 --- /dev/null +++ b/test/all_decl_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "all_decl_seq.cpp" + diff --git a/test/factorial.cpp b/test/factorial.cpp index 2ecc61e..71fb53b 100644 --- a/test/factorial.cpp +++ b/test/factorial.cpp @@ -6,11 +6,12 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestFactorial -#include +#include #include #include @@ -35,20 +36,17 @@ struct calculator { }; //] -BOOST_AUTO_TEST_CASE(test_factorial) { +int main(void) { std::vector v(3); v[0] = 1; v[1] = 3; v[2] = 4; calculator calc; calc.factorials(v); - BOOST_CHECK(calc.results[0] == 1); - BOOST_CHECK(calc.results[1] == 6); - BOOST_CHECK(calc.results[2] == 24); + BOOST_TEST(calc.results[0] == 1); + BOOST_TEST(calc.results[1] == 6); + BOOST_TEST(calc.results[2] == 24); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/factorial_seq.cpp b/test/factorial_seq.cpp index 3daaf94..f4c39be 100644 --- a/test/factorial_seq.cpp +++ b/test/factorial_seq.cpp @@ -6,8 +6,7 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestFactorialSeq -#include +#include #include #include @@ -30,14 +29,15 @@ struct calculator { } }; -BOOST_AUTO_TEST_CASE(test_factorial_seq) { +int main(void) { std::vector v(3); v[0] = 1; v[1] = 3; v[2] = 4; calculator calc; calc.factorials(v); - BOOST_CHECK(calc.results[0] == 1); - BOOST_CHECK(calc.results[1] == 6); - BOOST_CHECK(calc.results[2] == 24); + BOOST_TEST(calc.results[0] == 1); + BOOST_TEST(calc.results[1] == 6); + BOOST_TEST(calc.results[2] == 24); + return boost::report_errors(); } diff --git a/test/factorial_seq_nova.cpp b/test/factorial_seq_nova.cpp new file mode 100644 index 0000000..b937612 --- /dev/null +++ b/test/factorial_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "factorial_seq.cpp" + diff --git a/test/goto.cpp b/test/goto.cpp index ce07c99..fa2a067 100644 --- a/test/goto.cpp +++ b/test/goto.cpp @@ -6,11 +6,11 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestGoto -#include //[goto int error(int x, int y) { @@ -25,13 +25,10 @@ int error(int x, int y) { } //] -BOOST_AUTO_TEST_CASE(test_goto) { +int main(void) { error(1, 2); + return 0; } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/goto_error.cpp b/test/goto_error.cpp index 3282ef8..8d1597a 100644 --- a/test/goto_error.cpp +++ b/test/goto_error.cpp @@ -6,11 +6,11 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestGotoError -#include //[goto_error int error(int x, int y) { @@ -27,13 +27,10 @@ faliure: } //] -BOOST_AUTO_TEST_CASE(test_goto_error) { +int main(void) { error(1, 2); + return 0; } -#else - -#error "Trivial error." - #endif diff --git a/test/goto_error_seq.cpp b/test/goto_error_seq.cpp index 8ca22a2..41c8217 100644 --- a/test/goto_error_seq.cpp +++ b/test/goto_error_seq.cpp @@ -6,8 +6,6 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestGotoErrorSeq -#include int error(int x, int y) { int BOOST_LOCAL_FUNCTION( (int x) ) { @@ -22,7 +20,8 @@ faliure: return -1; } -BOOST_AUTO_TEST_CASE(test_goto_error_seq) { +int main(void) { error(1, 2); + return 0; } diff --git a/test/goto_error_seq_nova.cpp b/test/goto_error_seq_nova.cpp new file mode 100644 index 0000000..6433add --- /dev/null +++ b/test/goto_error_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "goto_error_seq.cpp" + diff --git a/test/goto_seq.cpp b/test/goto_seq.cpp index 82ee85f..3a50fd0 100644 --- a/test/goto_seq.cpp +++ b/test/goto_seq.cpp @@ -6,8 +6,6 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestGotoSeq -#include int error(int x, int y) { int BOOST_LOCAL_FUNCTION( (int x) ) { @@ -20,7 +18,8 @@ int error(int x, int y) { return validate(x + y); } -BOOST_AUTO_TEST_CASE(test_goto_seq) { +int main(void) { error(1, 2); + return 0; } diff --git a/test/goto_seq_nova.cpp b/test/goto_seq_nova.cpp new file mode 100644 index 0000000..edec9f2 --- /dev/null +++ b/test/goto_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "goto_seq.cpp" + diff --git a/test/macro_commas.cpp b/test/macro_commas.cpp index 5bd04eb..787fd27 100644 --- a/test/macro_commas.cpp +++ b/test/macro_commas.cpp @@ -6,13 +6,12 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include #include -#include -#define BOOST_TEST_MODULE TestMacroCommas -#include #include #include @@ -25,7 +24,7 @@ struct key_sizeof { typedef int sign_t; -BOOST_AUTO_TEST_CASE(test_macro_commas) { +int main(void) { //[macro_commas void BOOST_LOCAL_FUNCTION( BOOST_IDENTITY_TYPE((const std::map&)) m, @@ -41,11 +40,8 @@ BOOST_AUTO_TEST_CASE(test_macro_commas) { std::map m; ::sign_t sign = -1; f(m, sign); + return 0; } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/macro_commas_seq.cpp b/test/macro_commas_seq.cpp index 2ff4188..e8fbb0a 100644 --- a/test/macro_commas_seq.cpp +++ b/test/macro_commas_seq.cpp @@ -8,8 +8,6 @@ #include #include #include -#define BOOST_TEST_MODULE TestMacroCommasSeq -#include #include #include @@ -22,7 +20,7 @@ struct key_sizeof { typedef int sign_t; -BOOST_AUTO_TEST_CASE(test_macro_commas_seq) { +int main(void) { void BOOST_LOCAL_FUNCTION( (BOOST_IDENTITY_TYPE((const std::map&)) m) (BOOST_IDENTITY_TYPE((::sign_t)) sign) @@ -36,5 +34,6 @@ BOOST_AUTO_TEST_CASE(test_macro_commas_seq) { std::map m; ::sign_t sign = -1; f(m, sign); + return 0; } diff --git a/test/macro_commas_seq_nova.cpp b/test/macro_commas_seq_nova.cpp new file mode 100644 index 0000000..4252379 --- /dev/null +++ b/test/macro_commas_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "macro_commas_seq.cpp" + diff --git a/test/nesting.cpp b/test/nesting.cpp index 0a6d696..bb97d64 100644 --- a/test/nesting.cpp +++ b/test/nesting.cpp @@ -6,13 +6,14 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestNesting -#include +#include -BOOST_AUTO_TEST_CASE(test_nesting) { +int main(void) { //[nesting int x = 0; @@ -28,12 +29,9 @@ BOOST_AUTO_TEST_CASE(test_nesting) { f(); //] - BOOST_CHECK(x == 0); + BOOST_TEST(x == 0); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/nesting_seq.cpp b/test/nesting_seq.cpp index 0110539..6e18558 100644 --- a/test/nesting_seq.cpp +++ b/test/nesting_seq.cpp @@ -6,10 +6,9 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestNestingSeq -#include +#include -BOOST_AUTO_TEST_CASE(test_nesting_seq) { +int main(void) { int x = 0; void BOOST_LOCAL_FUNCTION( (bind& x) ) { @@ -23,6 +22,7 @@ BOOST_AUTO_TEST_CASE(test_nesting_seq) { f(); - BOOST_CHECK(x == 0); + BOOST_TEST(x == 0); + return boost::report_errors(); } diff --git a/test/nesting_seq_nova.cpp b/test/nesting_seq_nova.cpp new file mode 100644 index 0000000..caeb072 --- /dev/null +++ b/test/nesting_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "nesting_seq.cpp" + diff --git a/test/nova.hpp b/test/nova.hpp new file mode 100644 index 0000000..58984ac --- /dev/null +++ b/test/nova.hpp @@ -0,0 +1,21 @@ + +// Copyright (C) 2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/scope_exit + +#ifndef NOVA_HPP_ +#define NOVA_HPP_ + +#include + +// WARNING: This file must be included first in each compilation unit. + +// Force no variadic macros but avoiding macro redefinition warning/error. +#ifndef BOOST_NO_VARIADIC_MACROS +# define BOOST_NO_VARIADIC_MACROS +#endif + +#endif // #include guard + diff --git a/test/operator.cpp b/test/operator.cpp index a7871e7..86079f4 100644 --- a/test/operator.cpp +++ b/test/operator.cpp @@ -6,11 +6,12 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestOperator -#include +#include //[operator struct point { @@ -18,20 +19,17 @@ struct point { int y; }; -BOOST_AUTO_TEST_CASE(test_operator) { +int main(void) { bool BOOST_LOCAL_FUNCTION(const point& p, const point& q) { return p.x == q.x && p.y == q.y; } BOOST_LOCAL_FUNCTION_NAME(equal) // OK: not using `operator...`. point a; a.x = 1; a.y = 2; point b = a; - BOOST_CHECK(equal(a, b)); + BOOST_TEST(equal(a, b)); + return boost::report_errors(); } //] -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/operator_error.cpp b/test/operator_error.cpp index e479045..08f8945 100644 --- a/test/operator_error.cpp +++ b/test/operator_error.cpp @@ -6,11 +6,12 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestOperatorError -#include +#include //[operator_error struct point { @@ -25,13 +26,10 @@ BOOST_AUTO_TEST_CASE(test_operator_error) { point a; a.x = 1; a.y = 2; point b = a; - BOOST_CHECK(a == b); + BOOST_TEST(a == b); + return boost::report_errors(); } //] -#else - -#error "Trivial error." - -#endif +#endif // VARIADIC_MACROS diff --git a/test/operator_error_seq.cpp b/test/operator_error_seq.cpp index 41defbd..5da791c 100644 --- a/test/operator_error_seq.cpp +++ b/test/operator_error_seq.cpp @@ -6,21 +6,21 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestOperatorErrorSeq -#include +#include struct point { int x; int y; }; -BOOST_AUTO_TEST_CASE(test_operator_error_seq) { +int main(void) { bool BOOST_LOCAL_FUNCTION( (const point& p) (const point& q) ) { return p.x == q.x && p.y == q.y; } BOOST_LOCAL_FUNCTION_NAME(operator==) point a; a.x = 1; a.y = 2; point b = a; - BOOST_CHECK(a == b); + BOOST_TEST(a == b); + return boost::report_errors(); } diff --git a/test/operator_error_seq_nova.cpp b/test/operator_error_seq_nova.cpp new file mode 100644 index 0000000..6df7178 --- /dev/null +++ b/test/operator_error_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "operator_error_seq.cpp" + diff --git a/test/operator_seq.cpp b/test/operator_seq.cpp index b4a1642..029390d 100644 --- a/test/operator_seq.cpp +++ b/test/operator_seq.cpp @@ -6,21 +6,21 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestOperatorSeq -#include +#include struct point { int x; int y; }; -BOOST_AUTO_TEST_CASE(test_operator_seq) { +int main(void) { bool BOOST_LOCAL_FUNCTION( (const point& p) (const point& q) ) { return p.x == q.x && p.y == q.y; } BOOST_LOCAL_FUNCTION_NAME(equal) point a; a.x = 1; a.y = 2; point b = a; - BOOST_CHECK(equal(a, b)); + BOOST_TEST(equal(a, b)); + return boost::report_errors(); } diff --git a/test/operator_seq_nova.cpp b/test/operator_seq_nova.cpp new file mode 100644 index 0000000..e6f6246 --- /dev/null +++ b/test/operator_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "operator_seq.cpp" + diff --git a/test/overload.cpp b/test/overload.cpp index 88bc273..8ed70b3 100644 --- a/test/overload.cpp +++ b/test/overload.cpp @@ -6,19 +6,20 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include #include // For overloading. -#define BOOST_TEST_MODULE TestOverload -#include +#include #include #include //[overload int add_i(int x, int y) { return x + y; } -BOOST_AUTO_TEST_CASE(test_overload) { +int main(void) { std::string s = "abc"; std::string BOOST_LOCAL_FUNCTION( const bind& s, const std::string& x) { @@ -37,16 +38,12 @@ BOOST_AUTO_TEST_CASE(test_overload) { , int (int, int) > add(add_s, add_d, add_d, add_i); // Overloaded function object. - BOOST_CHECK(add("xyz") == "abcxyz"); // Call `add_s`. - BOOST_CHECK(fabs(add(3.21) - 4.44) < 0.001); // Call `add_d` (no default). - BOOST_CHECK(fabs(add(3.21, 40.0) - 44.44) < 0.001); // Call `add_d`. - BOOST_CHECK(add(1, 2) == 3); // Call `add_i`. + BOOST_TEST(add("xyz") == "abcxyz"); // Call `add_s`. + BOOST_TEST(fabs(add(3.21) - 4.44) < 0.001); // Call `add_d` (no default). + BOOST_TEST(fabs(add(3.21, 40.0) - 44.44) < 0.001); // Call `add_d`. + BOOST_TEST(add(1, 2) == 3); // Call `add_i`. + return boost::report_errors(); } -//] -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/overload_seq.cpp b/test/overload_seq.cpp index 2fb4cad..b31c5d1 100644 --- a/test/overload_seq.cpp +++ b/test/overload_seq.cpp @@ -7,14 +7,13 @@ #include #include -#define BOOST_TEST_MODULE TestOverloadSeq -#include +#include #include #include int add_i(int x, int y) { return x + y; } -BOOST_AUTO_TEST_CASE(test_overload_seq) { +int main(void) { std::string s = "abc"; std::string BOOST_LOCAL_FUNCTION( (const bind& s) (const std::string& x) ) { @@ -34,9 +33,10 @@ BOOST_AUTO_TEST_CASE(test_overload_seq) { , int (int, int) > add(add_s, add_d, add_d, add_i); - BOOST_CHECK(add("xyz") == "abcxyz"); - BOOST_CHECK(fabs(add(3.21) - 4.44) < 0.001); - BOOST_CHECK(fabs(add(3.21, 40.0) - 44.44) < 0.001); - BOOST_CHECK(add(1, 2) == 3); + BOOST_TEST(add("xyz") == "abcxyz"); + BOOST_TEST(fabs(add(3.21) - 4.44) < 0.001); + BOOST_TEST(fabs(add(3.21, 40.0) - 44.44) < 0.001); + BOOST_TEST(add(1, 2) == 3); + return boost::report_errors(); } diff --git a/test/overload_seq_nova.cpp b/test/overload_seq_nova.cpp new file mode 100644 index 0000000..e72b63b --- /dev/null +++ b/test/overload_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "overload_seq.cpp" + diff --git a/test/return_assign.cpp b/test/return_assign.cpp index dc02995..4bde550 100644 --- a/test/return_assign.cpp +++ b/test/return_assign.cpp @@ -6,17 +6,18 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include #include -#define BOOST_TEST_MODULE TestReturnAssign -#include +#include #include //[return_assign -void call1(boost::function f) { BOOST_CHECK(f(1) == 5); } -void call0(boost::function f) { BOOST_CHECK(f() == 5); } +void call1(boost::function f) { BOOST_TEST(f(1) == 5); } +void call0(boost::function f) { BOOST_TEST(f() == 5); } boost::function linear(const int& slope) { int BOOST_LOCAL_FUNCTION(const bind& slope, @@ -25,7 +26,7 @@ boost::function linear(const int& slope) { } BOOST_LOCAL_FUNCTION_NAME(lin) boost::function f = lin; // Assign to local variable. - BOOST_CHECK(f(1, 2) == 5); + BOOST_TEST(f(1, 2) == 5); call1(lin); // Pass to other functions. call0(lin); @@ -35,17 +36,14 @@ boost::function linear(const int& slope) { void call(void) { boost::function f = linear(2); - BOOST_CHECK(f(1, 2) == 5); + BOOST_TEST(f(1, 2) == 5); } //] -BOOST_AUTO_TEST_CASE(test_return_assign) { +int main(void) { call(); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/return_assign_seq.cpp b/test/return_assign_seq.cpp index b456aa3..95c6bf1 100644 --- a/test/return_assign_seq.cpp +++ b/test/return_assign_seq.cpp @@ -7,12 +7,11 @@ #include #include -#define BOOST_TEST_MODULE TestReturnAssignSeq -#include +#include #include -void call1(boost::function f) { BOOST_CHECK(f(1) == 5); } -void call0(boost::function f) { BOOST_CHECK(f() == 5); } +void call1(boost::function f) { BOOST_TEST(f(1) == 5); } +void call0(boost::function f) { BOOST_TEST(f() == 5); } boost::function linear(const int& slope) { int BOOST_LOCAL_FUNCTION( (const bind& slope) @@ -21,7 +20,7 @@ boost::function linear(const int& slope) { } BOOST_LOCAL_FUNCTION_NAME(lin) boost::function f = lin; - BOOST_CHECK(f(1, 2) == 5); + BOOST_TEST(f(1, 2) == 5); call1(lin); call0(lin); @@ -31,10 +30,11 @@ boost::function linear(const int& slope) { void call(void) { boost::function f = linear(2); - BOOST_CHECK(f(1, 2) == 5); + BOOST_TEST(f(1, 2) == 5); } -BOOST_AUTO_TEST_CASE(test_return_assign_seq) { +int main(void) { call(); + return boost::report_errors(); } diff --git a/test/return_assign_seq_nova.cpp b/test/return_assign_seq_nova.cpp new file mode 100644 index 0000000..12de8da --- /dev/null +++ b/test/return_assign_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "return_assign_seq.cpp" + diff --git a/test/return_derivative.cpp b/test/return_derivative.cpp index 55c8c73..c80ac73 100644 --- a/test/return_derivative.cpp +++ b/test/return_derivative.cpp @@ -6,12 +6,13 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include #include -#define BOOST_TEST_MODULE TestReturnDerivative -#include +#include boost::function derivative(boost::function& f, int dx) { int BOOST_LOCAL_FUNCTION(bind& f, const bind dx, int x) { @@ -21,7 +22,7 @@ boost::function derivative(boost::function& f, int dx) { return deriv; } -BOOST_AUTO_TEST_CASE(test_return_derivative) { +int main(void) { int BOOST_LOCAL_FUNCTION(int x) { return x + 4; } BOOST_LOCAL_FUNCTION_NAME(add2) @@ -29,12 +30,9 @@ BOOST_AUTO_TEST_CASE(test_return_derivative) { boost::function a2 = add2; // Reference valid where closure used. boost::function d2 = derivative(a2, 2); - BOOST_CHECK(d2(6) == 1); + BOOST_TEST(d2(6) == 1); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/return_derivative_seq.cpp b/test/return_derivative_seq.cpp index ecfad7b..6f2ea4d 100644 --- a/test/return_derivative_seq.cpp +++ b/test/return_derivative_seq.cpp @@ -7,8 +7,7 @@ #include #include -#define BOOST_TEST_MODULE TestReturnDerivativeSeq -#include +#include boost::function derivative(boost::function& f, int dx) { int BOOST_LOCAL_FUNCTION( (bind& f) (const bind dx) (int x) ) { @@ -18,7 +17,7 @@ boost::function derivative(boost::function& f, int dx) { return deriv; } -BOOST_AUTO_TEST_CASE(test_return_derivative_seq) { +int main(void) { int BOOST_LOCAL_FUNCTION( (int x) ) { return x + 4; } BOOST_LOCAL_FUNCTION_NAME(add2) @@ -26,6 +25,7 @@ BOOST_AUTO_TEST_CASE(test_return_derivative_seq) { boost::function a2 = add2; boost::function d2 = derivative(a2, 2); - BOOST_CHECK(d2(6) == 1); + BOOST_TEST(d2(6) == 1); + return boost::report_errors(); } diff --git a/test/return_derivative_seq_nova.cpp b/test/return_derivative_seq_nova.cpp new file mode 100644 index 0000000..49bccdd --- /dev/null +++ b/test/return_derivative_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "return_derivative_seq.cpp" + diff --git a/test/return_inc.cpp b/test/return_inc.cpp index c73393e..4be2d01 100644 --- a/test/return_inc.cpp +++ b/test/return_inc.cpp @@ -6,12 +6,13 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include #include -#define BOOST_TEST_MODULE TestReturnInc -#include +#include boost::function inc(int& value) { int BOOST_LOCAL_FUNCTION(bind& value) { @@ -20,21 +21,18 @@ boost::function inc(int& value) { return i; } -BOOST_AUTO_TEST_CASE(test_return_inc) { +int main(void) { int value1 = 0; // Reference valid in scope where closure is used. boost::function inc1 = inc(value1); int value2 = 0; boost::function inc2 = inc(value2); - BOOST_CHECK(inc1() == 1); - BOOST_CHECK(inc1() == 2); - BOOST_CHECK(inc2() == 1); - BOOST_CHECK(inc1() == 3); + BOOST_TEST(inc1() == 1); + BOOST_TEST(inc1() == 2); + BOOST_TEST(inc2() == 1); + BOOST_TEST(inc1() == 3); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/return_inc_seq.cpp b/test/return_inc_seq.cpp index 65ee386..6116ea9 100644 --- a/test/return_inc_seq.cpp +++ b/test/return_inc_seq.cpp @@ -7,8 +7,7 @@ #include #include -#define BOOST_TEST_MODULE TestReturnIncSeq -#include +#include boost::function inc(int& value) { int BOOST_LOCAL_FUNCTION( (bind& value) ) { @@ -17,15 +16,16 @@ boost::function inc(int& value) { return i; } -BOOST_AUTO_TEST_CASE(test_return_inc_seq) { +int main(void) { int value1 = 0; boost::function inc1 = inc(value1); int value2 = 0; boost::function inc2 = inc(value2); - BOOST_CHECK(inc1() == 1); - BOOST_CHECK(inc1() == 2); - BOOST_CHECK(inc2() == 1); - BOOST_CHECK(inc1() == 3); + BOOST_TEST(inc1() == 1); + BOOST_TEST(inc1() == 2); + BOOST_TEST(inc2() == 1); + BOOST_TEST(inc1() == 3); + return boost::report_errors(); } diff --git a/test/return_inc_seq_nova.cpp b/test/return_inc_seq_nova.cpp new file mode 100644 index 0000000..c55ade6 --- /dev/null +++ b/test/return_inc_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "return_inc_seq.cpp" + diff --git a/test/return_setget.cpp b/test/return_setget.cpp index ad63c01..0d07350 100644 --- a/test/return_setget.cpp +++ b/test/return_setget.cpp @@ -6,12 +6,13 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include #include -#define BOOST_TEST_MODULE TestReturnSetGet -#include +#include #include boost::function set; @@ -19,12 +20,12 @@ boost::function get; void action(void) { // State `message` hidden behind access functions from here. - BOOST_CHECK(get() == "abc"); + BOOST_TEST(get() == "abc"); set("xyz"); - BOOST_CHECK(get() == "xyz"); + BOOST_TEST(get() == "xyz"); } -BOOST_AUTO_TEST_CASE(test_return_setget) { +int main(void) { std::string message = "abc"; // Reference valid where closure used. void BOOST_LOCAL_FUNCTION(bind& message, const std::string& text) { @@ -38,11 +39,8 @@ BOOST_AUTO_TEST_CASE(test_return_setget) { get = g; action(); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/return_setget_seq.cpp b/test/return_setget_seq.cpp index c4cd27d..42c1246 100644 --- a/test/return_setget_seq.cpp +++ b/test/return_setget_seq.cpp @@ -7,20 +7,19 @@ #include #include -#define BOOST_TEST_MODULE TestReturnSetgetSeq -#include +#include #include boost::function set; boost::function get; void action(void) { - BOOST_CHECK(get() == "abc"); + BOOST_TEST(get() == "abc"); set("xyz"); - BOOST_CHECK(get() == "xyz"); + BOOST_TEST(get() == "xyz"); } -BOOST_AUTO_TEST_CASE(test_return_setget_seq) { +int main(void) { std::string message = "abc"; void BOOST_LOCAL_FUNCTION( (bind& message) (const std::string& text) ) { @@ -34,5 +33,6 @@ BOOST_AUTO_TEST_CASE(test_return_setget_seq) { get = g; action(); + return boost::report_errors(); } diff --git a/test/return_setget_seq_nova.cpp b/test/return_setget_seq_nova.cpp new file mode 100644 index 0000000..87e2bde --- /dev/null +++ b/test/return_setget_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "return_setget_seq.cpp" + diff --git a/test/return_this.cpp b/test/return_this.cpp index 4666272..4669230 100644 --- a/test/return_this.cpp +++ b/test/return_this.cpp @@ -6,12 +6,13 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include #include -#define BOOST_TEST_MODULE TestReturnThis -#include +#include struct number { number(int value) : value_(value) {} @@ -27,21 +28,18 @@ private: int value_; }; -BOOST_AUTO_TEST_CASE(test_return_this) { +int main(void) { number n1 = 0; // Object valid in scope where closure is used. boost::function inc1 = n1.inc(); number n2 = 0; boost::function inc2 = n2.inc(); - BOOST_CHECK(inc1() == 1); - BOOST_CHECK(inc1() == 2); - BOOST_CHECK(inc2() == 1); - BOOST_CHECK(inc1() == 3); + BOOST_TEST(inc1() == 1); + BOOST_TEST(inc1() == 2); + BOOST_TEST(inc2() == 1); + BOOST_TEST(inc1() == 3); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/return_this_seq.cpp b/test/return_this_seq.cpp index ddc32f6..be7870f 100644 --- a/test/return_this_seq.cpp +++ b/test/return_this_seq.cpp @@ -7,8 +7,7 @@ #include #include -#define BOOST_TEST_MODULE TestReturnThisSeq -#include +#include struct number { number(int value) : value_(value) {} @@ -24,15 +23,16 @@ private: int value_; }; -BOOST_AUTO_TEST_CASE(test_return_this_seq) { +int main(void) { number n1 = 0; // Object valid in scope where closure is used. boost::function inc1 = n1.inc(); number n2 = 0; boost::function inc2 = n2.inc(); - BOOST_CHECK(inc1() == 1); - BOOST_CHECK(inc1() == 2); - BOOST_CHECK(inc2() == 1); - BOOST_CHECK(inc1() == 3); + BOOST_TEST(inc1() == 1); + BOOST_TEST(inc1() == 2); + BOOST_TEST(inc2() == 1); + BOOST_TEST(inc1() == 3); + return boost::report_errors(); } diff --git a/test/return_this_seq_nova.cpp b/test/return_this_seq_nova.cpp new file mode 100644 index 0000000..1f0cfc2 --- /dev/null +++ b/test/return_this_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "return_this_seq.cpp" + diff --git a/test/same_line.cpp b/test/same_line.cpp index 76f7cc7..4ff6e6b 100644 --- a/test/same_line.cpp +++ b/test/same_line.cpp @@ -6,12 +6,13 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include #include -#define BOOST_TEST_MODULE TestSameLine -#include +#include #include //[same_line @@ -28,18 +29,14 @@ return x - offset; \ } BOOST_LOCAL_FUNCTION_NAME(dec) -BOOST_AUTO_TEST_CASE(test_same_line) -{ +int main(void) { int delta = 10; LOCAL_INC_DEC(delta) // Multiple local functions on same line. - BOOST_CHECK(dec(inc(123)) == 123); + BOOST_TEST(dec(inc(123)) == 123); + return boost::report_errors(); } //] -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/same_line_seq.cpp b/test/same_line_seq.cpp index 6745438..82fac9e 100644 --- a/test/same_line_seq.cpp +++ b/test/same_line_seq.cpp @@ -7,8 +7,7 @@ #include #include -#define BOOST_TEST_MODULE TestSameLineSeq -#include +#include #include #define LOCAL_INC_DEC(offset) \ @@ -24,11 +23,11 @@ return x - offset; \ } BOOST_LOCAL_FUNCTION_NAME(dec) -BOOST_AUTO_TEST_CASE(test_same_line_seq) -{ +int main(void) { int delta = 10; LOCAL_INC_DEC(delta) // Declare local functions on same line using `_ID`. - BOOST_CHECK(dec(inc(123)) == 123); + BOOST_TEST(dec(inc(123)) == 123); + return boost::report_errors(); } diff --git a/test/same_line_seq_nova.cpp b/test/same_line_seq_nova.cpp new file mode 100644 index 0000000..fb5cc17 --- /dev/null +++ b/test/same_line_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "same_line_seq.cpp" + diff --git a/test/ten_void.cpp b/test/ten_void.cpp index f71d10a..99bf1bf 100644 --- a/test/ten_void.cpp +++ b/test/ten_void.cpp @@ -6,17 +6,16 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestTenVoid -#include -#include +#include -BOOST_AUTO_TEST_CASE(test_ten_void) { +int main(void) { //[ten_void int BOOST_LOCAL_FUNCTION(void) { // No parameter. return 10; } BOOST_LOCAL_FUNCTION_NAME(ten) - BOOST_CHECK(ten() == 10); + BOOST_TEST(ten() == 10); //] + return boost::report_errors(); } diff --git a/test/ten_void_nova.cpp b/test/ten_void_nova.cpp new file mode 100644 index 0000000..64b01c5 --- /dev/null +++ b/test/ten_void_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "ten_void.cpp" + diff --git a/test/transform.cpp b/test/transform.cpp index c2e685b..f72cf73 100644 --- a/test/transform.cpp +++ b/test/transform.cpp @@ -6,22 +6,23 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include -#define BOOST_TEST_MODULE TestTranform -#include +#include #include #include -BOOST_AUTO_TEST_CASE(test_transform) { +int main(void) { //[transform int offset = 5; std::vector v; std::vector w; for(int i = 1; i <= 2; ++i) v.push_back(i * 10); - BOOST_CHECK(v[0] == 10); BOOST_CHECK(v[1] == 20); + BOOST_TEST(v[0] == 10); BOOST_TEST(v[1] == 20); w.resize(v.size()); int BOOST_LOCAL_FUNCTION(const bind& offset, int i) { @@ -29,7 +30,7 @@ BOOST_AUTO_TEST_CASE(test_transform) { } BOOST_LOCAL_FUNCTION_NAME(inc) std::transform(v.begin(), v.end(), w.begin(), inc); - BOOST_CHECK(w[0] == 16); BOOST_CHECK(w[1] == 26); + BOOST_TEST(w[0] == 16); BOOST_TEST(w[1] == 26); int BOOST_LOCAL_FUNCTION(bind& inc, int i, int j) { return inc(i + j); // Call the other bound local function. @@ -37,13 +38,10 @@ BOOST_AUTO_TEST_CASE(test_transform) { offset = 0; std::transform(v.begin(), v.end(), w.begin(), v.begin(), inc_sum); - BOOST_CHECK(v[0] == 27); BOOST_CHECK(v[1] == 47); + BOOST_TEST(v[0] == 27); BOOST_TEST(v[1] == 47); //] + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/transform_seq.cpp b/test/transform_seq.cpp index d885f68..b29514c 100644 --- a/test/transform_seq.cpp +++ b/test/transform_seq.cpp @@ -6,18 +6,17 @@ // Home at http://www.boost.org/libs/local_function #include -#define BOOST_TEST_MODULE TestTranformSeq -#include +#include #include #include -BOOST_AUTO_TEST_CASE(test_transform_seq) { +int main(void) { int offset = 5; std::vector v; std::vector w; for(int i = 1; i <= 2; ++i) v.push_back(i * 10); - BOOST_CHECK(v[0] == 10); BOOST_CHECK(v[1] == 20); + BOOST_TEST(v[0] == 10); BOOST_TEST(v[1] == 20); w.resize(v.size()); int BOOST_LOCAL_FUNCTION( (const bind& offset) (int i) ) { @@ -25,7 +24,7 @@ BOOST_AUTO_TEST_CASE(test_transform_seq) { } BOOST_LOCAL_FUNCTION_NAME(inc) std::transform(v.begin(), v.end(), w.begin(), inc); - BOOST_CHECK(w[0] == 16); BOOST_CHECK(w[1] == 26); + BOOST_TEST(w[0] == 16); BOOST_TEST(w[1] == 26); int BOOST_LOCAL_FUNCTION( (bind& inc) (int i) (int j) ) { return inc(i + j); @@ -33,6 +32,8 @@ BOOST_AUTO_TEST_CASE(test_transform_seq) { offset = 0; std::transform(v.begin(), v.end(), w.begin(), v.begin(), inc_sum); - BOOST_CHECK(v[0] == 27); BOOST_CHECK(v[1] == 47); + BOOST_TEST(v[0] == 27); BOOST_TEST(v[1] == 47); + + return boost::report_errors(); } diff --git a/test/transform_seq_nova.cpp b/test/transform_seq_nova.cpp new file mode 100644 index 0000000..9f06e4f --- /dev/null +++ b/test/transform_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "transform_seq.cpp" + diff --git a/test/typeof.cpp b/test/typeof.cpp index 8cc5a1c..0b50120 100644 --- a/test/typeof.cpp +++ b/test/typeof.cpp @@ -6,17 +6,18 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include "addable.hpp" #include #include #include -#define BOOST_TEST_MODULE TestTypeof -#include +#include #include -BOOST_AUTO_TEST_CASE(test_typeof) { +int main(void) { //[typeof int sum = 0, factor = 10; @@ -32,12 +33,9 @@ BOOST_AUTO_TEST_CASE(test_typeof) { add(6); //] - BOOST_CHECK(sum == 60); + BOOST_TEST(sum == 60); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/typeof_seq.cpp b/test/typeof_seq.cpp index 8fc2413..01dd463 100644 --- a/test/typeof_seq.cpp +++ b/test/typeof_seq.cpp @@ -9,11 +9,10 @@ #include #include #include -#define BOOST_TEST_MODULE TestTypeofSeq -#include +#include #include -BOOST_AUTO_TEST_CASE(test_typeof_seq) { +int main(void) { int sum = 0, factor = 10; void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) { @@ -25,6 +24,7 @@ BOOST_AUTO_TEST_CASE(test_typeof_seq) { } BOOST_LOCAL_FUNCTION_NAME(add) add(6); - BOOST_CHECK(sum == 60); + BOOST_TEST(sum == 60); + return boost::report_errors(); } diff --git a/test/typeof_seq_nova.cpp b/test/typeof_seq_nova.cpp new file mode 100644 index 0000000..bf8b982 --- /dev/null +++ b/test/typeof_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "typeof_seq.cpp" + diff --git a/test/typeof_template.cpp b/test/typeof_template.cpp index 1370d61..f6a8c43 100644 --- a/test/typeof_template.cpp +++ b/test/typeof_template.cpp @@ -6,14 +6,15 @@ // Home at http://www.boost.org/libs/local_function #include -#ifndef BOOST_NO_VARIADIC_MACROS +#ifdef BOOST_NO_VARIADIC_MACROS +# error "variadic macros required" +#else #include "addable.hpp" #include #include #include -#define BOOST_TEST_MODULE TestTypeofTemplate -#include +#include #include //[typeof_template @@ -33,13 +34,10 @@ T calculate(const T& factor) { } //] -BOOST_AUTO_TEST_CASE(test_typeof_template) { - BOOST_CHECK(calculate(10) == 60); +int main(void) { + BOOST_TEST(calculate(10) == 60); + return boost::report_errors(); } -#else - -int main(void) { return 0; } // Trivial test. - -#endif +#endif // VARIADIC_MACROS diff --git a/test/typeof_template_seq.cpp b/test/typeof_template_seq.cpp index 6541256..9aca5a5 100644 --- a/test/typeof_template_seq.cpp +++ b/test/typeof_template_seq.cpp @@ -9,8 +9,7 @@ #include #include #include -#define BOOST_TEST_MODULE TestTypeofTemplateSeq -#include +#include #include template @@ -27,7 +26,8 @@ T calculate(const T& factor) { return sum; } -BOOST_AUTO_TEST_CASE(test_typeof_template_seq) { - BOOST_CHECK(calculate(10) == 60); +int main(void) { + BOOST_TEST(calculate(10) == 60); + return boost::report_errors(); } diff --git a/test/typeof_template_seq_nova.cpp b/test/typeof_template_seq_nova.cpp new file mode 100644 index 0000000..48df4d4 --- /dev/null +++ b/test/typeof_template_seq_nova.cpp @@ -0,0 +1,10 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under the Boost Software License, Version 1.0 +// (see accompanying file LICENSE_1_0.txt or a copy at +// http://www.boost.org/LICENSE_1_0.txt) +// Home at http://www.boost.org/libs/local_function + +#include "nova.hpp" +#include "typeof_template_seq.cpp" +