Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63817 - sandbox/SOC/2010/bit_masks/lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-07-10 12:27:57


Author: bbartman
Date: 2010-07-10 12:27:56 EDT (Sat, 10 Jul 2010)
New Revision: 63817
URL: http://svn.boost.org/trac/boost/changeset/63817

Log:
working on fixing some of my errors in side of the high and low masks
Text files modified:
   sandbox/SOC/2010/bit_masks/lib/integer/test/compound_mask_test.cpp | 2
   sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp | 69 ++++++++++++++++++---------------------
   2 files changed, 33 insertions(+), 38 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/compound_mask_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/compound_mask_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/compound_mask_test.cpp 2010-07-10 12:27:56 EDT (Sat, 10 Jul 2010)
@@ -17,7 +17,7 @@
 
         typedef compound_mask< combo_mask, bits_mask<int, 3, 5> > combo_mask2;
         BOOST_ASSERT(( combo_mask2() == (combo_mask() | bits_mask<int, 3, 5>() ) ));
- BOOST_ASSERT(( combo_mask2() > 0 )) ;
+ BOOST_ASSERT(( combo_mask2() != 0 )) ;
         
         typedef compound_mask<
                     combo_mask2,

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-07-10 12:27:56 EDT (Sat, 10 Jul 2010)
@@ -6,9 +6,13 @@
 
 
 #include <boost/integer/high_low_bits.hpp>
+#include <boost/detail/lightweight_test.hpp>
 #include "test_type_list.hpp"
 #include <iostream>
 #include <typeinfo>
+#include <iomanip>
+
+
 
 // tesitng for bit width.
 using namespace boost;
@@ -17,44 +21,30 @@
 void test_function() {
 
     using namespace std;
+
+
     cout << "Starting test. Test Type = " << typeid(T).name() << endl;
     // making sure that the value type is transfered correctly.
- BOOST_ASSERT((is_same< typename high_bits_mask<T, 3>::value_type, T >::value));
-
- cout << "Mask Value: " << boost::high_bits_mask<T,1>::value << endl;
- cout << "Test Value: " << ~(~(T(0)) >> 1) << endl;
- BOOST_ASSERT(( boost::high_bits_mask<T,1>::value == ~(~(T(0)) >> 1) ));
-
- cout << "Mask Value: " << boost::high_bits_mask<T,2>::value << endl;
- cout << "Test Value: " << ~(~(T(0)) >> 2) << endl;
- BOOST_ASSERT(( boost::high_bits_mask<T,2>::value == ~(~(T(0)) >> 2) ));
-
- cout << "Mask Value: " << boost::high_bits_mask<T,3>::value << endl;
- cout << "Test Value: " << ~(~(T(0)) >> 3) << endl;
- BOOST_ASSERT(( boost::high_bits_mask<T,3>::value == ~(~(T(0)) >> 3) ));
-
- cout << "Mask Value: " << boost::high_bits_mask<T,4>::value << endl;
- cout << "Test Value: " << ~(~(T(0)) >> 4) << endl;
- BOOST_ASSERT(( boost::high_bits_mask<T,4>::value == ~(~(T(0)) >> 4) ));
-
- cout << "Mask Value: " << boost::high_bits_mask<T,5>::value << endl;
- cout << "Test Value: " << ~(~(T(0)) >> 5) << endl;
- BOOST_ASSERT(( boost::high_bits_mask<T,5>::value == ~(~(T(0)) >> 5) ));
-
- cout << "Mask Value: " << boost::high_bits_mask<T,6>::value << endl;
- cout << "Test Value: " << ~(~(T(0)) >> 6) << endl;
- BOOST_ASSERT(( boost::high_bits_mask<T,6>::value == ~(~(T(0)) >> 6) ));
-
- cout << "Mask Value: " << boost::high_bits_mask<T,7>::value << endl;
- cout << "Test Value: " << ~(~(T(0)) >> 7) << endl;
- BOOST_ASSERT(( boost::high_bits_mask<T,7>::value == ~(~(T(0)) >> 7) ));
-
- cout << "Mask Value: " << boost::high_bits_mask<T,8>::value << endl;
- cout << "Test Value: " << ~(~(T(0)) >> 8) << endl;
- BOOST_ASSERT(( boost::high_bits_mask<T,8>::value == ~(~(T(0)) >> 8) ));
+ BOOST_TEST((is_same< typename high_bits_mask<T, 3>::value_type, T >::value));
+ BOOST_TEST(( boost::high_bits_mask<T,1>::value ==
+ static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 1)) ));
+ BOOST_TEST(( boost::high_bits_mask<T,2>::value ==
+ static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 2)) ));
+ BOOST_TEST(( boost::high_bits_mask<T,3>::value ==
+ static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 3)) ));
+ BOOST_TEST(( boost::high_bits_mask<T,4>::value ==
+ static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 4)) ));
+ BOOST_TEST(( boost::high_bits_mask<T,5>::value ==
+ static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 5)) ));
+ BOOST_TEST(( boost::high_bits_mask<T,6>::value ==
+ static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 6)) ));
+ BOOST_TEST(( boost::high_bits_mask<T,7>::value ==
+ static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 7)) ));
+ BOOST_TEST(( boost::high_bits_mask<T,8>::value ==
+ static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 8)) ));
 
     // assert that type returns the correct typedef.
- BOOST_ASSERT(( is_same<
+ BOOST_TEST(( is_same<
                     typename high_bits_mask<T, 3>::type,
                     high_bits_mask<T, 3> >::value
               ));
@@ -65,7 +55,11 @@
     template< typename U >
     void operator()(U) {
         test_function<U>();
-
+ }
+ void operator() (wchar_t)
+ {
+ using namespace std;
+ cout << "can't use wchar_t" << endl;
     }
 };
 
@@ -73,6 +67,7 @@
 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;
+ mpl::for_each< test_types_3 >( type_tester() );
+
+ 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