Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64686 - in sandbox/SOC/2010/bit_masks: boost/integer/detail/bitfield_vector lib/integer/test/bitfield_vector_testing
From: bbartmanboost_at_[hidden]
Date: 2010-08-08 15:04:11


Author: bbartman
Date: 2010-08-08 15:04:09 EDT (Sun, 08 Aug 2010)
New Revision: 64686
URL: http://svn.boost.org/trac/boost/changeset/64686

Log:
completed test for two byte masks for storing data within a char array/
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp | 23 +++++++++++++++++++++++
   sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp | 21 +++++++++++++++++----
   2 files changed, 40 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-08 15:04:09 EDT (Sun, 08 Aug 2010)
@@ -15,6 +15,7 @@
 #include <boost/assert.hpp>
 #include <cstring>
 #include <boost/integer/low_bits_mask.hpp>
+#include <boost/integer/bit_width.hpp>
 #include <iostream>
 #include <iomanip>
 
@@ -224,6 +225,28 @@
         }
         
         if(_mask._size == 2) {
+ storage_t to_be_stored = 0;
+ std::size_t bits_in_first_mask = 8 - _mask._offset;
+ std::cout << "bits_in_first_mask: " << bits_in_first_mask << std::endl;
+ value_type first_mask = (~(~value_type(0) << bits_in_first_mask))
+ << (width - bits_in_first_mask - 1);
+ typedef unsigned long long ullt;
+ std::cout << "first_mask: " << std::hex << ullt(first_mask) << std::endl;
+ to_be_stored = storage_t((first_mask&x)>>(width - bits_in_first_mask - 1));
+ std::cout << "to be stored: " << std::hex << ullt(to_be_stored) << std::endl;
+ storage_ptr_t byte_ptr = _ptr;
+
+ *byte_ptr = (*byte_ptr & ~_mask._first_byte) | to_be_stored;
+ ++byte_ptr;
+ std::size_t bits_in_mask = width - bits_in_first_mask;
+ std::cout << "bits in second mask: " << bits_in_mask << std::endl;
+ value_type second_mask = ~(~value_type(0) << bits_in_mask);
+ std::cout << "second mask: " << std::hex << ullt(second_mask) << std::endl;
+ to_be_stored = storage_t((second_mask & x) << _mask._last_shift);
+ std::cout << "to be stored: " << std::hex << ullt(to_be_stored) << std::endl;
+ *byte_ptr = (*byte_ptr & ~_mask._last_byte) | to_be_stored;
+
+ return *this;
         }
         
         return *this;

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-08 15:04:09 EDT (Sun, 08 Aug 2010)
@@ -273,7 +273,6 @@
         storage_type storage[20];
         storage_ptr ptr = storage;
         std::memset(ptr,0,20);
-
         test_type_1 t1(ptr, 0);
         t1 = 0x7;
         std::cout << std::hex << std::size_t(*ptr) << std::endl;
@@ -282,16 +281,30 @@
 
 
         std::cout << "-----------------------------------------" << std::endl;
- std::cout << "1 byte offset not 2" << std::endl;
+ std::cout << "1 byte offset 2" << std::endl;
         std::cout << "-----------------------------------------" << std::endl;
-
         std::memset(ptr,0,1);
-
         test_type_1 t2(ptr, 2);
         t2 = 0x7;
         std::cout << std::hex << std::size_t(*ptr) << std::endl;
         print_mask_details(t2);
         BOOST_TEST(*ptr == 0x38);
+
+ std::cout << "-----------------------------------------" << std::endl;
+ std::cout << "multi byte extraction" << std::endl;
+ std::cout << "-----------------------------------------" << std::endl;
+ // std::memset(ptr,0,1);
+ test_type_1 t3(ptr, 6);
+
+ t3 = 0x7;
+ std::cout << std::hex << std::size_t(*ptr) << std::endl;
+ BOOST_TEST(t2 == 7);
+ ++ptr;
+ std::cout << std::hex << std::size_t(*ptr) << std::endl;
+ BOOST_TEST(*ptr == 0x80);
+ ptr = storage;
+
+ // BOOST_TEST(false);
 /*
 test_type_1;
 test_type_2;


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