From f77950a542dfd19f87265fa8ef6e53dd71fc9c84 Mon Sep 17 00:00:00 2001 From: Qrox Date: Thu, 1 Feb 2024 16:42:31 +0800 Subject: [PATCH] Fix suffering tests by normalizing the initialization calls Also add some generated CMake files to .gitignore --- .gitignore | 1 + tests/char_suffer_test.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index e1f2c715bc6ae..535f275c4b033 100644 --- a/.gitignore +++ b/.gitignore @@ -76,6 +76,7 @@ Directory.Build.targets /msvc-full-features/**/ # Temporary CMakeFiles +CMakeFiles/git-data CMakeUserPresets.json out/ diff --git a/tests/char_suffer_test.cpp b/tests/char_suffer_test.cpp index e7fbc75b10bd1..ad9a4183c9d26 100644 --- a/tests/char_suffer_test.cpp +++ b/tests/char_suffer_test.cpp @@ -15,6 +15,7 @@ #include "item.h" #include "map.h" #include "map_helpers.h" +#include "options_helpers.h" #include "player_helpers.h" #include "test_statistics.h" #include "type_id.h" @@ -101,9 +102,10 @@ static int test_suffer_pain_felt( Character &dummy, const time_duration &dur ) TEST_CASE( "suffering_from_albinism", "[char][suffer][albino]" ) { clear_map(); + clear_avatar(); + set_time_to_day(); + scoped_weather_override clear_weather( WEATHER_CLEAR ); avatar &dummy = get_avatar(); - clear_character( dummy ); - g->reset_light_level(); int focus_lost = 0; // TODO: The random chance of pain is too unprectable to test reliably. @@ -123,7 +125,6 @@ TEST_CASE( "suffering_from_albinism", "[char][suffer][albino]" ) item longshirt( "test_longshirt" ); GIVEN( "avatar is in sunlight with the albino trait" ) { - calendar::turn = calendar::turn_zero + 12_hours; REQUIRE( g->is_in_sunlight( dummy.pos() ) ); dummy.toggle_trait( trait_ALBINO ); @@ -207,8 +208,9 @@ TEST_CASE( "suffering_from_sunburn", "[char][suffer][sunburn]" ) { clear_map(); clear_avatar(); + set_time_to_day(); + scoped_weather_override clear_weather( WEATHER_CLEAR ); Character &dummy = get_player_character(); - g->reset_light_level(); const std::vector body_parts_with_hp = dummy.get_all_body_parts( get_body_part_flags::only_main ); @@ -221,7 +223,6 @@ TEST_CASE( "suffering_from_sunburn", "[char][suffer][sunburn]" ) item longshirt( "test_longshirt" ); GIVEN( "avatar is in sunlight with the solar sensitivity trait" ) { - calendar::turn = calendar::turn_zero + 12_hours; REQUIRE( g->is_in_sunlight( dummy.pos() ) ); dummy.toggle_trait( trait_SUNBURN );