From 6ef54c7caf64e943fd3a2a3a7615ac1afebd005b Mon Sep 17 00:00:00 2001 From: RobbieNeko <30732426+RobbieNeko@users.noreply.github.com> Date: Fri, 13 Dec 2024 19:20:39 -0500 Subject: [PATCH] Fix the rest of the consumption tests --- tests/char_edible_rating_test.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/char_edible_rating_test.cpp b/tests/char_edible_rating_test.cpp index f02867914bd1..cdf4b3ef1739 100644 --- a/tests/char_edible_rating_test.cpp +++ b/tests/char_edible_rating_test.cpp @@ -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" ); +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" ); // Character "edible rating" tests, covering the `can_eat` and `will_eat` functions @@ -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 ); } @@ -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).", @@ -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" ) );