diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 7220a36..0732774 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -4,11 +4,20 @@ import testing ; +project : requirements all gcc:-Wextra ; + test-suite integer - : [ run cstdint_test.cpp ] + : [ run cstdint_test.cpp : : : gcc:-Wno-long-long gcc:-Wno-type-limits ] [ run integer_traits_test.cpp ] - [ run integer_test.cpp ] + [ run integer_test.cpp : : : gcc:-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 ] ; diff --git a/test/cstdint_include_test.cpp b/test/cstdint_include_test.cpp new file mode 100644 index 0000000..aac2e21 --- /dev/null +++ b/test/cstdint_include_test.cpp @@ -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 // 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; +} diff --git a/test/integer_fwd_include_test.cpp b/test/integer_fwd_include_test.cpp new file mode 100644 index 0000000..4346b69 --- /dev/null +++ b/test/integer_fwd_include_test.cpp @@ -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 // must be the only #include! + +// just declare some functions that use the incomplete types in the header: + +void f1(const boost::integer_traits*); +void f2(const boost::int_fast_t*); +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>*); diff --git a/test/integer_include_test.cpp b/test/integer_include_test.cpp new file mode 100644 index 0000000..653a197 --- /dev/null +++ b/test/integer_include_test.cpp @@ -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 // must be the only #include! + +int main() +{ + boost::int_fast_t::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; +} diff --git a/test/integer_mask_include_test.cpp b/test/integer_mask_include_test.cpp new file mode 100644 index 0000000..09af189 --- /dev/null +++ b/test/integer_mask_include_test.cpp @@ -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 // 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; +} diff --git a/test/integer_traits_include_test.cpp b/test/integer_traits_include_test.cpp new file mode 100644 index 0000000..ddbe070 --- /dev/null +++ b/test/integer_traits_include_test.cpp @@ -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 // must be the only #include! + +template +void check_numeric_limits_derived(const std::numeric_limits&){} + +template +void check() +{ + typedef boost::integer_traits 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(); + check(); + check(); + check(); + check(); + check(); + check(); + check(); + check(); +#ifdef BOOST_HAS_LONG_LONG + check(); + check(); +#endif +} diff --git a/test/static_log2_include_test.cpp b/test/static_log2_include_test.cpp new file mode 100644 index 0000000..d39b871 --- /dev/null +++ b/test/static_log2_include_test.cpp @@ -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 // 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; +} diff --git a/test/static_min_max_include_test.cpp b/test/static_min_max_include_test.cpp new file mode 100644 index 0000000..8055062 --- /dev/null +++ b/test/static_min_max_include_test.cpp @@ -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 // 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; +}