From df62ab15eec75da82ced183879fc3f7450c8111a Mon Sep 17 00:00:00 2001 From: Raffi Enficiaud Date: Mon, 11 May 2015 19:21:10 +0200 Subject: [PATCH] Slight advances on BOOST_TEST Adding the boost_test examples to the tests --- doc/examples/boost_test_macro2.cpp | 25 +++++++++++++++++++ doc/testing_tools/boost_test_super_macro.qbk | 10 +++++--- doc/testing_tools/testing_tools_reference.qbk | 6 ++--- test/Jamfile.v2 | 17 +++++++++++++ 4 files changed, 51 insertions(+), 7 deletions(-) diff --git a/doc/examples/boost_test_macro2.cpp b/doc/examples/boost_test_macro2.cpp index eee88192..4190cc45 100644 --- a/doc/examples/boost_test_macro2.cpp +++ b/doc/examples/boost_test_macro2.cpp @@ -22,3 +22,28 @@ BOOST_AUTO_TEST_CASE( test_compound1 ) BOOST_TEST(a == b + 11 == false); } //] + +int count = 0; +struct my_type +{ + bool operator==(my_type const& ) const { return false; } + friend std::ostream& operator<<(std::ostream& o, my_type const& m) + { + o << count ++; + return o; + } +}; + +bool operator==(std::vector const& l, std::vector const& r) +{ + return true; +} + +BOOST_AUTO_TEST_CASE( test_compound2 ) +{ + std::vector a(3); + std::vector b(3); + + BOOST_TEST(a == b); + BOOST_TEST((a == b)); +} \ No newline at end of file diff --git a/doc/testing_tools/boost_test_super_macro.qbk b/doc/testing_tools/boost_test_super_macro.qbk index 338019bb..41549c2e 100644 --- a/doc/testing_tools/boost_test_super_macro.qbk +++ b/doc/testing_tools/boost_test_super_macro.qbk @@ -5,7 +5,7 @@ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) /] -[section:boost_test_super_macro `BOOST_TEST` or the Swiss Army knife] +[section:boost_test_super_macro BOOST_TEST or the Swiss Army knife] Once a test case has been declared, the body of this test should be written. A test case is a sequence of operations in which *assertions* are inserted. Those assertions evaluate /statements/ that verify the integrity @@ -44,12 +44,14 @@ gives flexibility to __BOOST_TEST__ at the cost of narrowing the supported state * statements containing ternary conditions: those statement should be surrounded by parenthesis as they cannot be overloaded * statements containing comas: those statements will be intercepted by the preprocessor -* compound statements containing any logical composition `||`, `&&` +* compound statements containing any logical composition `||`, `&&`. Those are disabled intentionally. [bt_example boost_test_macro1..BOOST_TEST acceptable expressions] -The expression tree is processed by the compiler, and a specific object is composed from the left of `statement`. -An expression chain [footnote which *differs* from an expression tree] is constructed from the statement, by left composition. +The expression tree is processed by the compiler, and a specific object is composed from the left of `statement`. This left +object composition has highest precedence. +An expression chain [footnote which *differs* from an expression tree] is constructed from the statement, starting with this left +composition. The operators precedences are applied by the language. The chain is built from left to right, combining one binary operation with two operands. The following statements diff --git a/doc/testing_tools/testing_tools_reference.qbk b/doc/testing_tools/testing_tools_reference.qbk index c1c33983..3bcf2cb8 100644 --- a/doc/testing_tools/testing_tools_reference.qbk +++ b/doc/testing_tools/testing_tools_reference.qbk @@ -159,13 +159,13 @@ BOOST_TEST(statement, floating_point_comparison_manipulation); // bitwise comparison, requires variadic macros, auto and decltype - BOOST_TEST(statement, boost::test_tools::bitwise); + BOOST_TEST(statement, boost::test_tools::bitwise() ); // element-wise comparison, for containers - BOOST_TEST(statement, boost::test_tools::per_element); + BOOST_TEST(statement, boost::test_tools::per_element() ); // element-wise comparison, for containers - BOOST_TEST(statement, boost::test_tools::lexicographic); + BOOST_TEST(statement, boost::test_tools::lexicographic() ); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 339ffd91..15738c6b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -161,6 +161,23 @@ test-suite "unit_test_framework_test" [ test-btl-lib-c11 run : dataset_example66 : : : ../doc/examples/dataset_example66.cpp ] [ test-btl-lib-c11 run : dataset_example67 : : : ../doc/examples/dataset_example67.cpp ] [ test-btl-lib-c11 run-fail : dataset_example68 : : : ../doc/examples/dataset_example68.cpp ] + + # examples in BOOST_TEST + [ test-btl-lib-c11 run : boost_test_macro1 : : : ../doc/examples/boost_test_macro1.cpp ] + [ test-btl-lib-c11 run : boost_test_macro2 : : : ../doc/examples/boost_test_macro2.cpp ] + [ test-btl-lib-c11 run : boost_test_macro_bitwise : : : ../doc/examples/boost_test_macro_bitwise.cpp ] + [ test-btl-lib-c11 run : boost_test_macro_container_c_array : : : ../doc/examples/boost_test_macro_container_c_array.cpp ] + [ test-btl-lib-c11 run : boost_test_macro_container_float : : : ../doc/examples/boost_test_macro_container_float.cpp ] + [ test-btl-lib-c11 run : boost_test_macro_container_value_type : : : ../doc/examples/boost_test_macro_container_value_type.cpp ] + [ test-btl-lib-c11 run : boost_test_macro_float : : : ../doc/examples/boost_test_macro_float.cpp ] + [ test-btl-lib-c11 run : boost_test_macro_float2 : : : ../doc/examples/boost_test_macro_float2.cpp ] + [ test-btl-lib-c11 run : boost_test_macro_message : : : ../doc/examples/boost_test_macro_message.cpp ] + [ test-btl-lib-c11 run : boost_test_macro_sequence : : : ../doc/examples/boost_test_macro_sequence.cpp ] + [ test-btl-lib-c11 run : boost_test_macro_string : : : ../doc/examples/boost_test_macro_string.cpp ] + + + + ;