2
0
mirror of https://github.com/boostorg/test.git synced 2026-01-24 18:32:30 +00:00
Files
test/doc/examples/boost_test_macro_float.cpp
Raffi Enficiaud f26f458d78 tighters in x
2015-05-02 20:23:52 +02:00

25 lines
682 B
C++

// (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_float
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_CASE( test_float )
{
namespace tt = boost::test_tools;
double d1 = 1.1e-5;
double d2 = 1.101e-5;
// Tolerance using strong comparison (Equ (2)).
BOOST_TEST( d1 == d2, tt::tolerance( 1e-7 ) );
// tolerance set in percentage
BOOST_TEST( d1 == d2, 1e-5 % tt::tolerance());
}
//]