Skip to content

Commit

Permalink
Make tests exact, set character to exact calorie count
Browse files Browse the repository at this point in the history
This strategy makes the test repeatable
  • Loading branch information
feinorgh committed Jun 11, 2024
1 parent 5e8eb72 commit 9fcc074
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions tests/char_volume_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "map_helpers.h"
#include "mutation.h"
#include "player_helpers.h"
#include "units.h"
#include "vehicle.h"
#include "veh_type.h"

Expand Down Expand Up @@ -42,25 +43,23 @@ TEST_CASE( "character_baseline_volumes", "[volume]" )
{
clear_avatar();
Character &you = get_player_character();
you.set_stored_kcal( you.get_healthy_kcal() );
REQUIRE( you.get_mutations().empty() );
REQUIRE( you.height() == 175 );
CHECK( ( you.get_base_volume() > 55_liter && you.get_base_volume() < 80_liter ) );
REQUIRE( you.bodyweight() == 76562390_milligram );
CHECK( you.get_base_volume() == 73485_ml );

REQUIRE( your_height_with_trait( trait_SMALL2 ) == 70 );
CHECK( ( your_volume_with_trait( trait_SMALL2 ) > 20_liter &&
your_volume_with_trait( trait_SMALL2 ) < 30_liter ) );
CHECK( your_volume_with_trait( trait_SMALL2 ) == 23326_ml );

REQUIRE( your_height_with_trait( trait_SMALL ) == 122 );
CHECK( ( your_volume_with_trait( trait_SMALL ) > 40_liter &&
your_volume_with_trait( trait_SMALL ) < 50_liter ) );
CHECK( your_volume_with_trait( trait_SMALL ) == 42476_ml );

REQUIRE( your_height_with_trait( trait_LARGE ) == 227 );
CHECK( ( your_volume_with_trait( trait_LARGE ) > 100_liter &&
your_volume_with_trait( trait_LARGE ) < 120_liter ) );
CHECK( your_volume_with_trait( trait_LARGE ) == 116034_ml );

REQUIRE( your_height_with_trait( trait_HUGE ) == 280 );
CHECK( ( your_volume_with_trait( trait_HUGE ) > 150_liter &&
your_volume_with_trait( trait_HUGE ) < 200_liter ) );
CHECK( your_volume_with_trait( trait_HUGE ) == 156228_ml );
}

TEST_CASE( "character_at_volume_can_or_cannot_enter_vehicle", "[volume]" )
Expand Down Expand Up @@ -109,15 +108,15 @@ TEST_CASE( "character_at_volume_can_or_cannot_enter_vehicle", "[volume]" )
cramped = false;

// Try the cramped aisle with a rock again, but now we are tiny, so it is easy.
CHECK( your_volume_with_trait( trait_SMALL2 ) < 30_liter );
CHECK( your_volume_with_trait( trait_SMALL2 ) == 23326_ml );
you.setpos( test_pos ); // set our position again, clear_avatar() moved us
dest_loc = dest_loc + tripoint_north;
CHECK( you.can_move_to_vehicle_tile( dest_loc, cramped ) );
CHECK( !cramped );
dest_loc = you.get_location(); //reset

// Same aisle, but now we have HUGE GUTS. We will never fit.
CHECK( your_volume_with_trait( trait_HUGE ) > 150_liter );
CHECK( your_volume_with_trait( trait_HUGE ) == 156228_ml );
you.setpos( test_pos ); // set our position again, clear_avatar() moved us
dest_loc = dest_loc + tripoint_north;
CHECK( !you.can_move_to_vehicle_tile( dest_loc ) );
Expand Down

0 comments on commit 9fcc074

Please sign in to comment.