16 #define GETTEXT_DOMAIN "wesnoth-test"
19 #include <boost/test/unit_test.hpp>
24 static map_location va,
vb,
vc,
vz,
vt1,
vt2,
vt3,
vs1,
vs2,
vs3,
vs4;
70 #ifndef MAP_LOCATION_GET_OUTPUT
81 BOOST_CHECK_EQUAL(dir_answers.size(), int_answers.size());
83 std::vector<map_location::direction>::const_iterator dir_it = dir_answers.begin();
84 std::vector<std::size_t>::const_iterator int_it = int_answers.begin();
86 for (std::vector<map_location>::const_iterator it_a = locs.begin(); it_a != locs.end(); ++it_a) {
87 for (std::vector<map_location>::const_iterator it_b = it_a + 1; it_b != locs.end(); ++it_b) {
90 #ifdef MAP_LOCATION_GET_OUTPUT
94 int expected_dist = *(int_it++);
111 for (std::vector<map_location>::const_iterator it_c = it_b + 1; it_c != locs.end(); ++it_c) {
118 BOOST_CHECK_EQUAL(expected_dir, (a.
vector_sum(
c)).get_relative_dir(
b.vector_sum(
c),mode));
125 BOOST_CHECK_MESSAGE( dir_it == dir_answers.end(),
"Did not exhaust answers list.");
126 BOOST_CHECK_MESSAGE( int_it == int_answers.end(),
"Did not exhaust answers list.");
129 static std::size_t
get_first (std::pair<std::size_t, std::string> arg) {
return arg.first; }
202 std::vector<std::pair<std::size_t, std::string>> generated_answers {
203 std::make_pair(7,
"se"),
204 std::make_pair(6,
"sw"),
205 std::make_pair(6,
"n"),
206 std::make_pair(12,
"n"),
207 std::make_pair(16,
"s"),
208 std::make_pair(9,
"n"),
209 std::make_pair(7,
"nw"),
210 std::make_pair(7,
"n"),
211 std::make_pair(4,
"n"),
212 std::make_pair(5,
"nw"),
213 std::make_pair(10,
"sw"),
214 std::make_pair(13,
"nw"),
215 std::make_pair(19,
"nw"),
216 std::make_pair(9,
"s"),
217 std::make_pair(16,
"n"),
218 std::make_pair(14,
"nw"),
219 std::make_pair(14,
"nw"),
220 std::make_pair(11,
"nw"),
221 std::make_pair(12,
"nw"),
222 std::make_pair(9,
"n"),
223 std::make_pair(15,
"n"),
224 std::make_pair(13,
"se"),
225 std::make_pair(15,
"n"),
226 std::make_pair(10,
"n"),
227 std::make_pair(11,
"n"),
228 std::make_pair(8,
"n"),
229 std::make_pair(8,
"n"),
230 std::make_pair(6,
"n"),
231 std::make_pair(22,
"s"),
232 std::make_pair(6,
"ne"),
233 std::make_pair(1,
"nw"),
234 std::make_pair(2,
"ne"),
235 std::make_pair(2,
"s"),
236 std::make_pair(1,
"s"),
237 std::make_pair(28,
"s"),
238 std::make_pair(6,
"se"),
239 std::make_pair(5,
"s"),
240 std::make_pair(5,
"se"),
241 std::make_pair(8,
"s"),
242 std::make_pair(7,
"s"),
243 std::make_pair(25,
"n"),
244 std::make_pair(23,
"n"),
245 std::make_pair(23,
"n"),
246 std::make_pair(20,
"n"),
247 std::make_pair(21,
"n"),
248 std::make_pair(6,
"sw"),
249 std::make_pair(4,
"sw"),
250 std::make_pair(7,
"s"),
251 std::make_pair(7,
"s"),
252 std::make_pair(2,
"ne"),
253 std::make_pair(3,
"se"),
254 std::make_pair(2,
"s"),
255 std::make_pair(3,
"s"),
256 std::make_pair(3,
"s"),
257 std::make_pair(1,
"nw")};
259 std::vector<std::size_t> ans1;
260 std::vector<map_location::direction> ans2;
261 std::transform(generated_answers.begin(), generated_answers.end(), back_inserter(ans1), &
get_first);
262 std::transform(generated_answers.begin(), generated_answers.end(), back_inserter(ans2), &
get_second);
269 p.first =
p.first.get_direction(
d);
271 BOOST_CHECK_EQUAL(
p.first,
p.second.vector_negation());
277 std::pair<map_location, map_location>
p(
vz,
vz);
348 for (
unsigned int i = 0;
i < 7;
i++ ) {
375 for (
unsigned int i = 0;
i < 7;
i++ ) {
384 for (std::vector<map_location>::const_iterator it_a = locs.begin(); it_a != locs.end(); ++it_a) {
385 for (std::vector<map_location>::const_iterator it_b = it_a + 1; it_b != locs.end(); ++it_b) {
455 BOOST_AUTO_TEST_SUITE_END()
std::size_t distance_between(const map_location &a, const map_location &b)
Function which gives the number of hexes between two tiles (i.e.
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
Encapsulates the map of the game.
map_location & vector_difference_assign(const map_location &a)
static std::string write_direction(direction dir)
map_location vector_negation() const
map_location vector_sum(const map_location &a) const
map_location get_direction(direction dir, unsigned int n=1u) const
map_location rotate_right_around_center(const map_location ¢er, int k) const
static constexpr direction get_opposite_direction(direction d)
direction
Valid directions which can be moved in our hexagonal world.
direction get_relative_dir(const map_location &loc, map_location::RELATIVE_DIR_MODE mode) const
static direction parse_direction(const std::string &str)
static constexpr direction rotate_direction(direction d, int steps=1)
Returns the direction one would face having taken steps clockwise around an undefined center.
static const map_location & ZERO()
BOOST_FIXTURE_TEST_SUITE(test_map_location, MLFixture)
static map_location::direction n
static map_location::direction sw
static map_location vector_difference(const map_location &v1, const map_location &v2)
static std::size_t get_first(std::pair< std::size_t, std::string > arg)
static void rotate_around_centers(const std::vector< map_location > &locs)
static map_location::direction se
static void characterization_distance_direction(const std::vector< map_location > &locs, const std::vector< map_location::direction > &dir_answers, const std::vector< std::size_t > &int_answers, map_location::RELATIVE_DIR_MODE mode)
static void reality_check_get_direction_helper(const map_location &loc, const map_location::direction d)
static map_location::direction get_second(std::pair< std::size_t, std::string > arg)
BOOST_AUTO_TEST_CASE(map_location_characterization_test_radial_mode)
static std::vector< map_location > preset_locs
static std::pair< map_location, map_location > mirror_walk(std::pair< map_location, map_location > p, map_location::direction d)
static map_location::direction nw
static map_location::direction s
static map_location::direction ne
static map_location::direction legacy_get_opposite_dir(map_location::direction d)