$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r62877 - in sandbox/SOC/2010/bit_masks: boost/integer lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-06-12 17:02:45
Author: bbartman
Date: 2010-06-12 17:02:45 EDT (Sat, 12 Jun 2010)
New Revision: 62877
URL: http://svn.boost.org/trac/boost/changeset/62877
Log:
Completed testing for reference type.
Text files modified: 
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp                  |     9 ++--                                    
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/ref_type_testing.cpp |    75 +++++++++++++++++++++++++++++++++------ 
   2 files changed, 67 insertions(+), 17 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp	(original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp	2010-06-12 17:02:45 EDT (Sat, 12 Jun 2010)
@@ -76,17 +76,16 @@
         typedef typename integer::bitfield<
             unsigned_storage_type,
             MaskInfo::offset::value,
-            MaskInfo::offset::value + MaskInfo::field_width::value - 1,
-            unsigned_return_type
+            MaskInfo::offset::value + MaskInfo::field_width::value - 1
         >                                                       bitfield_type;
 
-        typedef typename bitfield_type::value_type somethingl;
+        // typedef typename bitfield_type::value_type somethingl;
         /** Reference constructor.
          *  Because the bit_ref is an abstraction of a reference then it also
          *  must behave like a reference type.
          */
         bit_ref(storage_type& ref)
-            :_ref( (typename bitfield_type::storage_type&)ref )
+            :_ref( *reinterpret_cast<unsigned_storage_type*>(&ref) )
         { }
         
         /** Implicit conversion operator 
@@ -102,7 +101,7 @@
          */
         _self const& operator=(return_type const& rhs) {
             _ref.set(
-                static_cast< typename make_unsigned<return_type>::type > (rhs));
+                static_cast< typename make_unsigned<storage_type>::type > (rhs));
             return *this;
         }
         
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/ref_type_testing.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/ref_type_testing.cpp	(original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/ref_type_testing.cpp	2010-06-12 17:02:45 EDT (Sat, 12 Jun 2010)
@@ -18,26 +18,77 @@
 >       bft;
 
 
+typedef details::bitfield_element_< char,
+red,mpl::size_t<9>,mpl::size_t<8> >             element_1;
 
+typedef details::bitfield_element_< char, 
+red, mpl::size_t<0>, mpl::size_t<8> >           element_2;
 
+typedef details::bitfield_element_< char, 
+red, mpl::size_t<8>, mpl::size_t<8> >           element_3;
+
+typedef details::bitfield_element_< char, 
+red, mpl::size_t<16>, mpl::size_t<8> >          element_4;
+
+typedef details::bitfield_element_< char, 
+red, mpl::size_t<24>, mpl::size_t<8> >          element_5;
 int main() {
 
     int data_storage(0);
-    typedef details::bitfield_element_<
-        char,
-        red,
-        mpl::size_t<9>,
-        mpl::size_t<8>
-    >                                               element;
 
-    typedef bft::bit_ref<element> ref_type_1;
+    // simple test entery and retreval.
+    {
+    typedef bft::bit_ref<element_1> ref_type_1;
 
     ref_type_1 test_1( data_storage );
 
-    // char temp = test_1;
-    char value_to_assign = 'a';
-    test_1 = value_to_assign;
-    BOOST_ASSERT(( data_storage >> 9 == 'a' ));
-
+    char temp = 'a';
+    test_1 = temp;
+    BOOST_ASSERT(( test_1 == temp ));
+    }
+    
+    data_storage = 0;
+
+    // slightly more complex.
+    // multiple fields which arn't next to one another.
+    {
+        typedef bft::bit_ref<element_2> ref_type_1;
+        typedef bft::bit_ref<element_4> ref_type_2;
+
+        // constructing reference types.
+        ref_type_1 ref_1(data_storage);
+        ref_type_2 ref_2(data_storage);
+        ref_1 = 'q';
+        ref_2 = 'p';
+
+        BOOST_ASSERT(( ref_1 == 'q' ));
+        BOOST_ASSERT(( ref_2 == 'p' ));
+    }
+
+    data_storage = 0;
+
+    // case the integer storage type is completely filled with fields.
+    {
+        // create fake reference type to test..
+        typedef bft::bit_ref<element_2> ref_type_1;
+        typedef bft::bit_ref<element_3> ref_type_2;
+        typedef bft::bit_ref<element_4> ref_type_3;
+        typedef bft::bit_ref<element_5> ref_type_4;
+        //
+        ref_type_1 ref_1(data_storage);
+        ref_type_2 ref_2(data_storage);
+        ref_type_3 ref_3(data_storage);
+        ref_type_4 ref_4(data_storage);
+
+        ref_1 = 'p';
+        ref_2 = 'q';
+        ref_3 = 'r';
+        ref_4 = 's';
+
+        BOOST_ASSERT(( ref_1 == 'p' )); 
+        BOOST_ASSERT(( ref_2 == 'q' )); 
+        BOOST_ASSERT(( ref_3 == 'r' )); 
+        BOOST_ASSERT(( ref_4 == 's' )); 
+    }
     return 0;
 }