15 #define GETTEXT_DOMAIN "wesnoth-test"
17 #include <boost/assign/list_of.hpp>
19 #include <boost/test/unit_test.hpp>
24 static map_location va,
vb,
vc,
vz,
vt1,
vt2,
vt3,
vs1,
vs2,
vs3,
vs4;
50 preset_locs.push_back(va);
51 preset_locs.push_back(vb);
52 preset_locs.push_back(vc);
53 preset_locs.push_back(vz);
54 preset_locs.push_back(vt1);
55 preset_locs.push_back(vt2);
56 preset_locs.push_back(vt3);
57 preset_locs.push_back(vs1);
58 preset_locs.push_back(vs2);
59 preset_locs.push_back(vs3);
60 preset_locs.push_back(vs4);
72 #ifndef MAP_LOCATION_GET_OUTPUT
83 BOOST_CHECK_EQUAL(dir_answers.size(), int_answers.size());
85 std::vector<map_location::DIRECTION>::const_iterator dir_it = dir_answers.begin();
86 std::vector<size_t>::const_iterator int_it = int_answers.begin();
88 for (std::vector<map_location>::const_iterator it_a = locs.begin(); it_a != locs.end(); ++it_a) {
89 for (std::vector<map_location>::const_iterator it_b = it_a + 1; it_b != locs.end(); ++it_b) {
92 #ifdef MAP_LOCATION_GET_OUTPUT
96 int expected_dist = *(int_it++);
107 temp1.vector_difference_assign(b);
113 for (std::vector<map_location>::const_iterator it_c = it_b + 1; it_c != locs.end(); ++it_c) {
127 BOOST_CHECK_MESSAGE( dir_it == dir_answers.end(),
"Did not exhaust answers list.");
128 BOOST_CHECK_MESSAGE( int_it == int_answers.end(),
"Did not exhaust answers list.");
131 static size_t get_first (std::pair<size_t, std::string> arg) {
return arg.first; }
204 std::vector<std::pair<size_t, std::string> > generated_answers = boost::assign::list_of(std::make_pair(7,
"se"))
205 (std::make_pair(6,
"sw"))
206 (std::make_pair(6,
"n"))
207 (std::make_pair(12,
"n"))
208 (std::make_pair(16,
"s"))
209 (std::make_pair(9,
"n"))
210 (std::make_pair(7,
"nw"))
211 (std::make_pair(7,
"n"))
212 (std::make_pair(4,
"n"))
213 (std::make_pair(5,
"nw"))
214 (std::make_pair(10,
"sw"))
215 (std::make_pair(13,
"nw"))
216 (std::make_pair(19,
"nw"))
217 (std::make_pair(9,
"s"))
218 (std::make_pair(16,
"n"))
219 (std::make_pair(14,
"nw"))
220 (std::make_pair(14,
"nw"))
221 (std::make_pair(11,
"nw"))
222 (std::make_pair(12,
"nw"))
223 (std::make_pair(9,
"n"))
224 (std::make_pair(15,
"n"))
225 (std::make_pair(13,
"se"))
226 (std::make_pair(15,
"n"))
227 (std::make_pair(10,
"n"))
228 (std::make_pair(11,
"n"))
229 (std::make_pair(8,
"n"))
230 (std::make_pair(8,
"n"))
231 (std::make_pair(6,
"n"))
232 (std::make_pair(22,
"s"))
233 (std::make_pair(6,
"ne"))
234 (std::make_pair(1,
"nw"))
235 (std::make_pair(2,
"ne"))
236 (std::make_pair(2,
"s"))
237 (std::make_pair(1,
"s"))
238 (std::make_pair(28,
"s"))
239 (std::make_pair(6,
"se"))
240 (std::make_pair(5,
"s"))
241 (std::make_pair(5,
"se"))
242 (std::make_pair(8,
"s"))
243 (std::make_pair(7,
"s"))
244 (std::make_pair(25,
"n"))
245 (std::make_pair(23,
"n"))
246 (std::make_pair(23,
"n"))
247 (std::make_pair(20,
"n"))
248 (std::make_pair(21,
"n"))
249 (std::make_pair(6,
"sw"))
250 (std::make_pair(4,
"sw"))
251 (std::make_pair(7,
"s"))
252 (std::make_pair(7,
"s"))
253 (std::make_pair(2,
"ne"))
254 (std::make_pair(3,
"se"))
255 (std::make_pair(2,
"s"))
256 (std::make_pair(3,
"s"))
257 (std::make_pair(3,
"s"))
258 (std::make_pair(1,
"nw")).to_container(generated_answers);
260 std::vector<size_t> ans1;
261 std::vector<map_location::DIRECTION> ans2;
270 p.first = p.first.get_direction(d);
272 BOOST_CHECK_EQUAL(p.first, p.second.vector_negation());
278 std::pair<map_location, map_location>
p(vz,vz);
349 for (
unsigned int i = 0;
i < 7;
i++ ) {
376 for (
unsigned int i = 0;
i < 7;
i++ ) {
385 for (std::vector<map_location>::const_iterator it_a = locs.begin(); it_a != locs.end(); ++it_a) {
386 for (std::vector<map_location>::const_iterator it_b = it_a + 1; it_b != locs.end(); ++it_b) {
456 BOOST_AUTO_TEST_SUITE_END()
static DIRECTION parse_direction(const std::string &str)
map_location rotate_right_around_center(const map_location ¢er, int k) const
static const map_location & ZERO()
Old implementation:
static void rotate_around_centers(const std::vector< map_location > &locs)
GLfloat GLfloat GLfloat v2
map_location & vector_difference_assign(const map_location &a)
static map_location::DIRECTION legacy_get_opposite_dir(map_location::DIRECTION d)
static std::vector< map_location > preset_locs
BOOST_AUTO_TEST_SUITE(test_map_location)
DIRECTION get_relative_dir(const map_location &loc, map_location::RELATIVE_DIR_MODE mode) const
static map_location vector_difference(const map_location &v1, const map_location &v2)
GLdouble GLdouble GLdouble b
GLuint GLenum GLenum transform
static void characterization_distance_direction(const std::vector< map_location > &locs, const std::vector< map_location::DIRECTION > &dir_answers, const std::vector< size_t > &int_answers, map_location::RELATIVE_DIR_MODE mode)
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
static void reality_check_get_direction_helper(const map_location &loc, const map_location::DIRECTION d)
size_t distance_between(const map_location &a, const map_location &b)
Function which gives the number of hexes between two tiles (i.e.
map_location vector_sum(const map_location &a) const
GLboolean GLboolean GLboolean GLboolean a
static DIRECTION get_opposite_dir(DIRECTION d)
static map_location::DIRECTION se
Encapsulates the map of the game.
static map_location::DIRECTION get_second(std::pair< size_t, std::string > arg)
static DIRECTION rotate_right(DIRECTION d, unsigned int k=1u)
Inlined bodies.
DIRECTION
Valid directions which can be moved in our hexagonal world.
static map_location::DIRECTION sw
BOOST_GLOBAL_FIXTURE(MLFixture)
static map_location::DIRECTION nw
static size_t get_first(std::pair< size_t, std::string > arg)
map_location get_direction(DIRECTION d, unsigned int n=1u) const
map_location vector_negation() const
Inline vector ops.
static map_location::DIRECTION ne
static std::pair< map_location, map_location > mirror_walk(std::pair< map_location, map_location > p, map_location::DIRECTION d)
BOOST_AUTO_TEST_CASE(map_location_characterization_test_radial_mode)
static std::string write_direction(DIRECTION dir)