narrow down test failure to a unit test.

learn_skill doesn't use u->number!
This commit is contained in:
Enno Rehling 2016-03-13 13:42:26 +01:00
parent c91da12883
commit 18c8148b74
1 changed files with 22 additions and 2 deletions

View File

@ -230,7 +230,7 @@ static void test_academy_building(CuTest *tc) {
test_cleanup(); test_cleanup();
} }
void test_learn_skill(CuTest *tc) { void test_learn_skill_single(CuTest *tc) {
unit *u; unit *u;
skill *sv; skill *sv;
test_cleanup(); test_cleanup();
@ -248,6 +248,25 @@ void test_learn_skill(CuTest *tc) {
test_cleanup(); test_cleanup();
} }
void test_learn_skill_multi(CuTest *tc) {
unit *u;
skill *sv;
test_cleanup();
u = test_create_unit(0, 0);
scale_number(u, 10);
learn_skill(u, SK_ALCHEMY, STUDYDAYS * u->number);
CuAssertPtrNotNull(tc, sv = u->skills);
CuAssertIntEquals(tc, SK_ALCHEMY, sv->id);
CuAssertIntEquals(tc, 1, sv->level);
CuAssertIntEquals(tc, 2, sv->weeks);
learn_skill(u, SK_ALCHEMY, STUDYDAYS * u->number);
CuAssertIntEquals(tc, 1, sv->weeks);
learn_skill(u, SK_ALCHEMY, STUDYDAYS * u->number * 2);
CuAssertIntEquals(tc, 2, sv->level);
CuAssertIntEquals(tc, 1, sv->weeks);
test_cleanup();
}
void test_demon_skillchanges(CuTest *tc) { void test_demon_skillchanges(CuTest *tc) {
unit * u; unit * u;
race * rc; race * rc;
@ -264,7 +283,8 @@ void test_demon_skillchanges(CuTest *tc) {
CuSuite *get_study_suite(void) CuSuite *get_study_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_learn_skill); SUITE_ADD_TEST(suite, test_learn_skill_single);
SUITE_ADD_TEST(suite, test_learn_skill_multi);
SUITE_ADD_TEST(suite, test_study_no_teacher); SUITE_ADD_TEST(suite, test_study_no_teacher);
SUITE_ADD_TEST(suite, test_study_with_teacher); SUITE_ADD_TEST(suite, test_study_with_teacher);
SUITE_ADD_TEST(suite, test_study_with_bad_teacher); SUITE_ADD_TEST(suite, test_study_with_bad_teacher);