Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand and improve iteminfo_tests #37823

Merged
merged 14 commits into from
Feb 13, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 193 additions & 41 deletions tests/iteminfo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,83 @@ static void iteminfo_test( const item &i, const iteminfo_query &q, const std::st
CHECK( info == reference );
}

TEST_CASE( "armor_info", "[item][iteminfo]" )
TEST_CASE( "item description and physical attributes", "[item][iteminfo]" )
{
// Just a generic typical piece of clothing
iteminfo_query q( { iteminfo_parts::ARMOR_BODYPARTS, iteminfo_parts::ARMOR_LAYER,
iteminfo_parts::ARMOR_COVERAGE, iteminfo_parts::ARMOR_WARMTH,
iteminfo_parts::ARMOR_ENCUMBRANCE, iteminfo_parts::ARMOR_PROTECTION
} );
iteminfo_query q( { iteminfo_parts::DESCRIPTION, iteminfo_parts::BASE_CATEGORY,
iteminfo_parts::BASE_PRICE, iteminfo_parts::BASE_VOLUME,
iteminfo_parts::BASE_WEIGHT, iteminfo_parts::BASE_MATERIAL } );
iteminfo_test(
item( "longshirt" ), q,
item( "jug_plastic" ), q,
"A standard plastic jug used for milk and household cleaning chemicals.\n"
"--\n"
"Category: <color_c_magenta>CONTAINERS</color> Price: $<color_c_yellow>0.00</color>\n"
"<color_c_white>Volume</color>: <color_c_yellow>3.750</color> L"
" Weight: <color_c_yellow>0.42</color> lbs\n"
"--\n"
// NOLINTNEXTLINE(cata-text-style)
"Covers: The <color_c_cyan>torso</color>. The <color_c_cyan>arms</color>. \n"
// NOLINTNEXTLINE(cata-text-style)
"Layer: <color_c_light_blue>Normal</color>. \n"
"Coverage: <color_c_yellow>90</color>% Warmth: <color_c_yellow>5</color>\n"
"Material: <color_c_light_blue>Plastic</color>\n" );

}

TEST_CASE( "weapon attack ratings and moves", "[item][iteminfo]" )
{
iteminfo_query q( { iteminfo_parts::BASE_DAMAGE, iteminfo_parts::BASE_TOHIT,
iteminfo_parts::BASE_MOVES } );

iteminfo_test(
item( "halligan" ), q,
"Bash: <color_c_yellow>20</color>"
" Cut: <color_c_yellow>5</color>"
" To-hit bonus: <color_c_yellow>+2</color>\n"
"Moves per attack: <color_c_yellow>145</color>\n" );

}

TEST_CASE( "techniques when wielded", "[item][iteminfo]" )
{
iteminfo_query q( { iteminfo_parts::DESCRIPTION_TECHNIQUES } );

iteminfo_test(
item( "halligan" ), q,
"--\n"
"<color_c_white>Encumbrance</color>: <color_c_yellow>3</color> <color_c_red>(poor fit)</color>\n"
"<color_c_white>Protection</color>: Bash: <color_c_yellow>1</color> Cut: <color_c_yellow>1</color>\n"
" Acid: <color_c_yellow>0</color> Fire: <color_c_yellow>0</color> Environmental: <color_c_yellow>0</color>\n" );
"<color_c_white>Techniques when wielded</color>:"
" <color_c_light_blue>Brutal Strike:</color> <color_c_cyan>Stun 1 turn, knockback 1 tile, crit only</color>,"
" <color_c_light_blue>Sweep Attack:</color> <color_c_cyan>Down 2 turns</color>, and"
" <color_c_light_blue>Block:</color> <color_c_cyan>Medium blocking ability</color>\n" );

}

TEST_CASE( "if_covers_nothing_omit_irreelevant_info", "[item][iteminfo]" )
TEST_CASE( "armor coverage and protection values", "[item][iteminfo]" )
{
iteminfo_query q( { iteminfo_parts::ARMOR_BODYPARTS, iteminfo_parts::ARMOR_LAYER,
iteminfo_parts::ARMOR_COVERAGE, iteminfo_parts::ARMOR_WARMTH,
iteminfo_parts::ARMOR_ENCUMBRANCE, iteminfo_parts::ARMOR_PROTECTION
} );
iteminfo_test(
item( "ear_plugs" ), q,
"--\n"
"Covers: <color_c_cyan>Nothing</color>.\n" );

SECTION( "shows coverage, encumbrance, and protection for armor with coverage" ) {
iteminfo_test(
item( "longshirt" ), q,
"--\n"
// NOLINTNEXTLINE(cata-text-style)
"Covers: The <color_c_cyan>torso</color>. The <color_c_cyan>arms</color>. \n"
// NOLINTNEXTLINE(cata-text-style)
"Layer: <color_c_light_blue>Normal</color>. \n"
"Coverage: <color_c_yellow>90</color>% Warmth: <color_c_yellow>5</color>\n"
"--\n"
"<color_c_white>Encumbrance</color>: <color_c_yellow>3</color> <color_c_red>(poor fit)</color>\n"
"<color_c_white>Protection</color>: Bash: <color_c_yellow>1</color> Cut: <color_c_yellow>1</color>\n"
" Acid: <color_c_yellow>0</color> Fire: <color_c_yellow>0</color> Environmental: <color_c_yellow>0</color>\n" );
}

SECTION( "omits irrelevant info if it covers nothing" ) {
iteminfo_test(
item( "ear_plugs" ), q,
"--\n"
"Covers: <color_c_cyan>Nothing</color>.\n" );
}
}

TEST_CASE( "gun_lists_default_ammo", "[item][iteminfo]" )

TEST_CASE( "default ammo for gun", "[item][iteminfo]" )
{
iteminfo_query q( { iteminfo_parts::GUN_DEFAULT_AMMO } );
iteminfo_test(
Expand All @@ -58,7 +101,7 @@ TEST_CASE( "gun_lists_default_ammo", "[item][iteminfo]" )
"Gun is not loaded, so stats below assume the default ammo: <color_c_light_blue>wooden broadhead arrow</color>\n" );
}

TEST_CASE( "gun_damage_multiplier_not_integer", "[item][iteminfo]" )
TEST_CASE( "gun damage with floating-point damage multiplier", "[item][iteminfo]" )
{
iteminfo_query q( { iteminfo_parts::GUN_DAMAGE, iteminfo_parts::GUN_DAMAGE_AMMOPROP,
iteminfo_parts::GUN_DAMAGE_TOTAL
Expand All @@ -69,33 +112,142 @@ TEST_CASE( "gun_damage_multiplier_not_integer", "[item][iteminfo]" )
"Damage: <color_c_yellow>18</color>*<color_c_yellow>1.25</color> = <color_c_yellow>22</color>\n" );
}

TEST_CASE( "nutrients_in_regular_item", "[item][iteminfo]" )
{
TEST_CASE( "nutrients in food", "[item][iteminfo]" )
wapcaplet marked this conversation as resolved.
Show resolved Hide resolved
iteminfo_query q( { iteminfo_parts::FOOD_NUTRITION, iteminfo_parts::FOOD_VITAMINS,
iteminfo_parts::FOOD_QUENCH
} );
item i( "icecream" );
SECTION( "fixed nutrient values in regular item" )
{
item i( "icecream" );
iteminfo_test(
i, q,
"--\n"
"<color_c_white>Calories (kcal)</color>: <color_c_yellow>325</color> "
"Quench: <color_c_yellow>0</color>\n"
"Vitamins (RDA): Calcium (9%), Vitamin A (9%), and Vitamin B12 (11%)\n" );
}

SECTION( "nutrient ranges for recipe exemplars", "[item][iteminfo]" )
{
item i( "icecream" );
i.set_var( "recipe_exemplar", "icecream" );
iteminfo_test(
i, q,
"--\n"
"Nutrition will <color_cyan>vary with chosen ingredients</color>.\n"
"<color_c_white>Calories (kcal)</color>: <color_c_yellow>317</color>-"
"<color_c_yellow>469</color> Quench: <color_c_yellow>0</color>\n"
"Vitamins (RDA): Calcium (7-28%), Iron (0-83%), "
"Vitamin A (3-11%), Vitamin B12 (2-6%), and Vitamin C (1-85%)\n" );
}
}

TEST_CASE( "item conductivity", "[item][iteminfo]" )
{
iteminfo_query q( { iteminfo_parts::DESCRIPTION_CONDUCTIVITY } );

SECTION( "non-conductive items" ) {
iteminfo_test(
item( "2x4" ), q,
"--\n"
"* This item <color_c_green>does not conduct</color> electricity.\n" );
iteminfo_test(
item( "fire_ax" ), q,
"--\n"
"* This item <color_c_green>does not conduct</color> electricity.\n" );
}

SECTION( "conductive items" ) {
iteminfo_test(
item( "pipe" ), q,
"--\n"
"* This item <color_c_red>conducts</color> electricity.\n" );
iteminfo_test(
item( "halligan" ), q,
"--\n"
"* This item <color_c_red>conducts</color> electricity.\n" );
}
}

TEST_CASE( "list of item qualities", "[item][iteminfo]" )
{
iteminfo_query q( { iteminfo_parts::QUALITIES } );

SECTION( "screwdriver" ) {
iteminfo_test(
item( "screwdriver" ), q,
"--\n"
"Has level <color_c_cyan>1 screw driving</color> quality.\n" );
}

SECTION( "screwdriver set" ) {
iteminfo_test(
item( "screwdriver_set" ), q,
"--\n"
"Has level <color_c_cyan>1 screw driving</color> quality.\n"
"Has level <color_c_cyan>1 fine screw driving</color> quality.\n" );
}

SECTION( "Halligan bar" ) {
iteminfo_test(
item( "halligan" ), q,
"--\n"
"Has level <color_c_cyan>1 digging</color> quality.\n"
"Has level <color_c_cyan>2 hammering</color> quality.\n"
"Has level <color_c_cyan>4 prying</color> quality.\n" );
}
}

TEST_CASE( "repairable and with what tools", "[item][iteminfo]" )
{
iteminfo_query q( { iteminfo_parts::DESCRIPTION_REPAIREDWITH } );

iteminfo_test(
item( "longshirt" ), q,
"--\n"
"<color_c_white>Repaired with</color>: bone needle, wooden needle, sewing kit, or tailor's kit\n"
"--\n"
"* This item can be <color_c_green>reinforced</color>.\n" );

iteminfo_test(
item( "halligan" ), q,
"--\n"
"<color_c_white>Repaired with</color>: extended toolset, arc welder, or makeshift arc welder\n" );

iteminfo_test(
i, q,
item( "hazmat_suit" ), q,
"--\n"
"<color_c_white>Calories (kcal)</color>: <color_c_yellow>325</color> "
"Quench: <color_c_yellow>0</color>\n"
"Vitamins (RDA): Calcium (9%), Vitamin A (9%), and Vitamin B12 (11%)\n" );
"<color_c_white>Repaired with</color>: soldering iron or extended toolset\n" );

iteminfo_test(
item( "rock" ), q,
"--\n"
"* This item is <color_c_red>not repairable</color>.\n" );
}

TEST_CASE( "nutrient_ranges_for_recipe_exemplars", "[item][iteminfo]" )
TEST_CASE( "item description flags", "[item][iteminfo]" )
{
iteminfo_query q( { iteminfo_parts::FOOD_NUTRITION, iteminfo_parts::FOOD_VITAMINS,
iteminfo_parts::FOOD_QUENCH
} );
item i( "icecream" );
i.set_var( "recipe_exemplar", "icecream" );
iteminfo_query q( { iteminfo_parts::DESCRIPTION_FLAGS } );

iteminfo_test(
i, q,
item( "halligan" ), q,
"--\n"
"Nutrition will <color_cyan>vary with chosen ingredients</color>.\n"
"<color_c_white>Calories (kcal)</color>: <color_c_yellow>317</color>-"
"<color_c_yellow>469</color> Quench: <color_c_yellow>0</color>\n"
"Vitamins (RDA): Calcium (7-28%), Iron (0-83%), "
"Vitamin A (3-11%), Vitamin B12 (2-6%), and Vitamin C (1-85%)\n" );
"* This item can be clipped on to a <color_c_cyan>belt loop</color> of the appropriate size.\n"
"* As a weapon, this item is <color_c_green>well-made</color> and will"
" <color_c_cyan>withstand the punishment of combat</color>.\n" );

iteminfo_test(
item( "hazmat_suit" ), q,
"--\n"
"* This gear <color_c_green>completely protects</color> you from"
" <color_c_cyan>electric discharges</color>.\n"
"* This gear <color_c_green>completely protects</color> you from"
" <color_c_cyan>any gas</color>.\n"
"* This gear is generally <color_c_cyan>worn over</color> clothing.\n"
"* This clothing <color_c_green>completely protects</color> you from"
" <color_c_cyan>radiation</color>.\n"
"* This piece of clothing is designed to keep you <color_c_cyan>dry</color> in the rain.\n"
"* This clothing <color_c_cyan>won't let water through</color>."
" Unless you jump in the river or something like that.\n" );
}