forked from github/server
bugfix: KONTAKTIERE ohne Parameter crasht.
This commit is contained in:
parent
4e9d35adec
commit
141e95c5c9
|
@ -115,13 +115,13 @@ int contact_cmd(unit * u, order * ord)
|
|||
}
|
||||
else {
|
||||
/* old-style syntax, KONTAKTIERE foo */
|
||||
unit *u2;
|
||||
unit *u2 = NULL;
|
||||
int n = 0;
|
||||
if (p == P_TEMP) {
|
||||
n = getid();
|
||||
u2 = findnewunit(u->region, u->faction, n);
|
||||
}
|
||||
else {
|
||||
else if (str) {
|
||||
n = atoi36((const char *)str);
|
||||
u2 = findunit(n);
|
||||
}
|
||||
|
|
|
@ -74,11 +74,73 @@ static void test_contact_cmd(CuTest *tc) {
|
|||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_contact_cmd_invalid(CuTest *tc) {
|
||||
struct unit *u;
|
||||
struct region *r;
|
||||
const struct locale *lang;
|
||||
struct order *ord;
|
||||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
lang = u->faction->locale;
|
||||
|
||||
/* KONTAKTIERE EINHEIT <not-found> */
|
||||
ord = create_order(K_CONTACT, u->faction->locale, "%s %i",
|
||||
LOC(lang, parameters[P_UNIT]), u->no + 1);
|
||||
contact_cmd(u, ord);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "feedback_unit_not_found"));
|
||||
free_order(ord);
|
||||
test_clear_messages(u->faction);
|
||||
|
||||
/* KONTAKTIERE EINHEIT TEMP <not-found> */
|
||||
ord = create_order(K_CONTACT, u->faction->locale, "%s %s %i",
|
||||
LOC(lang, parameters[P_UNIT]), LOC(lang, parameters[P_TEMP]), u->no + 1);
|
||||
contact_cmd(u, ord);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "feedback_unit_not_found"));
|
||||
free_order(ord);
|
||||
test_clear_messages(u->faction);
|
||||
|
||||
/* KONTAKTIERE EINHEIT TEMP */
|
||||
ord = create_order(K_CONTACT, u->faction->locale, "%s %s",
|
||||
LOC(lang, parameters[P_UNIT]), LOC(lang, parameters[P_TEMP]));
|
||||
contact_cmd(u, ord);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "feedback_unit_not_found"));
|
||||
free_order(ord);
|
||||
test_clear_messages(u->faction);
|
||||
|
||||
/* KONTAKTIERE EINHEIT */
|
||||
ord = create_order(K_CONTACT, u->faction->locale,
|
||||
LOC(lang, parameters[P_UNIT]));
|
||||
contact_cmd(u, ord);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "feedback_unit_not_found"));
|
||||
free_order(ord);
|
||||
test_clear_messages(u->faction);
|
||||
|
||||
/* KONTAKTIERE TEMP */
|
||||
ord = create_order(K_CONTACT, u->faction->locale,
|
||||
LOC(lang, parameters[P_TEMP]));
|
||||
contact_cmd(u, ord);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "feedback_unit_not_found"));
|
||||
free_order(ord);
|
||||
test_clear_messages(u->faction);
|
||||
|
||||
/* KONTAKTIERE */
|
||||
ord = create_order(K_CONTACT, u->faction->locale, NULL);
|
||||
contact_cmd(u, ord);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "feedback_unit_not_found"));
|
||||
free_order(ord);
|
||||
test_clear_messages(u->faction);
|
||||
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_contact_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_contact);
|
||||
SUITE_ADD_TEST(suite, test_contact_cmd);
|
||||
SUITE_ADD_TEST(suite, test_contact_cmd_invalid);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue