Skip to content

Commit

Permalink
Avoid printfs in starve_test
Browse files Browse the repository at this point in the history
We can do the same job more neatly with Catch2 features.
  • Loading branch information
jbytheway committed Apr 12, 2020
1 parent 03b7ba9 commit 333959c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions tests/stomach_contents_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,22 @@ static void eat_all_nutrients( player &p )
// player does not thirst or tire or require vitamins
TEST_CASE( "starve_test", "[starve][slow]" )
{
// change this bool when editing the test
const bool print_tests = false;
player &dummy = g->u;
reset_time();
clear_stomach( dummy );
if( print_tests ) {
printf( "\n\n" );
}
constexpr int expected_day = 30;
int day = 0;
std::vector<std::string> results;

do {
if( print_tests ) {
printf( "day %d: %d\n", day, dummy.get_stored_kcal() );
}
results.push_back( string_format( "\nday %d: %d", day, dummy.get_stored_kcal() ) );
pass_time( dummy, 1_days );
dummy.set_thirst( 0 );
dummy.set_fatigue( 0 );
set_all_vitamins( 0, dummy );
day++;
} while( dummy.get_stored_kcal() > 0 && day < expected_day * 2 );
if( print_tests ) {
printf( "\n\n" );
}
CAPTURE( results );
CHECK( day == expected_day );
}

Expand Down

0 comments on commit 333959c

Please sign in to comment.