|
Boost-Commit : |
From: troy_at_[hidden]
Date: 2008-06-30 10:30:35
Author: troy
Date: 2008-06-30 10:30:33 EDT (Mon, 30 Jun 2008)
New Revision: 46912
URL: http://svn.boost.org/trac/boost/changeset/46912
Log:
merge from release branch
Added:
branches/CMake/release/libs/ptr_container/module.cmake (contents, props changed)
branches/CMake/release/libs/ptr_container/test/ptr_circular_buffer.cpp
- copied unchanged from r46902, /branches/release/libs/ptr_container/test/ptr_circular_buffer.cpp
branches/CMake/release/libs/ptr_container/test/ptr_inserter.cpp
- copied unchanged from r46902, /branches/release/libs/ptr_container/test/ptr_inserter.cpp
branches/CMake/release/libs/ptr_container/test/ptr_unordered_map.cpp
- copied unchanged from r46902, /branches/release/libs/ptr_container/test/ptr_unordered_map.cpp
branches/CMake/release/libs/ptr_container/test/ptr_unordered_set.cpp
- copied unchanged from r46902, /branches/release/libs/ptr_container/test/ptr_unordered_set.cpp
Text files modified:
branches/CMake/release/libs/ptr_container/test/CMakeLists.txt | 9 ++
branches/CMake/release/libs/ptr_container/test/Jamfile.v2 | 8 ++
branches/CMake/release/libs/ptr_container/test/associative_test_data.hpp | 55 +++++++++++++++++----
branches/CMake/release/libs/ptr_container/test/ptr_map.cpp | 31 ++++++++++++
branches/CMake/release/libs/ptr_container/test/ptr_map_adapter.cpp | 37 ++++++++++----
branches/CMake/release/libs/ptr_container/test/ptr_set.cpp | 8 +-
branches/CMake/release/libs/ptr_container/test/sequence_test_data.hpp | 28 +++++++++-
branches/CMake/release/libs/ptr_container/test/serialization.cpp | 99 +++++++++++++++++++++++++++++++++++++--
branches/CMake/release/libs/ptr_container/test/test_data.hpp | 61 ++++++++++++++++++++++--
9 files changed, 289 insertions(+), 47 deletions(-)
Added: branches/CMake/release/libs/ptr_container/module.cmake
==============================================================================
--- (empty file)
+++ branches/CMake/release/libs/ptr_container/module.cmake 2008-06-30 10:30:33 EDT (Mon, 30 Jun 2008)
@@ -0,0 +1 @@
+boost_module(pointer_containers DEPENDS serialization)
\ No newline at end of file
Modified: branches/CMake/release/libs/ptr_container/test/CMakeLists.txt
==============================================================================
--- branches/CMake/release/libs/ptr_container/test/CMakeLists.txt (original)
+++ branches/CMake/release/libs/ptr_container/test/CMakeLists.txt 2008-06-30 10:30:33 EDT (Mon, 30 Jun 2008)
@@ -1,3 +1,4 @@
+boost_test_run(ptr_inserter DEPENDS boost_unit_test_framework)
boost_test_run(ptr_vector DEPENDS boost_unit_test_framework)
boost_test_run(ptr_list DEPENDS boost_unit_test_framework)
boost_test_run(ptr_deque DEPENDS boost_unit_test_framework)
@@ -6,9 +7,13 @@
boost_test_run(ptr_array DEPENDS boost_unit_test_framework)
boost_test_run(tree_test DEPENDS boost_unit_test_framework)
boost_test_run(incomplete_type_test DEPENDS boost_unit_test_framework)
-boost_test_run(view_example DEPENDS boost_unit_test_framework)
+boost_test_run(view_example)
boost_test_run(iterator_test DEPENDS boost_unit_test_framework)
-boost_test_run(tut1 DEPENDS boost_unit_test_framework)
+boost_test_run(tut1)
boost_test_run(indirect_fun DEPENDS boost_unit_test_framework)
boost_test_run(serialization DEPENDS boost_unit_test_framework boost_serialization)
boost_test_run(no_exceptions DEPENDS boost_unit_test_framework)
+
+boost_test_run(ptr_unordered_set DEPENDS boost_unit_test_framework)
+boost_test_run(ptr_unordered_map DEPENDS boost_unit_test_framework)
+boost_test_run(ptr_circular_buffer DEPENDS boost_unit_test_framework)
Modified: branches/CMake/release/libs/ptr_container/test/Jamfile.v2
==============================================================================
--- branches/CMake/release/libs/ptr_container/test/Jamfile.v2 (original)
+++ branches/CMake/release/libs/ptr_container/test/Jamfile.v2 2008-06-30 10:30:33 EDT (Mon, 30 Jun 2008)
@@ -18,11 +18,13 @@
test-suite ptr_container :
+ [ sc-test ptr_inserter ]
[ sc-test ptr_vector ]
[ sc-test ptr_list ]
[ sc-test ptr_deque ]
[ sc-test ptr_set ]
[ sc-test ptr_map ]
+ [ sc-test ptr_map_adapter ]
[ sc-test ptr_array ]
[ sc-test tree_test ]
[ sc-test incomplete_type_test ]
@@ -32,5 +34,9 @@
[ sc-test indirect_fun ]
[ sc-test serialization : /boost/serialization//boost_serialization ]
[ sc-test no_exceptions ]
-
+
+ [ sc-test ptr_unordered_set ]
+ [ sc-test ptr_unordered_map ]
+ [ sc-test ptr_circular_buffer ]
+
;
Modified: branches/CMake/release/libs/ptr_container/test/associative_test_data.hpp
==============================================================================
--- branches/CMake/release/libs/ptr_container/test/associative_test_data.hpp (original)
+++ branches/CMake/release/libs/ptr_container/test/associative_test_data.hpp 2008-06-30 10:30:33 EDT (Mon, 30 Jun 2008)
@@ -13,10 +13,44 @@
#include <boost/ptr_container/exception.hpp>
#include <boost/range/sub_range.hpp>
-template< typename C, typename B, typename T >
+template< typename C, typename B, typename T, bool Ordered >
void ptr_set_test();
-template< typename C, typename B, typename T >
+template< class T, bool Ordered >
+struct test_algorithms
+{
+ template< class Cont >
+ void operator()( Cont& c, const Cont& c2 ) const
+ {
+ typename Cont::iterator i;
+ typename Cont::const_iterator ci;
+
+ T* t = new T;
+ i = c.lower_bound( *t );
+ ci = c2.lower_bound( *t );
+ i = c.upper_bound( *t );
+ ci = c2.upper_bound( *t );
+ delete t;
+
+ BOOST_DEDUCED_TYPENAME Cont::reverse_iterator ri = c.rbegin();
+ BOOST_DEDUCED_TYPENAME Cont::const_reverse_iterator cri = c2.rbegin();
+ BOOST_DEDUCED_TYPENAME Cont::reverse_iterator rv2 = c.rend();
+ BOOST_DEDUCED_TYPENAME Cont::const_reverse_iterator cvr2 = c2.rend();
+ cri = c.crbegin();
+ cri = c.crend();
+ }
+};
+
+template< class T >
+struct test_algorithms<T,false>
+{
+ template< class Cont>
+ void operator()( Cont& c, const Cont& c2 ) const
+ {
+ }
+};
+
+template< typename C, typename B, typename T, bool Ordered >
void ptr_set_test()
{
using namespace boost;
@@ -27,7 +61,7 @@
BOOST_CHECK( c.size() == 0 );
c.insert( c.end(), new T );
c.insert( c.end(), new T );
-
+
const C c2( c.begin(), c.end() );
BOOST_CHECK( c.size() == c2.size() );
@@ -49,12 +83,10 @@
BOOST_DEDUCED_TYPENAME C::allocator_type alloc = c.get_allocator();
BOOST_DEDUCED_TYPENAME C::iterator i = c.begin();
BOOST_DEDUCED_TYPENAME C::const_iterator ci = c2.begin();
+ ci = c.cbegin();
+ ci = c.cend();
BOOST_DEDUCED_TYPENAME C::iterator i2 = c.end();
BOOST_DEDUCED_TYPENAME C::const_iterator ci2 = c2.begin();
- BOOST_DEDUCED_TYPENAME C::reverse_iterator ri = c.rbegin();
- BOOST_DEDUCED_TYPENAME C::const_reverse_iterator cri = c2.rbegin();
- BOOST_DEDUCED_TYPENAME C::reverse_iterator rv2 = c.rend();
- BOOST_DEDUCED_TYPENAME C::const_reverse_iterator cvr2 = c2.rend();
BOOST_MESSAGE( "finished iterator test" );
@@ -111,6 +143,7 @@
BOOST_CHECK( c3.empty() == false );
c.clear();
unsigned long c3size = c3.size();
+ hide_warning( c3size );
unsigned long num = c. BOOST_NESTED_TEMPLATE transfer<C>( c3.begin(),
c3.end(),
c3 );
@@ -142,14 +175,12 @@
i = c.find( *t );
ci = c2.find( *t );
c2.count( *t );
- i = c.lower_bound( *t );
- ci = c2.lower_bound( *t );
- i = c.upper_bound( *t );
- ci = c2.upper_bound( *t );
+
+ test_algorithms<T,Ordered>()( c, c2 );
sub = c.equal_range( *t );
csub = c2.equal_range( *t );
delete t;
-
+
BOOST_MESSAGE( "finished algorithms interface test" );
}
Modified: branches/CMake/release/libs/ptr_container/test/ptr_map.cpp
==============================================================================
--- branches/CMake/release/libs/ptr_container/test/ptr_map.cpp (original)
+++ branches/CMake/release/libs/ptr_container/test/ptr_map.cpp 2008-06-30 10:30:33 EDT (Mon, 30 Jun 2008)
@@ -381,6 +381,36 @@
}
+#include <boost/tuple/tuple.hpp>
+#include <boost/iterator/zip_iterator.hpp>
+#include <map>
+#include <boost/ptr_container/ptr_map.hpp>
+
+void test_map_iterators()
+{
+ using boost::zip_iterator;
+ using boost::tuple;
+ using boost::make_tuple;
+ using boost::ptr_map;
+ using std::map;
+
+ //typedef map<int, int> theMapType;
+ /*
+ @remark: the following will not compile
+ because of the proxy (non-reference) returned by operator*()
+ of the ptr_map's iterator type.
+
+ typedef boost::ptr_map<int, int> theMapType;
+ typedef zip_iterator
+ <tuple<theMapType::iterator, theMapType::iterator> > zipIter;
+ theMapType map1;
+ theMapType map2;
+ zipIter zip(make_tuple(map1.begin(), map2.begin()));
+ */
+}
+
+
+
using boost::unit_test::test_suite;
test_suite* init_unit_test_suite( int argc, char* argv[] )
@@ -388,6 +418,7 @@
test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" );
test->add( BOOST_TEST_CASE( &test_map ) );
+ test->add( BOOST_TEST_CASE( &test_map_iterators ) );
return test;
}
Modified: branches/CMake/release/libs/ptr_container/test/ptr_map_adapter.cpp
==============================================================================
--- branches/CMake/release/libs/ptr_container/test/ptr_map_adapter.cpp (original)
+++ branches/CMake/release/libs/ptr_container/test/ptr_map_adapter.cpp 2008-06-30 10:30:33 EDT (Mon, 30 Jun 2008)
@@ -8,25 +8,26 @@
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
-
+
+#include "test_data.hpp"
#include <boost/ptr_container/ptr_map.hpp>
#include <string>
using namespace std;
-int test_main( int, char*[] )
+void test_ptr_map_adapter()
{
- typedef_test< ptr_map<int, Base>, Derived >();
- typedef_test< ptr_map<int, Value>, Value >();
+ //typedef_test< ptr_map<int, Base>, Derived >();
+ //typedef_test< ptr_map<int, Value>, Value >();
- associative_container_test< ptr_map<int, Base>, Base, Derived >();
- associative_container_test< ptr_map<int, Value>, Value, Value >();
+ //associative_container_test< ptr_map<int, Base>, Base, Derived >();
+ //associative_container_test< ptr_map<int, Value>, Value, Value >();
- typedef_test< ptr_multimap<int, Base>, Derived >();
- typedef_test< ptr_multimap<int, Value>, Value >();
+ //typedef_test< ptr_multimap<int, Base>, Derived >();
+ //typedef_test< ptr_multimap<int, Value>, Value >();
- associative_container_test< ptr_multimap<int, Base>, Base, Derived >();
- associative_container_test< ptr_multimap<int, Value>, Value, Value >();
+ //associative_container_test< ptr_multimap<int, Base>, Base, Derived >();
+ //associative_container_test< ptr_multimap<int, Value>, Value, Value >();
string joe = "joe";
string brian = "brian";
@@ -44,7 +45,19 @@
catch( const bad_ptr_container_operation& )
{ }
- return 0;
+ ptr_map<string,int> m2;
+ m2.insert( m2.begin(), *m.begin() );
+ BOOST_CHECK( m != m2 );
+ BOOST_CHECK( m2 < m );
+ m2.insert( m2.begin(), joe, new int(5) );
+ BOOST_CHECK( m != m2 );
+ BOOST_CHECK( m2 > m );
+
+ ptr_multimap<string,int> m3;
+ m3.insert( m3.begin(), *m.begin() );
+ BOOST_CHECK( m3.size() == 1u );
+ m3.insert( m3.begin(), brian, new int(11 ) );
+ BOOST_CHECK( m3.size() == 2u );
}
@@ -56,7 +69,7 @@
{
test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" );
- test->add( BOOST_TEST_CASE( &test_container_adapter ) );
+ test->add( BOOST_TEST_CASE( &test_ptr_map_adapter ) );
return test;
}
Modified: branches/CMake/release/libs/ptr_container/test/ptr_set.cpp
==============================================================================
--- branches/CMake/release/libs/ptr_container/test/ptr_set.cpp (original)
+++ branches/CMake/release/libs/ptr_container/test/ptr_set.cpp 2008-06-30 10:30:33 EDT (Mon, 30 Jun 2008)
@@ -41,11 +41,11 @@
void test_set()
{
srand( 0 );
- ptr_set_test< ptr_set<Base>, Base, Derived_class >();
- ptr_set_test< ptr_set<Value>, Value, Value >();
+ ptr_set_test< ptr_set<Base>, Base, Derived_class, true >();
+ ptr_set_test< ptr_set<Value>, Value, Value, true >();
- ptr_set_test< ptr_multiset<Base>, Base, Derived_class >();
- ptr_set_test< ptr_multiset<Value>, Value, Value >();
+ ptr_set_test< ptr_multiset<Base>, Base, Derived_class, true >();
+ ptr_set_test< ptr_multiset<Value>, Value, Value, true >();
test_copy< ptr_set<Base>, ptr_set<Derived_class>,
Derived_class>();
Modified: branches/CMake/release/libs/ptr_container/test/sequence_test_data.hpp
==============================================================================
--- branches/CMake/release/libs/ptr_container/test/sequence_test_data.hpp (original)
+++ branches/CMake/release/libs/ptr_container/test/sequence_test_data.hpp 2008-06-30 10:30:33 EDT (Mon, 30 Jun 2008)
@@ -27,20 +27,25 @@
BOOST_MESSAGE( "starting reversible container test" );
enum { max_cnt = 10, size = 100 };
C c;
+ set_capacity<C>()( c );
BOOST_CHECK( c.size() == 0 );
c.push_back( new T );
BOOST_CHECK( c.size() == 1 );
+ const C c2_dummy( c.begin(), c.end() );
+ BOOST_CHECK_EQUAL( c2_dummy.size(), c.size() );
const C c2( c.clone() );
- BOOST_CHECK( c2.size() == c.size() );
+ BOOST_CHECK_EQUAL( c2.size(), c.size() );
C c3( c.begin(), c.end() );
- BOOST_CHECK( c.size() == c3.size() );
+ set_capacity<C>()( c3 );
+ BOOST_CHECK_EQUAL( c.size(), c3.size() );
c.assign( c3.begin(), c3.end() );
- BOOST_CHECK( c.size() == c3.size() );
+ BOOST_CHECK_EQUAL( c.size(), c3.size() );
c.assign( c3 );
+ set_capacity<C>()( c );
BOOST_MESSAGE( "finished construction test" );
C a_copy( c );
@@ -50,10 +55,11 @@
a_copy.clear();
a_copy = a_copy;
BOOST_CHECK( a_copy.empty() );
+ BOOST_CHECK( !c.empty() );
BOOST_MESSAGE( "finished copying test" );
BOOST_DEDUCED_TYPENAME C::allocator_type alloc = c.get_allocator();
- hide_warning(alloc);
+ hide_warning(alloc);
BOOST_DEDUCED_TYPENAME C::iterator i = c.begin();
BOOST_DEDUCED_TYPENAME C::const_iterator ci = c2.begin();
BOOST_DEDUCED_TYPENAME C::iterator i2 = c.end();
@@ -92,10 +98,13 @@
BOOST_MESSAGE( "finished accessors test" );
c.push_back( new T );
+ BOOST_CHECK_EQUAL( c.size(), 4u );
c.pop_back();
+ BOOST_CHECK( !c.empty() );
c.insert( c.end(), new T );
c.insert( c.end(), std::auto_ptr<T>( new T ) );
+ BOOST_CHECK_EQUAL( c.size(), 5u );
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
@@ -106,6 +115,7 @@
c3.erase( c3.begin(), c3.end() );
c3.erase( boost::make_iterator_range(c3) );
BOOST_CHECK( c3.empty() );
+ BOOST_CHECK( !c.empty() );
c.swap( c3 );
BOOST_CHECK( !c3.empty() );
c3.clear();
@@ -163,12 +173,17 @@
template< class CDerived, class CBase, class T >
void test_transfer()
{
+ BOOST_MESSAGE( "starting transfer test" );
CDerived from;
CBase to;
+ set_capacity<CDerived>()( from );
+ set_capacity<CBase>()( to );
+
from.push_back( new T );
from.push_back( new T );
to. BOOST_NESTED_TEMPLATE transfer<CDerived>( to.end(), from );
+ BOOST_MESSAGE( "finished transfer test" );
}
@@ -220,7 +235,10 @@
template< class IntContainer >
void random_access_algorithms_test()
{
+ BOOST_MESSAGE( "starting random accessors algorithms test" );
+
IntContainer c;
+ set_capacity<IntContainer>()( c );
assign::push_back( c )
( new int(1) )
( new int(3) )
@@ -265,6 +283,7 @@
// C = [0,2,3,6]
IntContainer c2;
+ set_capacity<IntContainer>()( c2 );
assign::push_back( c2 )
( new int(-1) )
( new int(1) )
@@ -276,5 +295,6 @@
BOOST_CHECK( c2.empty() );
BOOST_CHECK( c.size() == 9u );
BOOST_CHECK( is_sorted< std::less_equal<int> >( c ) );
+ BOOST_MESSAGE( "finished random accessors algorithms test" );
}
Modified: branches/CMake/release/libs/ptr_container/test/serialization.cpp
==============================================================================
--- branches/CMake/release/libs/ptr_container/test/serialization.cpp (original)
+++ branches/CMake/release/libs/ptr_container/test/serialization.cpp 2008-06-30 10:30:33 EDT (Mon, 30 Jun 2008)
@@ -19,6 +19,7 @@
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
+#include <boost/functional/hash.hpp>
#include <boost/ptr_container/ptr_container.hpp>
#include <boost/ptr_container/serialize_ptr_container.hpp>
#include <boost/serialization/export.hpp>
@@ -38,6 +39,25 @@
}
//
+// used to customize tests for circular_buffer
+//
+template< class Cont >
+struct set_capacity
+{
+ void operator()( Cont& ) const
+ { }
+};
+
+template<class T>
+struct set_capacity< boost::ptr_circular_buffer<T> >
+{
+ void operator()( boost::ptr_circular_buffer<T>& c ) const
+ {
+ c.set_capacity( 100u );
+ }
+};
+
+//
// class hierarchy
//
struct Base
@@ -48,7 +68,7 @@
template< class Archive >
- void serialize( Archive& ar, const unsigned int version )
+ void serialize( Archive& ar, const unsigned int /*version*/ )
{
ar & boost::serialization::make_nvp( "i", i );
}
@@ -68,12 +88,22 @@
return l.i < r.i;
}
+inline bool operator==( const Base& l, const Base& r )
+{
+ return l.i == r.i;
+}
+
+inline std::size_t hash_value( const Base& b )
+{
+ return boost::hash_value( b.i );
+}
+
struct Derived : Base
{
int i2;
template< class Archive >
- void serialize( Archive& ar, const unsigned int version )
+ void serialize( Archive& ar, const unsigned int /*version*/ )
{
ar & boost::serialization::make_nvp( "Base",
boost::serialization::base_object<Base>( *this ) );
@@ -95,7 +125,7 @@
//
template< class C, class T >
-void add( C& c, T* r, unsigned n )
+void add( C& c, T* r, unsigned /*n*/ )
{
c.insert( c.end(), r );
}
@@ -110,8 +140,10 @@
void test_serialization_helper()
{
Cont vec;
+ set_capacity<Cont>()( vec );
add( vec, new Base( -1 ), 0u );
add( vec, new Derived( 1 ), 1u );
+ BOOST_CHECK_EQUAL( vec.size(), 2u );
std::ofstream ofs("filename");
OArchive oa(ofs);
@@ -127,15 +159,41 @@
BOOST_CHECK_EQUAL( vec.size(), vec2.size() );
BOOST_CHECK_EQUAL( (*vec2.begin()).i, -1 );
- BOOST_CHECK_EQUAL( (*--vec2.end()).i, 0 );
+ BOOST_CHECK_EQUAL( (*++vec2.begin()).i, 0 );
- typename Cont::iterator i = vec2.end();
- --i;
+ typename Cont::iterator i = vec2.begin();
+ ++i;
Derived* d = dynamic_cast<Derived*>( &*i );
BOOST_CHECK_EQUAL( d->i2, 1 );
}
+template< class Cont, class OArchive, class IArchive >
+void test_serialization_unordered_set_helper()
+{
+ Cont vec;
+ set_capacity<Cont>()( vec );
+ add( vec, new Base( -1 ), 0u );
+ add( vec, new Derived( 1 ), 1u );
+ BOOST_CHECK_EQUAL( vec.size(), 2u );
+
+ std::ofstream ofs("filename");
+ OArchive oa(ofs);
+ oa << boost::serialization::make_nvp( "container", as_const(vec) );
+ ofs.close();
+
+
+ std::ifstream ifs("filename", std::ios::binary);
+ IArchive ia(ifs);
+ Cont vec2;
+ ia >> boost::serialization::make_nvp( "container", vec2 );
+ ifs.close();
+
+ BOOST_CHECK_EQUAL( vec.size(), vec2.size() );
+ BOOST_CHECK_EQUAL( (*vec2.begin()).i, 0 );
+ BOOST_CHECK_EQUAL( (*++vec2.begin()).i, -1 );
+}
+
template< class Map, class OArchive, class IArchive >
void test_serialization_map_helper()
{
@@ -209,6 +267,12 @@
test_serialization_helper< boost::ptr_vector<Base>,
boost::archive::xml_oarchive,
boost::archive::xml_iarchive>();
+ test_serialization_helper< boost::ptr_circular_buffer<Base>,
+ boost::archive::text_oarchive,
+ boost::archive::text_iarchive>();
+ test_serialization_helper< boost::ptr_circular_buffer<Base>,
+ boost::archive::xml_oarchive,
+ boost::archive::xml_iarchive>();
test_serialization_helper< boost::ptr_array<Base,2>,
boost::archive::text_oarchive,
boost::archive::text_iarchive>();
@@ -218,7 +282,14 @@
test_serialization_helper< boost::ptr_multiset<Base>,
boost::archive::text_oarchive,
boost::archive::text_iarchive>();
-
+
+ test_serialization_unordered_set_helper< boost::ptr_unordered_set<Base>,
+ boost::archive::text_oarchive,
+ boost::archive::text_iarchive>();
+ test_serialization_unordered_set_helper<boost::ptr_unordered_multiset<Base>,
+ boost::archive::text_oarchive,
+ boost::archive::text_iarchive>();
+
test_serialization_map_helper< boost::ptr_map<std::string,Base>,
boost::archive::text_oarchive,
boost::archive::text_iarchive>();
@@ -233,6 +304,20 @@
boost::archive::xml_oarchive,
boost::archive::xml_iarchive>();
+ test_serialization_map_helper< boost::ptr_unordered_map<std::string,Base>,
+ boost::archive::text_oarchive,
+ boost::archive::text_iarchive>();
+ test_serialization_map_helper< boost::ptr_unordered_multimap<std::string,Base>,
+ boost::archive::text_oarchive,
+ boost::archive::text_iarchive>();
+
+ test_serialization_map_helper< boost::ptr_unordered_map<std::string,Base>,
+ boost::archive::xml_oarchive,
+ boost::archive::xml_iarchive>();
+ test_serialization_map_helper< boost::ptr_unordered_multimap<std::string,Base>,
+ boost::archive::xml_oarchive,
+ boost::archive::xml_iarchive>();
+
}
Modified: branches/CMake/release/libs/ptr_container/test/test_data.hpp
==============================================================================
--- branches/CMake/release/libs/ptr_container/test/test_data.hpp (original)
+++ branches/CMake/release/libs/ptr_container/test/test_data.hpp 2008-06-30 10:30:33 EDT (Mon, 30 Jun 2008)
@@ -14,6 +14,7 @@
#include <boost/config.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/functional/hash.hpp>
#include <algorithm>
#include <iostream>
#include <string>
@@ -39,6 +40,8 @@
}
Base& operator=( const Base& );
+
+public: // for test reasons only
int data1, data2, data3;
string data;
@@ -67,7 +70,7 @@
Base* clone() const { return do_clone(); }
void foo() { do_foo(); }
- virtual bool less_than( const Base& b ) const
+ virtual bool less_than( const Base& /*b*/ ) const
{
return true;
}
@@ -92,9 +95,9 @@
#endif
private:
- virtual void do_print( ostream& out ) const { };
- virtual Base* do_clone() const { return new Base( *this ); };
- virtual void do_foo() { };
+ virtual void do_print( ostream& /*out*/ ) const { };
+ virtual Base* do_clone() const { return new Base( *this ); };
+ virtual void do_foo() { };
};
#ifdef PTR_CONTAINER_DEBUG
@@ -149,9 +152,23 @@
+inline std::size_t hash_value( const Base& b )
+{
+ std::size_t seed = 0;
+ boost::hash_combine( seed, b.data );
+ boost::hash_combine( seed, b.data1 );
+ boost::hash_combine( seed, b.data2 );
+ boost::hash_combine( seed, b.data3 );
+ return seed;
+}
+
+
class Derived_class : public Base
{
+public: // for test reasons only
int i_;
+
+private:
virtual void do_print( ostream& out ) const
{
@@ -180,12 +197,22 @@
}
};
+
+
+inline std::size_t hash_value( const Derived_class& b )
+{
+ std::size_t seed = hash_value( static_cast<const Base&>( b ) );
+ boost::hash_combine( seed, b.i_ );
+ return seed;
+}
+
//////////////////////////////////////////////////////////////////////////////
// Test class 2: a value class
//////////////////////////////////////////////////////////////////////////////
class Value
{
+public: // for test reasons only
string s_;
public:
@@ -236,23 +263,42 @@
return out << v.name() << " ";
}
+
+
+inline std::size_t hash_value( const Value& v )
+{
+ return boost::hash_value( v.s_ );
+}
+
//
// used to hide "unused variable" warnings
//
template< class T >
-inline void hide_warning( T& r )
+inline void hide_warning( T& /*r*/ )
{ }
//
+// used to customize tests for circular_buffer
+//
+template< class Cont >
+struct set_capacity
+{
+ void operator()( Cont& ) const
+ { }
+};
+
+//
// transfer() test
//
template< class Cont1, class Cont2 >
void transfer_test( Cont1& from, Cont2& to )
{
+ BOOST_MESSAGE( "starting container transfer test" );
BOOST_CHECK( !from.empty() );
to. BOOST_NESTED_TEMPLATE transfer<Cont1>( from );
BOOST_CHECK( !to.empty() );
+ BOOST_MESSAGE( "finishing container transfer test" );
}
@@ -263,7 +309,10 @@
template< class BaseContainer, class DerivedContainer, class Derived >
void container_assignment_test()
{
+ BOOST_MESSAGE( "starting container assignment test" );
+
DerivedContainer derived;
+ set_capacity<DerivedContainer>()( derived );
derived.insert( derived.begin(), new Derived );
derived.insert( derived.begin(), new Derived );
@@ -277,6 +326,8 @@
base2 = base;
BOOST_CHECK_EQUAL( base2.size(), base.size() );
base = base;
+
+ BOOST_MESSAGE( "finished container assignment test" );
}
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