Skip to content

Commit

Permalink
Forgot /tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Procyonae committed May 31, 2024
1 parent 7fb1198 commit 47eb971
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 140 deletions.
16 changes: 9 additions & 7 deletions tests/iuse_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ static const itype_id itype_diazepam( "diazepam" );
static const itype_id itype_thorazine( "thorazine" );
static const itype_id itype_towel_wet( "towel_wet" );

static const morale_type morale_wet( "morale_wet" );

TEST_CASE( "eyedrops", "[iuse][eyedrops]" )
{
avatar dummy;
Expand Down Expand Up @@ -435,16 +437,16 @@ TEST_CASE( "towel", "[iuse][towel]" )
GIVEN( "avatar has poor morale due to being wet" ) {
dummy.drench( 100, { body_part_torso, body_part_head, body_part_arm_l, body_part_arm_r },
false );
dummy.add_morale( MORALE_WET, -10, -10, 1_hours, 1_hours );
REQUIRE( dummy.has_morale( MORALE_WET ) == -10 );
dummy.add_morale( morale_wet, -10, -10, 1_hours, 1_hours );
REQUIRE( dummy.has_morale( morale_wet ) == -10 );

WHEN( "they use a wet towel" ) {
towel.convert( itype_towel_wet );
REQUIRE( towel.has_flag( flag_WET ) );
dummy.invoke_item( &towel );

THEN( "it does not improve their morale" ) {
CHECK( dummy.has_morale( MORALE_WET ) == -10 );
CHECK( dummy.has_morale( morale_wet ) == -10 );
}
}

Expand All @@ -453,7 +455,7 @@ TEST_CASE( "towel", "[iuse][towel]" )
dummy.invoke_item( &towel );

THEN( "it improves their morale" ) {
CHECK( dummy.has_morale( MORALE_WET ) == 0 );
CHECK( dummy.has_morale( morale_wet ) == 0 );

AND_THEN( "the towel becomes wet" ) {
CHECK( towel.typeId() == itype_towel_wet );
Expand Down Expand Up @@ -488,16 +490,16 @@ TEST_CASE( "towel", "[iuse][towel]" )

GIVEN( "avatar is boomered and wet" ) {
dummy.add_effect( effect_boomered, 1_hours );
dummy.add_morale( MORALE_WET, -10, -10, 1_hours, 1_hours );
REQUIRE( std::abs( dummy.has_morale( MORALE_WET ) ) );
dummy.add_morale( morale_wet, -10, -10, 1_hours, 1_hours );
REQUIRE( std::abs( dummy.has_morale( morale_wet ) ) );

WHEN( "they use a dry towel" ) {
REQUIRE_FALSE( towel.has_flag( flag_WET ) );
dummy.invoke_item( &towel );

THEN( "it removes the boomered effect, but not the wetness" ) {
CHECK_FALSE( dummy.has_effect( effect_boomered ) );
CHECK( std::abs( dummy.has_morale( MORALE_WET ) ) );
CHECK( std::abs( dummy.has_morale( morale_wet ) ) );

AND_THEN( "the towel becomes filthy" ) {
CHECK( towel.is_filthy() );
Expand Down
42 changes: 22 additions & 20 deletions tests/mission_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ static const itype_id itype_test_rock( "test_rock" );
static const mission_type_id mission_TEST_MISSION_GOAL_CONDITION1( "TEST_MISSION_GOAL_CONDITION1" );
static const mission_type_id mission_TEST_MISSION_GOAL_CONDITION2( "TEST_MISSION_GOAL_CONDITION2" );

static const morale_type morale_feeling_good( "morale_feeling_good" );

static const npc_template_id npc_template_test_talker( "test_talker" );

TEST_CASE( "mission_goal_condition_test", "[mission]" )
Expand All @@ -38,11 +40,11 @@ TEST_CASE( "mission_goal_condition_test", "[mission]" )
return it.typeId() == itype_test_rock;
} ) );
THEN( "mission_not_complete" ) {
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( u.get_completed_missions().empty() == true );
u.get_active_mission()->process();
CHECK( u.get_completed_missions().empty() == true );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
}
}
WHEN( "condition_met" ) {
Expand All @@ -52,12 +54,12 @@ TEST_CASE( "mission_goal_condition_test", "[mission]" )
return it.typeId() == itype_test_rock;
} ) );
THEN( "mission_complete" ) {
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( u.get_completed_missions().empty() == true );
u.get_active_mission()->process();
CHECK( u.get_completed_missions().empty() == false );
CHECK( u.get_completed_missions().front()->mission_id() == mission_TEST_MISSION_GOAL_CONDITION1 );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 10 );
CHECK( u.has_morale( morale_feeling_good ) == 10 );
}
}
}
Expand All @@ -72,11 +74,11 @@ TEST_CASE( "mission_goal_condition_test", "[mission]" )
return it.typeId() == itype_test_rock;
} ) );
THEN( "mission_not_complete" ) {
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( u.get_completed_missions().empty() == true );
u.get_active_mission()->process();
CHECK( u.get_completed_missions().empty() == true );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
}
}
WHEN( "condition_met" ) {
Expand All @@ -86,11 +88,11 @@ TEST_CASE( "mission_goal_condition_test", "[mission]" )
return it.typeId() == itype_test_rock;
} ) );
THEN( "mission_not_complete" ) {
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( u.get_completed_missions().empty() == true );
u.get_active_mission()->process();
CHECK( u.get_completed_missions().empty() == true );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
}
}
}
Expand All @@ -110,13 +112,13 @@ TEST_CASE( "mission_goal_condition_test", "[mission]" )
return it.typeId() == itype_test_rock;
} ) );
THEN( "mission_not_complete" ) {
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( u.get_completed_missions().empty() == true );
u.get_active_mission()->process();
CHECK( u.get_completed_missions().empty() == true );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( !u.get_active_mission()->is_complete( guy_id ) );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
}
}
WHEN( "condition_met" ) {
Expand All @@ -126,16 +128,16 @@ TEST_CASE( "mission_goal_condition_test", "[mission]" )
return it.typeId() == itype_test_rock;
} ) );
THEN( "mission_complete" ) {
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( u.get_completed_missions().empty() == true );
u.get_active_mission()->process();
CHECK( u.get_completed_missions().empty() == true );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( u.get_active_mission()->is_complete( guy_id ) );
u.get_active_mission()->wrap_up();
CHECK( u.get_completed_missions().empty() == false );
CHECK( u.get_completed_missions().front()->mission_id() == mission_TEST_MISSION_GOAL_CONDITION1 );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 10 );
CHECK( u.has_morale( morale_feeling_good ) == 10 );
}
}
}
Expand All @@ -150,13 +152,13 @@ TEST_CASE( "mission_goal_condition_test", "[mission]" )
return it.typeId() == itype_test_rock;
} ) );
THEN( "mission_not_complete" ) {
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( u.get_completed_missions().empty() == true );
u.get_active_mission()->process();
CHECK( u.get_completed_missions().empty() == true );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( !u.get_active_mission()->is_complete( guy_id ) );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
}
}
WHEN( "condition_met" ) {
Expand All @@ -166,16 +168,16 @@ TEST_CASE( "mission_goal_condition_test", "[mission]" )
return it.typeId() == itype_test_rock;
} ) );
THEN( "mission_complete" ) {
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( u.get_completed_missions().empty() == true );
u.get_active_mission()->process();
CHECK( u.get_completed_missions().empty() == true );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 0 );
CHECK( u.has_morale( morale_feeling_good ) == 0 );
CHECK( u.get_active_mission()->is_complete( guy_id ) );
u.get_active_mission()->wrap_up();
CHECK( u.get_completed_missions().empty() == false );
CHECK( u.get_completed_missions().front()->mission_id() == mission_TEST_MISSION_GOAL_CONDITION2 );
CHECK( u.has_morale( MORALE_FEELING_GOOD ) == 10 );
CHECK( u.has_morale( morale_feeling_good ) == 10 );
}
}
}
Expand Down
Loading

0 comments on commit 47eb971

Please sign in to comment.