Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61996 - sandbox/SOC/2010/bit_masks/lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-05-15 12:36:56


Author: bbartman
Date: 2010-05-15 12:36:56 EDT (Sat, 15 May 2010)
New Revision: 61996
URL: http://svn.boost.org/trac/boost/changeset/61996

Log:
working on completing a testing framework for my integer stuff as well as fixing some of the things one of my mentor asked me to
Text files modified:
   sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp | 45 ++++++++++++++++++++++++++++++++++-----
   sandbox/SOC/2010/bit_masks/lib/integer/test/low_bit_mask_test.cpp | 7 -----
   sandbox/SOC/2010/bit_masks/lib/integer/test/test_type_list.hpp | 1
   3 files changed, 41 insertions(+), 12 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp 2010-05-15 12:36:56 EDT (Sat, 15 May 2010)
@@ -3,19 +3,52 @@
 // (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/assert.hpp>
 #include <boost/type_traits.hpp>
+#include "test_type_list.hpp"
+
 #include <boost/integer/high_low_bits.hpp>
 
 // tesitng for bit width.
 using namespace boost;
 
-int main() {
- {
- typedef high_bits<unsigned int, 3> hb;
- BOOST_ASSERT(( hb::value == 3758096384 ));
- BOOST_ASSERT(( is_same<hb::value_type, unsigned int>::value ));
- BOOST_ASSERT(( is_same<hb::type, hb>::value ));
+template <typename T>
+void test_function() {
+
+ // making sure that the value type is transfered correctly.
+ BOOST_TEST((is_same< typename high_bits<T, 3>::value_type, T >::value));
+
+
+ BOOST_TEST(( boost::high_bits<T,1>::value == ~(~(T(0)) >> 1) ));
+ BOOST_TEST(( boost::high_bits<T,2>::value == ~(~(T(0)) >> 2) ));
+ BOOST_TEST(( boost::high_bits<T,3>::value == ~(~(T(0)) >> 3) ));
+ BOOST_TEST(( boost::high_bits<T,4>::value == ~(~(T(0)) >> 4) ));
+ BOOST_TEST(( boost::high_bits<T,5>::value == ~(~(T(0)) >> 5) ));
+ BOOST_TEST(( boost::high_bits<T,6>::value == ~(~(T(0)) >> 6) ));
+ BOOST_TEST(( boost::high_bits<T,7>::value == ~(~(T(0)) >> 7) ));
+ BOOST_TEST(( boost::high_bits<T,8>::value == ~(~(T(0)) >> 8) ));
+
+ // assert that type returns the correct typedef.
+ BOOST_TEST(( is_same<
+ typename high_bits<T, 3>::type,
+ low_bits<T, 3> >::value
+ ));
+}
+
+
+struct type_tester {
+ template< typename U >
+ void operator()(U) {
+ test_function<U>();
+
     }
+};
+
+
+int main() {
+ mpl::for_each< test_types >( type_tester() );
+ mpl::for_each< test_types_2 >( type_tester() );
+ mpl::for_each< test_types_3 >( type_tester() );
     return 0;
 }

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/low_bit_mask_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/low_bit_mask_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/low_bit_mask_test.cpp 2010-05-15 12:36:56 EDT (Sat, 15 May 2010)
@@ -3,13 +3,8 @@
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/mpl/list.hpp>
-#include <boost/mpl/for_each.hpp>
 
 
-#include <boost/detail/lightweight_test.hpp> // for main, BOOST_TEST
-#include <boost/assert.hpp>
-#include <boost/type_traits.hpp>
 #include "test_type_list.hpp"
 #include <boost/integer/high_low_bits.hpp>
 
@@ -24,7 +19,7 @@
     // making sure that the value type is transfered correctly.
     BOOST_TEST((is_same< typename low_bits<T, 3>::value_type, T >::value));
 
-
+
     BOOST_TEST(( boost::low_bits<T,1>::value == 1));
     BOOST_TEST(( boost::low_bits<T,2>::value == 3));
     BOOST_TEST(( boost::low_bits<T,3>::value == 7));

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/test_type_list.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/test_type_list.hpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/test_type_list.hpp 2010-05-15 12:36:56 EDT (Sat, 15 May 2010)
@@ -20,6 +20,7 @@
 
 
 // boost includes
+#include <boost/detail/lightweight_test.hpp>
 #include <boost/cstdint.hpp>
 #include <boost/mpl/list.hpp>
 #include <boost/mpl/for_each.hpp>


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