16 #define GETTEXT_DOMAIN "wesnoth-test"
18 #include <boost/test/unit_test.hpp>
42 orc_config[
"id"]=
"Orcish Grunt";
43 orc_config[
"random_traits"]=
false;
44 orc_config[
"animate"]=
false;
54 typedef std::pair<unit_map::unit_iterator, bool> t_uresult;
57 BOOST_CHECK_MESSAGE(uresult1.second ==
true,
"Good Add");
61 BOOST_CHECK_MESSAGE(uresult1.first == ui,
"Good Add");
62 BOOST_CHECK_MESSAGE(ui->underlying_id() == orc1_side0_real->underlying_id(),
"Found Orc1");
65 BOOST_CHECK_MESSAGE(ui2 ==
unit_map.
end(),
"Not Found Orc1");
67 BOOST_CHECK_MESSAGE(ui2 ==
unit_map.
end(),
"Not Found Orc1");
77 BOOST_CHECK_MESSAGE(uresult1.second ==
false,
"Didn't Add at occupied location.");
78 BOOST_CHECK_MESSAGE(uresult1.first ==
unit_map.
end(),
"Didn't Add at occupied location.");
85 BOOST_CHECK_MESSAGE(uresult1.second ==
false,
"Didn't Add at invalid location.");
86 BOOST_CHECK_MESSAGE(uresult1.first ==
unit_map.
end(),
"Didn't Add at invalid location.");
98 BOOST_CHECK_MESSAGE(uresult1.second ==
true,
"Added in face of id collision.");
99 BOOST_CHECK_MESSAGE(uresult1.first !=
unit_map.
end(),
"Added in face of id collision.");
100 BOOST_CHECK_MESSAGE(uresult1.first->underlying_id() != orc1_side0_real->underlying_id(),
"Found Orc1");
102 BOOST_CHECK_MESSAGE(!
unit_map.
end().
valid(),
"Hmm, unit_map.end() is valid for dereference...");
111 orc_config[
"id"]=
"Orcish Grunt";
112 orc_config[
"random_traits"] =
false;
113 orc_config[
"animate"]=
false;
120 std::size_t underlying_id = orc1_side0_real->underlying_id();
125 typedef std::pair<unit_map::unit_iterator, bool> t_uresult;
126 t_uresult uresult1 =
unit_map.
add(hex, *orc1_side0_real);
128 BOOST_CHECK(uresult1.second ==
true);
132 BOOST_CHECK(uresult1.first == ui);
133 BOOST_CHECK(ui->underlying_id() == orc1_side0_real->underlying_id());
144 extracted_unit.reset();
148 BOOST_CHECK(uresult1.first == ui);
149 BOOST_CHECK(ui->underlying_id() == orc1_side0_real->underlying_id());
157 orc_config[
"id"]=
"Orcish Grunt";
158 orc_config[
"random_traits"] =
false;
159 orc_config[
"animate"]=
false;
166 std::size_t underlying_id = orc1_side0_fake->underlying_id();
171 typedef std::pair<unit_map::unit_iterator, bool> t_uresult;
172 t_uresult uresult1 =
unit_map.
add(hex, *orc1_side0_fake);
174 BOOST_CHECK(uresult1.second ==
true);
178 BOOST_CHECK(uresult1.first == ui);
179 BOOST_CHECK(ui->underlying_id() == orc1_side0_fake->underlying_id());
190 extracted_unit.reset();
194 BOOST_CHECK(uresult1.first == ui);
195 BOOST_CHECK(ui->underlying_id() == orc1_side0_fake->underlying_id());
203 orc_config[
"id"]=
"Orcish Grunt";
204 orc_config[
"random_traits"] =
false;
205 orc_config[
"animate"]=
false;
216 typedef std::pair<unit_map::unit_iterator, bool> t_uresult;
217 t_uresult uresult1 =
unit_map.
add(hex, *orc1_side0_real);
221 BOOST_CHECK(unit_iterator.
valid());
225 BOOST_CHECK_MESSAGE(unit_iterator.
valid() ==
false,
"Iterator should be invalid after extraction.");
229 BOOST_CHECK_MESSAGE(unit_iterator.
valid(),
"Iterator should be valid after extraction and reinsertion.");
232 BOOST_CHECK(unit_iterator2.
valid());
233 BOOST_CHECK(unit_iterator == unit_iterator2);
240 orc_config[
"id"]=
"Orcish Grunt";
241 orc_config[
"random_traits"] =
false;
242 orc_config[
"animate"]=
false;
253 typedef std::pair<unit_map::unit_iterator, bool> t_uresult;
254 t_uresult uresult1 =
unit_map.
add(hex, *orc1_side0_fake);
258 BOOST_CHECK(unit_iterator.
valid());
262 BOOST_CHECK_MESSAGE(unit_iterator.
valid() ==
false,
"Iterator should be invalid after extraction.");
266 BOOST_CHECK_MESSAGE(unit_iterator.
valid(),
"Iterator should be valid after extraction and reinsertion.");
269 BOOST_CHECK(unit_iterator2.
valid());
270 BOOST_CHECK(unit_iterator == unit_iterator2);
274 BOOST_AUTO_TEST_SUITE_END()
A config object defines a single node in a WML file, with access to child nodes.
Container associating units to locations.
unit_ptr extract(const map_location &loc)
Extracts a unit from the map.
unit_iterator find(std::size_t id)
umap_retval_pair_t add(const map_location &l, const unit &u)
Adds a copy of unit u at location l of the map.
umap_retval_pair_t insert(unit_ptr p)
Inserts the unit pointed to by p into the map.
void build_unit_type(const unit_type &ut, unit_type::BUILD_STATUS status) const
Makes sure the provided unit_type is built to the specified level.
A single unit type that the player may recruit.
static unit_ptr create(const config &cfg, bool use_traits=false, const vconfig *vcfg=nullptr)
Initializes a unit from a config.
Definitions for the interface to Wesnoth Markup Language (WML).
Standard logging facilities (interface).
Game configuration data as global variables.
bool set_log_domain_severity(const std::string &name, severity severity)
std::shared_ptr< unit > unit_ptr
Encapsulates the map of the game.
BOOST_AUTO_TEST_SUITE(filesystem)
BOOST_AUTO_TEST_CASE(test_1)
unit_type_data unit_types