]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/conversion/test/bounds_test.cpp
1 // (c) Copyright Fernando Luis Cacciola Carballal 2000-2004
2 // Use, modification, and distribution is subject to the Boost Software
3 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 // See library home page at http://www.boost.org/libs/numeric/conversion
8 // Contact the author at: fernando_cacciola@hotmail.com
14 #include "boost/numeric/conversion/bounds.hpp"
20 #include "test_helpers.cpp"
23 using namespace boost
;
24 using namespace numeric
;
26 // Test the fields of boost::numeric::bounds<> against the expected values.
29 void test_bounds( T expected_lowest
, T expected_highest
, T expected_smallest
)
31 T lowest
= bounds
<T
>::lowest () ;
32 T highest
= bounds
<T
>::highest () ;
33 T smallest
= bounds
<T
>::smallest() ;
35 BOOST_TEST_EQ(lowest
, expected_lowest
);
37 BOOST_TEST_EQ(highest
, expected_highest
);
39 BOOST_TEST_EQ(smallest
, expected_smallest
);
44 void test_bounds_integer( MATCH_FNTPL_ARG(T
) )
46 test_bounds( numeric_limits
<T
>::min
BOOST_PREVENT_MACRO_SUBSTITUTION()
47 , numeric_limits
<T
>::max
BOOST_PREVENT_MACRO_SUBSTITUTION()
52 void test_bounds_float( MATCH_FNTPL_ARG(T
))
54 test_bounds( -numeric_limits
<T
>::max
BOOST_PREVENT_MACRO_SUBSTITUTION ()
55 , numeric_limits
<T
>::max
BOOST_PREVENT_MACRO_SUBSTITUTION ()
56 , numeric_limits
<T
>::min
BOOST_PREVENT_MACRO_SUBSTITUTION ()
60 void test_bounds_integers()
62 test_bounds_integer( SET_FNTPL_ARG(unsigned char) ) ;
63 test_bounds_integer( SET_FNTPL_ARG(signed char) ) ;
64 test_bounds_integer( SET_FNTPL_ARG(char) ) ;
65 test_bounds_integer( SET_FNTPL_ARG(unsigned short) ) ;
66 test_bounds_integer( SET_FNTPL_ARG(short) ) ;
67 test_bounds_integer( SET_FNTPL_ARG(unsigned int) ) ;
68 test_bounds_integer( SET_FNTPL_ARG(int) ) ;
69 test_bounds_integer( SET_FNTPL_ARG(unsigned long) ) ;
70 test_bounds_integer( SET_FNTPL_ARG(long) ) ;
73 void test_bounds_floats()
75 test_bounds_float( SET_FNTPL_ARG(float) );
76 test_bounds_float( SET_FNTPL_ARG(double) );
77 test_bounds_float( SET_FNTPL_ARG(long double) );
82 test_bounds_integers() ;
83 test_bounds_floats () ;
89 cout
<< setprecision( std::numeric_limits
<long double>::digits10
) ;
93 return boost::report_errors();