forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitemname_test.cpp
155 lines (127 loc) · 5.29 KB
/
itemname_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include "catch/catch.hpp"
#include <set>
#include <string>
#include "character.h"
#include "flag.h"
#include "flat_set.h"
#include "item.h"
#include "item_pocket.h"
#include "player_helpers.h"
#include "ret_val.h"
#include "type_id.h"
TEST_CASE( "item sizing display", "[item][iteminfo][display_name][sizing]" )
{
Character &player_character = get_player_character();
GIVEN( "player is a normal size" ) {
player_character.clear_mutations();
WHEN( "the item is a normal size" ) {
std::string name = item( "bookplate" ).display_name();
THEN( "the item name has no qualifier" ) {
CHECK( name == "<color_c_light_green>||\u00A0</color>bookplate" );
}
}
WHEN( "the item is oversized" ) {
std::string name = item( "bootsheath" ).display_name();
THEN( "the item name has no qualifier" ) {
CHECK( name == "<color_c_light_green>||\u00A0</color>ankle sheath" );
}
}
WHEN( "the item is undersized" ) {
item i = item( "tunic" );
i.set_flag( flag_UNDERSIZE );
i.set_flag( flag_FIT );
std::string name = i.display_name();
THEN( "we have the correct sizing" ) {
const item::sizing sizing_level = i.get_sizing( player_character );
CHECK( sizing_level == item::sizing::small_sized_human_char );
}
THEN( "the item name says its too small" ) {
CHECK( name == "<color_c_light_green>||\u00A0</color>tunic (too small)" );
}
}
}
GIVEN( "player is a huge size" ) {
player_character.clear_mutations();
player_character.toggle_trait( trait_id( "HUGE_OK" ) );
WHEN( "the item is a normal size" ) {
std::string name = item( "bookplate" ).display_name();
THEN( "the item name says its too small" ) {
CHECK( name == "<color_c_light_green>||\u00A0</color>bookplate (too small)" );
}
}
WHEN( "the item is oversized" ) {
std::string name = item( "bootsheath" ).display_name();
THEN( "the item name has no qualifier" ) {
CHECK( name == "<color_c_light_green>||\u00A0</color>ankle sheath" );
}
}
WHEN( "the item is undersized" ) {
item i = item( "tunic" );
i.set_flag( flag_UNDERSIZE );
i.set_flag( flag_FIT );
std::string name = i.display_name();
THEN( "we have the correct sizing" ) {
const item::sizing sizing_level = i.get_sizing( player_character );
CHECK( sizing_level == item::sizing::small_sized_big_char );
}
THEN( "the item name says its tiny" ) {
CHECK( name == "<color_c_light_green>||\u00A0</color>tunic (tiny!)" );
}
}
}
GIVEN( "player is a small size" ) {
player_character.clear_mutations();
player_character.toggle_trait( trait_id( "SMALL_OK" ) );
WHEN( "the item is a normal size" ) {
std::string name = item( "bookplate" ).display_name();
THEN( "the item name says its too big" ) {
CHECK( name == "<color_c_light_green>||\u00A0</color>bookplate (too big)" );
}
}
WHEN( "the item is oversized" ) {
std::string name = item( "bootsheath" ).display_name();
THEN( "the item name has no qualifier" ) {
CHECK( name == "<color_c_light_green>||\u00A0</color>ankle sheath (huge!)" );
}
}
WHEN( "the item is undersized" ) {
item i = item( "tunic" );
i.set_flag( flag_UNDERSIZE );
i.set_flag( flag_FIT );
std::string name = i.display_name();
THEN( "we have the correct sizing" ) {
const item::sizing sizing_level = i.get_sizing( player_character );
CHECK( sizing_level == item::sizing::small_sized_small_char );
}
THEN( "the item name has no qualifier" ) {
CHECK( name == "<color_c_light_green>||\u00A0</color>tunic" );
}
}
}
}
TEST_CASE( "display name includes item contents", "[item][display_name][contents]" )
{
clear_avatar();
item arrow( "test_arrow_wood", calendar::turn_zero, item::default_charges_tag{} );
// Arrows are ammo with a default count of 10
REQUIRE( arrow.is_ammo() );
REQUIRE( arrow.count() == 10 );
item quiver( "test_quiver" );
// Quivers are not magazines, nor do they have magazines
REQUIRE_FALSE( quiver.is_magazine() );
REQUIRE_FALSE( quiver.magazine_current() );
// But they do have ammo types and can contain ammo
REQUIRE_FALSE( quiver.ammo_types().empty() );
REQUIRE( quiver.can_contain( arrow ) );
// Check empty quiver display
CHECK( quiver.display_name() ==
"<color_c_light_green>||\u00A0</color>"
"test quiver (0)" );
// Insert one arrow
quiver.put_in( arrow, item_pocket::pocket_type::CONTAINER );
// Expect 1 arrow remaining and displayed
CHECK( quiver.ammo_remaining() == 10 );
CHECK( quiver.display_name() ==
"<color_c_light_green>||\u00A0</color>"
"test quiver > test wooden broadhead arrows (10)" );
}