Skip to content

Commit

Permalink
Add human flesh item and cannibalism info test
Browse files Browse the repository at this point in the history
  • Loading branch information
wapcaplet committed May 28, 2020
1 parent 9c2dfd7 commit 09beb54
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
21 changes: 21 additions & 0 deletions data/mods/TEST_DATA/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -1078,5 +1078,26 @@
"pocket_data": [ { "pocket_type": "MAGAZINE", "holster": true, "ammo_restriction": { "match": 20 } } ],
"use_action": { "type": "firestarter", "moves": 40, "moves_slow": 1000 },
"flags": [ "FIRESTARTER", "NO_RELOAD", "NO_UNLOAD" ]
},
{
"id": "test_thumb",
"type": "COMESTIBLE",
"category": "other",
"material": "hflesh",
"name": { "str": "test mutated thumb" },
"description": "A misshapen human thumb. Eating this would be incredibly disgusting and probably cause you to mutate.",
"volume": "100 ml",
"weight": "100 g",
"color": "brown",
"spoils_in": "2 days",
"use_action": { "type": "mutagen", "is_weak": true },
"flags": [ "TRADER_AVOID", "NUTRIENT_OVERRIDE" ],
"comestible_type": "FOOD",
"symbol": "%",
"healthy": -8,
"calories": 50,
"price": 0,
"price_postapoc": 0,
"fun": -20
}
]
35 changes: 35 additions & 0 deletions tests/iteminfo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,41 @@ TEST_CASE( "food with hidden poison or hallucinogen", "[iteminfo][food][poison][
}
}

// item::food_info
TEST_CASE( "food that is made of human flesh", "[iteminfo][food][cannibal]" )
{
// TODO: Test food that is_tainted(): "This food is *tainted* and will poison you"

clear_avatar();

std::vector<iteminfo_parts> cannibal = { iteminfo_parts::FOOD_CANNIBALISM };

item thumb( "test_thumb" );
REQUIRE( thumb.has_flag( "CANNIBALISM" ) );

GIVEN( "character is not a cannibal" ) {
REQUIRE_FALSE( g->u.has_trait( trait_id( "CANNIBAL" ) ) );
THEN( "human flesh is indicated as bad" ) {
// red highlight
CHECK( item_info_str( thumb, cannibal ) ==
"--\n"
"* This food contains <color_c_red>human flesh</color>.\n" );
}
}

GIVEN( "character is a cannibal" ) {
g->u.toggle_trait( trait_id( "CANNIBAL" ) );
REQUIRE( g->u.has_trait( trait_id( "CANNIBAL" ) ) );

THEN( "human flesh is indicated as good" ) {
// green highlight
CHECK( item_info_str( thumb, cannibal ) ==
"--\n"
"* This food contains <color_c_green>human flesh</color>.\n" );
}
}
}

// item::final_info
// FIXME: Move conducivity out of final_info
TEST_CASE( "item conductivity", "[iteminfo][conductivity]" )
Expand Down

0 comments on commit 09beb54

Please sign in to comment.