mirror of
https://github.com/boostorg/test.git
synced 2026-01-24 06:22:12 +00:00
Some cleanups and fixes
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
|
||||
22
doc/examples/boost_test_macro_float2.cpp
Normal file
22
doc/examples/boost_test_macro_float2.cpp
Normal file
@@ -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 <boost/test/included/unit_test.hpp>
|
||||
#include <sstream>
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_floating_points )
|
||||
{
|
||||
namespace tt = boost::test_tools;
|
||||
int a = 13;
|
||||
BOOST_TEST(float(a) == float(a + 1), tt::tolerance<float>( 1./13 ));
|
||||
|
||||
// tolerance not properly set for floating points
|
||||
BOOST_TEST(float(a) == float(a + 1), tt::tolerance( 1./13 ));
|
||||
}
|
||||
//]
|
||||
12
doc/examples/boost_test_macro_float2.output
Normal file
12
doc/examples/boost_test_macro_float2.output
Normal file
@@ -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"
|
||||
//]
|
||||
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user