Permalink
Browse files

More invlet_favorites tests

  • Loading branch information...
jbytheway committed Dec 4, 2018
1 parent b3a0bec commit d990d9f1ed912e62b2e1286a150fdb90aea8e158
Showing with 24 additions and 0 deletions.
  1. +24 −0 tests/invlet_test.cpp
@@ -688,13 +688,35 @@ TEST_CASE( "Inventory letter test", "[invlet]" )
merge_invlet_test_autoletter_off( "Merging worn item into an inventory stack", dummy, WORN );
}

void verify_invlet_consistency( const invlet_favorites &fav )
{
for( const auto &p : fav.get_invlets_by_id() ) {
for( const char invlet : p.second ) {
CHECK( fav.contains( invlet, p.first ) );
}
}
}

TEST_CASE( "invlet_favourites_can_erase", "[invlet]" )
{
invlet_favorites fav;
fav.set( 'a', "a" );
verify_invlet_consistency( fav );
CHECK( fav.invlets_for( "a" ) == "a" );
fav.erase( 'a' );
verify_invlet_consistency( fav );
CHECK( fav.invlets_for( "a" ) == "" );
}

TEST_CASE( "invlet_favourites_removes_clashing_on_insertion", "[invlet]" )
{
invlet_favorites fav;
fav.set( 'a', "a" );
verify_invlet_consistency( fav );
CHECK( fav.invlets_for( "a" ) == "a" );
CHECK( fav.invlets_for( "b" ) == "" );
fav.set( 'a', "b" );
verify_invlet_consistency( fav );
CHECK( fav.invlets_for( "a" ) == "" );
CHECK( fav.invlets_for( "b" ) == "a" );
}
@@ -705,7 +727,9 @@ TEST_CASE( "invlet_favourites_retains_order_on_insertion", "[invlet]" )
fav.set( 'a', "a" );
fav.set( 'b', "a" );
fav.set( 'c', "a" );
verify_invlet_consistency( fav );
CHECK( fav.invlets_for( "a" ) == "abc" );
fav.set( 'b', "a" );
verify_invlet_consistency( fav );
CHECK( fav.invlets_for( "a" ) == "abc" );
}

0 comments on commit d990d9f

Please sign in to comment.