|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r52195 - in branches/release/libs/ptr_container: . test
From: nesotto_at_[hidden]
Date: 2009-04-05 15:55:25
Author: nesotto
Date: 2009-04-05 15:55:25 EDT (Sun, 05 Apr 2009)
New Revision: 52195
URL: http://svn.boost.org/trac/boost/changeset/52195
Log:
merge from trunk
Properties modified:
branches/release/libs/ptr_container/CMakeLists.txt (props changed)
branches/release/libs/ptr_container/module.cmake (props changed)
branches/release/libs/ptr_container/test/CMakeLists.txt (props changed)
Text files modified:
branches/release/libs/ptr_container/test/Jamfile.v2 | 3 ++-
branches/release/libs/ptr_container/test/associative_test_data.hpp | 5 ++++-
branches/release/libs/ptr_container/test/ptr_set.cpp | 30 ++++++++++++++++++++++++++++--
branches/release/libs/ptr_container/test/ptr_unordered_set.cpp | 29 +++++++++++++++++++++++++++++
branches/release/libs/ptr_container/test/test_data.hpp | 21 +++++++--------------
5 files changed, 70 insertions(+), 18 deletions(-)
Modified: branches/release/libs/ptr_container/test/Jamfile.v2
==============================================================================
--- branches/release/libs/ptr_container/test/Jamfile.v2 (original)
+++ branches/release/libs/ptr_container/test/Jamfile.v2 2009-04-05 15:55:25 EDT (Sun, 05 Apr 2009)
@@ -38,5 +38,6 @@
[ sc-test ptr_unordered_set ]
[ sc-test ptr_unordered_map ]
[ sc-test ptr_circular_buffer ]
-
+ # [ sc-test null_filter_iterator ]
+
;
Modified: branches/release/libs/ptr_container/test/associative_test_data.hpp
==============================================================================
--- branches/release/libs/ptr_container/test/associative_test_data.hpp (original)
+++ branches/release/libs/ptr_container/test/associative_test_data.hpp 2009-04-05 15:55:25 EDT (Sun, 05 Apr 2009)
@@ -109,12 +109,14 @@
t = new T;
c.insert( new T );
c.erase( *t );
+ delete t;
BOOST_CHECK( c3.empty() );
c.swap( c3 );
BOOST_CHECK( !c3.empty() );
BOOST_CHECK( c.empty() );
c3.clear();
+
//
// remark: we cannot pass c3 directly as it would
// extract const iterators ... and the
@@ -146,7 +148,8 @@
hide_warning( c3size );
unsigned long num = c. BOOST_NESTED_TEMPLATE transfer<C>( c3.begin(),
c3.end(),
- c3 );
+ c3 );
+
BOOST_CHECK( num > 0 );
BOOST_CHECK_EQUAL( num, c.size() );
BOOST_CHECK( c3.empty() );
Modified: branches/release/libs/ptr_container/test/ptr_set.cpp
==============================================================================
--- branches/release/libs/ptr_container/test/ptr_set.cpp (original)
+++ branches/release/libs/ptr_container/test/ptr_set.cpp 2009-04-05 15:55:25 EDT (Sun, 05 Apr 2009)
@@ -38,6 +38,31 @@
base = base;
}
+
+
+template< class PtrSet >
+void test_erase()
+{
+ PtrSet s;
+ typedef typename PtrSet::key_type T;
+
+ T t;
+ T* t2 = t.clone();
+ s.insert ( new T );
+ s.insert ( t2 );
+ s.insert ( new T );
+ BOOST_CHECK_EQUAL( s.size(), 3u );
+ BOOST_CHECK_EQUAL( t, *t2 );
+ BOOST_CHECK( ! (t < *t2) );
+ BOOST_CHECK( ! (*t2 < t) );
+ BOOST_CHECK_EQUAL( t, *t2 );
+
+ unsigned n = s.erase( t );
+ BOOST_CHECK( n > 0 );
+}
+
+
+
void test_set()
{
srand( 0 );
@@ -51,7 +76,7 @@
Derived_class>();
test_copy< ptr_multiset<Base>, ptr_multiset<Derived_class>,
Derived_class>();
-
+
test_transfer< ptr_set<Derived_class>, ptr_set<Base>, Derived_class>();
test_transfer< ptr_multiset<Derived_class>, ptr_multiset<Base>, Derived_class>();
@@ -63,7 +88,8 @@
BOOST_CHECK_THROW( (set.replace(set.begin(), 0 )), bad_ptr_container_operation );
BOOST_CHECK_THROW( (set.replace(set.begin(), std::auto_ptr<int>(0) )), bad_ptr_container_operation );
-
+ test_erase< ptr_set<Base> >();
+ test_erase< ptr_multiset<Base> >();
}
using boost::unit_test::test_suite;
Modified: branches/release/libs/ptr_container/test/ptr_unordered_set.cpp
==============================================================================
--- branches/release/libs/ptr_container/test/ptr_unordered_set.cpp (original)
+++ branches/release/libs/ptr_container/test/ptr_unordered_set.cpp 2009-04-05 15:55:25 EDT (Sun, 05 Apr 2009)
@@ -59,6 +59,32 @@
c.rehash(1000);
}
+
+
+template< class PtrSet >
+void test_erase()
+{
+ PtrSet s;
+ typedef typename PtrSet::key_type T;
+
+ T t;
+ s.insert ( new T );
+ T* t2 = t.clone();
+ s.insert ( t2 );
+ s.insert ( new T );
+ BOOST_CHECK_EQUAL( s.size(), 3u );
+ BOOST_CHECK_EQUAL( hash_value(t), hash_value(*t2) );
+ BOOST_CHECK_EQUAL( t, *t2 );
+
+ typename PtrSet::iterator i = s.find( t );
+
+ BOOST_CHECK( i != s.end() );
+ unsigned n = s.erase( t );
+ BOOST_CHECK( n > 0 );
+}
+
+
+
void test_set()
{
srand( 0 );
@@ -86,6 +112,9 @@
test_unordered_interface< ptr_unordered_set<Base>, Derived_class >();
test_unordered_interface< ptr_unordered_multiset<Base>, Derived_class >();
+
+ test_erase< ptr_unordered_set<Base> >();
+ test_erase< ptr_unordered_multiset<Base> >();
}
using boost::unit_test::test_suite;
Modified: branches/release/libs/ptr_container/test/test_data.hpp
==============================================================================
--- branches/release/libs/ptr_container/test/test_data.hpp (original)
+++ branches/release/libs/ptr_container/test/test_data.hpp 2009-04-05 15:55:25 EDT (Sun, 05 Apr 2009)
@@ -70,24 +70,17 @@
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;
+ return data3 < b.data3;
}
virtual bool equal( const Base& b ) const
{
- return this == &b ;
- }
-
- bool data_less_than( const Base& b ) const
- {
- return data1 == b.data1 && data2 == b.data2 && data3 < b.data3;
- }
-
- bool data_less_than2( const Base& b ) const
- {
- return data_less_than(b) && data < b.data;
+ return data1 == b.data1 &&
+ data2 == b.data2 &&
+ data3 == b.data3 &&
+ data == b.data;
}
#ifdef PTR_CONTAINER_DEBUG
@@ -133,7 +126,7 @@
inline bool operator>( const Base& l, const Base& r )
{
- return !l.less_than( r ) && r.less_than( l );
+ return r < l;
}
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