Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64731 - in sandbox/SOC/2010/bits_and_ints: boost/integer libs/integer/test
From: muriloufg_at_[hidden]
Date: 2010-08-10 17:46:43


Author: murilov
Date: 2010-08-10 17:46:40 EDT (Tue, 10 Aug 2010)
New Revision: 64731
URL: http://svn.boost.org/trac/boost/changeset/64731

Log:
Fixed some files for compiling with MSVC++ without errors/warnings
Text files modified:
   sandbox/SOC/2010/bits_and_ints/boost/integer/count_trailing_zeros.hpp | 3 ++-
   sandbox/SOC/2010/bits_and_ints/boost/integer/static_count_trailing_zeros.hpp | 7 ++++---
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/count_trailing_zeros_test.cpp | 16 ++++++++--------
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/find_first_one_string_test.cpp | 2 ++
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/inc_rev_test.cpp | 2 +-
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/isqrt_test.cpp | 29 ++++++++++++++++-------------
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/rotate_test.cpp | 7 +++++--
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/sign_extend_test.cpp | 6 +++---
   8 files changed, 41 insertions(+), 31 deletions(-)

Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/count_trailing_zeros.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/count_trailing_zeros.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/count_trailing_zeros.hpp 2010-08-10 17:46:40 EDT (Tue, 10 Aug 2010)
@@ -74,7 +74,8 @@
 
 #else
 
-inline int count_trailing_zeros(uintmax_t value)
+template <typename T>
+inline int count_trailing_zeros(T value)
 {
         return pop_count(~value & (value - 1));
 }

Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/static_count_trailing_zeros.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/static_count_trailing_zeros.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_count_trailing_zeros.hpp 2010-08-10 17:46:40 EDT (Tue, 10 Aug 2010)
@@ -11,6 +11,7 @@
 #define BOOST_STATIC_COUNT_TRAILING_ZEROS_INCLUDED
 
 #include <boost/cstdint.hpp>
+#include <boost/integer_traits.hpp>
 #include <boost/static_assert.hpp>
 #include <boost/mpl/integral_c.hpp>
 #include <boost/integer/static_pop_count.hpp>
@@ -40,16 +41,16 @@
  * MPL integral_c<> compatible version
  */
 template <typename IC>
-struct count_trailing_zeros : pop_count< integral_c<uintmax_t, ~IC::value & (IC::value - 1)> >
+ struct count_trailing_zeros : pop_count< integral_c<typename IC::value_type, ((IC::value != 0) ? (~IC::value & (IC::value - 1)) : integer_traits<typename IC::value_type>::const_max)> >
 {
         BOOST_STATIC_ASSERT((is_integral_constant<IC>::value));
 };
 
 }
 
-template <uintmax_t Value>
+template <typename T, T Value>
 struct static_count_trailing_zeros :
- mpl::count_trailing_zeros< mpl::integral_c<uintmax_t, Value> >
+ mpl::count_trailing_zeros< mpl::integral_c<T, Value> >
 {};
         
 } // boost

Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/test/count_trailing_zeros_test.cpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/test/count_trailing_zeros_test.cpp (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/count_trailing_zeros_test.cpp 2010-08-10 17:46:40 EDT (Tue, 10 Aug 2010)
@@ -12,8 +12,8 @@
 #include <boost/integer/static_count_trailing_zeros.hpp>
 
 #define COUNT_ZEROS_TEST(x, y) \
-BOOST_TEST((::boost::count_trailing_zeros(unsigned(x)) == y)); \
-BOOST_TEST(((::boost::mpl::count_trailing_zeros< ::boost::mpl::integral_c< ::boost::uintmax_t, x> >::value) == y))
+BOOST_TEST((::boost::count_trailing_zeros(boost::uint32_t(x)) == y)); \
+BOOST_TEST(((::boost::mpl::count_trailing_zeros< ::boost::mpl::integral_c<boost::uint32_t, x> >::value) == y))
 
 
 // Main testing function
@@ -21,7 +21,7 @@
 {
         std::cout << "Doing tests on count_trailing_zeros functions." << std::endl;
         
- COUNT_ZEROS_TEST(0xF00000000, 32);
+ COUNT_ZEROS_TEST(0x00000000, 32);
         COUNT_ZEROS_TEST(0x1, 0);
         COUNT_ZEROS_TEST(0x2, 1);
         COUNT_ZEROS_TEST(0x4, 2);
@@ -33,14 +33,14 @@
         COUNT_ZEROS_TEST(0xAA, 1);
         COUNT_ZEROS_TEST(0xFFFF, 0);
         COUNT_ZEROS_TEST(0xF0A0, 5);
- COUNT_ZEROS_TEST(0xFFFFFFFF, 0);
- COUNT_ZEROS_TEST(0x55555555, 0);
- COUNT_ZEROS_TEST(0xBABEBEEF, 0);
+ COUNT_ZEROS_TEST(unsigned(0xFFFFFFFFU), 0);
+ COUNT_ZEROS_TEST(0x55555555U, 0);
+ COUNT_ZEROS_TEST(0xBABEBEEFU, 0);
         COUNT_ZEROS_TEST(0xFF800, 11);
         COUNT_ZEROS_TEST(0x800, 11);
- COUNT_ZEROS_TEST(0x123800, 11);
+ COUNT_ZEROS_TEST(0x123800U, 11);
         COUNT_ZEROS_TEST(0x33800, 11);
- COUNT_ZEROS_TEST(0x80000000, 31);
+ COUNT_ZEROS_TEST(0x80000000U, 31);
         
         return boost::report_errors();
 }
\ No newline at end of file

Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/test/find_first_one_string_test.cpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/test/find_first_one_string_test.cpp (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/find_first_one_string_test.cpp 2010-08-10 17:46:40 EDT (Tue, 10 Aug 2010)
@@ -15,6 +15,8 @@
 int main()
 {
         using boost::find_first_one_string;
+ using boost::uint32_t;
+ using boost::uint64_t;
         
         BOOST_TEST((find_first_one_string((uint32_t)0, 1) == -1));
         BOOST_TEST((find_first_one_string((uint32_t)0, 2) == -1));

Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/test/inc_rev_test.cpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/test/inc_rev_test.cpp (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/inc_rev_test.cpp 2010-08-10 17:46:40 EDT (Tue, 10 Aug 2010)
@@ -17,7 +17,7 @@
 int main()
 {
         using boost::inc_rev;
- uint8_t c = 0;
+ boost::uint8_t c = 0;
         
         INC_REV_TEST((c = inc_rev(c)), 128);
         INC_REV_TEST((c = inc_rev(c)), 64);

Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/test/isqrt_test.cpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/test/isqrt_test.cpp (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/isqrt_test.cpp 2010-08-10 17:46:40 EDT (Tue, 10 Aug 2010)
@@ -14,39 +14,42 @@
 
 int main()
 {
-
+ using boost::uint8_t;
+ using boost::uint16_t;
+ using boost::uint32_t;
+
         for (uint8_t i = 0; i < 255; ++i) {
- BOOST_TEST((boost::isqrt(i) == int(sqrt(i))));
+ BOOST_TEST((boost::isqrt(i) == int(sqrt(double(i)))));
         }
         
         for (uint16_t i = 0x0; i < 0xFF; ++i) {
- BOOST_TEST((boost::isqrt(i) == int(sqrt(i))));
+ BOOST_TEST((boost::isqrt(i) == int(sqrt(double(i)))));
         }
         
         for (uint16_t i = 0x0FFF; i < 0xFFFF; ++i) {
- BOOST_TEST((boost::isqrt(i) == int(sqrt(i))));
+ BOOST_TEST((boost::isqrt(i) == int(sqrt(double(i)))));
         }
         
         for (uint32_t i = 0x0; i < 0xFF; ++i) {
- BOOST_TEST((boost::isqrt(i) == int(sqrt(i))));
+ BOOST_TEST((boost::isqrt(i) == int(sqrt(double(i)))));
         }
         
         for (uint32_t i = 0xFFFF; i < 0xFFFFF; ++i) {
- BOOST_TEST((boost::isqrt(i) == int(sqrt(i))));
+ BOOST_TEST((boost::isqrt(i) == int(sqrt(double(i)))));
         }
         
- BOOST_TEST((boost::isqrt(unsigned(0)) == int(sqrt(0))));
- BOOST_TEST((boost::isqrt(unsigned(1)) == int(sqrt(1))));
- BOOST_TEST((boost::isqrt(unsigned(2)) == int(sqrt(2))));
- BOOST_TEST((boost::isqrt(unsigned(3)) == int(sqrt(3))));
+ BOOST_TEST((boost::isqrt(uint32_t(0)) == int(sqrt(0.0))));
+ BOOST_TEST((boost::isqrt(uint32_t(1)) == int(sqrt(1.0))));
+ BOOST_TEST((boost::isqrt(uint32_t(2)) == int(sqrt(2.0))));
+ BOOST_TEST((boost::isqrt(uint32_t(3)) == int(sqrt(3.0))));
         BOOST_TEST((boost::isqrt(std::numeric_limits<uint8_t>::max())
- == int(sqrt(std::numeric_limits<uint8_t>::max()))));
+ == int(sqrt(double(std::numeric_limits<uint8_t>::max())))));
         
         BOOST_TEST((boost::isqrt(std::numeric_limits<uint16_t>::max())
- == int(sqrt(std::numeric_limits<uint16_t>::max()))));
+ == int(sqrt(double(std::numeric_limits<uint16_t>::max())))));
         
         BOOST_TEST((boost::isqrt(std::numeric_limits<uint32_t>::max())
- == int(sqrt(std::numeric_limits<uint32_t>::max()))));
+ == int(sqrt(double(std::numeric_limits<uint32_t>::max())))));
 
         return boost::report_errors();
 }

Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/test/rotate_test.cpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/test/rotate_test.cpp (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/rotate_test.cpp 2010-08-10 17:46:40 EDT (Tue, 10 Aug 2010)
@@ -14,11 +14,14 @@
 BOOST_TEST((::boost::rotate_left(x, n) == y))
 
 #define ROTATE_R_TEST(x, n, y) \
-BOOST_TEST((::boost::rotate_right(x, n) == y)); \
-std::cout << "aah " << std::hex << ::boost::rotate_right(x, n) << std::endl
+BOOST_TEST((::boost::rotate_right(x, n) == y))
 
 int main()
 {
+ using boost::int64_t;
+ using boost::uint64_t;
+ using boost::int32_t;
+
     ROTATE_L_TEST(0x0, 1, 0);
         ROTATE_L_TEST(0x0, 30, 0);
         ROTATE_L_TEST(0xF0000000, 4, 0xF);

Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/test/sign_extend_test.cpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/test/sign_extend_test.cpp (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/sign_extend_test.cpp 2010-08-10 17:46:40 EDT (Tue, 10 Aug 2010)
@@ -14,7 +14,7 @@
 // Macros to compact code
 #define SIGN_EXTEND_TEST(d, b, e) \
         BOOST_TEST(::boost::sign_extend(d, b) == e); \
- BOOST_TEST((::boost::static_sign_extend< ::boost::int64_t, d, b>::value) == e)
+ BOOST_TEST((::boost::static_sign_extend< ::boost::intmax_t, d, b>::value) == e)
 
 // Main testing function
 int main(int, char* [])
@@ -60,8 +60,8 @@
         
 #ifndef BOOST_NO_INT64_T
         SIGN_EXTEND_TEST(0x7FFFFFFFFFLL, 39, -0x1LL);
- SIGN_EXTEND_TEST(0x100000000000LL, 63, 0x100000000000LL);
- SIGN_EXTEND_TEST(0x7FFFFFFFFFFFFFFFLL, 63, -0x1LL);
+ SIGN_EXTEND_TEST(0x1000000000000000LL, 63, 0x1000000000000000LL);
+ SIGN_EXTEND_TEST(0x7FFFFFFFFFFFFFFFLL, 63, -1LL);
 #endif
 
         return boost::report_errors();


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk