From 2aafa2b54f4c781051f4fbccb7aef6aa2312feaa Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 9 Nov 2015 13:41:53 +0100 Subject: [PATCH] missing test file --- src/attributes/otherfaction.test.c | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/attributes/otherfaction.test.c diff --git a/src/attributes/otherfaction.test.c b/src/attributes/otherfaction.test.c new file mode 100644 index 000000000..0b38901eb --- /dev/null +++ b/src/attributes/otherfaction.test.c @@ -0,0 +1,57 @@ +#include + +#include "otherfaction.h" + +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +static void test_rules(CuTest *tc) { + test_cleanup(); + set_param(&global.parameters, "stealth.faction.other", NULL); + CuAssertIntEquals(tc, true, rule_stealth_other()); + set_param(&global.parameters, "stealth.faction.other", "0"); + CuAssertIntEquals(tc, false, rule_stealth_other()); + set_param(&global.parameters, "stealth.faction.other", "1"); + CuAssertIntEquals(tc, true, rule_stealth_other()); + + set_param(&global.parameters, "stealth.faction.anon", NULL); + CuAssertIntEquals(tc, true, rule_stealth_anon()); + set_param(&global.parameters, "stealth.faction.anon", "0"); + CuAssertIntEquals(tc, false, rule_stealth_anon()); + set_param(&global.parameters, "stealth.faction.anon", "1"); + CuAssertIntEquals(tc, true, rule_stealth_anon()); + test_cleanup(); +} + +static void test_otherfaction(CuTest *tc) { + unit *u; + faction *f; + + test_cleanup(); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + f = test_create_faction(0); + set_param(&global.parameters, "stealth.faction.other", "1"); + CuAssertIntEquals(tc, true, rule_stealth_other()); + CuAssertPtrEquals(tc, u->faction, visible_faction(f, u)); + a_add(&u->attribs, make_otherfaction(f)); + CuAssertPtrEquals(tc, f, visible_faction(f, u)); + test_cleanup(); +} + +CuSuite *get_otherfaction_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_rules); + SUITE_ADD_TEST(suite, test_otherfaction); + return suite; +}