forked from github/server
Merge pull request #552 from ennorehling/issue-551-description
issue #551 and some other tests
This commit is contained in:
commit
b5298f60bf
|
@ -4,6 +4,7 @@ module("tests.e2.movement", package.seeall, lunit.testcase)
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
eressea.settings.set("rules.food.flags", "4")
|
||||||
eressea.settings.set("nmr.timeout", "0")
|
eressea.settings.set("nmr.timeout", "0")
|
||||||
eressea.settings.set("NewbieImmunity", "0")
|
eressea.settings.set("NewbieImmunity", "0")
|
||||||
end
|
end
|
||||||
|
@ -29,7 +30,9 @@ end
|
||||||
|
|
||||||
process_orders()
|
process_orders()
|
||||||
|
|
||||||
-- write_reports()
|
if r2~=u1.region then
|
||||||
|
write_reports()
|
||||||
|
end
|
||||||
assert_equal(r2, u1.region) -- should pass, but fails!!!
|
assert_equal(r2, u1.region) -- should pass, but fails!!!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -382,6 +382,18 @@ static void test_build_destroy_road_limit(CuTest *tc)
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_build_destroy_cmd(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
faction *f;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
u->thisorder = create_order(K_DESTROY, f->locale, NULL);
|
||||||
|
CuAssertIntEquals(tc, 138, destroy_cmd(u, u->thisorder));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error138"));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_build_suite(void)
|
CuSuite *get_build_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -396,6 +408,7 @@ CuSuite *get_build_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_build_building_success);
|
SUITE_ADD_TEST(suite, test_build_building_success);
|
||||||
SUITE_ADD_TEST(suite, test_build_building_with_golem);
|
SUITE_ADD_TEST(suite, test_build_building_with_golem);
|
||||||
SUITE_ADD_TEST(suite, test_build_building_no_materials);
|
SUITE_ADD_TEST(suite, test_build_building_no_materials);
|
||||||
|
SUITE_ADD_TEST(suite, test_build_destroy_cmd);
|
||||||
SUITE_ADD_TEST(suite, test_build_destroy_road);
|
SUITE_ADD_TEST(suite, test_build_destroy_road);
|
||||||
SUITE_ADD_TEST(suite, test_build_destroy_road_limit);
|
SUITE_ADD_TEST(suite, test_build_destroy_road_limit);
|
||||||
SUITE_ADD_TEST(suite, test_build_destroy_road_guard);
|
SUITE_ADD_TEST(suite, test_build_destroy_road_guard);
|
||||||
|
|
|
@ -387,10 +387,25 @@ static void test_limited_skills(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_unit_description(CuTest *tc) {
|
||||||
|
race *rc;
|
||||||
|
unit *u;
|
||||||
|
test_setup();
|
||||||
|
rc = test_create_race("hodor");
|
||||||
|
u = test_create_unit(test_create_faction(rc), test_create_region(0,0,0));
|
||||||
|
CuAssertPtrEquals(tc, 0, u->display);
|
||||||
|
CuAssertStrEquals(tc, 0, u_description(u, u->faction->locale));
|
||||||
|
u->display = _strdup("Hodor");
|
||||||
|
CuAssertStrEquals(tc, "Hodor", u_description(u, NULL));
|
||||||
|
CuAssertStrEquals(tc, "Hodor", u_description(u, u->faction->locale));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_unit_suite(void)
|
CuSuite *get_unit_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_scale_number);
|
SUITE_ADD_TEST(suite, test_scale_number);
|
||||||
|
SUITE_ADD_TEST(suite, test_unit_description);
|
||||||
SUITE_ADD_TEST(suite, test_unit_name);
|
SUITE_ADD_TEST(suite, test_unit_name);
|
||||||
SUITE_ADD_TEST(suite, test_unit_name_from_race);
|
SUITE_ADD_TEST(suite, test_unit_name_from_race);
|
||||||
SUITE_ADD_TEST(suite, test_update_monster_name);
|
SUITE_ADD_TEST(suite, test_update_monster_name);
|
||||||
|
|
|
@ -49,7 +49,7 @@ static const char *describe_race(const race * rc, const struct locale *lang)
|
||||||
{
|
{
|
||||||
char zText[32];
|
char zText[32];
|
||||||
sprintf(zText, "describe_%s", rc->_name);
|
sprintf(zText, "describe_%s", rc->_name);
|
||||||
return LOC(lang, zText);
|
return locale_getstring(lang, zText);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void count_particles(const char *monster, int *num_prefix, int *num_name, int *num_postfix)
|
static void count_particles(const char *monster, int *num_prefix, int *num_name, int *num_postfix)
|
||||||
|
|
|
@ -26,9 +26,44 @@ static void test_transliterate(CuTest * tc)
|
||||||
CuAssertStrEquals(tc, "h?", buffer);
|
CuAssertStrEquals(tc, "h?", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_transliterations(CuTest *tc) {
|
||||||
|
const char * umlauts = "\xc3\xa4\xc3\xb6\xc3\xbc\xc3\x9f"; /* auml ouml uuml szlig nul */
|
||||||
|
void * tokens = 0;
|
||||||
|
variant id;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
id.i = 3;
|
||||||
|
addtoken(&tokens, umlauts, id);
|
||||||
|
/* transliteration is the real magic */
|
||||||
|
result = findtoken(tokens, "AEoeUEss", &id);
|
||||||
|
CuAssertIntEquals(tc, E_TOK_SUCCESS, result);
|
||||||
|
CuAssertIntEquals(tc, 3, id.i);
|
||||||
|
|
||||||
|
result = findtoken(tokens, umlauts, &id);
|
||||||
|
CuAssertIntEquals(tc, E_TOK_SUCCESS, result);
|
||||||
|
CuAssertIntEquals(tc, 3, id.i);
|
||||||
|
|
||||||
|
freetokens(tokens);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_directions(CuTest * tc)
|
||||||
|
{
|
||||||
|
void * tokens = 0;
|
||||||
|
variant id;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
id.i = 2;
|
||||||
|
addtoken(&tokens, "nw", id);
|
||||||
|
addtoken(&tokens, "northwest", id);
|
||||||
|
|
||||||
|
result = findtoken(tokens, "northw", &id);
|
||||||
|
CuAssertIntEquals(tc, E_TOK_SUCCESS, result);
|
||||||
|
CuAssertIntEquals(tc, 2, id.i);
|
||||||
|
freetokens(tokens);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_umlaut(CuTest * tc)
|
static void test_umlaut(CuTest * tc)
|
||||||
{
|
{
|
||||||
const char * umlauts = "\xc3\xa4\xc3\xb6\xc3\xbc\xc3\x9f"; /* auml ouml uuml szlig nul */
|
|
||||||
void * tokens = 0;
|
void * tokens = 0;
|
||||||
variant id;
|
variant id;
|
||||||
int result;
|
int result;
|
||||||
|
@ -41,8 +76,7 @@ static void test_umlaut(CuTest * tc)
|
||||||
addtoken(&tokens, "herpderp", id);
|
addtoken(&tokens, "herpderp", id);
|
||||||
id.i = 2;
|
id.i = 2;
|
||||||
addtoken(&tokens, "derp", id);
|
addtoken(&tokens, "derp", id);
|
||||||
id.i = 3;
|
addtoken(&tokens, "d", id);
|
||||||
addtoken(&tokens, umlauts, id);
|
|
||||||
|
|
||||||
/* we can find substrings if they are significant */
|
/* we can find substrings if they are significant */
|
||||||
result = findtoken(tokens, "herp", &id);
|
result = findtoken(tokens, "herp", &id);
|
||||||
|
@ -57,15 +91,6 @@ static void test_umlaut(CuTest * tc)
|
||||||
CuAssertIntEquals(tc, E_TOK_SUCCESS, findtoken(tokens, "DERP", &id));
|
CuAssertIntEquals(tc, E_TOK_SUCCESS, findtoken(tokens, "DERP", &id));
|
||||||
CuAssertIntEquals(tc, 2, id.i);
|
CuAssertIntEquals(tc, 2, id.i);
|
||||||
|
|
||||||
result = findtoken(tokens, umlauts, &id);
|
|
||||||
CuAssertIntEquals(tc, E_TOK_SUCCESS, result);
|
|
||||||
CuAssertIntEquals(tc, 3, id.i);
|
|
||||||
|
|
||||||
/* transliteration is the real magic */
|
|
||||||
result = findtoken(tokens, "AEoeUEss", &id);
|
|
||||||
CuAssertIntEquals(tc, E_TOK_SUCCESS, result);
|
|
||||||
CuAssertIntEquals(tc, 3, id.i);
|
|
||||||
|
|
||||||
result = findtoken(tokens, "herp-a-derp", &id);
|
result = findtoken(tokens, "herp-a-derp", &id);
|
||||||
CuAssertIntEquals(tc, E_TOK_NOMATCH, result);
|
CuAssertIntEquals(tc, E_TOK_NOMATCH, result);
|
||||||
|
|
||||||
|
@ -76,6 +101,8 @@ CuSuite *get_umlaut_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_umlaut);
|
SUITE_ADD_TEST(suite, test_umlaut);
|
||||||
|
SUITE_ADD_TEST(suite, test_directions);
|
||||||
SUITE_ADD_TEST(suite, test_transliterate);
|
SUITE_ADD_TEST(suite, test_transliterate);
|
||||||
|
SUITE_ADD_TEST(suite, test_transliterations);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue