2014-06-16 03:34:39 +02:00
|
|
|
#include <platform.h>
|
2014-08-27 20:10:17 +02:00
|
|
|
|
2014-06-16 03:34:39 +02:00
|
|
|
#include "direction.h"
|
|
|
|
#include "tests.h"
|
|
|
|
|
2016-09-05 17:57:59 +02:00
|
|
|
#include <util/umlaut.h>
|
2014-08-27 21:09:39 +02:00
|
|
|
#include <util/language.h>
|
2014-08-27 20:10:17 +02:00
|
|
|
|
2014-06-16 03:34:39 +02:00
|
|
|
#include <CuTest.h>
|
|
|
|
|
2014-06-16 17:01:59 +02:00
|
|
|
static void test_init_directions(CuTest *tc) {
|
2014-06-16 03:34:39 +02:00
|
|
|
struct locale *lang;
|
|
|
|
|
2016-09-04 22:52:09 +02:00
|
|
|
test_setup();
|
2016-03-23 22:24:11 +01:00
|
|
|
lang = get_or_create_locale("de");
|
2014-06-16 03:34:39 +02:00
|
|
|
locale_setstring(lang, "dir_nw", "NW");
|
|
|
|
init_directions(lang);
|
2014-06-16 07:17:08 +02:00
|
|
|
CuAssertIntEquals(tc, D_NORTHWEST, get_direction("nw", lang));
|
2014-06-16 03:34:39 +02:00
|
|
|
test_cleanup();
|
|
|
|
}
|
|
|
|
|
2014-06-16 17:01:59 +02:00
|
|
|
static void test_init_direction(CuTest *tc) {
|
2014-06-16 03:34:39 +02:00
|
|
|
struct locale *lang;
|
2016-09-04 22:52:09 +02:00
|
|
|
test_setup();
|
2014-06-16 03:34:39 +02:00
|
|
|
|
2014-06-16 07:17:08 +02:00
|
|
|
lang = get_or_create_locale("de");
|
2014-06-16 03:34:39 +02:00
|
|
|
init_direction(lang, D_NORTHWEST, "NW");
|
2016-09-04 22:52:09 +02:00
|
|
|
init_direction(lang, D_NORTHWEST, "northwest");
|
2014-06-16 03:34:39 +02:00
|
|
|
init_direction(lang, D_EAST, "OST");
|
2016-09-04 22:52:09 +02:00
|
|
|
init_direction(lang, D_EAST, "O");
|
2014-06-16 07:17:08 +02:00
|
|
|
CuAssertIntEquals(tc, D_NORTHWEST, get_direction("nw", lang));
|
2016-09-04 22:52:09 +02:00
|
|
|
CuAssertIntEquals(tc, D_NORTHWEST, get_direction("northwest", lang));
|
2014-06-16 07:17:08 +02:00
|
|
|
CuAssertIntEquals(tc, D_EAST, get_direction("ost", lang));
|
2016-09-04 22:52:09 +02:00
|
|
|
CuAssertIntEquals(tc, D_EAST, get_direction("O", lang));
|
2014-06-16 07:17:08 +02:00
|
|
|
CuAssertIntEquals(tc, NODIRECTION, get_direction("east", lang));
|
2014-06-16 03:34:39 +02:00
|
|
|
test_cleanup();
|
|
|
|
}
|
|
|
|
|
2014-06-16 17:01:59 +02:00
|
|
|
static void test_finddirection(CuTest *tc) {
|
2016-09-04 22:52:09 +02:00
|
|
|
test_setup();
|
2014-06-16 07:17:08 +02:00
|
|
|
CuAssertIntEquals(tc, D_SOUTHWEST, finddirection("southwest"));
|
|
|
|
CuAssertIntEquals(tc, D_SOUTHEAST, finddirection("southeast"));
|
|
|
|
CuAssertIntEquals(tc, D_NORTHWEST, finddirection("northwest"));
|
|
|
|
CuAssertIntEquals(tc, D_NORTHEAST, finddirection("northeast"));
|
|
|
|
CuAssertIntEquals(tc, D_WEST, finddirection("west"));
|
|
|
|
CuAssertIntEquals(tc, D_EAST, finddirection("east"));
|
|
|
|
CuAssertIntEquals(tc, D_PAUSE, finddirection("pause"));
|
|
|
|
CuAssertIntEquals(tc, NODIRECTION, finddirection(""));
|
|
|
|
CuAssertIntEquals(tc, NODIRECTION, finddirection("potato"));
|
2016-09-04 22:52:09 +02:00
|
|
|
test_cleanup();
|
2014-06-16 07:17:08 +02:00
|
|
|
}
|
|
|
|
|
2014-06-16 03:34:39 +02:00
|
|
|
CuSuite *get_direction_suite(void)
|
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
CuSuite *suite = CuSuiteNew();
|
|
|
|
SUITE_ADD_TEST(suite, test_init_direction);
|
|
|
|
SUITE_ADD_TEST(suite, test_init_directions);
|
|
|
|
SUITE_ADD_TEST(suite, test_finddirection);
|
|
|
|
return suite;
|
2014-06-16 03:34:39 +02:00
|
|
|
}
|
|
|
|
|