server/src/kernel/skills.test.c

42 lines
1.1 KiB
C
Raw Normal View History

2018-01-17 18:04:04 +01:00
#ifdef _MSC_VER
#include <platform.h>
#endif
#include "skills.h"
#include "config.h"
2018-01-17 18:04:04 +01:00
#include "unit.h"
#include <CuTest.h>
#include <tests.h>
static void test_skills(CuTest * tc)
{
unit *u;
test_setup();
config_set_int("study.random_progress", 0);
2018-01-17 18:04:04 +01:00
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
CuAssertPtrEquals(tc, NULL, u->skills);
CuAssertIntEquals(tc, 0, u->skill_size);
CuAssertIntEquals(tc, 0, get_level(u, SK_CROSSBOW));
set_level(u, SK_CROSSBOW, 1);
CuAssertPtrNotNull(tc, u->skills);
CuAssertIntEquals(tc, 1, u->skill_size);
CuAssertIntEquals(tc, SK_CROSSBOW, u->skills->id);
CuAssertIntEquals(tc, 1, u->skills->level);
CuAssertIntEquals(tc, 2, u->skills->weeks);
2018-01-17 18:04:04 +01:00
CuAssertIntEquals(tc, 1, get_level(u, SK_CROSSBOW));
set_level(u, SK_CROSSBOW, 0);
CuAssertPtrEquals(tc, NULL, u->skills);
CuAssertIntEquals(tc, 0, u->skill_size);
test_teardown();
}
CuSuite *get_skills_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_skills);
return suite;
}