mirror of
https://github.com/boostorg/test.git
synced 2026-02-15 13:32:09 +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"
|
||||
//]
|
||||
Reference in New Issue
Block a user