Skip to content

Commit 318b79b

Browse files
committed
Update effect init tests to reflect constructor enforcement of rules
1 parent af05c7e commit 318b79b

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

tests/effect_test.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,40 @@ static const vitamin_id vitamin_test_vitx( "test_vitx" );
5757
// effect::get_start_time
5858
//
5959
// Create an `effect` object with given parameters, and check they were initialized correctly.
60-
static void check_effect_init( const std::string &eff_name, const time_duration &dur,
61-
const std::string &bp_name, const bool permanent, const int intensity,
60+
static void check_effect_init( const std::string &eff_name,
61+
const time_duration &requested_dur, const time_duration &expected_dur,
62+
const std::string &bp_name, const bool permanent,
63+
const int requested_int, const int expected_int,
6264
const time_point &start_time )
6365
{
6466
const efftype_id eff_id( eff_name );
6567
const effect_type &type = eff_id.obj();
6668
const bodypart_str_id bp( bp_name );
6769

68-
effect effect_obj( effect_source::empty(), &type, dur, bp, permanent, intensity, start_time );
70+
effect effect_obj( effect_source::empty(), &type, requested_dur, bp, permanent, requested_int,
71+
start_time );
6972

70-
CHECK( dur == effect_obj.get_duration() );
73+
CHECK( expected_dur == effect_obj.get_duration() );
7174
CHECK( bp.id() == effect_obj.get_bp() );
7275
CHECK( permanent == effect_obj.is_permanent() );
73-
CHECK( intensity == effect_obj.get_intensity() );
76+
CHECK( expected_int == effect_obj.get_intensity() );
7477
CHECK( start_time == effect_obj.get_start_time() );
7578
}
7679

7780
TEST_CASE( "effect_initialization_test", "[effect][init]" )
7881
{
7982
// "debugged" effect is defined in data/mods/TEST_DATA/effects.json
80-
check_effect_init( "debugged", 1_days, "head", false, 5, calendar::turn_zero );
81-
check_effect_init( "bite", 1_minutes, "torso", true, 2, calendar::turn );
82-
check_effect_init( "grabbed", 1_turns, "arm_r", false, 1, calendar::turn + 1_hours );
83+
// "debugged" effect has max_duration 1 hour, so 1 day gets clamped
84+
check_effect_init( "debugged", 1_days, 1_hours, "head", false, 5, 5, calendar::turn_zero );
85+
check_effect_init( "debugged", 1_minutes, 1_minutes, "head", false, 5, 5, calendar::turn_zero );
86+
// "bite" effect has int_dur_factor, so intensity is calculated from duration regardless of requested intensity
87+
check_effect_init( "bite", 60_minutes, 60_minutes, "torso", true, 99, 2, calendar::turn );
88+
check_effect_init( "bite", 30_minutes, 30_minutes, "torso", true, 99, 1, calendar::turn );
89+
check_effect_init( "grabbed", 1_turns, 1_turns, "arm_r", false, 100, 100,
90+
calendar::turn + 1_hours );
91+
check_effect_init( "grabbed", 100_turns, 100_turns, "arm_r", false, 1, 1,
92+
calendar::turn + 1_hours );
93+
check_effect_init( "grabbed", 1_turns, 1_turns, "arm_r", false, 10, 10, calendar::turn + 1_hours );
8394
}
8495

8596
// Effect duration

0 commit comments

Comments
 (0)