Boost logo

Boost-Commit :

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


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

Log:
completed testing for integral_mask
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/high_low_bits.hpp | 5 ++-
   sandbox/SOC/2010/bit_masks/boost/integer/integral_mask.hpp | 16 +++-------
   sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 | 1
   sandbox/SOC/2010/bit_masks/lib/integer/test/integral_mask_test.cpp | 56 ++++++++++++++++++++++++++++++++++++++++
   4 files changed, 65 insertions(+), 13 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/high_low_bits.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/high_low_bits.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/high_low_bits.hpp 2010-05-16 12:23:32 EDT (Sun, 16 May 2010)
@@ -10,6 +10,7 @@
 
 #include <boost/type_traits.hpp>
 #include <boost/integer/details/high_low_impl.hpp>
+#include <boost/integer/integral_mask.hpp>
 
 namespace boost {
 
@@ -20,7 +21,7 @@
 template <typename T, unsigned int Width>
 struct low_bits
     :details::low_bits_preconditions<T,Width>,
- integral_constant<T, ~(~T(0) << Width) >
+ integral_mask<T, ~(~T(0) << Width) >
 {
     typedef low_bits<T,Width> type;
 };
@@ -31,7 +32,7 @@
 template <typename T, unsigned int Width>
 struct high_bits
     :details::high_bits_preconditions<T,Width>,
- integral_constant<T, ~(~T(0) >> Width) >
+ integral_mask<T, ~(~T(0) >> Width) >
 {
     typedef high_bits<T,Width> type;
 };

Modified: sandbox/SOC/2010/bit_masks/boost/integer/integral_mask.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/integral_mask.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/integral_mask.hpp 2010-05-16 12:23:32 EDT (Sun, 16 May 2010)
@@ -22,22 +22,16 @@
  * The following preconditions apply to the integral_mask type.
  * Preconditions
  *
- * 1. T must be an integral type. NOTE: This is documented, but NOT enforeced.
- *
+ * 1. T must be an integral type.
+ * NOTE: This is documented, but NOT enforeced.
+ *
  * 2. Value must be in the domain of the integral type T.
+ * NOTE: Documented Requirement but Not enforeced.
  */
 template <typename T, T Value>
 struct integral_mask
- : // details::integral_mask_preconditions<T,Value>,
- integral_constant<T, Value>
+ : integral_constant<T, Value>
 {
- // precondition 1.
- // BOOST_STATIC_ASSERT(( is_integral<T>::value ));
-
- // precondition 2.
- BOOST_STATIC_ASSERT((std::numeric_limits<T>::max >= Value ));
- BOOST_STATIC_ASSERT((std::numeric_limits<T>::min <= Value ));
-
     typedef integral_mask<T,Value> type;
 
     T operator()() {

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:23:32 EDT (Sun, 16 May 2010)
@@ -14,6 +14,7 @@
 test-suite integer
     :
         [ run mask_check.cpp ]
+ [ run integral_mask_test.cpp ]
         [ run high_bit_mask_test.cpp ]
         [ run low_bit_mask_test.cpp ]
         [ run bit_width_test.cpp ]

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/integral_mask_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/integral_mask_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/integral_mask_test.cpp 2010-05-16 12:23:32 EDT (Sun, 16 May 2010)
@@ -0,0 +1,56 @@
+// Copyright 2010 Brian Bartman.
+// Distributed under the Boost Software License, Version 1.0.
+// (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/high_low_bits.hpp>
+
+// =============================================================================
+// Testing for integral_mask type.
+// =============================================================================
+
+using namespace boost;
+
+template <typename T>
+void test_function() {
+
+ // making sure that the value type is transfered correctly.
+ BOOST_ASSERT((is_same< typename integral_mask<T, 3>::value_type, T >::value));
+
+
+ BOOST_ASSERT(( boost::integral_mask<T,1>::value == 1 ));
+ BOOST_ASSERT(( boost::integral_mask<T,2>::value == 2 ));
+ BOOST_ASSERT(( boost::integral_mask<T,3>::value == 3 ));
+ BOOST_ASSERT(( boost::integral_mask<T,4>::value == 4 ));
+ BOOST_ASSERT(( boost::integral_mask<T,5>::value == 5 ));
+ BOOST_ASSERT(( boost::integral_mask<T,6>::value == 6 ));
+ BOOST_ASSERT(( boost::integral_mask<T,7>::value == 7 ));
+ BOOST_ASSERT(( boost::integral_mask<T,8>::value == 8 ));
+
+ // assert that type returns the correct typedef.
+ BOOST_ASSERT(( is_same<
+ typename integral_mask<T, 3>::type,
+ integral_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