Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63782 - sandbox/SOC/2010/bits_and_ints/libs/integer/test
From: muriloufg_at_[hidden]
Date: 2010-07-09 13:52:22


Author: murilov
Date: 2010-07-09 13:52:21 EDT (Fri, 09 Jul 2010)
New Revision: 63782
URL: http://svn.boost.org/trac/boost/changeset/63782

Log:
Added static_count_trailing_zeros<> and mpl::count_trailing_zeros<> static metafunctions and its test
Added:
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/count_trailing_zeros_test.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2010/bits_and_ints/libs/integer/test/Jamfile.v2 | 2 ++
   1 files changed, 2 insertions(+), 0 deletions(-)

Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/test/Jamfile.v2 (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/Jamfile.v2 2010-07-09 13:52:21 EDT (Fri, 09 Jul 2010)
@@ -21,6 +21,8 @@
                 [ run static_abs_test.cpp ]
                 [ run static_gcd_test.cpp ]
                 [ run static_lcm_test.cpp ]
+ [ run pop_count_test.cpp ]
+ [ run count_trailing_zeros_test.cpp ]
         [ compile cstdint_include_test.cpp ]
         [ compile integer_traits_include_test.cpp ]
         [ compile integer_include_test.cpp ]

Added: sandbox/SOC/2010/bits_and_ints/libs/integer/test/count_trailing_zeros_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/count_trailing_zeros_test.cpp 2010-07-09 13:52:21 EDT (Fri, 09 Jul 2010)
@@ -0,0 +1,47 @@
+// Boost count_trailing_zeros_test.hpp test program --------------------------------------//
+
+// (C) Copyright Murilo Adriano Vasconcelos 2010.
+// 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/detail/lightweight_test.hpp>
+#include <boost/integer/count_trailing_zeros.hpp>
+#include <boost/integer/static_count_trailing_zeros.hpp>
+#include <boost/mpl/integral_c.hpp>
+
+#include <iostream>
+
+#define COUNT_ZEROS_TEST(x, y) \
+BOOST_TEST((::boost::count_trailing_zeros(x) == y)); \
+BOOST_TEST(((::boost::mpl::count_trailing_zeros< ::boost::mpl::integral_c<uintmax_t, x> >::value) == y))
+
+
+// Main testing function
+int main(int, char* [])
+{
+ std::cout << "Doing tests on pop_count functions." << std::endl;
+
+ COUNT_ZEROS_TEST(0xF00000000, 32);
+ COUNT_ZEROS_TEST(0x1, 0);
+ COUNT_ZEROS_TEST(0x2, 1);
+ COUNT_ZEROS_TEST(0x4, 2);
+ COUNT_ZEROS_TEST(0x8, 3);
+ COUNT_ZEROS_TEST(0x3, 0);
+ COUNT_ZEROS_TEST(0x5, 0);
+ COUNT_ZEROS_TEST(0x9, 0);
+ COUNT_ZEROS_TEST(0x90, 4);
+ 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(0xFF800, 11);
+ COUNT_ZEROS_TEST(0x800, 11);
+ COUNT_ZEROS_TEST(0x123800, 11);
+ COUNT_ZEROS_TEST(0x33800, 11);
+ COUNT_ZEROS_TEST(0x80000000, 31);
+
+ return boost::report_errors();
+}
\ No newline at end of file


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