2012-06-30 20:07:28 +02:00
|
|
|
#include <platform.h>
|
|
|
|
#include "types.h"
|
|
|
|
#include "ally.h"
|
|
|
|
|
|
|
|
#include <CuTest.h>
|
|
|
|
#include <tests.h>
|
|
|
|
|
|
|
|
static void test_ally(CuTest * tc)
|
|
|
|
{
|
2018-10-26 21:49:58 +02:00
|
|
|
struct ally * al = NULL;
|
|
|
|
struct faction * f;
|
2012-06-30 20:07:28 +02:00
|
|
|
|
2018-10-26 21:49:58 +02:00
|
|
|
test_setup();
|
|
|
|
f = test_create_faction(NULL);
|
|
|
|
ally_set(&al, f, HELP_GUARD);
|
2014-10-31 15:38:37 +01:00
|
|
|
CuAssertPtrNotNull(tc, al);
|
2018-10-26 21:49:58 +02:00
|
|
|
CuAssertIntEquals(tc, HELP_GUARD, ally_get(al, f));
|
2012-06-30 20:07:28 +02:00
|
|
|
|
2018-10-26 21:49:58 +02:00
|
|
|
ally_set(&al, f, 0);
|
2018-10-14 11:48:21 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, al);
|
2018-10-26 21:49:58 +02:00
|
|
|
CuAssertIntEquals(tc, 0, ally_get(al, f));
|
|
|
|
allies_free(al);
|
|
|
|
test_teardown();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_allies_clone(CuTest * tc)
|
|
|
|
{
|
|
|
|
struct ally * al = NULL, *ac;
|
|
|
|
struct faction * f;
|
|
|
|
|
|
|
|
test_setup();
|
|
|
|
f = test_create_faction(NULL);
|
|
|
|
CuAssertPtrEquals(tc, NULL, allies_clone(NULL));
|
|
|
|
|
|
|
|
ally_set(&al, f, HELP_GUARD);
|
|
|
|
ac = allies_clone(al);
|
|
|
|
CuAssertPtrNotNull(tc, ac);
|
|
|
|
CuAssertTrue(tc, al != ac);
|
|
|
|
CuAssertIntEquals(tc, HELP_GUARD, ally_get(ac, f));
|
|
|
|
CuAssertIntEquals(tc, HELP_GUARD, ally_get(al, f));
|
|
|
|
allies_free(al);
|
|
|
|
allies_free(ac);
|
|
|
|
test_teardown();
|
2012-06-30 20:07:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CuSuite *get_ally_suite(void)
|
|
|
|
{
|
2014-10-31 15:38:37 +01:00
|
|
|
CuSuite *suite = CuSuiteNew();
|
|
|
|
SUITE_ADD_TEST(suite, test_ally);
|
2018-10-26 21:49:58 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_allies_clone);
|
2014-10-31 15:38:37 +01:00
|
|
|
return suite;
|
2012-06-30 20:07:28 +02:00
|
|
|
}
|
2014-06-16 03:34:39 +02:00
|
|
|
|