Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64759 - in sandbox/SOC/2010/bit_masks: boost/integer/detail/bitfield_vector lib/integer/test/bitfield_vector_testing
From: bbartmanboost_at_[hidden]
Date: 2010-08-12 10:41:20


Author: bbartman
Date: 2010-08-12 10:41:19 EDT (Thu, 12 Aug 2010)
New Revision: 64759
URL: http://svn.boost.org/trac/boost/changeset/64759

Log:
fixed sign bit mask creation testing
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp | 3 +
   sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp | 48 +++++++++++++++++++++++++++++++++++++--
   2 files changed, 47 insertions(+), 4 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp 2010-08-12 10:41:19 EDT (Thu, 12 Aug 2010)
@@ -109,7 +109,8 @@
     typedef std::size_t offset_type;
     BOOST_STATIC_CONSTANT( std::size_t, width = Width );
     BOOST_STATIC_CONSTANT(value_type, sign_bit =
- (high_bits_mask<value_type,1>::value));
+ (~value_type(0) <<(bit_width<value_type>::value-1) ));
+
     /** constructors and destructor for the proxy_reference_type type. */
     //@{
 

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp 2010-08-12 10:41:19 EDT (Thu, 12 Aug 2010)
@@ -26,6 +26,7 @@
 typedef proxy_reference_type<long, 7> test_type_8;
 typedef proxy_reference_type<long long, 17> test_type_9;
 typedef proxy_reference_type<long long, 50> test_type_10;
+typedef proxy_reference_type<short, 13> test_type_11;
 
 bool display_debug = false;
 /*
@@ -481,9 +482,11 @@
         BOOST_PRINT_ON_TEST_FAILURE_2(t6, 5);
         BOOST_PRINT_ON_TEST_FAILURE_2(t7, 6);
         BOOST_PRINT_ON_TEST_FAILURE_2(t8, 7);
-
- print_from_to(storage,10);
+ if(display_debug){
+ print_from_to(storage,10);
+ }
     }
+#undef ASSIGN_MONITOR
     {
         if(display_debug) {
             std::cout << "-----------------------------------------" << std::endl;
@@ -553,19 +556,58 @@
     // signed numbers.
     {
         display_debug = true;
-
         if(display_debug) {
             std::cout << "=========================================" << std::endl;
             std::cout << " Signed type tests" << std::endl;
             std::cout << "=========================================" << std::endl;
         }
+
+ typedef long long ll_type;
+ int int_sign_bit = ~int(0) << (boost::bit_width<int>::value-1);
+ char char_sign_bit = ~char(0) << (boost::bit_width<char>::value-1);
+ short short_sign_bit = ~long(0) <<
+ (boost::bit_width<short>::value-1);
+
+ long long_sign_bit = ~long(0) << (boost::bit_width<long>::value-1);
+ ll_type ll_sign_bit = ~ll_type(0) <<
+ (boost::bit_width<ll_type>::value-1);
+
+#define PRINT_ON_SIGNBIT_FAILURE(P1, P2) \
+ if(display_debug) { \
+ if(P1 != P2) {\
+ std::cout << #P1 << " = " << to_binary(P1) << std::endl;\
+ std::cout << #P2 << " = " << to_binary(P2) << std::endl;\
+ \
+ }\
+ }\
+ BOOST_TEST(P1 == P2);
+
+ // testing sign bits.
+ PRINT_ON_SIGNBIT_FAILURE(test_type_6::sign_bit, int_sign_bit);
+ PRINT_ON_SIGNBIT_FAILURE(test_type_7::sign_bit,char_sign_bit);
+ PRINT_ON_SIGNBIT_FAILURE(test_type_8::sign_bit,long_sign_bit);
+ PRINT_ON_SIGNBIT_FAILURE(test_type_9::sign_bit,ll_sign_bit);
+ PRINT_ON_SIGNBIT_FAILURE(test_type_10::sign_bit,ll_sign_bit);
+ PRINT_ON_SIGNBIT_FAILURE(test_type_11::sign_bit,short_sign_bit);
+#undef PRINT_ON_SIGNBIT_FAILURE
+
+
 /*
+typedef proxy_reference_type<int, 3> test_type_6;
+typedef proxy_reference_type<char, 9> test_type_7;
+typedef proxy_reference_type<long, 7> test_type_8;
+typedef proxy_reference_type<long long, 17> test_type_9;
+typedef proxy_reference_type<long long, 50> test_type_10;
+typedef proxy_reference_type<short, 13> test_type_11;
+
 test_type_6;
 test_type_7;
 test_type_8;
 test_type_9;
 test_type_10;
+test_type_11
 */
+
     }
     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