forked from github/server
add mail_cmd tests for REGION
This commit is contained in:
parent
070ed1a941
commit
403b8a2e7e
2 changed files with 30 additions and 5 deletions
|
@ -1003,7 +1003,7 @@ static unit * setup_mail_cmd(void) {
|
||||||
return test_create_unit(f, test_create_region(0, 0, 0));
|
return test_create_unit(f, test_create_region(0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_mail_cmd(CuTest *tc) {
|
static void test_mail_unit(CuTest *tc) {
|
||||||
order *ord;
|
order *ord;
|
||||||
unit *u;
|
unit *u;
|
||||||
|
|
||||||
|
@ -1014,7 +1014,18 @@ static void test_mail_cmd(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_mail_cmd_no_msg(CuTest *tc) {
|
static void test_mail_region(CuTest *tc) {
|
||||||
|
order *ord;
|
||||||
|
unit *u;
|
||||||
|
|
||||||
|
u = setup_mail_cmd();
|
||||||
|
ord = create_order(K_MAIL, u->faction->locale, "REGION 'Hodor!'", itoa36(u->no));
|
||||||
|
mail_cmd(u, ord);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(u->region->msgs, "mail_result"));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_mail_unit_no_msg(CuTest *tc) {
|
||||||
unit *u;
|
unit *u;
|
||||||
order *ord;
|
order *ord;
|
||||||
|
|
||||||
|
@ -1026,6 +1037,18 @@ static void test_mail_cmd_no_msg(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_mail_region_no_msg(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
order *ord;
|
||||||
|
|
||||||
|
u = setup_mail_cmd();
|
||||||
|
ord = create_order(K_MAIL, u->faction->locale, "REGION");
|
||||||
|
mail_cmd(u, ord);
|
||||||
|
CuAssertPtrEquals(tc, 0, test_find_messagetype(u->region->msgs, "mail_result"));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error30"));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_laws_suite(void)
|
CuSuite *get_laws_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -1070,8 +1093,10 @@ CuSuite *get_laws_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_force_leave_ships);
|
SUITE_ADD_TEST(suite, test_force_leave_ships);
|
||||||
SUITE_ADD_TEST(suite, test_force_leave_ships_on_ocean);
|
SUITE_ADD_TEST(suite, test_force_leave_ships_on_ocean);
|
||||||
SUITE_ADD_TEST(suite, test_peasant_luck_effect);
|
SUITE_ADD_TEST(suite, test_peasant_luck_effect);
|
||||||
SUITE_ADD_TEST(suite, test_mail_cmd);
|
SUITE_ADD_TEST(suite, test_mail_unit);
|
||||||
SUITE_ADD_TEST(suite, test_mail_cmd_no_msg);
|
SUITE_ADD_TEST(suite, test_mail_region);
|
||||||
|
SUITE_ADD_TEST(suite, test_mail_unit_no_msg);
|
||||||
|
SUITE_ADD_TEST(suite, test_mail_region_no_msg);
|
||||||
(void)test_luck_message; /* disabled, breaks on travis */
|
(void)test_luck_message; /* disabled, breaks on travis */
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
|
|
|
@ -257,7 +257,7 @@ const char * test_get_messagetype(const message *msg) {
|
||||||
|
|
||||||
struct message * test_find_messagetype(struct message_list *msgs, const char *name) {
|
struct message * test_find_messagetype(struct message_list *msgs, const char *name) {
|
||||||
struct mlist *ml;
|
struct mlist *ml;
|
||||||
assert(msgs);
|
if (!msgs) return 0;
|
||||||
for (ml = msgs->begin; ml; ml = ml->next) {
|
for (ml = msgs->begin; ml; ml = ml->next) {
|
||||||
if (strcmp(name, test_get_messagetype(ml->msg)) == 0) {
|
if (strcmp(name, test_get_messagetype(ml->msg)) == 0) {
|
||||||
return ml->msg;
|
return ml->msg;
|
||||||
|
|
Loading…
Reference in a new issue