|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64673 - in sandbox/SOC/2010/bit_masks: boost/integer/detail/bitfield_vector lib/integer/test/bitfield_vector_testing
From: bbartmanboost_at_[hidden]
Date: 2010-08-07 19:51:39
Author: bbartman
Date: 2010-08-07 19:51:32 EDT (Sat, 07 Aug 2010)
New Revision: 64673
URL: http://svn.boost.org/trac/boost/changeset/64673
Log:
completed test suite for mask creation there may be one or two trivial things still remaining however
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/mask_creator.hpp | 34 ++++++++++++++++++++++++++
sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/mask_creator_test.cpp | 49 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 1 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/mask_creator.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/mask_creator.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/mask_creator.hpp 2010-08-07 19:51:32 EDT (Sat, 07 Aug 2010)
@@ -20,6 +20,8 @@
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/at.hpp>
+#include <boost/assert.hpp>
+#include <boost/type_traits/remove_pointer.hpp>
#include <cstddef>
namespace boost { namespace detail {
@@ -249,7 +251,7 @@
{ }
template <typename MaskInfo>
- mask_detail(MaskInfo)
+ explicit mask_detail(MaskInfo const&)
:_offset(MaskInfo::offset),
_size(MaskInfo::size),
_last_shift(MaskInfo::last_shift),
@@ -282,5 +284,35 @@
storage_t _last_byte;
};
+/** This is the function responsible for taking both the width and the offset
+ * and using them to get the correct constant out of the create_masks function
+ * then storing that information inside of a mask_detail and returning that
+ * mask detail.
+ */
+template <std::size_t Width>
+mask_detail get_mask_info(std::size_t offset) {
+ typedef typename create_masks<Width>::type masks;
+ switch(offset){
+ case 0:
+ return mask_detail(typename mpl::at_c<masks,0>::type());
+ case 1:
+ return mask_detail(typename mpl::at_c<masks,1>::type());
+ case 2:
+ return mask_detail(typename mpl::at_c<masks,2>::type());
+ case 3:
+ return mask_detail(typename mpl::at_c<masks,3>::type());
+ case 4:
+ return mask_detail(typename mpl::at_c<masks,4>::type());
+ case 5:
+ return mask_detail(typename mpl::at_c<masks,5>::type());
+ case 6:
+ return mask_detail(typename mpl::at_c<masks,6>::type());
+ case 7:
+ return mask_detail(typename mpl::at_c<masks,7>::type());
+ default:
+ BOOST_ASSERT(false);
+ }
+}
+
}} // end booss::detail
#endif
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/mask_creator_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/mask_creator_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/mask_creator_test.cpp 2010-08-07 19:51:32 EDT (Sat, 07 Aug 2010)
@@ -199,5 +199,54 @@
mpl::at< mask_vector, mpl::size_t<7> >::type,
mask_info<7,3> >::value ));
}
+
+ // testing mask_detail type.
+ // this type is used for retrieving details related to a mask from the
+ // integral constants which can't be as easily used within the
+ // bitfield_vector's proxy_reference_type.
+ {
+ // default ctor test.
+ mask_detail t1;
+ BOOST_TEST(t1._offset==0);
+ BOOST_TEST(t1._size==0);
+ BOOST_TEST(t1._last_shift==0);
+ BOOST_TEST(t1._first_byte==0);
+ BOOST_TEST(t1._last_byte==0);
+
+ // copy ctor
+ t1._offset = 3;
+ t1._size = 2;
+ t1._last_shift=1;
+ t1._first_byte=0xf0;
+ t1._last_byte=0x0f;
+
+ mask_detail t2(t1);
+ BOOST_TEST(t2._offset==3);
+ BOOST_TEST(t2._size==2);
+ BOOST_TEST(t2._last_shift==1);
+ BOOST_TEST(t2._first_byte==0xf0);
+ BOOST_TEST(t2._last_byte==0x0f);
+
+ // assignment operator.
+ mask_detail t3;
+ t3 = t2;
+ BOOST_TEST(t3._offset==3);
+ BOOST_TEST(t3._size==2);
+ BOOST_TEST(t3._last_shift==1);
+ BOOST_TEST(t3._first_byte==0xf0);
+ BOOST_TEST(t3._last_byte==0x0f);
+ using namespace boost;
+ // template ctor
+ typedef create_masks<3>::type masks;
+ typedef mpl::at_c<masks,0>::type info;
+ info inf;
+ mask_detail t4( inf );
+ BOOST_TEST(t4._offset ==0);
+ BOOST_TEST(t4._size==1);
+ BOOST_TEST(t4._last_shift==5);
+ BOOST_TEST(t4._first_byte==0xE0);
+ BOOST_TEST(t4._last_byte==0x0);
+
+ }
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