// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
auto& i = data[idx];
- EXPECT_FALSE( s.contains( i.nKey ) );
- EXPECT_FALSE( s.contains( i ) );
- EXPECT_FALSE( s.contains( other_item( i.key() ), other_less()));
+ EXPECT_FALSE( s.contains( i.nKey ));
+ EXPECT_FALSE( s.contains( i ));
+ EXPECT_FALSE( s.contains( other_item( i.key()), other_less()));
EXPECT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
EXPECT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
EXPECT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
- EXPECT_TRUE( s.find( i.nKey ) == s.end() );
- EXPECT_TRUE( s.find( i ) == s.end() );
- EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less() ) == s.end() );
+ EXPECT_TRUE( s.find( i.nKey ) == s.end());
+ EXPECT_TRUE( s.find( i ) == s.end());
+ EXPECT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end());
std::pair<bool, bool> updResult;
updResult = s.update( i, []( value_type& cur, value_type* old )
{
EXPECT_FALSE( old == nullptr );
- EXPECT_EQ( cur.key(), old->key() );
+ EXPECT_EQ( cur.key(), old->key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
break;
case 1:
- EXPECT_TRUE( s.insert( i.key() ));
- EXPECT_FALSE( s.insert( i.key() ));
+ EXPECT_TRUE( s.insert( i.key()));
+ EXPECT_FALSE( s.insert( i.key()));
updResult = s.update( i.key(), []( value_type& cur, value_type* old )
{
EXPECT_FALSE( old == nullptr );
- EXPECT_EQ( cur.key(), old->key() );
+ EXPECT_EQ( cur.key(), old->key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
updResult = s.update( i, []( value_type& v, value_type* old )
{
EXPECT_FALSE( old == nullptr );
- EXPECT_EQ( v.key(), old->key() );
+ EXPECT_EQ( v.key(), old->key());
v.nUpdateNewCount = old->nUpdateNewCount + 1;
}, false );
EXPECT_TRUE( updResult.first );
updResult = s.update( i.key(), [&i]( value_type& v, value_type* old )
{
EXPECT_TRUE( old == nullptr );
- EXPECT_EQ( i.key(), v.key() );
+ EXPECT_EQ( i.key(), v.key());
++v.nUpdateNewCount;
});
EXPECT_TRUE( updResult.first );
updResult = s.update( i.key(), []( value_type& v, value_type* old )
{
EXPECT_FALSE( old == nullptr );
- EXPECT_EQ( v.key(), old->key() );
+ EXPECT_EQ( v.key(), old->key());
v.nUpdateNewCount = old->nUpdateNewCount + 1;
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nUpdateNewCount, 2u );
}));
break;
EXPECT_TRUE( s.emplace( i.key()));
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
}));
break;
EXPECT_TRUE( str.empty());
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
EXPECT_EQ( v.strVal, std::string( "Hello!" ));
- } ) );
+ } ));
break;
case 8:
{
updResult = s.upsert( i.key(), false );
EXPECT_FALSE( updResult.first );
EXPECT_FALSE( updResult.second );
- EXPECT_TRUE( s.find( i.key() ) == s.end() );
+ EXPECT_TRUE( s.find( i.key()) == s.end());
- updResult = s.upsert( i.key() );
+ updResult = s.upsert( i.key());
EXPECT_TRUE( updResult.first );
EXPECT_TRUE( updResult.second );
- auto it = s.find( i.key() );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
+ auto it = s.find( i.key());
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
updResult = s.upsert( i.key(), false );
EXPECT_TRUE( updResult.first );
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
} ));
}
break;
updResult = s.upsert( i, false );
EXPECT_FALSE( updResult.first );
EXPECT_FALSE( updResult.second );
- EXPECT_TRUE( s.find( i ) == s.end() );
+ EXPECT_TRUE( s.find( i ) == s.end());
updResult = s.upsert( i );
EXPECT_TRUE( updResult.first );
EXPECT_TRUE( updResult.second );
auto it = s.find( i );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
updResult = s.upsert( i, false );
EXPECT_TRUE( updResult.first );
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
} ));
}
break;
ASSERT_TRUE( false );
}
- EXPECT_TRUE( s.contains( i.nKey ) );
- EXPECT_TRUE( s.contains( i ) );
- EXPECT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
- EXPECT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ) );
- EXPECT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ) );
- EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type&, other_item const& ) {} ) );
+ EXPECT_TRUE( s.contains( i.nKey ));
+ EXPECT_TRUE( s.contains( i ));
+ EXPECT_TRUE( s.contains( other_item( i.key()), other_less()) );
+ EXPECT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ));
+ EXPECT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ));
+ EXPECT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
auto it = s.find( i );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
- it = s.find_with( other_item( i.key() ), other_less() );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
+ it = s.find_with( other_item( i.key()), other_less());
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
}
- EXPECT_FALSE( s.empty() );
+ EXPECT_FALSE( s.empty());
EXPECT_CONTAINER_SIZE( s, nSetSize );
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[idx];
- EXPECT_TRUE( s.contains( i.nKey ) );
- EXPECT_TRUE( s.contains( i ) );
- EXPECT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
+ EXPECT_TRUE( s.contains( i.nKey ));
+ EXPECT_TRUE( s.contains( i ));
+ EXPECT_TRUE( s.contains( other_item( i.key()), other_less()) );
EXPECT_TRUE( s.find( i.nKey, []( value_type& v, int )
{
v.nFindCount = 1;
{
EXPECT_EQ( ++v.nFindCount, 2u );
}));
- EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& )
+ EXPECT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& )
{
EXPECT_EQ( ++v.nFindCount, 3u );
}));
auto it = s.find( i );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
- it = s.find_with( other_item( i.key() ), other_less() );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
+ it = s.find_with( other_item( i.key()), other_less());
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
int nKey = i.key() - 1;
break;
case 2:
EXPECT_TRUE( s.erase_with( other_item( i.key()), other_less()));
- EXPECT_FALSE( s.erase_with( other_item( i.key() ), other_less() ) );
+ EXPECT_FALSE( s.erase_with( other_item( i.key()), other_less()) );
break;
case 3:
EXPECT_TRUE( s.erase( i.key(), [&nKey]( value_type const& v )
break;
}
- EXPECT_FALSE( s.contains( i.nKey ) );
- EXPECT_FALSE( s.contains( i ) );
- EXPECT_FALSE( s.contains( other_item( i.key() ), other_less()));
+ EXPECT_FALSE( s.contains( i.nKey ));
+ EXPECT_FALSE( s.contains( i ));
+ EXPECT_FALSE( s.contains( other_item( i.key()), other_less()));
EXPECT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
EXPECT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
EXPECT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
- EXPECT_TRUE( s.find( i.nKey ) == s.end() );
- EXPECT_TRUE( s.find( i ) == s.end() );
- EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less() ) == s.end() );
+ EXPECT_TRUE( s.find( i.nKey ) == s.end());
+ EXPECT_TRUE( s.find( i ) == s.end());
+ EXPECT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end());
}
- EXPECT_TRUE( s.empty() );
+ EXPECT_TRUE( s.empty());
EXPECT_CONTAINER_SIZE( s, 0u );
// clear
for ( auto& i : data ) {
- EXPECT_TRUE( s.insert( i ) );
+ EXPECT_TRUE( s.insert( i ));
}
- EXPECT_FALSE( s.empty() );
+ EXPECT_FALSE( s.empty());
EXPECT_CONTAINER_SIZE( s, nSetSize );
s.clear();
- EXPECT_TRUE( s.empty() );
+ EXPECT_TRUE( s.empty());
EXPECT_CONTAINER_SIZE( s, 0u );
- EXPECT_TRUE( s.begin() == s.end() );
- EXPECT_TRUE( s.cbegin() == s.cend() );
+ EXPECT_TRUE( s.begin() == s.end());
+ EXPECT_TRUE( s.cbegin() == s.cend());
}
};