add a failing test for bug 1685

This commit is contained in:
Enno Rehling 2015-09-05 18:14:28 +02:00
parent 4dc94323d8
commit 2e3c0db02a
4 changed files with 38 additions and 0 deletions

View File

@ -296,6 +296,31 @@ static void test_give_denied_by_rules(CuTest * tc) {
test_cleanup(); test_cleanup();
} }
static void test_give_invalid_target(CuTest *tc) {
// bug https://bugs.eressea.de/view.php?id=1685
struct give env;
order *ord;
struct locale * lang;
test_cleanup();
env.f1 = test_create_faction(0);
env.f2 = 0;
setup_give(&env);
i_change(&env.src->items, env.itype, 10);
lang = get_or_create_locale("test");
env.f1->locale = lang;
locale_setstring(lang, "KRAEUTER", "HERBS");
init_locale(lang);
ord = create_order(K_GIVE, lang, "## HERBS");
assert(ord);
give_cmd(env.src, ord);
CuAssertIntEquals(tc, 10, i_get(env.src->items, env.itype));
CuAssertPtrNotNull(tc, test_find_messagetype(env.f1->msgs, "feedback_unit_not_found"));
test_cleanup();
}
CuSuite *get_give_suite(void) CuSuite *get_give_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
@ -315,5 +340,6 @@ CuSuite *get_give_suite(void)
SUITE_ADD_TEST(suite, test_give_herbs); SUITE_ADD_TEST(suite, test_give_herbs);
SUITE_ADD_TEST(suite, test_give_okay); SUITE_ADD_TEST(suite, test_give_okay);
SUITE_ADD_TEST(suite, test_give_denied_by_rules); SUITE_ADD_TEST(suite, test_give_denied_by_rules);
SUITE_ADD_TEST(suite, test_give_invalid_target);
return suite; return suite;
} }

View File

@ -1025,6 +1025,16 @@ typedef struct param {
char *data; char *data;
} param; } param;
void free_params(struct param **pp) {
while (*pp) {
param *p = *pp;
free(p->name);
free(p->data);
*pp = p->next;
free(p);
}
}
const char *get_param(const struct param *p, const char *key) const char *get_param(const struct param *p, const char *key)
{ {
while (p != NULL) { while (p != NULL) {

View File

@ -277,6 +277,7 @@ extern "C" {
int get_param_int(const struct param *p, const char *key, int def); int get_param_int(const struct param *p, const char *key, int def);
int check_param(const struct param *p, const char *key, const char *searchvalue); int check_param(const struct param *p, const char *key, const char *searchvalue);
float get_param_flt(const struct param *p, const char *key, float def); float get_param_flt(const struct param *p, const char *key, float def);
void free_params(struct param **pp);
bool ExpensiveMigrants(void); bool ExpensiveMigrants(void);
int NMRTimeout(void); int NMRTimeout(void);

View File

@ -73,6 +73,7 @@ void test_cleanup(void)
free_resources(); free_resources();
global.functions.maintenance = NULL; global.functions.maintenance = NULL;
global.functions.wage = NULL; global.functions.wage = NULL;
free_params(&global.parameters);
default_locale = 0; default_locale = 0;
free_locales(); free_locales();
free_spells(); free_spells();