2015-11-09 13:41:53 +01:00
|
|
|
#include <platform.h>
|
|
|
|
|
|
|
|
#include "otherfaction.h"
|
|
|
|
|
|
|
|
#include <kernel/config.h>
|
|
|
|
#include <kernel/unit.h>
|
|
|
|
#include <kernel/region.h>
|
|
|
|
#include <kernel/faction.h>
|
|
|
|
|
2018-09-29 11:37:17 +02:00
|
|
|
#include <kernel/attrib.h>
|
2015-11-09 13:41:53 +01:00
|
|
|
|
|
|
|
#include <CuTest.h>
|
|
|
|
#include <tests.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
static void test_rules(CuTest *tc) {
|
2016-08-29 15:21:28 +02:00
|
|
|
test_setup();
|
2015-11-22 10:33:31 +01:00
|
|
|
config_set("stealth.faction.other", NULL);
|
2015-11-09 13:41:53 +01:00
|
|
|
CuAssertIntEquals(tc, true, rule_stealth_other());
|
2015-11-22 10:33:31 +01:00
|
|
|
config_set("stealth.faction.other", "0");
|
2015-11-09 13:41:53 +01:00
|
|
|
CuAssertIntEquals(tc, false, rule_stealth_other());
|
2015-11-22 10:33:31 +01:00
|
|
|
config_set("stealth.faction.other", "1");
|
2015-11-09 13:41:53 +01:00
|
|
|
CuAssertIntEquals(tc, true, rule_stealth_other());
|
|
|
|
|
2015-11-22 10:33:31 +01:00
|
|
|
config_set("stealth.faction.anon", NULL);
|
2015-11-09 13:41:53 +01:00
|
|
|
CuAssertIntEquals(tc, true, rule_stealth_anon());
|
2015-11-22 10:33:31 +01:00
|
|
|
config_set("stealth.faction.anon", "0");
|
2015-11-09 13:41:53 +01:00
|
|
|
CuAssertIntEquals(tc, false, rule_stealth_anon());
|
2015-11-22 10:33:31 +01:00
|
|
|
config_set("stealth.faction.anon", "1");
|
2015-11-09 13:41:53 +01:00
|
|
|
CuAssertIntEquals(tc, true, rule_stealth_anon());
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2015-11-09 13:41:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_otherfaction(CuTest *tc) {
|
|
|
|
unit *u;
|
|
|
|
faction *f;
|
|
|
|
|
2016-08-29 15:21:28 +02:00
|
|
|
test_setup();
|
2018-01-14 09:38:26 +01:00
|
|
|
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
|
|
|
f = test_create_faction(NULL);
|
2015-11-22 10:33:31 +01:00
|
|
|
config_set("stealth.faction.other", "1");
|
2015-11-09 13:41:53 +01:00
|
|
|
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));
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2015-11-09 13:41:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CuSuite *get_otherfaction_suite(void)
|
|
|
|
{
|
|
|
|
CuSuite *suite = CuSuiteNew();
|
|
|
|
SUITE_ADD_TEST(suite, test_rules);
|
|
|
|
SUITE_ADD_TEST(suite, test_otherfaction);
|
|
|
|
return suite;
|
|
|
|
}
|