|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62044 - sandbox/SOC/2010/bit_masks/lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-05-16 14:16:05
Author: bbartman
Date: 2010-05-16 14:16:04 EDT (Sun, 16 May 2010)
New Revision: 62044
URL: http://svn.boost.org/trac/boost/changeset/62044
Log:
adding bitwise operator overloading test into subversion
Text files modified:
sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_operator_test.cpp | 52 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_operator_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_operator_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_operator_test.cpp 2010-05-16 14:16:04 EDT (Sun, 16 May 2010)
@@ -0,0 +1,52 @@
+// 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/details/bit_mask_function_support.hpp>
+
+// Testing for operator overloads.
+using namespace boost;
+
+template <typename T>
+void test_function() {
+
+ // making sure that the value type is transfered correctly.
+ BOOST_ASSERT((is_same< typename high_bits<T, 3>::value_type, T >::value));
+
+
+ BOOST_ASSERT(( boost::high_bits<T,1>::value == ~(~(T(0)) >> 1) ));
+ BOOST_ASSERT(( boost::high_bits<T,2>::value == ~(~(T(0)) >> 2) ));
+ BOOST_ASSERT(( boost::high_bits<T,3>::value == ~(~(T(0)) >> 3) ));
+ BOOST_ASSERT(( boost::high_bits<T,4>::value == ~(~(T(0)) >> 4) ));
+ BOOST_ASSERT(( boost::high_bits<T,5>::value == ~(~(T(0)) >> 5) ));
+ BOOST_ASSERT(( boost::high_bits<T,6>::value == ~(~(T(0)) >> 6) ));
+ BOOST_ASSERT(( boost::high_bits<T,7>::value == ~(~(T(0)) >> 7) ));
+ BOOST_ASSERT(( boost::high_bits<T,8>::value == ~(~(T(0)) >> 8) ));
+
+ // assert that type returns the correct typedef.
+ BOOST_ASSERT(( is_same<
+ typename high_bits<T, 3>::type,
+ high_bits<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