From f2d3ff6419c3835b315208a32a24aae6cdd8d4d3 Mon Sep 17 00:00:00 2001 From: khizmax Date: Sun, 13 Sep 2015 18:28:44 +0300 Subject: [PATCH] Excluded deprecated functions ensure() and find(key) from tree unit tests --- tests/test-hdr/tree/hdr_ellenbintree_map.h | 54 ++-- tests/test-hdr/tree/hdr_ellenbintree_set.h | 42 +-- tests/test-hdr/tree/hdr_intrusive_bintree.h | 281 ++++++++++---------- 3 files changed, 195 insertions(+), 182 deletions(-) diff --git a/tests/test-hdr/tree/hdr_ellenbintree_map.h b/tests/test-hdr/tree/hdr_ellenbintree_map.h index 42811d00..a798b375 100644 --- a/tests/test-hdr/tree/hdr_ellenbintree_map.h +++ b/tests/test-hdr/tree/hdr_ellenbintree_map.h @@ -131,7 +131,7 @@ namespace tree { item.second.nVal = item.first * 3; } - // ensure ftor + // update ftor void operator()( bool bNew, pair_type& item ) { if ( bNew ) @@ -218,48 +218,52 @@ namespace tree { template void test_with( Map& m ) { - std::pair ensureResult; + std::pair updateResult; // insert CPPUNIT_ASSERT( m.empty() ); CPPUNIT_ASSERT( check_size( m, 0 )); - CPPUNIT_ASSERT( !m.find(25) ); + CPPUNIT_ASSERT( !m.contains(25) ); CPPUNIT_ASSERT( m.insert( 25 ) ) ; // value = 0 - CPPUNIT_ASSERT( m.find(25) ); + CPPUNIT_ASSERT( m.contains(25) ); CPPUNIT_ASSERT( !m.empty() ); CPPUNIT_ASSERT( check_size( m, 1 )); - CPPUNIT_ASSERT( m.find(25) ); + CPPUNIT_ASSERT( m.contains(25) ); CPPUNIT_ASSERT( !m.insert( 25 ) ); CPPUNIT_ASSERT( !m.empty() ); CPPUNIT_ASSERT( check_size( m, 1 )); - CPPUNIT_ASSERT( !m.find_with(10, less()) ); + CPPUNIT_ASSERT( !m.contains(10, less()) ); CPPUNIT_ASSERT( m.insert( 10, 10 ) ); CPPUNIT_ASSERT( !m.empty() ); CPPUNIT_ASSERT( check_size( m, 2 )); - CPPUNIT_ASSERT( m.find_with(10, less()) ); + CPPUNIT_ASSERT( m.contains(10, less()) ); CPPUNIT_ASSERT( !m.insert( 10, 20 ) ); CPPUNIT_ASSERT( !m.empty() ); CPPUNIT_ASSERT( check_size( m, 2 )); - CPPUNIT_ASSERT( !m.find(30) ); + CPPUNIT_ASSERT( !m.contains(30) ); CPPUNIT_ASSERT( m.insert_with( 30, insert_functor() ) ) ; // value = 90 CPPUNIT_ASSERT( !m.empty() ); CPPUNIT_ASSERT( check_size( m, 3 )); - CPPUNIT_ASSERT( m.find(30) ); + CPPUNIT_ASSERT( m.contains(30) ); CPPUNIT_ASSERT( !m.insert_with( 10, insert_functor() ) ); CPPUNIT_ASSERT( !m.insert_with( 25, insert_functor() ) ); CPPUNIT_ASSERT( !m.insert_with( 30, insert_functor() ) ); - // ensure (new key) - CPPUNIT_ASSERT( !m.find(27) ); - ensureResult = m.ensure( 27, insert_functor() ) ; // value = 54 - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( ensureResult.second ); - CPPUNIT_ASSERT( m.find(27) ); + // update (new key) + CPPUNIT_ASSERT( !m.contains(27) ); + updateResult = m.update( 27, insert_functor(), false ) ; // value = 54 + CPPUNIT_ASSERT( !updateResult.first ); + CPPUNIT_ASSERT( !updateResult.second ); + CPPUNIT_ASSERT( !m.contains(27) ); + updateResult = m.update( 27, insert_functor(), false ) ; // value = 54 + CPPUNIT_ASSERT( updateResult.first ); + CPPUNIT_ASSERT( updateResult.second ); + CPPUNIT_ASSERT( m.contains(27) ); // find test check_value chk(10); @@ -271,39 +275,39 @@ namespace tree { chk.m_nExpected = 54; CPPUNIT_ASSERT( m.find( 27, std::ref( chk ) ) ); - ensureResult = m.ensure( 10, insert_functor() ) ; // value = 50 - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( !ensureResult.second ); + updateResult = m.update( 10, insert_functor() ) ; // value = 50 + CPPUNIT_ASSERT( updateResult.first ); + CPPUNIT_ASSERT( !updateResult.second ); chk.m_nExpected = 50; CPPUNIT_ASSERT( m.find( 10, std::ref( chk ) ) ); // erase test - CPPUNIT_ASSERT( !m.find(100) ); + CPPUNIT_ASSERT( !m.contains(100) ); CPPUNIT_ASSERT( !m.erase( 100 )) ; // not found - CPPUNIT_ASSERT( m.find(25) ); + CPPUNIT_ASSERT( m.contains(25) ); CPPUNIT_ASSERT( check_size( m, 4 )); CPPUNIT_ASSERT( m.erase( 25 )); CPPUNIT_ASSERT( !m.empty() ); CPPUNIT_ASSERT( check_size( m, 3 )); - CPPUNIT_ASSERT( !m.find(25) ); + CPPUNIT_ASSERT( !m.contains(25) ); CPPUNIT_ASSERT( !m.erase( 25 )); - CPPUNIT_ASSERT( !m.find(258) ); + CPPUNIT_ASSERT( !m.contains(258) ); CPPUNIT_ASSERT( m.insert(258)) CPPUNIT_ASSERT( check_size( m, 4 )); - CPPUNIT_ASSERT( m.find_with(258, less()) ); + CPPUNIT_ASSERT( m.contains(258, less()) ); CPPUNIT_ASSERT( m.erase_with( 258, less() )); CPPUNIT_ASSERT( !m.empty() ); CPPUNIT_ASSERT( check_size( m, 3 )); - CPPUNIT_ASSERT( !m.find(258) ); + CPPUNIT_ASSERT( !m.contains(258) ); CPPUNIT_ASSERT( !m.erase_with( 258, less() )); int nVal; extract_functor ext; ext.m_pVal = &nVal; - CPPUNIT_ASSERT( !m.find(29) ); + CPPUNIT_ASSERT( !m.contains(29) ); CPPUNIT_ASSERT( m.insert(29, 290)); CPPUNIT_ASSERT( check_size( m, 4 )); CPPUNIT_ASSERT( m.erase_with( 29, less(), std::ref( ext ) ) ); diff --git a/tests/test-hdr/tree/hdr_ellenbintree_set.h b/tests/test-hdr/tree/hdr_ellenbintree_set.h index 98668fc6..2edba244 100644 --- a/tests/test-hdr/tree/hdr_ellenbintree_set.h +++ b/tests/test-hdr/tree/hdr_ellenbintree_set.h @@ -252,7 +252,7 @@ namespace tree { ++i.stat.nEnsureExistFuncCall; } - struct ensure_functor + struct update_functor { template void operator()( bool bNew, value_type& i, Q& val ) @@ -281,22 +281,22 @@ namespace tree { int key; // insert/find test - CPPUNIT_ASSERT( !s.find( 10 ) ); + CPPUNIT_ASSERT( !s.contains( 10 ) ); CPPUNIT_ASSERT( s.insert( 10 )); CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 1 )); - CPPUNIT_ASSERT( s.find( 10 ) ); + CPPUNIT_ASSERT( s.contains( 10 ) ); CPPUNIT_ASSERT( !s.insert( 10 )); CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 1 )); - CPPUNIT_ASSERT( !s.find_with( 20, less() ) ); + CPPUNIT_ASSERT( !s.contains( 20, less() ) ); CPPUNIT_ASSERT( s.insert( std::make_pair(20, 25) )); CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 2 )); - CPPUNIT_ASSERT( s.find_with( 10, less() ) ); - CPPUNIT_ASSERT( s.find( key = 20 ) ); + CPPUNIT_ASSERT( s.contains( 10, less() ) ); + CPPUNIT_ASSERT( s.contains( key = 20 ) ); CPPUNIT_ASSERT( s.find_with( key, less(), find_functor() ) ); { copy_found f; @@ -333,7 +333,7 @@ namespace tree { CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 2 )); - CPPUNIT_ASSERT( !s.find( 25 ) ); + CPPUNIT_ASSERT( !s.contains( 25 ) ); CPPUNIT_ASSERT( s.insert( std::make_pair(25, -1), insert_functor() )); CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 3 )); @@ -347,7 +347,7 @@ namespace tree { CPPUNIT_ASSERT( f.m_found.stat.nInsertFuncCall == 1 ); } - // ensure test + // update test key = 10; { copy_found f; @@ -358,8 +358,8 @@ namespace tree { CPPUNIT_ASSERT( f.m_found.stat.nEnsureExistFuncCall == 0 ); CPPUNIT_ASSERT( f.m_found.stat.nEnsureNewFuncCall == 0 ); } - std::pair ensureResult = s.ensure( key, ensure_functor() ); - CPPUNIT_ASSERT( ensureResult.first && !ensureResult.second ); + std::pair updateResult = s.update( key, update_functor(), false ); + CPPUNIT_ASSERT( updateResult.first && !updateResult.second ); CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 3 )); { @@ -372,8 +372,10 @@ namespace tree { CPPUNIT_ASSERT( f.m_found.stat.nEnsureNewFuncCall == 0 ); } - ensureResult = s.ensure( std::make_pair(13, 1300), ensure_functor() ); - CPPUNIT_ASSERT( ensureResult.first && ensureResult.second ); + updateResult = s.update( std::make_pair(13, 1300), update_functor(), false ); + CPPUNIT_ASSERT( !updateResult.first && !updateResult.second ); + updateResult = s.update( std::make_pair(13, 1300), update_functor()); + CPPUNIT_ASSERT( updateResult.first && updateResult.second ); CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 4 )); { @@ -389,23 +391,23 @@ namespace tree { // erase test CPPUNIT_ASSERT( s.erase(13) ); - CPPUNIT_ASSERT( !s.find( 13 )); + CPPUNIT_ASSERT( !s.contains( 13 )); CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 3 )); CPPUNIT_ASSERT( !s.erase(13) ); CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 3 )); - CPPUNIT_ASSERT( s.find( 10 )); + CPPUNIT_ASSERT( s.contains( 10 )); CPPUNIT_ASSERT( s.erase_with( 10, less() )); - CPPUNIT_ASSERT( !s.find( 10 )); + CPPUNIT_ASSERT( !s.contains( 10 )); CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 2 )); CPPUNIT_ASSERT( !s.erase_with(10, less()) ); CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 2 )); - CPPUNIT_ASSERT( s.find(20) ); + CPPUNIT_ASSERT( s.contains(20) ); { copy_found f; f.m_found.nKey = 0; @@ -418,7 +420,7 @@ namespace tree { CPPUNIT_ASSERT( f.m_found.nKey == 235 ); CPPUNIT_ASSERT( f.m_found.nVal == 2350 ); } - CPPUNIT_ASSERT( !s.find( 20 )); + CPPUNIT_ASSERT( !s.contains( 20 )); CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 1 )); @@ -433,9 +435,9 @@ namespace tree { CPPUNIT_ASSERT( !s.empty() ); CPPUNIT_ASSERT( check_size( s, 3 )); - CPPUNIT_ASSERT( s.find(151)); - CPPUNIT_ASSERT( s.find_with(174, less())); - CPPUNIT_ASSERT( s.find(190)); + CPPUNIT_ASSERT( s.contains(151)); + CPPUNIT_ASSERT( s.contains(174, less())); + CPPUNIT_ASSERT( s.contains(190)); { copy_found f; diff --git a/tests/test-hdr/tree/hdr_intrusive_bintree.h b/tests/test-hdr/tree/hdr_intrusive_bintree.h index 6bd4b55c..61320952 100644 --- a/tests/test-hdr/tree/hdr_intrusive_bintree.h +++ b/tests/test-hdr/tree/hdr_intrusive_bintree.h @@ -204,7 +204,7 @@ namespace tree { } }; - struct ensure_functor { + struct update_functor { template void operator()( bool bNew, T& dest, T& src) const { @@ -285,73 +285,80 @@ namespace tree { value_type v4( 25, 250 ); value_type v5( -50, -500 ); - // insert/ensure + // insert/update CPPUNIT_ASSERT( t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 0 )); - CPPUNIT_CHECK( !t.find( v1.nKey )); - CPPUNIT_CHECK( !t.find( v1 )); - CPPUNIT_CHECK( !t.find( v2.nKey )); - CPPUNIT_CHECK( !t.find( v2 )); - CPPUNIT_CHECK( !t.find( v3.nKey )); - CPPUNIT_CHECK( !t.find( v3 )); - CPPUNIT_CHECK( !t.find( v4.nKey )); - CPPUNIT_CHECK( !t.find( v4 )); - CPPUNIT_CHECK( !t.find( v5.nKey )); - CPPUNIT_CHECK( !t.find( v5 )); + CPPUNIT_CHECK( !t.contains( v1.nKey )); + CPPUNIT_CHECK( !t.contains( v1 )); + CPPUNIT_CHECK( !t.contains( v2.nKey )); + CPPUNIT_CHECK( !t.contains( v2 )); + CPPUNIT_CHECK( !t.contains( v3.nKey )); + CPPUNIT_CHECK( !t.contains( v3 )); + CPPUNIT_CHECK( !t.contains( v4.nKey )); + CPPUNIT_CHECK( !t.contains( v4 )); + CPPUNIT_CHECK( !t.contains( v5.nKey )); + CPPUNIT_CHECK( !t.contains( v5 )); CPPUNIT_ASSERT( t.insert( v1 )); CPPUNIT_ASSERT( t.check_consistency() ); CPPUNIT_ASSERT( !t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 1 )); - CPPUNIT_CHECK( t.find( v1.nKey )); - CPPUNIT_CHECK( t.find( v1 )); - CPPUNIT_CHECK( !t.find( v2.nKey )); - CPPUNIT_CHECK( !t.find( v2 )); - CPPUNIT_CHECK( !t.find( v3.nKey )); - CPPUNIT_CHECK( !t.find( v3 )); - CPPUNIT_CHECK( !t.find( v4.nKey )); - CPPUNIT_CHECK( !t.find( v4 )); - CPPUNIT_CHECK( !t.find( v5.nKey )); - CPPUNIT_CHECK( !t.find( v5 )); + CPPUNIT_CHECK( t.contains( v1.nKey )); + CPPUNIT_CHECK( t.contains( v1 )); + CPPUNIT_CHECK( !t.contains( v2.nKey )); + CPPUNIT_CHECK( !t.contains( v2 )); + CPPUNIT_CHECK( !t.contains( v3.nKey )); + CPPUNIT_CHECK( !t.contains( v3 )); + CPPUNIT_CHECK( !t.contains( v4.nKey )); + CPPUNIT_CHECK( !t.contains( v4 )); + CPPUNIT_CHECK( !t.contains( v5.nKey )); + CPPUNIT_CHECK( !t.contains( v5 )); CPPUNIT_ASSERT( v2.stat.nInsertFuncCall == 0 ); CPPUNIT_ASSERT( t.insert( v2, insert_functor() )); CPPUNIT_ASSERT( t.check_consistency() ); CPPUNIT_ASSERT( v2.stat.nInsertFuncCall == 1 ); - CPPUNIT_ASSERT( t.find( v1.nKey )); - CPPUNIT_ASSERT( t.find( v1 )); - CPPUNIT_ASSERT( t.find( v2.nKey )); - CPPUNIT_ASSERT( t.find( v2 )); - CPPUNIT_ASSERT( !t.find( v3.nKey )); - CPPUNIT_ASSERT( !t.find( v3 )); - CPPUNIT_ASSERT( !t.find( v4.nKey )); - CPPUNIT_ASSERT( !t.find( v4 )); - CPPUNIT_ASSERT( !t.find( v5.nKey )); - CPPUNIT_ASSERT( !t.find( v5 )); + CPPUNIT_ASSERT( t.contains( v1.nKey )); + CPPUNIT_ASSERT( t.contains( v1 )); + CPPUNIT_ASSERT( t.contains( v2.nKey )); + CPPUNIT_ASSERT( t.contains( v2 )); + CPPUNIT_ASSERT( !t.contains( v3.nKey )); + CPPUNIT_ASSERT( !t.contains( v3 )); + CPPUNIT_ASSERT( !t.contains( v4.nKey )); + CPPUNIT_ASSERT( !t.contains( v4 )); + CPPUNIT_ASSERT( !t.contains( v5.nKey )); + CPPUNIT_ASSERT( !t.contains( v5 )); CPPUNIT_ASSERT( !t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 2 )); + std::pair updateResult; CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 0 ); CPPUNIT_ASSERT( v3.stat.nEnsureExistFuncCall == 0 ); - CPPUNIT_ASSERT( t.ensure( v3, ensure_functor() ).second ); + updateResult = t.update( v3, update_functor(), false ); + CPPUNIT_ASSERT( !updateResult.first && !updateResult.second ); + CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 0 ); + CPPUNIT_ASSERT( v3.stat.nEnsureExistFuncCall == 0 ); + updateResult = t.update( v3, update_functor(), true ); + CPPUNIT_ASSERT( updateResult.first && updateResult.second ); CPPUNIT_ASSERT( t.check_consistency() ); CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 1 ); CPPUNIT_ASSERT( v3.stat.nEnsureExistFuncCall == 0 ); CPPUNIT_ASSERT( v3.nValue == 300 ); - CPPUNIT_ASSERT( !t.ensure( v3, ensure_functor() ).second ); + updateResult = t.update( v3, update_functor(), false ); + CPPUNIT_ASSERT( updateResult.first && !updateResult.second ); CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 1 ); CPPUNIT_ASSERT( v3.stat.nEnsureExistFuncCall == 1 ); CPPUNIT_ASSERT( v3.nValue == 600 ); - CPPUNIT_ASSERT( t.find( v1.nKey )); - CPPUNIT_ASSERT( t.find( v1 )); - CPPUNIT_ASSERT( t.find( v2.nKey )); - CPPUNIT_ASSERT( t.find( v2 )); - CPPUNIT_ASSERT( t.find( v3.nKey )); - CPPUNIT_ASSERT( t.find( v3 )); - CPPUNIT_ASSERT( !t.find( v4.nKey )); - CPPUNIT_ASSERT( !t.find( v4 )); - CPPUNIT_ASSERT( !t.find( v5.nKey )); - CPPUNIT_ASSERT( !t.find( v5 )); + CPPUNIT_ASSERT( t.contains( v1.nKey )); + CPPUNIT_ASSERT( t.contains( v1 )); + CPPUNIT_ASSERT( t.contains( v2.nKey )); + CPPUNIT_ASSERT( t.contains( v2 )); + CPPUNIT_ASSERT( t.contains( v3.nKey )); + CPPUNIT_ASSERT( t.contains( v3 )); + CPPUNIT_ASSERT( !t.contains( v4.nKey )); + CPPUNIT_ASSERT( !t.contains( v4 )); + CPPUNIT_ASSERT( !t.contains( v5.nKey )); + CPPUNIT_ASSERT( !t.contains( v5 )); CPPUNIT_ASSERT( !t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 3 )); @@ -361,7 +368,7 @@ namespace tree { CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 1 ); CPPUNIT_ASSERT( v3.stat.nEnsureExistFuncCall == 1 ); CPPUNIT_ASSERT( v3.nValue == 600 ); - CPPUNIT_ASSERT( !t.ensure( v, ensure_functor() ).second ); + CPPUNIT_ASSERT( !t.update( v, update_functor() ).second ); CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 1 ); CPPUNIT_ASSERT( v.stat.nEnsureExistFuncCall == 1 ); CPPUNIT_ASSERT( v3.nValue == 1200 ); @@ -372,31 +379,31 @@ namespace tree { CPPUNIT_ASSERT( t.insert( v4 )); CPPUNIT_ASSERT( t.check_consistency() ); - CPPUNIT_ASSERT( t.find( v1.nKey )); - CPPUNIT_ASSERT( t.find( v1 )); - CPPUNIT_ASSERT( t.find( v2.nKey )); - CPPUNIT_ASSERT( t.find( v2 )); - CPPUNIT_ASSERT( t.find( v3.nKey )); - CPPUNIT_ASSERT( t.find( v3 )); - CPPUNIT_ASSERT( t.find( v4.nKey )); - CPPUNIT_ASSERT( t.find( v4 )); - CPPUNIT_ASSERT( !t.find( v5.nKey )); - CPPUNIT_ASSERT( !t.find( v5 )); + CPPUNIT_ASSERT( t.contains( v1.nKey )); + CPPUNIT_ASSERT( t.contains( v1 )); + CPPUNIT_ASSERT( t.contains( v2.nKey )); + CPPUNIT_ASSERT( t.contains( v2 )); + CPPUNIT_ASSERT( t.contains( v3.nKey )); + CPPUNIT_ASSERT( t.contains( v3 )); + CPPUNIT_ASSERT( t.contains( v4.nKey )); + CPPUNIT_ASSERT( t.contains( v4 )); + CPPUNIT_ASSERT( !t.contains( v5.nKey )); + CPPUNIT_ASSERT( !t.contains( v5 )); CPPUNIT_ASSERT( !t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 4 )); CPPUNIT_ASSERT( t.insert( v5 )); CPPUNIT_ASSERT( t.check_consistency() ); - CPPUNIT_ASSERT( t.find( v1.nKey )); - CPPUNIT_ASSERT( t.find( v1 )); - CPPUNIT_ASSERT( t.find( v2.nKey )); - CPPUNIT_ASSERT( t.find( v2 )); - CPPUNIT_ASSERT( t.find( v3.nKey )); - CPPUNIT_ASSERT( t.find( v3 )); - CPPUNIT_ASSERT( t.find( v4.nKey )); - CPPUNIT_ASSERT( t.find( v4 )); - CPPUNIT_ASSERT( t.find( v5.nKey )); - CPPUNIT_ASSERT( t.find( v5 )); + CPPUNIT_ASSERT( t.contains( v1.nKey )); + CPPUNIT_ASSERT( t.contains( v1 )); + CPPUNIT_ASSERT( t.contains( v2.nKey )); + CPPUNIT_ASSERT( t.contains( v2 )); + CPPUNIT_ASSERT( t.contains( v3.nKey )); + CPPUNIT_ASSERT( t.contains( v3 )); + CPPUNIT_ASSERT( t.contains( v4.nKey )); + CPPUNIT_ASSERT( t.contains( v4 )); + CPPUNIT_ASSERT( t.contains( v5.nKey )); + CPPUNIT_ASSERT( t.contains( v5 )); CPPUNIT_ASSERT( !t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 5 )); @@ -404,51 +411,51 @@ namespace tree { ++v1.stat.nWaitingDispCount; CPPUNIT_ASSERT( t.unlink(v1)); CPPUNIT_ASSERT( t.check_consistency() ); - CPPUNIT_ASSERT( !t.find( v1.nKey )); - CPPUNIT_ASSERT( !t.find( v1 )); + CPPUNIT_ASSERT( !t.contains( v1.nKey )); + CPPUNIT_ASSERT( !t.contains( v1 )); CPPUNIT_ASSERT( !t.unlink(v1)); - CPPUNIT_ASSERT( t.find( v2.nKey )); - CPPUNIT_ASSERT( t.find( v2 )); - CPPUNIT_ASSERT( t.find( v3.nKey )); - CPPUNIT_ASSERT( t.find( v3 )); - CPPUNIT_ASSERT( t.find( v4.nKey )); - CPPUNIT_ASSERT( t.find( v4 )); - CPPUNIT_ASSERT( t.find( v5.nKey )); - CPPUNIT_ASSERT( t.find( v5 )); + CPPUNIT_ASSERT( t.contains( v2.nKey )); + CPPUNIT_ASSERT( t.contains( v2 )); + CPPUNIT_ASSERT( t.contains( v3.nKey )); + CPPUNIT_ASSERT( t.contains( v3 )); + CPPUNIT_ASSERT( t.contains( v4.nKey )); + CPPUNIT_ASSERT( t.contains( v4 )); + CPPUNIT_ASSERT( t.contains( v5.nKey )); + CPPUNIT_ASSERT( t.contains( v5 )); CPPUNIT_ASSERT( !t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 4 )); ++v2.stat.nWaitingDispCount; CPPUNIT_ASSERT( t.erase( v2.nKey )); CPPUNIT_ASSERT( t.check_consistency() ); - CPPUNIT_ASSERT( !t.find( v1.nKey )); - CPPUNIT_ASSERT( !t.find( v1 )); - CPPUNIT_ASSERT( !t.find( v2.nKey )); - CPPUNIT_ASSERT( !t.find( v2 )); + CPPUNIT_ASSERT( !t.contains( v1.nKey )); + CPPUNIT_ASSERT( !t.contains( v1 )); + CPPUNIT_ASSERT( !t.contains( v2.nKey )); + CPPUNIT_ASSERT( !t.contains( v2 )); CPPUNIT_ASSERT( !t.erase(v2)); - CPPUNIT_ASSERT( t.find( v3.nKey )); - CPPUNIT_ASSERT( t.find( v3 )); - CPPUNIT_ASSERT( t.find( v4.nKey )); - CPPUNIT_ASSERT( t.find( v4 )); - CPPUNIT_ASSERT( t.find( v5.nKey )); - CPPUNIT_ASSERT( t.find( v5 )); + CPPUNIT_ASSERT( t.contains( v3.nKey )); + CPPUNIT_ASSERT( t.contains( v3 )); + CPPUNIT_ASSERT( t.contains( v4.nKey )); + CPPUNIT_ASSERT( t.contains( v4 )); + CPPUNIT_ASSERT( t.contains( v5.nKey )); + CPPUNIT_ASSERT( t.contains( v5 )); CPPUNIT_ASSERT( !t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 3 )); ++v3.stat.nWaitingDispCount; CPPUNIT_ASSERT( t.erase_with( v3.nKey, less() )); CPPUNIT_ASSERT( t.check_consistency() ); - CPPUNIT_ASSERT( !t.find( v1.nKey )); - CPPUNIT_ASSERT( !t.find( v1 )); - CPPUNIT_ASSERT( !t.find( v2.nKey )); - CPPUNIT_ASSERT( !t.find( v2 )); - CPPUNIT_ASSERT( !t.find( v3.nKey )); - CPPUNIT_ASSERT( !t.find( v3 )); + CPPUNIT_ASSERT( !t.contains( v1.nKey )); + CPPUNIT_ASSERT( !t.contains( v1 )); + CPPUNIT_ASSERT( !t.contains( v2.nKey )); + CPPUNIT_ASSERT( !t.contains( v2 )); + CPPUNIT_ASSERT( !t.contains( v3.nKey )); + CPPUNIT_ASSERT( !t.contains( v3 )); CPPUNIT_ASSERT( !t.erase_with(v3, less() )); - CPPUNIT_ASSERT( t.find( v4.nKey )); - CPPUNIT_ASSERT( t.find( v4 )); - CPPUNIT_ASSERT( t.find( v5.nKey )); - CPPUNIT_ASSERT( t.find( v5 )); + CPPUNIT_ASSERT( t.contains( v4.nKey )); + CPPUNIT_ASSERT( t.contains( v4 )); + CPPUNIT_ASSERT( t.contains( v5.nKey )); + CPPUNIT_ASSERT( t.contains( v5 )); CPPUNIT_ASSERT( !t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 2 )); @@ -457,18 +464,18 @@ namespace tree { CPPUNIT_ASSERT( t.erase( v4.nKey, erase_functor() )); CPPUNIT_ASSERT( t.check_consistency() ); CPPUNIT_ASSERT( v4.stat.nEraseFuncCall == 1 ); - CPPUNIT_ASSERT( !t.find( v1.nKey )); - CPPUNIT_ASSERT( !t.find( v1 )); - CPPUNIT_ASSERT( !t.find( v2.nKey )); - CPPUNIT_ASSERT( !t.find( v2 )); - CPPUNIT_ASSERT( !t.find( v3.nKey )); - CPPUNIT_ASSERT( !t.find( v3 )); - CPPUNIT_ASSERT( !t.find( v4.nKey )); - CPPUNIT_ASSERT( !t.find( v4 )); + CPPUNIT_ASSERT( !t.contains( v1.nKey )); + CPPUNIT_ASSERT( !t.contains( v1 )); + CPPUNIT_ASSERT( !t.contains( v2.nKey )); + CPPUNIT_ASSERT( !t.contains( v2 )); + CPPUNIT_ASSERT( !t.contains( v3.nKey )); + CPPUNIT_ASSERT( !t.contains( v3 )); + CPPUNIT_ASSERT( !t.contains( v4.nKey )); + CPPUNIT_ASSERT( !t.contains( v4 )); CPPUNIT_ASSERT( !t.erase( v4.nKey, erase_functor() )); CPPUNIT_ASSERT( v4.stat.nEraseFuncCall == 1 ); - CPPUNIT_ASSERT( t.find( v5.nKey )); - CPPUNIT_ASSERT( t.find( v5 )); + CPPUNIT_ASSERT( t.contains( v5.nKey )); + CPPUNIT_ASSERT( t.contains( v5 )); CPPUNIT_ASSERT( !t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 1 )); @@ -476,23 +483,23 @@ namespace tree { CPPUNIT_ASSERT( t.erase_with( v5.nKey, less(), erase_functor() )); CPPUNIT_ASSERT( t.check_consistency() ); CPPUNIT_ASSERT( v5.stat.nEraseFuncCall == 1 ); - CPPUNIT_ASSERT( !t.find( v1.nKey )); - CPPUNIT_ASSERT( !t.find( v1 )); - CPPUNIT_ASSERT( !t.find( v2.nKey )); - CPPUNIT_ASSERT( !t.find( v2 )); - CPPUNIT_ASSERT( !t.find( v3.nKey )); - CPPUNIT_ASSERT( !t.find( v3 )); + CPPUNIT_ASSERT( !t.contains( v1.nKey )); + CPPUNIT_ASSERT( !t.contains( v1 )); + CPPUNIT_ASSERT( !t.contains( v2.nKey )); + CPPUNIT_ASSERT( !t.contains( v2 )); + CPPUNIT_ASSERT( !t.contains( v3.nKey )); + CPPUNIT_ASSERT( !t.contains( v3 )); CPPUNIT_ASSERT( !t.erase_with(v5, less(), erase_functor() )); - CPPUNIT_ASSERT( !t.find( v4.nKey )); - CPPUNIT_ASSERT( !t.find( v4 )); - CPPUNIT_ASSERT( !t.find( v5.nKey )); - CPPUNIT_ASSERT( !t.find( v5 )); + CPPUNIT_ASSERT( !t.contains( v4.nKey )); + CPPUNIT_ASSERT( !t.contains( v4 )); + CPPUNIT_ASSERT( !t.contains( v5.nKey )); + CPPUNIT_ASSERT( !t.contains( v5 )); CPPUNIT_ASSERT( t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 0 )); tree_type::gc::force_dispose(); - // find + // contains CPPUNIT_ASSERT( t.insert( v1 )); CPPUNIT_ASSERT( t.insert( v2 )); CPPUNIT_ASSERT( t.insert( v3 )); @@ -502,22 +509,22 @@ namespace tree { CPPUNIT_ASSERT( !t.empty() ); CPPUNIT_ASSERT( misc::check_size( t, 5 )); - CPPUNIT_ASSERT( t.find( 10 )); - CPPUNIT_ASSERT( !t.find( 11 )); - CPPUNIT_ASSERT( t.find( v1 )); - CPPUNIT_ASSERT( t.find( v2.nKey )); - CPPUNIT_ASSERT( t.find( v3 )); - CPPUNIT_ASSERT( t.find( v4.nKey )); - CPPUNIT_ASSERT( t.find( v5.nKey )); - - // find_with - CPPUNIT_ASSERT( t.find_with( 10, less() )); - CPPUNIT_ASSERT( !t.find_with( wrapped_int(11), wrapped_less() )); - CPPUNIT_ASSERT( t.find_with( v1, less() )); - CPPUNIT_ASSERT( t.find_with( wrapped_int(v2.nKey), wrapped_less() )); - CPPUNIT_ASSERT( t.find_with( v3, less() )); - CPPUNIT_ASSERT( t.find_with( v4.nKey, less() )); - CPPUNIT_ASSERT( t.find_with( v5.nKey, less() )); + CPPUNIT_ASSERT( t.contains( 10 )); + CPPUNIT_ASSERT( !t.contains( 11 )); + CPPUNIT_ASSERT( t.contains( v1 )); + CPPUNIT_ASSERT( t.contains( v2.nKey )); + CPPUNIT_ASSERT( t.contains( v3 )); + CPPUNIT_ASSERT( t.contains( v4.nKey )); + CPPUNIT_ASSERT( t.contains( v5.nKey )); + + // contains + CPPUNIT_ASSERT( t.contains( 10, less() )); + CPPUNIT_ASSERT( !t.contains( wrapped_int(11), wrapped_less() )); + CPPUNIT_ASSERT( t.contains( v1, less() )); + CPPUNIT_ASSERT( t.contains( wrapped_int(v2.nKey), wrapped_less() )); + CPPUNIT_ASSERT( t.contains( v3, less() )); + CPPUNIT_ASSERT( t.contains( v4.nKey, less() )); + CPPUNIT_ASSERT( t.contains( v5.nKey, less() )); // find CPPUNIT_ASSERT( v1.stat.nFindFuncCall == 0 ); @@ -626,14 +633,14 @@ namespace tree { CPPUNIT_ASSERT( t.check_consistency() ); for ( int n = 0; n < (int) c_nItemCount; ++n ) { - CPPUNIT_ASSERT_MSG( t.find( n ), n ); + CPPUNIT_ASSERT_MSG( t.contains( n ), n ); } for ( value_type * p = pFirst; p != pLast; ++p ) { - CPPUNIT_ASSERT( t.find( *p )); - CPPUNIT_ASSERT( t.find( p->nKey )); + CPPUNIT_ASSERT( t.contains( *p )); + CPPUNIT_ASSERT( t.contains( p->nKey )); CPPUNIT_ASSERT( t.unlink( *p ) ); CPPUNIT_ASSERT( !t.unlink( *p ) ); - CPPUNIT_ASSERT( !t.find( p->nKey )); + CPPUNIT_ASSERT( !t.contains( p->nKey )); } tree_type::gc::force_dispose(); @@ -792,7 +799,7 @@ namespace tree { value_type * pLast = arr.end(); for ( value_type * p = pFirst; p != pLast; ++p ) { - CPPUNIT_ASSERT( t.ensure( *p, ensure_functor()).second ); + CPPUNIT_ASSERT( t.update( *p, update_functor()).second ); } for ( int n = 0; n < (int) c_nItemCount; ++n ) { typename tree_type::guarded_ptr gp( t.extract_min() ); -- 2.34.1