mirror of
https://github.com/boostorg/integer.git
synced 2025-06-26 12:31:40 +02:00
Compare commits
3 Commits
boost-1.40
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
26f7ec0bd8 | |||
a1cc143de7 | |||
cd99f24a87 |
@ -113,10 +113,24 @@ void integral_constant_type_check(T1, T2)
|
|||||||
assert(sizeof(T1) == sizeof(T2));
|
assert(sizeof(T1) == sizeof(T2));
|
||||||
assert(t1 == t2);
|
assert(t1 == t2);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(BOOST_HAS_STDINT_H)
|
||||||
|
// native headers are permitted to promote small
|
||||||
|
// unsigned types to type int:
|
||||||
|
if(sizeof(T1) >= sizeof(int))
|
||||||
|
{
|
||||||
|
if(t1 > 0)
|
||||||
|
assert(t2 > 0);
|
||||||
|
else
|
||||||
|
assert(!(t2 > 0));
|
||||||
|
}
|
||||||
|
else if(t1 < 0)
|
||||||
|
assert(!(t2 > 0));
|
||||||
|
#else
|
||||||
if(t1 > 0)
|
if(t1 > 0)
|
||||||
assert(t2 > 0);
|
assert(t2 > 0);
|
||||||
else
|
else
|
||||||
assert(!(t2 > 0));
|
assert(!(t2 > 0));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,10 +202,9 @@ href="../../../people/daryle_walker.html">Daryle Walker</a>.</p>
|
|||||||
|
|
||||||
<p>Revised September 23, 2001</p>
|
<p>Revised September 23, 2001</p>
|
||||||
|
|
||||||
<p>© Copyright Daryle Walker 2001. Permission to copy, use,
|
<p>© Copyright Daryle Walker 2001. Use, modification, and distribution are
|
||||||
modify, sell and distribute this document is granted provided this
|
subject to the Boost Software License, Version 1.0. (See accompanying file <a
|
||||||
copyright notice appears in all copies. This document is provided
|
href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or a copy at <<a
|
||||||
"as is" without express or implied warranty, and with no claim
|
href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>>.)</p>
|
||||||
as to its suitability for any purpose.</p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -112,10 +112,9 @@ href="../../../people/daryle_walker.html">Daryle Walker</a>.</p>
|
|||||||
|
|
||||||
<p>Revised October 12, 2001</p>
|
<p>Revised October 12, 2001</p>
|
||||||
|
|
||||||
<p>© Copyright Daryle Walker 2001. Permission to copy, use,
|
<p>© Copyright Daryle Walker 2001. Use, modification, and distribution are
|
||||||
modify, sell and distribute this document is granted provided this
|
subject to the Boost Software License, Version 1.0. (See accompanying file <a
|
||||||
copyright notice appears in all copies. This document is provided
|
href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or a copy at <<a
|
||||||
"as is" without express or implied warranty, and with no claim
|
href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>>.)</p>
|
||||||
as to its suitability for any purpose.</p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -204,10 +204,9 @@ value-based sized templates.</p>
|
|||||||
|
|
||||||
<p>Revised May 20, 2001</p>
|
<p>Revised May 20, 2001</p>
|
||||||
|
|
||||||
<p>© Copyright Beman Dawes 1999. Permission to copy, use, modify,
|
<p>© Copyright Beman Dawes 1999. Use, modification, and distribution are
|
||||||
sell and distribute this document is granted provided this copyright
|
subject to the Boost Software License, Version 1.0. (See accompanying file <a
|
||||||
notice appears in all copies. This document is provided "as
|
href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or a copy at <<a
|
||||||
is" without express or implied warranty, and with no claim as to
|
href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>>.)</p>
|
||||||
its suitability for any purpose.</p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -19,16 +19,16 @@
|
|||||||
#include <iostream> // for std::cout (std::endl indirectly)
|
#include <iostream> // for std::cout (std::endl indirectly)
|
||||||
|
|
||||||
|
|
||||||
#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
|
#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_CHECK( ::boost::high_bit_mask_t< \
|
||||||
(v) >::high_bit == (1ul << (v)) );
|
(v) >::high_bit == (1ul << (v)) );
|
||||||
#define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
|
#define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_CHECK( ::boost::high_bit_mask_t< \
|
||||||
(v) >::high_bit_fast == (1ul << (v)) );
|
(v) >::high_bit_fast == (1ul << (v)) );
|
||||||
#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
|
#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
|
||||||
PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
|
PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
|
||||||
|
|
||||||
#define PRIVATE_LOW_BITS_SLOW_TEST(v) BOOST_TEST( ::boost::low_bits_mask_t< \
|
#define PRIVATE_LOW_BITS_SLOW_TEST(v) BOOST_CHECK( ::boost::low_bits_mask_t< \
|
||||||
(v) >::sig_bits == ((1ul << (v)) - 1) );
|
(v) >::sig_bits == ((1ul << (v)) - 1) );
|
||||||
#define PRIVATE_LOW_BITS_FAST_TEST(v) BOOST_TEST( ::boost::low_bits_mask_t< \
|
#define PRIVATE_LOW_BITS_FAST_TEST(v) BOOST_CHECK( ::boost::low_bits_mask_t< \
|
||||||
(v) >::sig_bits_fast == ((1ul << (v)) - 1) );
|
(v) >::sig_bits_fast == ((1ul << (v)) - 1) );
|
||||||
#define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \
|
#define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \
|
||||||
PRIVATE_LOW_BITS_FAST_TEST(v); } while (false)
|
PRIVATE_LOW_BITS_FAST_TEST(v); } while (false)
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
// Macros to compact code
|
// Macros to compact code
|
||||||
#define PRIVATE_LB_TEST( v, e ) BOOST_TEST( ::boost::static_log2<v>::value == e )
|
#define PRIVATE_LB_TEST( v, e ) BOOST_CHECK( ::boost::static_log2<v>::value == e )
|
||||||
|
|
||||||
#define PRIVATE_PRINT_LB( v ) ::std::cout << "boost::static_log2<" << (v) \
|
#define PRIVATE_PRINT_LB( v ) ::std::cout << "boost::static_log2<" << (v) \
|
||||||
<< "> = " << ::boost::static_log2< (v) >::value << '.' << ::std::endl
|
<< "> = " << ::boost::static_log2< (v) >::value << '.' << ::std::endl
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
// 23 Sep 2001 Initial version (Daryle Walker)
|
// 23 Sep 2001 Initial version (Daryle Walker)
|
||||||
|
|
||||||
#define BOOST_INCLUDE_MAIN
|
#define BOOST_INCLUDE_MAIN
|
||||||
#include <boost/test/test_tools.hpp> // for main, BOOST_TEST
|
#include <boost/test/test_tools.hpp> // for main, BOOST_CHECK
|
||||||
|
|
||||||
#include <boost/cstdlib.hpp> // for boost::exit_success
|
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||||
#include <boost/integer/static_min_max.hpp> // for boost::static_signed_min, etc.
|
#include <boost/integer/static_min_max.hpp> // for boost::static_signed_min, etc.
|
||||||
@ -37,57 +37,57 @@ test_main
|
|||||||
// Two positives
|
// Two positives
|
||||||
cout << "Doing tests with two positive values." << endl;
|
cout << "Doing tests with two positive values." << endl;
|
||||||
|
|
||||||
BOOST_TEST( (static_signed_min< 9, 14>::value) == 9 );
|
BOOST_CHECK( (static_signed_min< 9, 14>::value) == 9 );
|
||||||
BOOST_TEST( (static_signed_max< 9, 14>::value) == 14 );
|
BOOST_CHECK( (static_signed_max< 9, 14>::value) == 14 );
|
||||||
BOOST_TEST( (static_signed_min<14, 9>::value) == 9 );
|
BOOST_CHECK( (static_signed_min<14, 9>::value) == 9 );
|
||||||
BOOST_TEST( (static_signed_max<14, 9>::value) == 14 );
|
BOOST_CHECK( (static_signed_max<14, 9>::value) == 14 );
|
||||||
|
|
||||||
BOOST_TEST( (static_unsigned_min< 9, 14>::value) == 9 );
|
BOOST_CHECK( (static_unsigned_min< 9, 14>::value) == 9 );
|
||||||
BOOST_TEST( (static_unsigned_max< 9, 14>::value) == 14 );
|
BOOST_CHECK( (static_unsigned_max< 9, 14>::value) == 14 );
|
||||||
BOOST_TEST( (static_unsigned_min<14, 9>::value) == 9 );
|
BOOST_CHECK( (static_unsigned_min<14, 9>::value) == 9 );
|
||||||
BOOST_TEST( (static_unsigned_max<14, 9>::value) == 14 );
|
BOOST_CHECK( (static_unsigned_max<14, 9>::value) == 14 );
|
||||||
|
|
||||||
// Two negatives
|
// Two negatives
|
||||||
cout << "Doing tests with two negative values." << endl;
|
cout << "Doing tests with two negative values." << endl;
|
||||||
|
|
||||||
BOOST_TEST( (static_signed_min< -8, -101>::value) == -101 );
|
BOOST_CHECK( (static_signed_min< -8, -101>::value) == -101 );
|
||||||
BOOST_TEST( (static_signed_max< -8, -101>::value) == -8 );
|
BOOST_CHECK( (static_signed_max< -8, -101>::value) == -8 );
|
||||||
BOOST_TEST( (static_signed_min<-101, -8>::value) == -101 );
|
BOOST_CHECK( (static_signed_min<-101, -8>::value) == -101 );
|
||||||
BOOST_TEST( (static_signed_max<-101, -8>::value) == -8 );
|
BOOST_CHECK( (static_signed_max<-101, -8>::value) == -8 );
|
||||||
|
|
||||||
// With zero
|
// With zero
|
||||||
cout << "Doing tests with zero and a positive or negative value." << endl;
|
cout << "Doing tests with zero and a positive or negative value." << endl;
|
||||||
|
|
||||||
BOOST_TEST( (static_signed_min< 0, 14>::value) == 0 );
|
BOOST_CHECK( (static_signed_min< 0, 14>::value) == 0 );
|
||||||
BOOST_TEST( (static_signed_max< 0, 14>::value) == 14 );
|
BOOST_CHECK( (static_signed_max< 0, 14>::value) == 14 );
|
||||||
BOOST_TEST( (static_signed_min<14, 0>::value) == 0 );
|
BOOST_CHECK( (static_signed_min<14, 0>::value) == 0 );
|
||||||
BOOST_TEST( (static_signed_max<14, 0>::value) == 14 );
|
BOOST_CHECK( (static_signed_max<14, 0>::value) == 14 );
|
||||||
|
|
||||||
BOOST_TEST( (static_unsigned_min< 0, 14>::value) == 0 );
|
BOOST_CHECK( (static_unsigned_min< 0, 14>::value) == 0 );
|
||||||
BOOST_TEST( (static_unsigned_max< 0, 14>::value) == 14 );
|
BOOST_CHECK( (static_unsigned_max< 0, 14>::value) == 14 );
|
||||||
BOOST_TEST( (static_unsigned_min<14, 0>::value) == 0 );
|
BOOST_CHECK( (static_unsigned_min<14, 0>::value) == 0 );
|
||||||
BOOST_TEST( (static_unsigned_max<14, 0>::value) == 14 );
|
BOOST_CHECK( (static_unsigned_max<14, 0>::value) == 14 );
|
||||||
|
|
||||||
BOOST_TEST( (static_signed_min< 0, -101>::value) == -101 );
|
BOOST_CHECK( (static_signed_min< 0, -101>::value) == -101 );
|
||||||
BOOST_TEST( (static_signed_max< 0, -101>::value) == 0 );
|
BOOST_CHECK( (static_signed_max< 0, -101>::value) == 0 );
|
||||||
BOOST_TEST( (static_signed_min<-101, 0>::value) == -101 );
|
BOOST_CHECK( (static_signed_min<-101, 0>::value) == -101 );
|
||||||
BOOST_TEST( (static_signed_max<-101, 0>::value) == 0 );
|
BOOST_CHECK( (static_signed_max<-101, 0>::value) == 0 );
|
||||||
|
|
||||||
// With identical
|
// With identical
|
||||||
cout << "Doing tests with two identical values." << endl;
|
cout << "Doing tests with two identical values." << endl;
|
||||||
|
|
||||||
BOOST_TEST( (static_signed_min<0, 0>::value) == 0 );
|
BOOST_CHECK( (static_signed_min<0, 0>::value) == 0 );
|
||||||
BOOST_TEST( (static_signed_max<0, 0>::value) == 0 );
|
BOOST_CHECK( (static_signed_max<0, 0>::value) == 0 );
|
||||||
BOOST_TEST( (static_unsigned_min<0, 0>::value) == 0 );
|
BOOST_CHECK( (static_unsigned_min<0, 0>::value) == 0 );
|
||||||
BOOST_TEST( (static_unsigned_max<0, 0>::value) == 0 );
|
BOOST_CHECK( (static_unsigned_max<0, 0>::value) == 0 );
|
||||||
|
|
||||||
BOOST_TEST( (static_signed_min<14, 14>::value) == 14 );
|
BOOST_CHECK( (static_signed_min<14, 14>::value) == 14 );
|
||||||
BOOST_TEST( (static_signed_max<14, 14>::value) == 14 );
|
BOOST_CHECK( (static_signed_max<14, 14>::value) == 14 );
|
||||||
BOOST_TEST( (static_unsigned_min<14, 14>::value) == 14 );
|
BOOST_CHECK( (static_unsigned_min<14, 14>::value) == 14 );
|
||||||
BOOST_TEST( (static_unsigned_max<14, 14>::value) == 14 );
|
BOOST_CHECK( (static_unsigned_max<14, 14>::value) == 14 );
|
||||||
|
|
||||||
BOOST_TEST( (static_signed_min< -101, -101>::value) == -101 );
|
BOOST_CHECK( (static_signed_min< -101, -101>::value) == -101 );
|
||||||
BOOST_TEST( (static_signed_max< -101, -101>::value) == -101 );
|
BOOST_CHECK( (static_signed_max< -101, -101>::value) == -101 );
|
||||||
|
|
||||||
return boost::exit_success;
|
return boost::exit_success;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user