15 #define GETTEXT_DOMAIN "wesnoth-test"
17 #include <boost/test/unit_test.hpp>
42 orc_config[
"id"]=
"Orcish Grunt";
43 orc_config[
"random_traits"]=
false;
44 orc_config[
"animate"]=
false;
49 unit orc1_side0_real(orc_type, 0,
false);
50 unit orc2_side0_fake(orc_type, 0,
false);
54 typedef std::pair<unit_map::unit_iterator, bool> t_uresult;
57 BOOST_CHECK_MESSAGE(uresult1.second ==
true,
"Good Add");
58 BOOST_CHECK_EQUAL(unit_map.
size(), 1);
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");
76 BOOST_CHECK_EQUAL(unit_map.
size(), 1);
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.");
84 BOOST_CHECK_EQUAL(unit_map.
size(), 1);
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.");
97 BOOST_CHECK_EQUAL(unit_map.
size(), 2);
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...");
130 orc_config[
"id"]=
"Orcish Grunt";
131 orc_config[
"random_traits"] =
false;
132 orc_config[
"animate"]=
false;
137 unit orc1_side0_real(orc_type, 0,
true);
144 typedef std::pair<unit_map::unit_iterator, bool> t_uresult;
145 t_uresult uresult1 = unit_map.
add(hex, orc1_side0_real);
147 BOOST_CHECK(uresult1.second ==
true);
151 BOOST_CHECK(uresult1.first == ui);
152 BOOST_CHECK(ui->underlying_id() == orc1_side0_real.
underlying_id());
159 BOOST_CHECK(ui == unit_map.
end());
162 unit_map.
insert(extracted_unit);
163 extracted_unit.reset();
167 BOOST_CHECK(uresult1.first == ui);
168 BOOST_CHECK(ui->underlying_id() == orc1_side0_real.
underlying_id());
178 orc_config[
"id"]=
"Orcish Grunt";
179 orc_config[
"random_traits"] =
false;
180 orc_config[
"animate"]=
false;
185 unit orc1_side0_fake(orc_type, 0,
false);
192 typedef std::pair<unit_map::unit_iterator, bool> t_uresult;
193 t_uresult uresult1 = unit_map.
add(hex, orc1_side0_fake);
195 BOOST_CHECK(uresult1.second ==
true);
199 BOOST_CHECK(uresult1.first == ui);
200 BOOST_CHECK(ui->underlying_id() == orc1_side0_fake.
underlying_id());
207 BOOST_CHECK(ui == unit_map.
end());
210 unit_map.
insert(extracted_unit);
211 extracted_unit.reset();
215 BOOST_CHECK(uresult1.first == ui);
216 BOOST_CHECK(ui->underlying_id() == orc1_side0_fake.
underlying_id());
227 orc_config[
"id"]=
"Orcish Grunt";
228 orc_config[
"random_traits"] =
false;
229 orc_config[
"animate"]=
false;
234 unit orc1_side0_real(orc_type, 0,
true);
240 typedef std::pair<unit_map::unit_iterator, bool> t_uresult;
241 t_uresult uresult1 = unit_map.
add(hex, orc1_side0_real);
245 BOOST_CHECK(unit_iterator.
valid());
249 BOOST_CHECK_MESSAGE(unit_iterator.
valid() ==
false,
"Iterator should be invalid after extraction.");
251 unit_map.
insert(extracted_unit);
253 BOOST_CHECK_MESSAGE(unit_iterator.
valid(),
"Iterator should be valid after extraction and reinsertion.");
256 BOOST_CHECK(unit_iterator2.valid());
257 BOOST_CHECK(unit_iterator == unit_iterator2);
266 orc_config[
"id"]=
"Orcish Grunt";
267 orc_config[
"random_traits"] =
false;
268 orc_config[
"animate"]=
false;
273 unit orc1_side0_fake(orc_type, 0,
false);
279 typedef std::pair<unit_map::unit_iterator, bool> t_uresult;
280 t_uresult uresult1 = unit_map.
add(hex, orc1_side0_fake);
284 BOOST_CHECK(unit_iterator.
valid());
288 BOOST_CHECK_MESSAGE(unit_iterator.
valid() ==
false,
"Iterator should be invalid after extraction.");
290 unit_map.
insert(extracted_unit);
292 BOOST_CHECK_MESSAGE(unit_iterator.
valid(),
"Iterator should be valid after extraction and reinsertion.");
295 BOOST_CHECK(unit_iterator2.valid());
296 BOOST_CHECK(unit_iterator == unit_iterator2);
300 BOOST_AUTO_TEST_SUITE_END()
size_t underlying_id() const
The unique internal ID of the unit.
unit_type_data unit_types
BOOST_AUTO_TEST_SUITE(test_map_location)
BOOST_AUTO_TEST_CASE(test_1)
Definitions for the interface to Wesnoth Markup Language (WML).
bool set_log_domain_severity(std::string const &name, int severity)
std::pair< unit_iterator, bool > insert(unit_ptr p)
Adds the unit to 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.
std::pair< unit_iterator, bool > add(const map_location &l, const unit &u)
Adds a copy of unit u at location l of the map.
Encapsulates the map of the game.
Game configuration data as global variables.
unit_ptr extract(const map_location &loc)
Extracts a unit from the map.
Standard logging facilities (interface).
Container associating units to locations.
unit_iterator find(size_t id)
A config object defines a single node in a WML file, with access to child nodes.