Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62037 - in sandbox/SOC/2010/bit_masks: boost/integer lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-05-16 12:37:05


Author: bbartman
Date: 2010-05-16 12:37:04 EDT (Sun, 16 May 2010)
New Revision: 62037
URL: http://svn.boost.org/trac/boost/changeset/62037

Log:
completed testing for bit_mask
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp | 9 ++++-----
   sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 | 1 +
   sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_test.cpp | 39 +++++++++++++++++++++++++++++++++++++++
   3 files changed, 44 insertions(+), 5 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bit_mask.hpp 2010-05-16 12:37:04 EDT (Sun, 16 May 2010)
@@ -11,7 +11,7 @@
 #include <boost/type_traits.hpp>
 #include <boost/static_assert.hpp>
 #include <boost/integer/bit_width.hpp>
-#include <limits>
+
 
 
 namespace boost {
@@ -40,13 +40,12 @@
 
     // precondition 2.
     BOOST_STATIC_ASSERT(( Width > 0 ));
-
- // precondition 3.
- // BOOST_STATIC_ASSERT(( is_integral<T>::value ));
-
 
     typedef bit_mask<T, Offset, Width> type;
 
+ BOOST_STATIC_CONSTANT(unsigned int, offset = Offset);
+
+ BOOST_STATIC_CONSTANT(unsigned int, width = Width);
 
     T operator()() {
         return type::value;

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 2010-05-16 12:37:04 EDT (Sun, 16 May 2010)
@@ -13,6 +13,7 @@
 
 test-suite integer
     :
+ [ run bit_mask_test.cpp ]
         [ run mask_check.cpp ]
         [ run integral_mask_test.cpp ]
         [ run high_bit_mask_test.cpp ]

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_test.cpp 2010-05-16 12:37:04 EDT (Sun, 16 May 2010)
@@ -3,6 +3,45 @@
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
+#include "test_type_list.hpp"
+#include <boost/integer/bit_mask.hpp>
+
+template <typename T>
+void test_function() {
+ // making sure that the value type is transfered correctly.
+ BOOST_ASSERT((is_same< typename bit_mask<T, 3>::value_type, T >::value));
+
+ // basic testing only using the offset.
+ BOOST_ASSERT(( boost::bit_mask<T,0>::value == 1 ));
+ BOOST_ASSERT(( boost::bit_mask<T,1>::value == 2 ));
+ BOOST_ASSERT(( boost::bit_mask<T,2>::value == 4 ));
+ BOOST_ASSERT(( boost::bit_mask<T,3>::value == 8 ));
+ BOOST_ASSERT(( boost::bit_mask<T,4>::value == 16 ));
+
+
+ // testing using offset + width.
+ BOOST_ASSERT(( boost::bit_mask<T,3,2>::value == 24 ));
+ BOOST_ASSERT(( boost::bit_mask<T,2,3>::value == 28 ));
+
+ // assert that type returns the correct typedef.
+ BOOST_ASSERT(( is_same<
+ typename bit_mask<T, 3>::type,
+ bit_mask<T, 3> >::value
+ ));
+}
+
+
+struct type_tester {
+ template< typename U >
+ void operator()(U) {
+ test_function<U>();
+ }
+};
+
+
 int main() {
+ mpl::for_each< test_types >( type_tester() );
+ mpl::for_each< test_types_2 >( type_tester() );
+ mpl::for_each< test_types_3 >( type_tester() );
     return 0;
 }


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