Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64436 - in sandbox/SOC/2010/bit_masks: . lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-07-29 09:53:47


Author: bbartman
Date: 2010-07-29 09:53:43 EDT (Thu, 29 Jul 2010)
New Revision: 64436
URL: http://svn.boost.org/trac/boost/changeset/64436

Log:
working on updating my test suite for all of the bitfield_tuple tests
Text files modified:
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/align_test.cpp | 12 ++++----
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/bitfield_tuple_test.cpp | 26 ++++++++---------
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/boost_endian_integration_test.cpp | 34 +++++++++++++++++++++--
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/deduced_storage_type_long_long_test.cpp | 6 ++--
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/deduced_storage_type_test.cpp | 2
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fails_on_64_bit.cpp | 19 ++++--------
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/flag_test.cpp | 6 ++--
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_interface_test.cpp | 20 +++++++++++++
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/make_bft_testing.cpp | 3 +
   sandbox/SOC/2010/bit_masks/notes.txt | 58 +++++++++++++++------------------------
   10 files changed, 108 insertions(+), 78 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/align_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/align_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/align_test.cpp 2010-07-29 09:53:43 EDT (Thu, 29 Jul 2010)
@@ -5,7 +5,7 @@
 
 
 #include <boost/integer/bitfield_tuple.hpp>
-#include <boost/assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
 
 
 using namespace boost;
@@ -30,7 +30,7 @@
             bitfields::align<32>
> test_tuple_1;
         test_tuple_1 temp;
- BOOST_ASSERT(( test_tuple_1::bits_used::value == 32 ));
+ BOOST_TEST(( test_tuple_1::bits_used::value == 32 ));
     }
 
     // test case where alignment is 32 and bit align attempts to set it to 32
@@ -40,7 +40,7 @@
             bitfields::align<32>
> test_tuple_2;
         test_tuple_2 temp;
- BOOST_ASSERT(( test_tuple_2::bits_used::value == 0 ));
+ BOOST_TEST(( test_tuple_2::bits_used::value == 0 ));
     }
 
     // test case where user has a field that extends past the first 8 bits
@@ -52,7 +52,7 @@
             bitfields::align<8>
> test_tuple_3;
         test_tuple_3 temp;
- BOOST_ASSERT(( test_tuple_3::bits_used::value == 16));
+ BOOST_TEST(( test_tuple_3::bits_used::value == 16));
     }
 
     // test case calling align 2x times in a row doesn't do anything.
@@ -63,7 +63,7 @@
             storage<unsigned int>
> test_tuple_4;
         test_tuple_4 temp;
- BOOST_ASSERT(( test_tuple_4::bits_used::value == 0 ));
+ BOOST_TEST(( test_tuple_4::bits_used::value == 0 ));
     }
- return 0;
+ return boost::report_errors();
 }

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/bitfield_tuple_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/bitfield_tuple_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/bitfield_tuple_test.cpp 2010-07-29 09:53:43 EDT (Thu, 29 Jul 2010)
@@ -4,23 +4,21 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 
 #include <boost/integer/bitfield_tuple.hpp>
-#include "../test_type_list.hpp"
+// #include "../test_type_list.hpp"
+#include <boost/detail/lightweight_test.hpp>
 #include <boost/mpl/front.hpp>
 #include <boost/mpl/find_if.hpp>
 #include <boost/mpl/end.hpp>
 #include <boost/mpl/begin.hpp>
-
+using namespace boost;
 using namespace boost::bitfields;
-void ignore(...) {}
+
+
 
 struct red { };
 struct green { };
 struct blue { };
 
-template <typename T>
-void test_get_data(T const& x, int value) {
- BOOST_ASSERT(( x.get_data() == value ));
-}
 
 
 int main() {
@@ -30,10 +28,10 @@
         typedef bitfields::detail::bitfield_element<
             int, red, mpl::size_t<5>, mpl::size_t<4>
> bft_element_test_1;
- BOOST_ASSERT(( is_same<bft_element_test_1::return_type, int>::value ));
- BOOST_ASSERT(( is_same<bft_element_test_1::name_type, red>::value ));
- BOOST_ASSERT(( bft_element_test_1::offset::value == 5 ));
- BOOST_ASSERT(( bft_element_test_1::field_width::value == 4 ));
+ BOOST_TEST(( is_same<bft_element_test_1::return_type, int>::value ));
+ BOOST_TEST(( is_same<bft_element_test_1::name_type, red>::value ));
+ BOOST_TEST(( bft_element_test_1::offset::value == 5 ));
+ BOOST_TEST(( bft_element_test_1::field_width::value == 4 ));
 
     }
 
@@ -43,12 +41,12 @@
         // default constructor.
         typedef bitfield_tuple< storage<int>, member<int,red,3> > bft1;
         bft1 bft_test_1;
- BOOST_ASSERT(( bft_test_1.data() == 0 ));
+ BOOST_TEST(( bft_test_1.data() == 0 ));
 
         // value constructor
         bft1 bft_test_2(5);
- BOOST_ASSERT(( bft_test_2.data() == 5 ));
+ BOOST_TEST(( bft_test_2.data() == 5 ));
 
     }
- return 0;
+ return boost::report_errors();
 }

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/boost_endian_integration_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/boost_endian_integration_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/boost_endian_integration_test.cpp 2010-07-29 09:53:43 EDT (Thu, 29 Jul 2010)
@@ -3,9 +3,37 @@
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-// TODO: add actual tests here for bitfield_tuple to make sure that it can handle
-// and store types with different endianness.
+#include <boost/integer/endian.hpp>
+#include <boost/integer/endian_binary_stream.hpp>
+#include <boost/binary_stream.hpp>
+
+#include <boost/integer/bitfield_tuple.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct red;
+struct green;
+struct blue;
+
+using namespace boost;
+using namespace boost::integer;
+using namespace boost::bitfields;
+
+typedef bitfield_tuple<
+ storage< big32_t >,
+ member<unsigned char, red, 5>,
+ member<unsigned char, green, 6>,
+ member<unsigned char, blue, 5>
+> rgb565_t;
+
+
 
 int main() {
- return 0;
+ {
+ rgb565_t rgb565;
+ rgb565.get<red>() = 3;
+ BOOST_TEST(rgb565.get<red>() == 3);
+ rgb565.get<0>() = 4;
+ BOOST_TEST(rgb565.get<0>() == 4);
+ }
+ return boost::report_errors();
 }

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/deduced_storage_type_long_long_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/deduced_storage_type_long_long_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/deduced_storage_type_long_long_test.cpp 2010-07-29 09:53:43 EDT (Thu, 29 Jul 2010)
@@ -5,7 +5,7 @@
 
 
 #include <boost/integer/bitfield_tuple.hpp>
-#include <boost/assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
 
 
 using namespace boost;
@@ -24,6 +24,6 @@
 
 int main() {
 
- BOOST_ASSERT(( is_same<test_tuple::storage_type,uint_least64_t>::value ));
- return 0;
+ BOOST_TEST(( is_same<test_tuple::storage_type,uint_least64_t>::value ));
+ return boost::report_errors();
 }

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/deduced_storage_type_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/deduced_storage_type_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/deduced_storage_type_test.cpp 2010-07-29 09:53:43 EDT (Thu, 29 Jul 2010)
@@ -5,7 +5,7 @@
 
 
 #include <boost/integer/bitfield_tuple.hpp>
-#include <boost/assert.hpp>
+
 #include <boost/mpl/assert.hpp>
 
 

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fails_on_64_bit.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fails_on_64_bit.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fails_on_64_bit.cpp 2010-07-29 09:53:43 EDT (Thu, 29 Jul 2010)
@@ -1,3 +1,8 @@
+// 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 <boost/integer/endian.hpp>
 #include <boost/integer/endian_binary_stream.hpp>
 #include <boost/binary_stream.hpp>
@@ -5,18 +10,8 @@
 #include <boost/integer/bitfield_tuple.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
-// used for working with the special conversion tools for creating
-// specific endianed storage.
-#include <boost/type_traits/is_convertible.hpp>
-
-#include <boost/mpl/bitwise.hpp>
-#include <boost/mpl/arithmetic.hpp>
-#include <climits>
-
-#include <boost/assert.hpp>
-#include <iostream>
-#include <typeinfo>
-#include <cstdio>
+
+
 
 
 struct red;

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/flag_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/flag_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/flag_test.cpp 2010-07-29 09:53:43 EDT (Thu, 29 Jul 2010)
@@ -5,7 +5,7 @@
 
 
 #include <boost/integer/bitfield_tuple.hpp>
-#include <boost/assert.hpp>
+#include <boost/detail/lightweight_test.hpp>
 
 
 using namespace boost;
@@ -30,8 +30,8 @@
     test_tuple temp;
 
     temp.get<blue>() = false;
- BOOST_ASSERT(( temp.get<blue>() == false));
- return 0;
+ BOOST_TEST(( temp.get<blue>() == false));
+ return boost::report_errors();
 }
 
 

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_interface_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_interface_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_interface_test.cpp 2010-07-29 09:53:43 EDT (Thu, 29 Jul 2010)
@@ -41,6 +41,16 @@
                 test_tuple const&
>(test_1).get<salmon>() == 6
         ));
+ BOOST_TEST((
+ const_cast<
+ test_tuple const&
+ >(test_1).get<green>() == 15
+ ));
+ BOOST_TEST((
+ const_cast<
+ test_tuple const&
+ >(test_1).get<red>() == 3
+ ));
     }
 
     // get using an index.
@@ -58,6 +68,16 @@
                 test_tuple const&
>(test_2).get<2>() == 6
         ));
+ BOOST_TEST((
+ const_cast<
+ test_tuple const&
+ >(test_2).get<0>() == 3
+ ));
+ BOOST_TEST((
+ const_cast<
+ test_tuple const&
+ >(test_2).get<1>() == 14
+ ));
     }
 
     // negative value testing

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/make_bft_testing.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/make_bft_testing.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/make_bft_testing.cpp 2010-07-29 09:53:43 EDT (Thu, 29 Jul 2010)
@@ -3,7 +3,7 @@
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-
+#define BOOST_BFT_PARAM_COUNT 50
 #include <boost/integer/bitfield_tuple.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
@@ -26,6 +26,7 @@
     flag<blue>
> test_tuple;
 
+
 int main() {
     {
         test_tuple bft = make_bitfield_tuple<test_tuple>(1,2,4,true);

Modified: sandbox/SOC/2010/bit_masks/notes.txt
==============================================================================
--- sandbox/SOC/2010/bit_masks/notes.txt (original)
+++ sandbox/SOC/2010/bit_masks/notes.txt 2010-07-29 09:53:43 EDT (Thu, 29 Jul 2010)
@@ -8,6 +8,20 @@
     "Ensures the offset of the next bit field is divisible by the supplied value."
 
 -> 6) consider renaming member to field or bitfield
+7) Consider moving everything from bitfield_tuple into its own library.
+
+8) begin relocating all parts of the interface into the bitfield_tuple file.
+ Things which I know need to eventually move.
+ I ) Fusion extension .
+ A) Basically the entire ext directory.
+ II ) make_bitfield_tuple
+ A) relocate the single macro which actually generates all of the
+ functions into its own file.
+ B) Rename the file which previously held the make_bitfield_tuple into
+ make_bitfield_tuple_impl
+
+
+9) Create a VIEW version of the bitfield_tuple.
 --------------------------------------------------------------------------------
 List of TODO's throughout the bitfield_tuple
 
@@ -47,64 +61,32 @@
 7) name_accessor_test.cpp
 
 9) make_bft_testing.cpp
- b) Change to using the <boost/detail/lightweight_test.hpp> framework.
     c) This may need additional test to make sure that the macros are correctly
         generating the code for the correct number of valid parameters.
 
 10) get_interface_test.cpp
- c) Need to do more const interface testing.
-
 11) fusion_iterator_testing.cpp
- c) Not sure just how I should test the iterator. This may be good as it
- however that doesn't mean that it should just stay as is. Look into
- other fusion iterator tests.
- *) bitfield_iterator.hpp
- - Make sure that this works in const situation.
-
 12) fusion_integration_testing.cpp
- a) remove testing from name.
- b) Change to using the <boost/detail/lightweight_test.hpp> framework.
-
 13) flag_test.cpp
- a) .
- b) Change to using the <boost/detail/lightweight_test.hpp> framework.
-
 14) filler_test.cpp
- a) .
- b) Change to using the <boost/detail/lightweight_test.hpp> framework.
-
 15) deduced_storage_type_test.cpp
- a) .
- b) Change to using the <boost/detail/lightweight_test.hpp> framework.
-
 16) deduced_storage_type_long_long_test.cpp
- a) .
- b) Change to using the <boost/detail/lightweight_test.hpp> framework.
- c) Maybe merge this with the other storage type.
+
 
 17) custom_member_test.cpp
- a) .
- b) Implement before testing this.
+ b) Implement test suite.
 
 18) bitfield_tuple_test.hpp
- a) .
- b) Change to using the <boost/detail/lightweight_test.hpp> framework.
- c) remove previous dependency on test_list_type.hpp
-
 19) align_test.cpp
- a) .
- b) Change to using the <boost/detail/lightweight_test.hpp> framework.
+
 
 20) fails_on_64_bit.cpp
     a) Move the contents into boost_endian_integration_test.cpp
 
-21) Remove the ppb_testing folder and tests from the jam file.
 
                         TO BE ADDED TO TESTS SECTION
     Test which need to be created as a result of modifications or additions!
 --------------------------------------------------------------------------------
-1) !DONE! Add interface test for the interface macros. !DONE!
- 2) interface meta-function test suite.
 3) Create additional tests for count leading and trailing zero meta-functions.
 4) Create compile failure test for pointer member mask being 0.
 5) Create compile failure test for pointer member mask not being same size as
@@ -162,4 +144,10 @@
 
 
 
+ Future Testing Work
+--------------------------------------------------------------------------------
+
+* make_bitfield_tuple - Do testing similar to the variadic template parameter
+ tests, testing to make sure that this works for all cases.
+--------------------------------------------------------------------------------
     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