forked from github/server
very basic tests for teach and study
This commit is contained in:
parent
be6a7a5e39
commit
267dafcee5
|
@ -460,7 +460,6 @@ static void test_follow_ship_msg(CuTest * tc) {
|
||||||
const ship_type *stype;
|
const ship_type *stype;
|
||||||
message *msg;
|
message *msg;
|
||||||
order *ord;
|
order *ord;
|
||||||
|
|
||||||
traveldir *td = NULL;
|
traveldir *td = NULL;
|
||||||
attrib *a;
|
attrib *a;
|
||||||
|
|
||||||
|
|
|
@ -299,12 +299,33 @@ static void test_study_cmd(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
init_resources();
|
init_resources();
|
||||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
u->thisorder = create_order(K_STUDY, u->faction->locale, "ALCHEMY");
|
u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
|
||||||
learn_inject();
|
learn_inject();
|
||||||
study_cmd(u, u->thisorder);
|
study_cmd(u, u->thisorder);
|
||||||
learn_reset();
|
learn_reset();
|
||||||
CuAssertPtrEquals(tc, u, log_learners[0].u);
|
CuAssertPtrEquals(tc, u, log_learners[0].u);
|
||||||
CuAssertIntEquals(tc, SK_ALCHEMY, log_learners[0].sk);
|
CuAssertIntEquals(tc, SK_CROSSBOW, log_learners[0].sk);
|
||||||
|
CuAssertIntEquals(tc, 30, log_learners[0].days);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_teach_cmd(CuTest *tc) {
|
||||||
|
unit *u, *ut;
|
||||||
|
test_cleanup();
|
||||||
|
init_resources();
|
||||||
|
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
scale_number(u, 10);
|
||||||
|
u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
|
||||||
|
ut = test_create_unit(u->faction, u->region);
|
||||||
|
set_level(ut, SK_CROSSBOW, TEACHDIFFERENCE);
|
||||||
|
ut->thisorder = create_order(K_TEACH, u->faction->locale, itoa36(u->no));
|
||||||
|
learn_inject();
|
||||||
|
teach_cmd(ut, ut->thisorder);
|
||||||
|
study_cmd(u, u->thisorder);
|
||||||
|
learn_reset();
|
||||||
|
CuAssertPtrEquals(tc, u, log_learners[0].u);
|
||||||
|
CuAssertIntEquals(tc, SK_CROSSBOW, log_learners[0].sk);
|
||||||
|
CuAssertIntEquals(tc, 600, log_learners[0].days);
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,6 +333,7 @@ CuSuite *get_study_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_study_cmd);
|
SUITE_ADD_TEST(suite, test_study_cmd);
|
||||||
|
SUITE_ADD_TEST(suite, test_teach_cmd);
|
||||||
SUITE_ADD_TEST(suite, test_learn_skill_single);
|
SUITE_ADD_TEST(suite, test_learn_skill_single);
|
||||||
SUITE_ADD_TEST(suite, test_learn_skill_multi);
|
SUITE_ADD_TEST(suite, test_learn_skill_multi);
|
||||||
SUITE_ADD_TEST(suite, test_study_no_teacher);
|
SUITE_ADD_TEST(suite, test_study_no_teacher);
|
||||||
|
|
Loading…
Reference in New Issue