Skip to content

Commit

Permalink
Fix some tests that relied on previous ordering, maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
RenechCDDA committed Dec 21, 2024
1 parent ce9c687 commit 21f7f72
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 4 deletions.
6 changes: 5 additions & 1 deletion tests/char_sight_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "map.h"
#include "map_helpers.h"
#include "options_helpers.h"
#include "overmapbuffer.h"
#include "player_helpers.h"
#include "type_id.h"

Expand Down Expand Up @@ -112,7 +113,10 @@ TEST_CASE( "light_and_fine_detail_vision_mod", "[character][sight][light][vision
TEST_CASE( "npc_light_and_fine_detail_vision_mod", "[character][npc][sight][light][vision]" )
{
Character &u = get_player_character();
standard_npc n( "Mr. Testerman" );
shared_ptr_fast<npc> guy = make_shared_fast<npc>();
overmap_buffer.insert_npc( guy );
g->load_npcs();
npc &n = *guy;
n.set_body();

clear_avatar();
Expand Down
6 changes: 3 additions & 3 deletions tests/eoc_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ TEST_CASE( "EOC_transform_line", "[eoc][timed_event]" )
{
clear_avatar();
clear_map();
standard_npc npc( "Mr. Testerman" );
shared_ptr_fast<npc> guy = make_shared_fast<npc>();
overmap_buffer.insert_npc( guy );
npc &npc = *guy;
std::optional<tripoint> const dest = random_point( get_map(), []( tripoint const & p ) {
return p.xy() != get_avatar().pos().xy();
} );
Expand Down Expand Up @@ -1229,7 +1231,6 @@ TEST_CASE( "EOC_combat_event_test", "[eoc]" )
clear_map();
npc &npc_dst_ranged = spawn_npc( target_pos.xy(), "thug" );
for( loop = 0; loop < 1000; loop++ ) {
get_avatar().set_body();
arm_shooter( get_avatar(), "shotgun_s" );
get_avatar().recoil = 0;
get_avatar().fire_gun( target_pos, 1, *get_avatar().get_wielded_item() );
Expand All @@ -1249,7 +1250,6 @@ TEST_CASE( "EOC_combat_event_test", "[eoc]" )
clear_map();
monster &mon_dst_ranged = spawn_test_monster( "mon_zombie", target_pos );
for( loop = 0; loop < 1000; loop++ ) {
get_avatar().set_body();
arm_shooter( get_avatar(), "shotgun_s" );
get_avatar().recoil = 0;
get_avatar().fire_gun( mon_dst_ranged.pos_bub(), 1, *get_avatar().get_wielded_item() );
Expand Down
5 changes: 5 additions & 0 deletions tests/melee_dodge_hit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ TEST_CASE( "player_get_dodge", "[player][melee][dodge]" )

avatar &dummy = get_avatar();
clear_character( dummy );
dodge_base_with_dex_and_skill( dummy, 10, 10 );
dummy.set_dodges_left( 1 );

const float base_dodge = dummy.get_dodge_base();

Expand All @@ -241,6 +243,7 @@ TEST_CASE( "player_get_dodge_with_effects", "[player][melee][dodge][effect]" )

avatar &dummy = get_avatar();
clear_character( dummy );
dodge_base_with_dex_and_skill( dummy, 8, 4 );

// Compare all effects against base dodge ability
const float base_dodge = dummy.get_dodge_base();
Expand All @@ -263,6 +266,7 @@ TEST_CASE( "player_get_dodge_with_effects", "[player][melee][dodge][effect]" )
}

SECTION( "unstable footing: 1/4 dodge" ) {
// FIXME: Margin is flat instead of relative %.
CHECK( dodge_with_effect( dummy, "bouldering" ) == Approx( base_dodge / 4 ).margin( 0.1f ) );
}

Expand Down Expand Up @@ -298,6 +302,7 @@ TEST_CASE( "player_get_dodge_stamina_effects", "[player][melee][dodge][stamina]"
{
avatar &dummy = get_avatar();
clear_character( dummy );
dodge_base_with_dex_and_skill( dummy, 8, 0 );

SECTION( "8/8/8/8, no skills, unencumbered" ) {
const int stamina_max = dummy.get_stamina_max();
Expand Down
3 changes: 3 additions & 0 deletions tests/mongroup_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ static void test_multi_spawn( const mtype_id &old_mon, int range, int min, int m
{
const int upgrade_attempts = 100;
clear_avatar();
// make sure tested scenarios haven't messed with our start time
calendar::start_of_cataclysm = calendar::turn_zero;
calendar::start_of_game = calendar::turn_zero;

for( int i = 0; i < upgrade_attempts; i++ ) {
clear_map();
Expand Down
3 changes: 3 additions & 0 deletions tests/npc_talk_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,9 @@ TEST_CASE( "npc_arithmetic", "[npc_talk]" )
d.add_topic( "TALK_TEST_ARITHMETIC" );
gen_response_lines( d, 31 );

// make sure tested scenarios haven't messed with our start time
calendar::start_of_cataclysm = calendar::turn_zero;
calendar::start_of_game = calendar::turn_zero;
calendar::turn = calendar::turn_zero;
REQUIRE( calendar::turn == time_point( 0 ) );
// "Sets time since cataclysm to 1."
Expand Down
1 change: 1 addition & 0 deletions tests/stomach_contents_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ TEST_CASE( "all_nutrition_starve_test", "[starve][slow]" )
const bool print_tests = false;
avatar &dummy = get_avatar();
reset_time();
dummy.set_stored_kcal( dummy.get_healthy_kcal() );
clear_stomach( dummy );
eat_all_nutrients( dummy );
if( print_tests ) {
Expand Down
1 change: 1 addition & 0 deletions tests/vehicle_power_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ TEST_CASE( "Daily_solar_power", "[vehicle][power]" )

TEST_CASE( "maximum_reverse_velocity", "[vehicle][power][reverse]" )
{
clear_map();
reset_player();
build_test_map( ter_id( "t_pavement" ) );
clear_vehicles();
Expand Down
2 changes: 2 additions & 0 deletions tests/vehicle_split_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ static const vproto_id vehicle_prototype_cross_split_test( "cross_split_test" );

TEST_CASE( "vehicle_split_section", "[vehicle]" )
{
wipe_map_terrain();
clear_vehicles();
map &here = get_map();
Character &player_character = get_player_character();
for( units::angle dir = 0_degrees; dir < 360_degrees; dir += vehicles::steer_increment ) {
Expand Down

0 comments on commit 21f7f72

Please sign in to comment.