|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64682 - 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 10:27:17
Author: bbartman
Date: 2010-08-08 10:27:16 EDT (Sun, 08 Aug 2010)
New Revision: 64682
URL: http://svn.boost.org/trac/boost/changeset/64682
Log:
completed another set of tests and a round of debugging for bitfield_vector's proxy_reference type
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp | 26 +++++++++++---------------
sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp | 31 +++++++++++++++++++++++++++----
2 files changed, 38 insertions(+), 19 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 10:27:16 EDT (Sun, 08 Aug 2010)
@@ -131,16 +131,6 @@
mask_detail _mask;
};
-
-/** Used for returning information about the mask used to apply the mask to
- * another char array.
- */
-struct mask_array_info {
- std::size_t mask_size;
- storage_ptr_t mask;
- std::size_t last_left_shift;
-};
-
/** Proxy reference type for unsigned types. */
template <typename RetType, std::size_t Width>
class proxy_reference_type<RetType,Width,false> {
@@ -193,7 +183,8 @@
_mask._last_shift;
++byte_ptr;
- ret += value_type( _mask._last_byte & *byte_ptr) >> (8 - _mask._last_shift);
+ ret += value_type( _mask._last_byte & *byte_ptr) >>
+ (8 - _mask._last_shift);
if( _mask._last_byte != 0xFF) {
ret >>= _mask._last_shift - 1;
}
@@ -202,8 +193,10 @@
const storage_t all_bits = 0xFF;
// gettting first byte.
- ret = value_type(_mask._first_byte & *byte_ptr) << 8;
+
+ ret = value_type( _mask._first_byte & *byte_ptr);
++byte_ptr;
+
// getting middle bytes
for(std::size_t index = 0; index < _mask._size - 2; ++index) {
ret <<= 8;
@@ -211,9 +204,12 @@
++byte_ptr;
}
// shifting bits
- ++byte_ptr;
- ret <<= _mask._last_shift;
- ret += value_type( *byte_ptr & _mask._last_byte ) >> (8 - _mask._last_shift);
+ if(_mask._last_shift == 8){
+ ret <<= 8;
+ }else{
+ ret <<= 8 - _mask._last_shift;
+ }
+ ret += value_type( *byte_ptr & _mask._last_byte ) >> ( _mask._last_shift);
return ret;
}
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 10:27:16 EDT (Sun, 08 Aug 2010)
@@ -15,8 +15,8 @@
// unsigned type testing.
typedef proxy_reference_type<unsigned int, 3> test_type_1;
-typedef proxy_reference_type<unsigned char, 9> test_type_2;
-typedef proxy_reference_type<unsigned long, 7> test_type_3;
+typedef proxy_reference_type<unsigned char, 7> test_type_2;
+typedef proxy_reference_type<unsigned long, 9> test_type_3;
typedef proxy_reference_type<unsigned long long, 17> test_type_4;
typedef proxy_reference_type<unsigned long long, 50> test_type_5;
@@ -171,11 +171,34 @@
*ptr = 0xFF;
--ptr;
print_type_and_value(t4);
- print_mask_details(t4);
+ print_mask_details(t4);
BOOST_TEST(t4 == 0x1FF);
// testing multi byte > 2
-
+ std::cout << "-----------------------------------------" << std::endl;
+ std::cout << "Multi byte mask > 2 bytes" << std::endl;
+ std::cout << "0 offset" << std::endl;
+ std::cout << "-----------------------------------------" << std::endl;
+ ptr = storage;
+ test_type_4 t5(ptr,0);
+ print_type_and_value(t5);
+ print_mask_details(t5);
+ std::memset(ptr,0,4);
+ *ptr = 0xFF;
+ std::cout << std::hex<< std::size_t(*ptr) << std::endl;
+ ++ptr;
+ *ptr = 0xFF;
+ std::cout << std::hex<< std::size_t(*ptr) << std::endl;
+ ++ptr;
+ *ptr = 0x80;
+ std::cout << std::hex<< std::size_t(*ptr) << std::endl;
+ ptr = storage;
+
+ // expected mask
+ // 0xFF 0xFF 0x80
+
+ BOOST_TEST(t5 == 0x1FFFF);
+
}
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