//$$CDS-header$$
#include "cppunit/cppunit_proxy.h"
-#include <cds/container/michael_list_base.h>
+#include <cds/container/details/michael_list_base.h>
namespace ordlist {
namespace cc = cds::container;
}
};
struct dummy_insert_functor {
- void operator ()( item& i )
+ void operator ()( item& /*i*/ )
{
// This functor should not be called
TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_insert_functor should not be called", __FILE__, __LINE__ );
{
i.nVal = i.nKey * 1024;
}
- static void dummy_insert_function( item& i )
+ static void dummy_insert_function( item& /*i*/ )
{
// This function should not be called
TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_insert_function should not be called", __FILE__, __LINE__ );
};
struct dummy_check_value {
- void operator()( item& i, int )
+ void operator()( item& /*i*/, int )
{
// This functor should not be called
TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_check_value should not be called", __FILE__, __LINE__ );
};
struct ensure_functor {
- void operator()( bool bNew, item& i, int n )
+ void operator()( bool /*bNew*/, item& i, int n )
{
i.nVal = i.nKey * 1024;
}
};
- static void ensure_func( bool bNew, item& i, int n )
+ static void ensure_func( bool /*bNew*/, item& i, int n )
{
i.nVal = n * 1033;
}
// passed by ref
{
insert_functor f;
- CPPUNIT_ASSERT( l.insert( item(25), boost::ref(f)) );
- CPPUNIT_ASSERT( !l.insert( item(100), boost::ref(f)) );
+ CPPUNIT_ASSERT( l.insert( item( 25 ), std::ref( f ) ) );
+ CPPUNIT_ASSERT( !l.insert( item( 100 ), std::ref( f ) ) );
}
// Test insert with function
CPPUNIT_ASSERT( l.insert( 50, insert_function ));
check_value f(1033);
i = 25;
CPPUNIT_ASSERT( l.find_with( 25, lt<value_type>() ));
- CPPUNIT_ASSERT( l.find_with( i, lt<value_type>(), boost::ref(f) ));
+ CPPUNIT_ASSERT( l.find_with( i, lt<value_type>(), std::ref( f ) ) );
}
i = 50;
CPPUNIT_ASSERT( l.find( 50 ));
CPPUNIT_ASSERT( ensureResult.first );
CPPUNIT_ASSERT( ensureResult.second );
- ensureResult = l.ensure( 200, boost::ref(f) );
+ ensureResult = l.ensure( 200, std::ref( f ) );
CPPUNIT_ASSERT( ensureResult.first );
CPPUNIT_ASSERT( ensureResult.second );
{
erase_functor ef;
CPPUNIT_ASSERT( ef.nEraseCall == 0 );
- CPPUNIT_ASSERT( l.erase_with( 160, lt<value_type>(), cds::ref(ef) ));
+ CPPUNIT_ASSERT( l.erase_with( 160, lt<value_type>(), std::ref(ef) ));
CPPUNIT_ASSERT( ef.nEraseCall == 1 );
- CPPUNIT_ASSERT( !l.erase_with( 160, lt<value_type>(), cds::ref(ef) ));
+ CPPUNIT_ASSERT( !l.erase_with( 160, lt<value_type>(), std::ref(ef) ));
CPPUNIT_ASSERT( ef.nEraseCall == 1 );
- CPPUNIT_ASSERT( l.erase( 250, cds::ref(ef) ));
+ CPPUNIT_ASSERT( l.erase( 250, std::ref(ef) ));
CPPUNIT_ASSERT( ef.nEraseCall == 2 );
- CPPUNIT_ASSERT( !l.erase( 250, cds::ref(ef) ));
+ CPPUNIT_ASSERT( !l.erase( 250, std::ref(ef) ));
CPPUNIT_ASSERT( ef.nEraseCall == 2 );
}
l.clear();
CPPUNIT_ASSERT( l.empty() );
-#ifdef CDS_EMPLACE_SUPPORT
{
int i;
l.clear();
CPPUNIT_ASSERT( l.empty() );
}
-#endif
// Iterator test
{
for ( int i = 0; i < nCount; ++i )
CPPUNIT_ASSERT( l.insert(i) );
+ {
+ typename OrdList::iterator it( l.begin() );
+ typename OrdList::const_iterator cit( l.cbegin() );
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ ++it;
+ CPPUNIT_CHECK( it != cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ ++cit;
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ }
+
int i = 0;
for ( typename OrdList::iterator it = l.begin(), itEnd = l.end(); it != itEnd; ++it, ++i ) {
it->nVal = i * 2;
for ( int i = 0; i < nLimit; ++i ) {
int nKey = arr[i];
- CPPUNIT_ASSERT( l.get(gp, nKey));
+ gp = l.get( nKey );
+ CPPUNIT_ASSERT( gp );
CPPUNIT_ASSERT( !gp.empty());
CPPUNIT_CHECK( gp->nKey == nKey );
CPPUNIT_CHECK( gp->nVal == nKey * 2 );
- gp.release();
- CPPUNIT_ASSERT( l.extract(gp, nKey));
+ gp = l.extract( nKey );
+ CPPUNIT_ASSERT( gp );
CPPUNIT_ASSERT( !gp.empty());
CPPUNIT_CHECK( gp->nKey == nKey );
CPPUNIT_CHECK( gp->nVal == nKey*2 );
- gp.release();
- CPPUNIT_CHECK( !l.get(gp, nKey));
+ gp = l.get( nKey );
+ CPPUNIT_CHECK( !gp );
CPPUNIT_CHECK( gp.empty());
- CPPUNIT_CHECK( !l.extract( gp, nKey));
+ CPPUNIT_CHECK( !l.extract( nKey));
CPPUNIT_CHECK( gp.empty());
}
CPPUNIT_ASSERT( l.empty());
- CPPUNIT_CHECK( !l.get(gp, arr[0]));
+ CPPUNIT_CHECK( !l.get(arr[0]));
CPPUNIT_CHECK( gp.empty());
- CPPUNIT_CHECK( !l.extract( gp, arr[0]));
+ CPPUNIT_CHECK( !l.extract( arr[0]));
CPPUNIT_CHECK( gp.empty());
}
int nKey = arr[i];
other_item key( nKey );
- CPPUNIT_ASSERT( l.get_with(gp, key, other_less()));
+ gp = l.get_with( key, other_less() );
+ CPPUNIT_ASSERT( gp );
CPPUNIT_ASSERT( !gp.empty());
CPPUNIT_CHECK( gp->nKey == nKey );
CPPUNIT_CHECK( gp->nVal == nKey * 2 );
- gp.release();
- CPPUNIT_ASSERT( l.extract_with(gp, key, other_less()));
+ gp = l.extract_with( key, other_less() );
+ CPPUNIT_ASSERT( gp );
CPPUNIT_ASSERT( !gp.empty());
CPPUNIT_CHECK( gp->nKey == nKey );
CPPUNIT_CHECK( gp->nVal == nKey*2 );
- gp.release();
- CPPUNIT_CHECK( !l.get_with(gp, key, other_less()));
+ gp = l.get_with( key, other_less() );
+ CPPUNIT_CHECK( !gp );
CPPUNIT_CHECK( gp.empty());
- CPPUNIT_CHECK( !l.extract_with( gp, key, other_less()));
+ CPPUNIT_CHECK( !l.extract_with( key, other_less()));
CPPUNIT_CHECK( gp.empty());
}
CPPUNIT_ASSERT( l.empty());
- CPPUNIT_CHECK( !l.get_with(gp, other_item(arr[0]), other_less()));
+ CPPUNIT_CHECK( !l.get_with(other_item(arr[0]), other_less()));
CPPUNIT_CHECK( gp.empty());
- CPPUNIT_CHECK( !l.extract_with( gp, other_item(arr[0]), other_less()));
+ CPPUNIT_CHECK( !l.extract_with( other_item(arr[0]), other_less()));
CPPUNIT_CHECK( gp.empty());
}
}
{
rcu_lock lock;
value_type * pGet = l.get( a[i] );
- CPPUNIT_ASSERT( pGet != NULL );
+ CPPUNIT_ASSERT( pGet != nullptr );
CPPUNIT_CHECK( pGet->nKey == a[i] );
CPPUNIT_CHECK( pGet->nVal == a[i] * 2 );
- CPPUNIT_ASSERT( l.extract( ep, a[i] ));
+ ep = l.extract( a[i] );
+ CPPUNIT_ASSERT( ep );
CPPUNIT_ASSERT( !ep.empty() );
CPPUNIT_CHECK( ep->nKey == a[i] );
CPPUNIT_CHECK( (*ep).nVal == a[i] * 2 );
ep.release();
{
rcu_lock lock;
- CPPUNIT_CHECK( l.get( a[i]) == NULL );
- CPPUNIT_CHECK( !l.extract( ep, a[i] ));
+ CPPUNIT_CHECK( l.get( a[i] ) == nullptr );
+ ep = l.extract( a[i] );
+ CPPUNIT_CHECK( !ep );
CPPUNIT_CHECK( ep.empty() );
}
}
{
rcu_lock lock;
- CPPUNIT_CHECK( l.get( a[0] ) == NULL );
- CPPUNIT_CHECK( !l.extract( ep, a[0] ) );
+ CPPUNIT_CHECK( l.get( a[0] ) == nullptr );
+ CPPUNIT_CHECK( !l.extract( a[0] ) );
CPPUNIT_CHECK( ep.empty() );
}
{
rcu_lock lock;
value_type * pGet = l.get_with( itm, other_less() );
- CPPUNIT_ASSERT( pGet != NULL );
+ CPPUNIT_ASSERT( pGet != nullptr );
CPPUNIT_CHECK( pGet->nKey == a[i] );
CPPUNIT_CHECK( pGet->nVal == a[i] * 2 );
- CPPUNIT_ASSERT( l.extract_with( ep, itm, other_less() ));
+ ep = l.extract_with( itm, other_less() );
+ CPPUNIT_ASSERT( ep );
CPPUNIT_ASSERT( !ep.empty() );
CPPUNIT_CHECK( ep->nKey == a[i] );
CPPUNIT_CHECK( ep->nVal == a[i] * 2 );
ep.release();
{
rcu_lock lock;
- CPPUNIT_CHECK( l.get_with( itm, other_less()) == NULL );
- CPPUNIT_CHECK( !l.extract_with( ep, itm, other_less() ));
+ CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr );
+ ep = l.extract_with( itm, other_less() );
+ CPPUNIT_CHECK( !ep );
CPPUNIT_CHECK( ep.empty() );
}
}
{
rcu_lock lock;
- CPPUNIT_CHECK( l.get_with( other_item(0), other_less() ) == NULL );
- CPPUNIT_CHECK( !l.extract_with( ep, other_item(0), other_less() ));
+ CPPUNIT_CHECK( l.get_with( other_item( 0 ), other_less() ) == nullptr );
+ CPPUNIT_CHECK( !l.extract_with( other_item(0), other_less() ));
CPPUNIT_CHECK( ep.empty() );
}
}
l.clear();
CPPUNIT_ASSERT( l.empty() );
-#ifdef CDS_EMPLACE_SUPPORT
// insert test
CPPUNIT_ASSERT( l.emplace( 501 ) != l.end() );
CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end());
CPPUNIT_ASSERT( it->nKey == 1001 );
CPPUNIT_ASSERT( it->nVal == 1001 * 2 );
+ {
+ typename OrdList::iterator it( l.begin() );
+ typename OrdList::const_iterator cit( l.cbegin() );
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ ++it;
+ CPPUNIT_CHECK( it != cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ ++cit;
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ }
+
+
l.clear();
CPPUNIT_ASSERT( l.empty() );
-#endif
}
void HP_cmp();
void HP_cmpmix();
void HP_ic();
- void PTB_cmp();
- void PTB_less();
- void PTB_cmpmix();
- void PTB_ic();
-
- void HRC_cmp();
- void HRC_less();
- void HRC_cmpmix();
- void HRC_ic();
+ void DHP_cmp();
+ void DHP_less();
+ void DHP_cmpmix();
+ void DHP_ic();
void RCU_GPI_cmp();
void RCU_GPI_less();
CPPUNIT_TEST(HP_cmpmix)
CPPUNIT_TEST(HP_ic)
- CPPUNIT_TEST(PTB_cmp)
- CPPUNIT_TEST(PTB_less)
- CPPUNIT_TEST(PTB_cmpmix)
- CPPUNIT_TEST(PTB_ic)
-
- CPPUNIT_TEST(HRC_cmp)
- CPPUNIT_TEST(HRC_less)
- CPPUNIT_TEST(HRC_cmpmix)
- CPPUNIT_TEST(HRC_ic)
+ CPPUNIT_TEST(DHP_cmp)
+ CPPUNIT_TEST(DHP_less)
+ CPPUNIT_TEST(DHP_cmpmix)
+ CPPUNIT_TEST(DHP_ic)
CPPUNIT_TEST(RCU_GPI_cmp)
CPPUNIT_TEST(RCU_GPI_less)