Ticket #8272: test_expression_template_fpt.cpp

File test_expression_template_fpt.cpp, 1.0 KB (added by John Maddock, 10 years ago)

Test cases.

Line 
1///////////////////////////////////////////////////////////////////////////////
2// Copyright 2013 John Maddock. Distributed under the Boost
3// Software License, Version 1.0. (See accompanying file
4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6
7#include <boost/multiprecision/cpp_dec_float.hpp>
8#define BOOST_TEST_MODULE multiprecision
9#include <boost/test/unit_test.hpp>
10
11BOOST_AUTO_TEST_CASE(multiprecision)
12{
13 using namespace boost::multiprecision;
14
15 cpp_dec_float_50 a(0), b(0), c(1);
16 cpp_dec_float_50 eps = std::numeric_limits<cpp_dec_float_50>::epsilon();
17
18 BOOST_CHECK_EQUAL(a, b);
19 BOOST_CHECK_NE(a, c);
20 BOOST_CHECK_LE(a, b);
21 BOOST_CHECK_GE(a, b);
22 BOOST_CHECK_GT(c, a);
23 BOOST_CHECK_LT(a, c);
24
25 BOOST_CHECK_SMALL(a, eps);
26 BOOST_CHECK_SMALL(eps/2, eps);
27
28 b = c + 10 * eps;
29
30 BOOST_CHECK_CLOSE_FRACTION(b, c, eps * 20);
31 BOOST_CHECK_CLOSE(b, c, eps * 20 * 100);
32
33 BOOST_CHECK_CLOSE_FRACTION(1 * b, c, eps * 20);
34 BOOST_CHECK_CLOSE(1 * b, c, eps * 20 * 100);
35}
36