Skip to content

Commit

Permalink
Fix the rest of the consumption tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbieNeko committed Dec 14, 2024
1 parent 380533b commit 6ef54c7
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions tests/char_edible_rating_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@
#include "state_helpers.h"
#include "type_id.h"

static const vitamin_id vitamin_bread_allergen( "bread_allergen" );
static const vitamin_id vitamin_egg_allergen( "egg_allergen" );
static const vitamin_id vitamin_fruit_allergen( "fruit_allergen" );
static const vitamin_id vitamin_human_flesh_vitamin( "human_flesh_vitamin" );
static const vitamin_id vitamin_junk_allergen( "junk_allergen" );
static const vitamin_id vitamin_meat_allergen( "meat_allergen" );
static const vitamin_id vitamin_milk_allergen( "milk_allergen" );

Check warning on line 22 in tests/char_edible_rating_test.cpp

View workflow job for this annotation

GitHub Actions / build

Variable 'vitamin_milk_allergen' declared but not used. [cata-unused-statics]
static const vitamin_id vitamin_nut_allergen( "nut_allergen" );
static const vitamin_id vitamin_veggy_allergen( "veggy_allergen" );
static const vitamin_id vitamin_wheat_allergen( "wheat_allergen" );

Check warning on line 25 in tests/char_edible_rating_test.cpp

View workflow job for this annotation

GitHub Actions / build

Variable 'vitamin_wheat_allergen' declared but not used. [cata-unused-statics]

// Character "edible rating" tests, covering the `can_eat` and `will_eat` functions

Expand Down Expand Up @@ -171,14 +180,14 @@ TEST_CASE( "what herbivores can eat", "[can_eat][edible_rating][herbivore]" )

THEN( "they cannot eat meat" ) {
item &meat = *item::spawn_temporary( "meat_cooked" );
REQUIRE( meat.has_flag( flag_ALLERGEN_MEAT ) );
REQUIRE( meat.has_vitamin( vitamin_meat_allergen ) );

expect_cannot_eat( dummy, meat, expect_reason, edible_rating::inedible_mutation );
}

THEN( "they cannot eat eggs" ) {
item &eggs = *item::spawn_temporary( "scrambled_eggs" );
REQUIRE( eggs.has_flag( flag_ALLERGEN_EGG ) );
REQUIRE( eggs.has_vitamin( vitamin_egg_allergen ) );

expect_cannot_eat( dummy, eggs, expect_reason, edible_rating::inedible_mutation );
}
Expand All @@ -198,35 +207,35 @@ TEST_CASE( "what carnivores can eat", "[can_eat][edible_rating][carnivore]" )

THEN( "they cannot eat veggies" ) {
item &veggy = *item::spawn_temporary( "veggy" );
REQUIRE( veggy.has_flag( flag_ALLERGEN_VEGGY ) );
REQUIRE( veggy.has_vitamin( vitamin_veggy_allergen ) );

expect_cannot_eat( dummy, veggy, expect_reason, edible_rating::inedible_mutation );
}

THEN( "they cannot eat fruit" ) {
item &apple = *item::spawn_temporary( "apple" );
REQUIRE( apple.has_flag( flag_ALLERGEN_FRUIT ) );
REQUIRE( apple.has_vitamin( vitamin_fruit_allergen ) );

expect_cannot_eat( dummy, apple, expect_reason, edible_rating::inedible_mutation );
}

THEN( "they cannot eat wheat" ) {
item &bread = *item::spawn_temporary( "sourdough_bread" );
REQUIRE( bread.has_flag( flag_ALLERGEN_WHEAT ) );
REQUIRE( bread.has_vitamin( vitamin_bread_allergen ) );

expect_cannot_eat( dummy, bread, expect_reason, edible_rating::inedible_mutation );
}

THEN( "they cannot eat nuts" ) {
item &nuts = *item::spawn_temporary( "pine_nuts" );
REQUIRE( nuts.has_flag( flag_ALLERGEN_NUT ) );
REQUIRE( nuts.has_vitamin( vitamin_nut_allergen ) );

expect_cannot_eat( dummy, nuts, expect_reason, edible_rating::inedible_mutation );
}

THEN( "they can eat junk food, but are allergic to it" ) {
item &chocolate = *item::spawn_temporary( "chocolate" );
REQUIRE( chocolate.has_flag( flag_ALLERGEN_JUNK ) );
REQUIRE( chocolate.has_vitamin( vitamin_junk_allergen ) );

expect_can_eat( dummy, chocolate );
expect_will_eat( dummy, chocolate, "Your stomach won't be happy (allergy).",
Expand Down Expand Up @@ -338,7 +347,7 @@ TEST_CASE( "can eat with allergies", "[will_eat][edible_rating][allergy]" )
clear_all_state();
avatar dummy = prepare_avatar();
item &fruit = *item::spawn_temporary( "apple" );
REQUIRE( fruit.has_flag( flag_ALLERGEN_FRUIT ) );
REQUIRE( fruit.has_vitamin( vitamin_fruit_allergen ) );

GIVEN( "character hates fruit" ) {
dummy.toggle_trait( trait_id( "ANTIFRUIT" ) );
Expand Down

0 comments on commit 6ef54c7

Please sign in to comment.