forked from boostorg/integer
Changed to use the lightweight test framework - we can now test with a much wider range of compilers.
[SVN r57942]
This commit is contained in:
@ -5,15 +5,10 @@
|
||||
import testing ;
|
||||
|
||||
test-suite integer
|
||||
: [ run cstdint_test.cpp /boost/test//minimal ]
|
||||
[ run integer_traits_test.cpp
|
||||
/boost/test//boost_test_exec_monitor ]
|
||||
[ run integer_test.cpp
|
||||
/boost/test//minimal ]
|
||||
[ run integer_mask_test.cpp
|
||||
/boost/test//minimal ]
|
||||
[ run static_log2_test.cpp
|
||||
/boost/test//boost_test_exec_monitor ]
|
||||
[ run static_min_max_test.cpp
|
||||
/boost/test//boost_test_exec_monitor ]
|
||||
: [ run cstdint_test.cpp ]
|
||||
[ run integer_traits_test.cpp ]
|
||||
[ run integer_test.cpp ]
|
||||
[ run integer_mask_test.cpp ]
|
||||
[ run static_log2_test.cpp ]
|
||||
[ run static_min_max_test.cpp ]
|
||||
;
|
||||
|
@ -15,8 +15,7 @@
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#include <iostream>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
//
|
||||
@ -55,24 +54,24 @@ struct integral_constant_checker
|
||||
|
||||
void integral_constant_checker::check()
|
||||
{
|
||||
BOOST_CHECK( int8 == -127 );
|
||||
BOOST_CHECK( int_least8 == -127 );
|
||||
BOOST_CHECK( int_fast8 == -127 );
|
||||
BOOST_CHECK( uint8 == 255u );
|
||||
BOOST_CHECK( uint_least8 == 255u );
|
||||
BOOST_CHECK( uint_fast8 == 255u );
|
||||
BOOST_CHECK( int16 == -32767 );
|
||||
BOOST_CHECK( int_least16 == -32767 );
|
||||
BOOST_CHECK( int_fast16 == -32767 );
|
||||
BOOST_CHECK( uint16 == 65535u );
|
||||
BOOST_CHECK( uint_least16 == 65535u );
|
||||
BOOST_CHECK( uint_fast16 == 65535u );
|
||||
BOOST_CHECK( int32 == -2147483647 );
|
||||
BOOST_CHECK( int_least32 == -2147483647 );
|
||||
BOOST_CHECK( int_fast32 == -2147483647 );
|
||||
BOOST_CHECK( uint32 == 4294967295u );
|
||||
BOOST_CHECK( uint_least32 == 4294967295u );
|
||||
BOOST_CHECK( uint_fast32 == 4294967295u );
|
||||
BOOST_TEST( int8 == -127 );
|
||||
BOOST_TEST( int_least8 == -127 );
|
||||
BOOST_TEST( int_fast8 == -127 );
|
||||
BOOST_TEST( uint8 == 255u );
|
||||
BOOST_TEST( uint_least8 == 255u );
|
||||
BOOST_TEST( uint_fast8 == 255u );
|
||||
BOOST_TEST( int16 == -32767 );
|
||||
BOOST_TEST( int_least16 == -32767 );
|
||||
BOOST_TEST( int_fast16 == -32767 );
|
||||
BOOST_TEST( uint16 == 65535u );
|
||||
BOOST_TEST( uint_least16 == 65535u );
|
||||
BOOST_TEST( uint_fast16 == 65535u );
|
||||
BOOST_TEST( int32 == -2147483647 );
|
||||
BOOST_TEST( int_least32 == -2147483647 );
|
||||
BOOST_TEST( int_fast32 == -2147483647 );
|
||||
BOOST_TEST( uint32 == 4294967295u );
|
||||
BOOST_TEST( uint_least32 == 4294967295u );
|
||||
BOOST_TEST( uint_fast32 == 4294967295u );
|
||||
}
|
||||
#endif // BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
|
||||
@ -101,10 +100,10 @@ void integral_constant_type_check(T1, T2)
|
||||
// if we have a native stdint.h
|
||||
// then the INTXX_C macros may define
|
||||
// a type that's wider than required:
|
||||
BOOST_CHECK(sizeof(T1) <= sizeof(T2));
|
||||
BOOST_TEST(sizeof(T1) <= sizeof(T2));
|
||||
#else
|
||||
BOOST_CHECK(sizeof(T1) == sizeof(T2));
|
||||
BOOST_CHECK(t1 == t2);
|
||||
BOOST_TEST(sizeof(T1) == sizeof(T2));
|
||||
BOOST_TEST(t1 == t2);
|
||||
#endif
|
||||
#if defined(BOOST_HAS_STDINT_H)
|
||||
// native headers are permitted to promote small
|
||||
@ -112,22 +111,22 @@ void integral_constant_type_check(T1, T2)
|
||||
if(sizeof(T1) >= sizeof(int))
|
||||
{
|
||||
if(t1 > 0)
|
||||
BOOST_CHECK(t2 > 0);
|
||||
BOOST_TEST(t2 > 0);
|
||||
else
|
||||
BOOST_CHECK(!(t2 > 0));
|
||||
BOOST_TEST(!(t2 > 0));
|
||||
}
|
||||
else if(t1 < 0)
|
||||
BOOST_CHECK(!(t2 > 0));
|
||||
BOOST_TEST(!(t2 > 0));
|
||||
#else
|
||||
if(t1 > 0)
|
||||
BOOST_CHECK(t2 > 0);
|
||||
BOOST_TEST(t2 > 0);
|
||||
else
|
||||
BOOST_CHECK(!(t2 > 0));
|
||||
BOOST_TEST(!(t2 > 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int test_main(int, char*[])
|
||||
int main(int, char*[])
|
||||
{
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
integral_constant_checker::check();
|
||||
@ -186,37 +185,37 @@ int test_main(int, char*[])
|
||||
boost::uintmax_t uintmax = UINTMAX_C(4294967295);
|
||||
#endif
|
||||
|
||||
BOOST_CHECK( int8 == -127 );
|
||||
BOOST_CHECK( int_least8 == -127 );
|
||||
BOOST_CHECK( int_fast8 == -127 );
|
||||
BOOST_CHECK( uint8 == 255u );
|
||||
BOOST_CHECK( uint_least8 == 255u );
|
||||
BOOST_CHECK( uint_fast8 == 255u );
|
||||
BOOST_CHECK( int16 == -32767 );
|
||||
BOOST_CHECK( int_least16 == -32767 );
|
||||
BOOST_CHECK( int_fast16 == -32767 );
|
||||
BOOST_CHECK( uint16 == 65535u );
|
||||
BOOST_CHECK( uint_least16 == 65535u );
|
||||
BOOST_CHECK( uint_fast16 == 65535u );
|
||||
BOOST_CHECK( int32 == -2147483647 );
|
||||
BOOST_CHECK( int_least32 == -2147483647 );
|
||||
BOOST_CHECK( int_fast32 == -2147483647 );
|
||||
BOOST_CHECK( uint32 == 4294967295u );
|
||||
BOOST_CHECK( uint_least32 == 4294967295u );
|
||||
BOOST_CHECK( uint_fast32 == 4294967295u );
|
||||
BOOST_TEST( int8 == -127 );
|
||||
BOOST_TEST( int_least8 == -127 );
|
||||
BOOST_TEST( int_fast8 == -127 );
|
||||
BOOST_TEST( uint8 == 255u );
|
||||
BOOST_TEST( uint_least8 == 255u );
|
||||
BOOST_TEST( uint_fast8 == 255u );
|
||||
BOOST_TEST( int16 == -32767 );
|
||||
BOOST_TEST( int_least16 == -32767 );
|
||||
BOOST_TEST( int_fast16 == -32767 );
|
||||
BOOST_TEST( uint16 == 65535u );
|
||||
BOOST_TEST( uint_least16 == 65535u );
|
||||
BOOST_TEST( uint_fast16 == 65535u );
|
||||
BOOST_TEST( int32 == -2147483647 );
|
||||
BOOST_TEST( int_least32 == -2147483647 );
|
||||
BOOST_TEST( int_fast32 == -2147483647 );
|
||||
BOOST_TEST( uint32 == 4294967295u );
|
||||
BOOST_TEST( uint_least32 == 4294967295u );
|
||||
BOOST_TEST( uint_fast32 == 4294967295u );
|
||||
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
BOOST_CHECK( int64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_CHECK( int_least64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_CHECK( int_fast64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_CHECK( uint64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_CHECK( uint_least64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_CHECK( uint_fast64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_CHECK( intmax == INT64_C(-9223372036854775807) );
|
||||
BOOST_CHECK( uintmax == UINT64_C(18446744073709551615) );
|
||||
BOOST_TEST( int64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( int_least64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( int_fast64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( uint64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_TEST( uint_least64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_TEST( uint_fast64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_TEST( intmax == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( uintmax == UINT64_C(18446744073709551615) );
|
||||
#else
|
||||
BOOST_CHECK( intmax == -2147483647 );
|
||||
BOOST_CHECK( uintmax == 4294967295u );
|
||||
BOOST_TEST( intmax == -2147483647 );
|
||||
BOOST_TEST( uintmax == 4294967295u );
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
// Revision History
|
||||
// 23 Sep 2001 Initial version (Daryle Walker)
|
||||
|
||||
#include <boost/test/minimal.hpp> // for main
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||
#include <boost/integer/integer_mask.hpp> // for boost::high_bit_mask_t, etc.
|
||||
@ -21,9 +21,9 @@
|
||||
#pragma warning(disable:4127) // conditional expression is constant
|
||||
#endif
|
||||
|
||||
#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_CHECK( ::boost::high_bit_mask_t< \
|
||||
#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
|
||||
(v) >::high_bit == (1ul << (v)) );
|
||||
#define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_CHECK( ::boost::high_bit_mask_t< \
|
||||
#define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
|
||||
(v) >::high_bit_fast == (1ul << (v)) );
|
||||
#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
|
||||
PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
|
||||
@ -33,20 +33,20 @@
|
||||
unsigned long mask = 0;\
|
||||
if(v > 0)\
|
||||
{ mask = ((1ul << (v-1)) - 1); mask <<= 1; mask |= 1; }\
|
||||
BOOST_CHECK( ::boost::low_bits_mask_t< (v) >::sig_bits == mask); \
|
||||
BOOST_TEST( ::boost::low_bits_mask_t< (v) >::sig_bits == mask); \
|
||||
}while(false);
|
||||
#define PRIVATE_LOW_BITS_FAST_TEST(v) \
|
||||
do{ \
|
||||
unsigned long mask = 0;\
|
||||
if(v > 0)\
|
||||
{ mask = ((1ul << (v-1)) - 1); mask <<= 1; mask |= 1; }\
|
||||
BOOST_CHECK( ::boost::low_bits_mask_t< (v) >::sig_bits_fast == mask);\
|
||||
BOOST_TEST( ::boost::low_bits_mask_t< (v) >::sig_bits_fast == mask);\
|
||||
}while(false);
|
||||
#define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \
|
||||
PRIVATE_LOW_BITS_FAST_TEST(v); } while (false)
|
||||
|
||||
|
||||
int test_main( int, char*[] )
|
||||
int main( int, char*[] )
|
||||
{
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
@ -15,7 +15,7 @@
|
||||
// 10 Mar 01 Boost Test Library now used for tests (Beman Dawes)
|
||||
// 31 Aug 99 Initial version
|
||||
|
||||
#include <boost/test/minimal.hpp> // for main, BOOST_CHECK
|
||||
#include <boost/detail/lightweight_test.hpp> // for main, BOOST_TEST
|
||||
#include <boost/integer.hpp> // for boost::int_t, boost::uint_t
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
@ -26,11 +26,15 @@
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(disable:4127) // conditional expression is constant
|
||||
#endif
|
||||
#if defined( __BORLANDC__ )
|
||||
# pragma option -w-8008 -w-8066 // condition is always true
|
||||
#endif
|
||||
|
||||
//
|
||||
// Keep track of error count, so we can print out detailed
|
||||
// info only if we need it:
|
||||
//
|
||||
unsigned last_error_count = 0;
|
||||
int last_error_count = 0;
|
||||
//
|
||||
// Helpers to print out the name of a type,
|
||||
// we use these as typeid(X).name() doesn't always
|
||||
@ -59,8 +63,8 @@ void do_test_exact(boost::mpl::true_ const&)
|
||||
typedef typename boost::int_t<Bits>::least least_int;
|
||||
typedef typename boost::uint_t<Bits>::least least_uint;
|
||||
|
||||
BOOST_CHECK((boost::is_same<int_exact, least_int>::value));
|
||||
BOOST_CHECK((boost::is_same<uint_exact, least_uint>::value));
|
||||
BOOST_TEST((boost::is_same<int_exact, least_int>::value));
|
||||
BOOST_TEST((boost::is_same<uint_exact, least_uint>::value));
|
||||
}
|
||||
template <int Bits>
|
||||
void do_test_exact(boost::mpl::false_ const&)
|
||||
@ -98,31 +102,31 @@ void do_test_bits()
|
||||
|
||||
if(std::numeric_limits<least_int>::is_specialized)
|
||||
{
|
||||
BOOST_CHECK(std::numeric_limits<least_int>::digits + 1 >= Bits);
|
||||
BOOST_TEST(std::numeric_limits<least_int>::digits + 1 >= Bits);
|
||||
}
|
||||
if(std::numeric_limits<least_uint>::is_specialized)
|
||||
{
|
||||
BOOST_CHECK(std::numeric_limits<least_uint>::digits >= Bits);
|
||||
BOOST_TEST(std::numeric_limits<least_uint>::digits >= Bits);
|
||||
}
|
||||
BOOST_CHECK(sizeof(least_int) * CHAR_BIT >= Bits);
|
||||
BOOST_CHECK(sizeof(least_uint) * CHAR_BIT >= Bits);
|
||||
BOOST_CHECK(sizeof(fast_int) >= sizeof(least_int));
|
||||
BOOST_CHECK(sizeof(fast_uint) >= sizeof(least_uint));
|
||||
BOOST_TEST(sizeof(least_int) * CHAR_BIT >= Bits);
|
||||
BOOST_TEST(sizeof(least_uint) * CHAR_BIT >= Bits);
|
||||
BOOST_TEST(sizeof(fast_int) >= sizeof(least_int));
|
||||
BOOST_TEST(sizeof(fast_uint) >= sizeof(least_uint));
|
||||
//
|
||||
// There should be no type smaller than least_* that also has enough bits:
|
||||
//
|
||||
if(!boost::is_same<signed char, least_int>::value)
|
||||
{
|
||||
BOOST_CHECK(std::numeric_limits<signed char>::digits < Bits);
|
||||
BOOST_TEST(std::numeric_limits<signed char>::digits < Bits);
|
||||
if(!boost::is_same<short, least_int>::value)
|
||||
{
|
||||
BOOST_CHECK(std::numeric_limits<short>::digits < Bits);
|
||||
BOOST_TEST(std::numeric_limits<short>::digits < Bits);
|
||||
if(!boost::is_same<int, least_int>::value)
|
||||
{
|
||||
BOOST_CHECK(std::numeric_limits<int>::digits < Bits);
|
||||
BOOST_TEST(std::numeric_limits<int>::digits < Bits);
|
||||
if(!boost::is_same<long, least_int>::value)
|
||||
{
|
||||
BOOST_CHECK(std::numeric_limits<long>::digits < Bits);
|
||||
BOOST_TEST(std::numeric_limits<long>::digits < Bits);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,24 +134,24 @@ void do_test_bits()
|
||||
// And again, but unsigned:
|
||||
if(!boost::is_same<unsigned char, least_uint>::value)
|
||||
{
|
||||
BOOST_CHECK(std::numeric_limits<unsigned char>::digits < Bits);
|
||||
BOOST_TEST(std::numeric_limits<unsigned char>::digits < Bits);
|
||||
if(!boost::is_same<unsigned short, least_uint>::value)
|
||||
{
|
||||
BOOST_CHECK(std::numeric_limits<unsigned short>::digits < Bits);
|
||||
BOOST_TEST(std::numeric_limits<unsigned short>::digits < Bits);
|
||||
if(!boost::is_same<unsigned int, least_uint>::value)
|
||||
{
|
||||
BOOST_CHECK(std::numeric_limits<unsigned int>::digits < Bits);
|
||||
BOOST_TEST(std::numeric_limits<unsigned int>::digits < Bits);
|
||||
if(!boost::is_same<unsigned long, least_uint>::value)
|
||||
{
|
||||
BOOST_CHECK(std::numeric_limits<unsigned long>::digits < Bits);
|
||||
BOOST_TEST(std::numeric_limits<unsigned long>::digits < Bits);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(boost::minimal_test::errors_counter() != last_error_count)
|
||||
if(boost::detail::test_errors() != last_error_count)
|
||||
{
|
||||
last_error_count = boost::minimal_test::errors_counter();
|
||||
last_error_count = boost::detail::test_errors();
|
||||
std::cout << "Errors occured while testing with bit count = " << Bits << std::endl;
|
||||
std::cout << "Type int_t<" << Bits << ">::least was " << get_name_of_type(least_int(0)) << std::endl;
|
||||
std::cout << "Type int_t<" << Bits << ">::fast was " << get_name_of_type(fast_int(0)) << std::endl;
|
||||
@ -166,14 +170,14 @@ void test_min_max_type(Expected val)
|
||||
{
|
||||
typedef typename Traits::least least_type;
|
||||
typedef typename Traits::fast fast_type;
|
||||
BOOST_CHECK((boost::is_same<least_type, Expected>::value));
|
||||
BOOST_CHECK(sizeof(fast_type) >= sizeof(least_type));
|
||||
BOOST_CHECK((std::numeric_limits<least_type>::min)() <= val);
|
||||
BOOST_CHECK((std::numeric_limits<least_type>::max)() >= val);
|
||||
BOOST_TEST((boost::is_same<least_type, Expected>::value));
|
||||
BOOST_TEST(sizeof(fast_type) >= sizeof(least_type));
|
||||
BOOST_TEST((std::numeric_limits<least_type>::min)() <= val);
|
||||
BOOST_TEST((std::numeric_limits<least_type>::max)() >= val);
|
||||
}
|
||||
|
||||
// Test program
|
||||
int test_main(int, char*[])
|
||||
int main(int, char*[])
|
||||
{
|
||||
// Test int_t and unint_t first:
|
||||
if(std::numeric_limits<boost::intmax_t>::is_specialized)
|
||||
|
@ -17,7 +17,7 @@
|
||||
// use int64_t instead of long long for better portability
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
/*
|
||||
* General portability note:
|
||||
@ -52,22 +52,22 @@ void runtest(const char * type, T)
|
||||
<< "; min is " << make_char_numeric_for_streaming((traits::min)())
|
||||
<< ", max is " << make_char_numeric_for_streaming((traits::max)())
|
||||
<< std::endl;
|
||||
BOOST_CHECK(traits::is_specialized);
|
||||
BOOST_TEST(traits::is_specialized);
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1200)
|
||||
// MSVC++ 6.0 issues a LNK1179 error (duplicate comdat) when the compiler
|
||||
// generates different symbol names with a very long common prefix:
|
||||
// the dummy "&& true" disambiguates between the symbols generated by this
|
||||
// BOOST_CHECK instantiation and the preceding one.
|
||||
BOOST_CHECK(traits::is_integer && true);
|
||||
// BOOST_TEST instantiation and the preceding one.
|
||||
BOOST_TEST(traits::is_integer && true);
|
||||
#else
|
||||
BOOST_CHECK(traits::is_integer);
|
||||
BOOST_TEST(traits::is_integer);
|
||||
#endif
|
||||
BOOST_CHECK(traits::is_integral == true);
|
||||
BOOST_CHECK(traits::const_min == (traits::min)());
|
||||
BOOST_CHECK(traits::const_max == (traits::max)());
|
||||
BOOST_TEST(traits::is_integral == true);
|
||||
BOOST_TEST(traits::const_min == (traits::min)());
|
||||
BOOST_TEST(traits::const_max == (traits::max)());
|
||||
}
|
||||
|
||||
int test_main(int, char*[])
|
||||
int main(int, char*[])
|
||||
{
|
||||
runtest("bool", bool());
|
||||
runtest("char", char());
|
||||
|
@ -10,7 +10,7 @@
|
||||
// Revision History
|
||||
// 01 Oct 2001 Initial version (Daryle Walker)
|
||||
|
||||
#include <boost/test/test_tools.hpp> // for main
|
||||
#include <boost/detail/lightweight_test.hpp> // for main
|
||||
|
||||
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||
#include <boost/integer/static_log2.hpp> // for boost::static_log2
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
// Macros to compact code
|
||||
#define PRIVATE_LB_TEST( v, e ) BOOST_CHECK( ::boost::static_log2<v>::value == e )
|
||||
#define PRIVATE_LB_TEST( v, e ) BOOST_TEST( ::boost::static_log2<v>::value == e )
|
||||
|
||||
#define PRIVATE_PRINT_LB( v ) ::std::cout << "boost::static_log2<" << (v) \
|
||||
<< "> = " << ::boost::static_log2< (v) >::value << '.' << ::std::endl
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
// Main testing function
|
||||
int
|
||||
test_main
|
||||
main
|
||||
(
|
||||
int , // "argc" is unused
|
||||
char * [] // "argv" is unused
|
||||
|
@ -10,8 +10,7 @@
|
||||
// Revision History
|
||||
// 23 Sep 2001 Initial version (Daryle Walker)
|
||||
|
||||
#define BOOST_INCLUDE_MAIN
|
||||
#include <boost/test/test_tools.hpp> // for main, BOOST_CHECK
|
||||
#include <boost/detail/lightweight_test.hpp> // for main, BOOST_TEST
|
||||
|
||||
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||
#include <boost/integer/static_min_max.hpp> // for boost::static_signed_min, etc.
|
||||
@ -21,7 +20,7 @@
|
||||
|
||||
// Main testing function
|
||||
int
|
||||
test_main
|
||||
main
|
||||
(
|
||||
int , // "argc" is unused
|
||||
char * [] // "argv" is unused
|
||||
@ -37,57 +36,57 @@ test_main
|
||||
// Two positives
|
||||
cout << "Doing tests with two positive values." << endl;
|
||||
|
||||
BOOST_CHECK( (static_signed_min< 9, 14>::value) == 9 );
|
||||
BOOST_CHECK( (static_signed_max< 9, 14>::value) == 14 );
|
||||
BOOST_CHECK( (static_signed_min<14, 9>::value) == 9 );
|
||||
BOOST_CHECK( (static_signed_max<14, 9>::value) == 14 );
|
||||
BOOST_TEST( (static_signed_min< 9, 14>::value) == 9 );
|
||||
BOOST_TEST( (static_signed_max< 9, 14>::value) == 14 );
|
||||
BOOST_TEST( (static_signed_min<14, 9>::value) == 9 );
|
||||
BOOST_TEST( (static_signed_max<14, 9>::value) == 14 );
|
||||
|
||||
BOOST_CHECK( (static_unsigned_min< 9, 14>::value) == 9 );
|
||||
BOOST_CHECK( (static_unsigned_max< 9, 14>::value) == 14 );
|
||||
BOOST_CHECK( (static_unsigned_min<14, 9>::value) == 9 );
|
||||
BOOST_CHECK( (static_unsigned_max<14, 9>::value) == 14 );
|
||||
BOOST_TEST( (static_unsigned_min< 9, 14>::value) == 9 );
|
||||
BOOST_TEST( (static_unsigned_max< 9, 14>::value) == 14 );
|
||||
BOOST_TEST( (static_unsigned_min<14, 9>::value) == 9 );
|
||||
BOOST_TEST( (static_unsigned_max<14, 9>::value) == 14 );
|
||||
|
||||
// Two negatives
|
||||
cout << "Doing tests with two negative values." << endl;
|
||||
|
||||
BOOST_CHECK( (static_signed_min< -8, -101>::value) == -101 );
|
||||
BOOST_CHECK( (static_signed_max< -8, -101>::value) == -8 );
|
||||
BOOST_CHECK( (static_signed_min<-101, -8>::value) == -101 );
|
||||
BOOST_CHECK( (static_signed_max<-101, -8>::value) == -8 );
|
||||
BOOST_TEST( (static_signed_min< -8, -101>::value) == -101 );
|
||||
BOOST_TEST( (static_signed_max< -8, -101>::value) == -8 );
|
||||
BOOST_TEST( (static_signed_min<-101, -8>::value) == -101 );
|
||||
BOOST_TEST( (static_signed_max<-101, -8>::value) == -8 );
|
||||
|
||||
// With zero
|
||||
cout << "Doing tests with zero and a positive or negative value." << endl;
|
||||
|
||||
BOOST_CHECK( (static_signed_min< 0, 14>::value) == 0 );
|
||||
BOOST_CHECK( (static_signed_max< 0, 14>::value) == 14 );
|
||||
BOOST_CHECK( (static_signed_min<14, 0>::value) == 0 );
|
||||
BOOST_CHECK( (static_signed_max<14, 0>::value) == 14 );
|
||||
BOOST_TEST( (static_signed_min< 0, 14>::value) == 0 );
|
||||
BOOST_TEST( (static_signed_max< 0, 14>::value) == 14 );
|
||||
BOOST_TEST( (static_signed_min<14, 0>::value) == 0 );
|
||||
BOOST_TEST( (static_signed_max<14, 0>::value) == 14 );
|
||||
|
||||
BOOST_CHECK( (static_unsigned_min< 0, 14>::value) == 0 );
|
||||
BOOST_CHECK( (static_unsigned_max< 0, 14>::value) == 14 );
|
||||
BOOST_CHECK( (static_unsigned_min<14, 0>::value) == 0 );
|
||||
BOOST_CHECK( (static_unsigned_max<14, 0>::value) == 14 );
|
||||
BOOST_TEST( (static_unsigned_min< 0, 14>::value) == 0 );
|
||||
BOOST_TEST( (static_unsigned_max< 0, 14>::value) == 14 );
|
||||
BOOST_TEST( (static_unsigned_min<14, 0>::value) == 0 );
|
||||
BOOST_TEST( (static_unsigned_max<14, 0>::value) == 14 );
|
||||
|
||||
BOOST_CHECK( (static_signed_min< 0, -101>::value) == -101 );
|
||||
BOOST_CHECK( (static_signed_max< 0, -101>::value) == 0 );
|
||||
BOOST_CHECK( (static_signed_min<-101, 0>::value) == -101 );
|
||||
BOOST_CHECK( (static_signed_max<-101, 0>::value) == 0 );
|
||||
BOOST_TEST( (static_signed_min< 0, -101>::value) == -101 );
|
||||
BOOST_TEST( (static_signed_max< 0, -101>::value) == 0 );
|
||||
BOOST_TEST( (static_signed_min<-101, 0>::value) == -101 );
|
||||
BOOST_TEST( (static_signed_max<-101, 0>::value) == 0 );
|
||||
|
||||
// With identical
|
||||
cout << "Doing tests with two identical values." << endl;
|
||||
|
||||
BOOST_CHECK( (static_signed_min<0, 0>::value) == 0 );
|
||||
BOOST_CHECK( (static_signed_max<0, 0>::value) == 0 );
|
||||
BOOST_CHECK( (static_unsigned_min<0, 0>::value) == 0 );
|
||||
BOOST_CHECK( (static_unsigned_max<0, 0>::value) == 0 );
|
||||
BOOST_TEST( (static_signed_min<0, 0>::value) == 0 );
|
||||
BOOST_TEST( (static_signed_max<0, 0>::value) == 0 );
|
||||
BOOST_TEST( (static_unsigned_min<0, 0>::value) == 0 );
|
||||
BOOST_TEST( (static_unsigned_max<0, 0>::value) == 0 );
|
||||
|
||||
BOOST_CHECK( (static_signed_min<14, 14>::value) == 14 );
|
||||
BOOST_CHECK( (static_signed_max<14, 14>::value) == 14 );
|
||||
BOOST_CHECK( (static_unsigned_min<14, 14>::value) == 14 );
|
||||
BOOST_CHECK( (static_unsigned_max<14, 14>::value) == 14 );
|
||||
BOOST_TEST( (static_signed_min<14, 14>::value) == 14 );
|
||||
BOOST_TEST( (static_signed_max<14, 14>::value) == 14 );
|
||||
BOOST_TEST( (static_unsigned_min<14, 14>::value) == 14 );
|
||||
BOOST_TEST( (static_unsigned_max<14, 14>::value) == 14 );
|
||||
|
||||
BOOST_CHECK( (static_signed_min< -101, -101>::value) == -101 );
|
||||
BOOST_CHECK( (static_signed_max< -101, -101>::value) == -101 );
|
||||
BOOST_TEST( (static_signed_min< -101, -101>::value) == -101 );
|
||||
BOOST_TEST( (static_signed_max< -101, -101>::value) == -101 );
|
||||
|
||||
return boost::exit_success;
|
||||
}
|
||||
|
Reference in New Issue
Block a user