forked from boostorg/integer
Get the tests warning free with gcc, and add conceptual-header-inclusion tests.
[SVN r57948]
This commit is contained in:
@ -4,11 +4,20 @@
|
||||
|
||||
import testing ;
|
||||
|
||||
project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra ;
|
||||
|
||||
test-suite integer
|
||||
: [ run cstdint_test.cpp ]
|
||||
: [ run cstdint_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-long-long <toolset>gcc:<cxxflags>-Wno-type-limits ]
|
||||
[ run integer_traits_test.cpp ]
|
||||
[ run integer_test.cpp ]
|
||||
[ run integer_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-long-long ]
|
||||
[ run integer_mask_test.cpp ]
|
||||
[ run static_log2_test.cpp ]
|
||||
[ run static_min_max_test.cpp ]
|
||||
[ compile cstdint_include_test.cpp ]
|
||||
[ compile integer_traits_include_test.cpp ]
|
||||
[ compile integer_include_test.cpp ]
|
||||
[ compile integer_mask_include_test.cpp ]
|
||||
[ compile static_log2_include_test.cpp ]
|
||||
[ compile static_min_max_include_test.cpp ]
|
||||
[ compile integer_fwd_include_test.cpp ]
|
||||
;
|
||||
|
69
test/cstdint_include_test.cpp
Normal file
69
test/cstdint_include_test.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
// Copyright John Maddock 2009.
|
||||
// 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)
|
||||
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#include <boost/cstdint.hpp> // must be the only #include!
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::int8_t i8 = INT8_C(0);
|
||||
(void)i8;
|
||||
boost::uint8_t ui8 = UINT8_C(0);
|
||||
(void)ui8;
|
||||
boost::int16_t i16 = INT16_C(0);
|
||||
(void)i16;
|
||||
boost::uint16_t ui16 = UINT16_C(0);
|
||||
(void)ui16;
|
||||
boost::int32_t i32 = INT32_C(0);
|
||||
(void)i32;
|
||||
boost::uint32_t ui32 = UINT32_C(0);
|
||||
(void)ui32;
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
boost::int64_t i64 = 0;
|
||||
(void)i64;
|
||||
boost::uint64_t ui64 = 0;
|
||||
(void)ui64;
|
||||
#endif
|
||||
boost::int_least8_t i8least = INT8_C(0);
|
||||
(void)i8least;
|
||||
boost::uint_least8_t ui8least = UINT8_C(0);
|
||||
(void)ui8least;
|
||||
boost::int_least16_t i16least = INT16_C(0);
|
||||
(void)i16least;
|
||||
boost::uint_least16_t ui16least = UINT16_C(0);
|
||||
(void)ui16least;
|
||||
boost::int_least32_t i32least = INT32_C(0);
|
||||
(void)i32least;
|
||||
boost::uint_least32_t ui32least = UINT32_C(0);
|
||||
(void)ui32least;
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
boost::int_least64_t i64least = 0;
|
||||
(void)i64least;
|
||||
boost::uint_least64_t ui64least = 0;
|
||||
(void)ui64least;
|
||||
#endif
|
||||
boost::int_fast8_t i8fast = INT8_C(0);
|
||||
(void)i8fast;
|
||||
boost::uint_fast8_t ui8fast = UINT8_C(0);
|
||||
(void)ui8fast;
|
||||
boost::int_fast16_t i16fast = INT16_C(0);
|
||||
(void)i16fast;
|
||||
boost::uint_fast16_t ui16fast = UINT16_C(0);
|
||||
(void)ui16fast;
|
||||
boost::int_fast32_t i32fast = INT32_C(0);
|
||||
(void)i32fast;
|
||||
boost::uint_fast32_t ui32fast = UINT32_C(0);
|
||||
(void)ui32fast;
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
boost::int_fast64_t i64fast = 0;
|
||||
(void)i64fast;
|
||||
boost::uint_fast64_t ui64fast = 0;
|
||||
(void)ui64fast;
|
||||
#endif
|
||||
boost::intmax_t im = 0;
|
||||
(void)im;
|
||||
boost::uintmax_t uim = 0;
|
||||
(void)uim;
|
||||
}
|
22
test/integer_fwd_include_test.cpp
Normal file
22
test/integer_fwd_include_test.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright John Maddock 2009.
|
||||
// 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)
|
||||
|
||||
#include <boost/integer_fwd.hpp> // must be the only #include!
|
||||
|
||||
// just declare some functions that use the incomplete types in the header:
|
||||
|
||||
void f1(const boost::integer_traits<char>*);
|
||||
void f2(const boost::int_fast_t<char>*);
|
||||
void f3(const boost::int_t<12>*);
|
||||
void f4(const boost::uint_t<31>*);
|
||||
void f5(const boost::int_max_value_t<100>*);
|
||||
void f6(const boost::int_min_value_t<-100>*);
|
||||
void f7(const boost::uint_value_t<100>*);
|
||||
void f8(const boost::high_bit_mask_t<10>*);
|
||||
void f9(const boost::low_bits_mask_t<10>*);
|
||||
void f10(boost::static_log2_argument_type, boost::static_log2_result_type, boost::static_log2<10>*);
|
||||
void f11(boost::static_min_max_signed_type, boost::static_min_max_unsigned_type);
|
||||
void f12(boost::static_signed_min<1, 2>*, boost::static_signed_max<1,2>*);
|
||||
void f13(boost::static_unsigned_min<1,2>*, boost::static_unsigned_min<1,2>*);
|
36
test/integer_include_test.cpp
Normal file
36
test/integer_include_test.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright John Maddock 2009.
|
||||
// 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)
|
||||
|
||||
#include <boost/integer.hpp> // must be the only #include!
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::int_fast_t<char>::fast f = 0;
|
||||
(void)f;
|
||||
boost::int_t<16>::fast f2 = 0;
|
||||
(void)f2;
|
||||
boost::int_t<32>::exact e = 0;
|
||||
(void)e;
|
||||
boost::int_t<12>::least l = 0;
|
||||
(void)l;
|
||||
boost::uint_t<16>::fast uf2 = 0;
|
||||
(void)uf2;
|
||||
boost::uint_t<32>::exact ue = 0;
|
||||
(void)ue;
|
||||
boost::uint_t<12>::least ul = 0;
|
||||
(void)ul;
|
||||
boost::int_max_value_t<200>::fast v1 = 0;
|
||||
(void)v1;
|
||||
boost::int_max_value_t<2000>::least v2 = 0;
|
||||
(void)v2;
|
||||
boost::int_min_value_t<-200>::fast v3 = 0;
|
||||
(void)v3;
|
||||
boost::int_min_value_t<-2000>::least v4 = 0;
|
||||
(void)v4;
|
||||
boost::uint_value_t<200>::fast v5 = 0;
|
||||
(void)v5;
|
||||
boost::uint_value_t<2000>::least v6 = 0;
|
||||
(void)v6;
|
||||
}
|
18
test/integer_mask_include_test.cpp
Normal file
18
test/integer_mask_include_test.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright John Maddock 2009.
|
||||
// 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)
|
||||
|
||||
#include <boost/integer/integer_mask.hpp> // must be the only #include!
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::high_bit_mask_t<20>::least l = boost::high_bit_mask_t<20>::high_bit;
|
||||
boost::high_bit_mask_t<12>::fast f = boost::high_bit_mask_t<12>::high_bit_fast;
|
||||
l += f + boost::high_bit_mask_t<12>::bit_position;
|
||||
(void)l;
|
||||
boost::low_bits_mask_t<20>::least l2 = boost::low_bits_mask_t<20>::sig_bits;
|
||||
boost::low_bits_mask_t<12>::fast f2 = boost::low_bits_mask_t<12>::sig_bits_fast;
|
||||
l2 += f2 + boost::low_bits_mask_t<12>::bit_count;
|
||||
(void)l2;
|
||||
}
|
37
test/integer_traits_include_test.cpp
Normal file
37
test/integer_traits_include_test.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright John Maddock 2009.
|
||||
// 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)
|
||||
|
||||
#include <boost/integer_traits.hpp> // must be the only #include!
|
||||
|
||||
template <class T>
|
||||
void check_numeric_limits_derived(const std::numeric_limits<T>&){}
|
||||
|
||||
template <class T>
|
||||
void check()
|
||||
{
|
||||
typedef boost::integer_traits<T> traits;
|
||||
check_numeric_limits_derived(traits());
|
||||
bool b = traits::is_integral;
|
||||
(void)b;
|
||||
T v = traits::const_min + traits::const_max;
|
||||
(void)v;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
check<signed char>();
|
||||
check<unsigned char>();
|
||||
check<char>();
|
||||
check<short>();
|
||||
check<unsigned short>();
|
||||
check<int>();
|
||||
check<unsigned int>();
|
||||
check<signed long>();
|
||||
check<unsigned long>();
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
check<boost::long_long_type>();
|
||||
check<boost::ulong_long_type>();
|
||||
#endif
|
||||
}
|
14
test/static_log2_include_test.cpp
Normal file
14
test/static_log2_include_test.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright John Maddock 2009.
|
||||
// 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)
|
||||
|
||||
#include <boost/integer/static_log2.hpp> // must be the only #include!
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::static_log2_argument_type arg = 0;
|
||||
(void)arg;
|
||||
boost::static_log2_result_type result = boost::static_log2<30>::value;
|
||||
(void)result;
|
||||
}
|
14
test/static_min_max_include_test.cpp
Normal file
14
test/static_min_max_include_test.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright John Maddock 2009.
|
||||
// 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)
|
||||
|
||||
#include <boost/integer/static_min_max.hpp> // must be the only #include!
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::static_min_max_signed_type m = boost::static_signed_min<2, 3>::value + boost::static_signed_max<2, 3>::value;
|
||||
(void)m;
|
||||
boost::static_min_max_unsigned_type u = boost::static_unsigned_min<2, 3>::value + boost::static_unsigned_max<2, 3>::value;
|
||||
(void)u;
|
||||
}
|
Reference in New Issue
Block a user