From bfc7a4bcdf01fc19cf31e6d4e665cd72027fa1b4 Mon Sep 17 00:00:00 2001 From: Raffi Enficiaud Date: Mon, 4 May 2015 01:06:34 +0200 Subject: [PATCH] Some cleanups and fixes --- doc/examples/CMakeLists.txt | 1 + doc/examples/boost_test_macro_float2.cpp | 22 ++++++++++++++++++++ doc/examples/boost_test_macro_float2.output | 12 +++++++++++ doc/testing_tools/boost_test_super_macro.qbk | 16 +++++++------- 4 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 doc/examples/boost_test_macro_float2.cpp create mode 100644 doc/examples/boost_test_macro_float2.output diff --git a/doc/examples/CMakeLists.txt b/doc/examples/CMakeLists.txt index 2126fa15..1b63c3fb 100644 --- a/doc/examples/CMakeLists.txt +++ b/doc/examples/CMakeLists.txt @@ -28,6 +28,7 @@ set(EXAMPLES_VARIADIC_MACROS_SRC boost_test_macro_collections.cpp boost_test_macro_string.cpp boost_test_macro_float.cpp + boost_test_macro_float2.cpp boost_test_macro_message.cpp ) diff --git a/doc/examples/boost_test_macro_float2.cpp b/doc/examples/boost_test_macro_float2.cpp new file mode 100644 index 00000000..018306d1 --- /dev/null +++ b/doc/examples/boost_test_macro_float2.cpp @@ -0,0 +1,22 @@ +// (C) Copyright Raffi Enficiaud 2014. +// Distributed under 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) + +// See http://www.boost.org/libs/test for the library home page. + +//[example_code +#define BOOST_TEST_MODULE boost_test_macro_float2 +#include +#include + +BOOST_AUTO_TEST_CASE( test_floating_points ) +{ + namespace tt = boost::test_tools; + int a = 13; + BOOST_TEST(float(a) == float(a + 1), tt::tolerance( 1./13 )); + + // tolerance not properly set for floating points + BOOST_TEST(float(a) == float(a + 1), tt::tolerance( 1./13 )); +} +//] diff --git a/doc/examples/boost_test_macro_float2.output b/doc/examples/boost_test_macro_float2.output new file mode 100644 index 00000000..7b56015a --- /dev/null +++ b/doc/examples/boost_test_macro_float2.output @@ -0,0 +1,12 @@ +//[example_output +> ./boost_test_macro_float2 --log_level=all +Running 1 test case... +Entering test module "boost_test_macro_float2" +boost_test_macro_float2.cpp:13: Entering test case "test_floating_points" +boost_test_macro_float2.cpp:17: info: check float(a) == float(a + 1) has passed +boost_test_macro_float2.cpp:20: error: in "test_floating_points": check float(a) == float(a + 1) has failed [13 != 14] +boost_test_macro_float2.cpp:13: Leaving test case "test_floating_points"; testing time: 290mks +Leaving test module "boost_test_macro_float2"; testing time: 417mks + +*** 1 failure is detected in the test module "boost_test_macro_float2" +//] diff --git a/doc/testing_tools/boost_test_super_macro.qbk b/doc/testing_tools/boost_test_super_macro.qbk index 042cbadb..51be167c 100644 --- a/doc/testing_tools/boost_test_super_macro.qbk +++ b/doc/testing_tools/boost_test_super_macro.qbk @@ -17,7 +17,7 @@ consistency of the test case: If such as assertion fails, the test case execution stops immediately, and the test-case is flagged as /failed/. * *checks*: this is the most commonly used assertion level. If the statement evaluates to `false`, the test case is flagged as failed but its execution continues. -* *warnings*: this is the lowest level of the assertions. The test case execution continues and a warning message is logged. +* *warnings*: this is an assertion providing information. The test case execution continues and a warning message is logged. The warning does not change the success status of a test case. These three levels of assertions are reported into the test log and output, as described in details in the @@ -57,10 +57,11 @@ Collections are compared using a specified operator, applied /in sequence/ on ea The sequence of comparisons is provided by the iterators of the respective collections. In case of failure, the indices of the elements for which the comparison fails are returned. -In order for the collections to be comparable, they should have the same number of elements. +In order for the collections to be comparable, they should have the same number of elements. The comparison is made over +all the elements returned by the collections iterators. The comparison used is the one in the + __BOOST_TEST__ statement (`==`, `<` ...). -[caution the comparison is made over the elements returned by the collections iterators, using the operation appearing the in - __BOOST_TEST__ statement (`==`, `<` ...). The type returned by the dereference of the iterator should support the selected operator.] +[caution The type returned by the dereference of the iterator should support the specified comparison.] [bt_example boost_test_macro_collections..BOOST_TEST collection comparison support] @@ -164,13 +165,12 @@ appropriate comparison methods. More control can be provided over the tolerance providing an optional [funcref boost::test_tools::tolerance] argument to __BOOST_TEST__. The tolerance might also be expressed in /percentage/ using `operator%` of this tolerance object, as in the examples below: -[bt_example boost_test_macro_float..BOOST_TEST bitwise comparison] +[bt_example boost_test_macro_float..BOOST_TEST floating point comparison] [note All floating point comparisons use Equ (2) on [link boost_test.users_guide.testing_tools.testing_floating_points this page].] -[caution The tolerance should be of the same type as of the first operand - [bt_example boost_test_macro2..BOOST_TEST tolerance settings] -] +[caution A current caveat of the implementation requires the tolerance to be of the same type as of the first operand.] +[bt_example boost_test_macro_float2..BOOST_TEST tolerance type] [endsect] [/ floating points]