|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62096 - sandbox/SOC/2010/bit_masks/lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-05-19 09:07:53
Author: bbartman
Date: 2010-05-19 09:07:51 EDT (Wed, 19 May 2010)
New Revision: 62096
URL: http://svn.boost.org/trac/boost/changeset/62096
Log:
working on completing test suite for bit_wise operators for all masks
Text files modified:
sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_high_bits_testing.cpp | 21 ++++++++++++++++++---
sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_integral_mask_testing.cpp | 23 ++++++++++++++++++-----
sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_low_bits_testing.cpp | 2 ++
sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_operator_test.cpp | 2 ++
4 files changed, 40 insertions(+), 8 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_high_bits_testing.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_high_bits_testing.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_high_bits_testing.cpp 2010-05-19 09:07:51 EDT (Wed, 19 May 2010)
@@ -13,29 +13,44 @@
// Testing for operator overloads.
using namespace boost;
+// this test is to ensure that the overloads
+// provide the exact same functionality as their underlying operators.
+
+
template <typename T>
void test_function() {
+ T mask_value(high_bits<T, 1>::value);
// operator &(T, high_bits)
T bit_result = T(0) & high_bits<T, 1>();
+ BOOST_ASSERT(( bit_result == (T(0) & mask_value) ));
// operator &(high_bits, T)
bit_result = high_bits<T, 1>() & T(0);
+ BOOST_ASSERT(( bit_result == (mask_value & T(0)) ));
// operator |(T, high_bits)
bit_result = T(0) | high_bits<T, 1>();
+ BOOST_ASSERT(( bit_result == ( T(0) | mask_value) ));
// operator |(high_bits, T)
- bit_result = T(0) | high_bits<T,1>();
-
- // operator |(T, high_bits)
bit_result = high_bits<T,1>() | T(0);
+ BOOST_ASSERT(( bit_result == (mask_value | T(0)) ));
// operator ^(high_bits, T)
bit_result = T(0) ^ high_bits<T,1>();
+ BOOST_ASSERT(( bit_result == (T(0) ^ mask_value) ));
// operator ^(T, high_bits)
bit_result = high_bits<T,1>() ^ T(0);
+ BOOST_ASSERT(( bit_result == ( mask_value ^ T(0)) ));
+
+ // operator ~(high_bits)
+ bit_result = ~ (high_bits<T,1>());
+
+ // this is causing errors with unsigned types.
+ mask_value = ~( mask_value );
+ BOOST_ASSERT(( bit_result == mask_value ));
}
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_integral_mask_testing.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_integral_mask_testing.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_integral_mask_testing.cpp 2010-05-19 09:07:51 EDT (Wed, 19 May 2010)
@@ -13,29 +13,42 @@
// Testing for operator overloads.
using namespace boost;
+// Operators compaired against the same operatorations to assure that
+// the operators preform in the same manner.
+
template <typename T>
void test_function() {
- // operator &(T, bit_mask)
+ T mask_value( integral_mask<T,1>::value );
+
+ // operator &(T, integral_mask)
T bit_result = T(0) & integral_mask<T, 1>();
+ BOOST_ASSERT(( bit_result == (T(0) & mask_value) ));
// operator &(integral_mask, T)
bit_result = integral_mask<T, 1>() & T(0);
+ BOOST_ASSERT(( bit_result == ( mask_value & T(0)) ));
// operator |(T, integral_mask)
bit_result = T(0) | integral_mask<T, 1>();
+ BOOST_ASSERT(( bit_result == (T(0) | mask_value) ));
// operator |(integral_mask, T)
- bit_result = T(0) | integral_mask<T,1>();
-
- // operator |(T, integral_mask)
bit_result = integral_mask<T,1>() | T(0);
+ BOOST_ASSERT(( bit_result == (mask_value | T(0)) ));
// operator ^(integral_mask, T)
bit_result = T(0) ^ integral_mask<T,1>();
+ BOOST_ASSERT(( bit_result == (T(0) ^ mask_value) ));
- // operator ^(T, bit_mask)
+ // operator ^(T, integral_mask.)
bit_result = integral_mask<T,1>() ^ T(0);
+ BOOST_ASSERT(( bit_result == (mask_value ^ T(0)) ));
+
+ // operator~(integral_mask)
+ bit_result = ~ (integral_mask<T,1>());
+ mask_value = ~mask_value;
+ BOOST_ASSERT(( bit_result == mask_value ));
}
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_low_bits_testing.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_low_bits_testing.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitwise_low_bits_testing.cpp 2010-05-19 09:07:51 EDT (Wed, 19 May 2010)
@@ -36,6 +36,8 @@
// operator ^(T, low_bits)
bit_result = low_bits<T,1>() ^ T(0);
+
+ bit_result = ~ (low_bits<T,1>());
}
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-19 09:07:51 EDT (Wed, 19 May 2010)
@@ -37,6 +37,8 @@
// operator ^(T, bit_mask)
bit_result = bit_mask<T,1>() ^ T(0);
+
+ bit_result = ~ (bit_mask<T,1>());
}
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