very simple calendar test.

This commit is contained in:
Enno Rehling 2017-05-07 13:40:43 +02:00
parent 3e1462a192
commit fa7e21b783
1 changed files with 30 additions and 0 deletions

View File

@ -7,19 +7,49 @@
#include <CuTest.h> #include <CuTest.h>
#include "tests.h" #include "tests.h"
static void test_calendar_config(CuTest * tc)
{
gamedate gd;
test_setup();
get_gamedate(0, &gd);
CuAssertIntEquals(tc, 0, first_turn());
config_set_int("game.start", 42);
CuAssertIntEquals(tc, 42, first_turn());
test_cleanup();
}
static void test_calendar(CuTest * tc) static void test_calendar(CuTest * tc)
{ {
gamedate gd; gamedate gd;
test_setup(); test_setup();
get_gamedate(0, &gd); get_gamedate(0, &gd);
CuAssertIntEquals(tc, 1, gd.year);
CuAssertIntEquals(tc, 0, gd.season);
CuAssertIntEquals(tc, 0, gd.month); CuAssertIntEquals(tc, 0, gd.month);
CuAssertIntEquals(tc, 0, gd.week);
get_gamedate(1, &gd);
CuAssertIntEquals(tc, 1, gd.year);
CuAssertIntEquals(tc, 0, gd.season);
CuAssertIntEquals(tc, 0, gd.month);
CuAssertIntEquals(tc, 1, gd.week);
config_set_int("game.start", 42);
get_gamedate(42, &gd);
CuAssertIntEquals(tc, 1, gd.year);
CuAssertIntEquals(tc, 0, gd.season);
CuAssertIntEquals(tc, 0, gd.month);
CuAssertIntEquals(tc, 0, gd.week);
test_cleanup(); test_cleanup();
} }
CuSuite *get_calendar_suite(void) CuSuite *get_calendar_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_calendar_config);
SUITE_ADD_TEST(suite, test_calendar); SUITE_ADD_TEST(suite, test_calendar);
return suite; return suite;
} }