Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64504 - sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing
From: bbartmanboost_at_[hidden]
Date: 2010-07-31 13:37:48


Author: bbartman
Date: 2010-07-31 13:37:46 EDT (Sat, 31 Jul 2010)
New Revision: 64504
URL: http://svn.boost.org/trac/boost/changeset/64504

Log:
working on testing bitfield_vector_base which it more time consuming then I expected

Text files modified:
   sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/bitfield_vector_base_test.cpp | 125 ++++++++++++++++++++++++++++-----------
   1 files changed, 90 insertions(+), 35 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/bitfield_vector_base_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/bitfield_vector_base_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/bitfield_vector_base_test.cpp 2010-07-31 13:37:46 EDT (Sat, 31 Jul 2010)
@@ -10,39 +10,90 @@
 #include <boost/type_traits/is_convertible.hpp>
 
 using namespace boost;
-template <class T> class allocator {
+
+void* ptr_allocation_requested;
+bool allocate_called = false;
+bool allocator_copy_called = false;
+bool default_constructor_called = false;
+bool copy_other_allocator_called = false;
+std::size_t allocation_size = 0;
+void* ptr_deallocation_address = 0;
+std::size_t deallocation_size = 0;
+bool destructor_called = false;
+bool deallocate_called = false;
+
+void reset_allocator_test_variables() {
+ ptr_allocation_requested = (void*)0xdeadbeef;
+ allocator_copy_called = false;
+ default_constructor_called = false;
+ copy_other_allocator_called = false;
+ allocation_size = 0;
+ ptr_deallocation_address = (void*)0;
+ deallocation_size = 0;
+ destructor_called = false;
+ allocate_called = false;
+ deallocate_called = false;
+}
+
+template <class T>
+class allocator {
 public:
-typedef size_t size_type;
-typedef ptrdiff_t difference_type;
-typedef T* pointer;
-typedef const T* const_pointer;
-typedef T& reference;
-typedef const T& const_reference;
-typedef T value_type;
-template <class U> struct rebind { typedef allocator<U>
-other; };
-
-allocator() throw();
-allocator(const allocator&) throw();
-template <class U> allocator(const allocator<U>&) throw();
-~allocator() throw();
-
-pointer address(reference x) const;
-const_pointer address(const_reference x) const;
-
-pointer allocate(size_type, void* hint = 0);
-void deallocate(pointer p, size_type n);
-size_type max_size() const throw();
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T value_type;
+
+ template <class U>
+ struct rebind {
+ typedef allocator<U> other;
+ };
+
+ allocator() throw() {
+ default_constructor_called = true;
+ }
+
+ allocator(const allocator&) throw() {
+ allocator_copy_called = true;
+ }
+
+ template <class U>
+ allocator(const allocator<U>&) throw() {
+ copy_other_allocator_called = true;
+ }
+
+ ~allocator() throw() {
+ destructor_called = true;
+ }
+
+ pointer address(reference x) const;
+ const_pointer address(const_reference x) const;
+
+ pointer allocate(size_type n, void* = 0) {
+ allocate_called = true;
+ allocation_size = n;
+ return reinterpret_cast<pointer>(ptr_allocation_requested);
+ }
+
+ void deallocate(pointer p, size_type n) {
+ deallocation_size = n;
+ deallocate_called = true;
+ ptr_deallocation_address = reinterpret_cast<void*>(p);
+ }
+
+ size_type max_size() const throw();
 
-void construct(pointer p, const T& val);
-void destroy(pointer p);
+ void construct(pointer p, const T& val);
+ void destroy(pointer p);
 };
 
 
 
 typedef bits<short,2> T;
-typedef std::allocator<int> alloc;
-typedef std::allocator<unsigned char> rebound_alloc;
+typedef allocator<int> alloc;
+typedef allocator<unsigned char> rebound_alloc;
 typedef detail::bitfield_vector_base<
     T,
     alloc
@@ -108,23 +159,27 @@
         BOOST_TEST(default_constructed._impl._start == 0 );
         BOOST_TEST(default_constructed._impl._end == 0 );
         BOOST_TEST(default_constructed._impl._bits_in_use == 0 );
-
+ }
+ {
         // Allocator Constructor
         alloc temp_alloc;
         vector_base_type allocator_constructed(temp_alloc);
- BOOST_TEST(default_constructed._impl._start == 0 );
- BOOST_TEST(default_constructed._impl._end == 0 );
- BOOST_TEST(default_constructed._impl._bits_in_use == 0 );
-
+ BOOST_TEST(allocator_constructed._impl._start == 0 );
+ BOOST_TEST(allocator_constructed._impl._end == 0 );
+ BOOST_TEST(allocator_constructed._impl._bits_in_use == 0 );
+ }
+ {
         // N Constructor
         vector_base_type n_array_constructed(3);
- BOOST_TEST(n_array_constructed._impl._start != 0 );
- BOOST_TEST(n_array_constructed._impl._end != 0 );
+// BOOST_TEST(n_array_constructed._impl._start != 0 );
+// BOOST_TEST(n_array_constructed._impl._end != 0 );
         BOOST_TEST(n_array_constructed._impl._bits_in_use == 0 );
-
+ }
+ {
+ alloc temp_alloc;
         // N + Allocator Constructor
         vector_base_type n_plus_allocator_array_constructed(3, temp_alloc);
- BOOST_TEST(n_plus_allocator_array_constructed._impl._start != 0 );
+// BOOST_TEST(n_plus_allocator_array_constructed._impl._start != 0 );
         BOOST_TEST(n_plus_allocator_array_constructed._impl._end != 0 );
         BOOST_TEST(n_plus_allocator_array_constructed._impl._bits_in_use == 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