forked from github/server
fleshing out the calendar tests
This commit is contained in:
parent
fa7e21b783
commit
29061fa4ba
|
@ -6,7 +6,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
int first_month = 0;
|
||||
int weeks_per_month = 4;
|
||||
int weeks_per_month = 3;
|
||||
int months_per_year = 12;
|
||||
char **seasonnames = NULL;
|
||||
char **weeknames = NULL;
|
||||
|
@ -73,4 +73,8 @@ void calendar_cleanup(void)
|
|||
weeknames = 0;
|
||||
free(weeknames2);
|
||||
weeknames2 = 0;
|
||||
|
||||
first_month = 0;
|
||||
weeks_per_month = 3;
|
||||
months_per_year = 12;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,18 @@ static void test_calendar(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, gd.month);
|
||||
CuAssertIntEquals(tc, 1, gd.week);
|
||||
|
||||
get_gamedate(weeks_per_month, &gd);
|
||||
CuAssertIntEquals(tc, 1, gd.year);
|
||||
CuAssertIntEquals(tc, 0, gd.season);
|
||||
CuAssertIntEquals(tc, 1, gd.month);
|
||||
CuAssertIntEquals(tc, 0, gd.week);
|
||||
|
||||
get_gamedate(weeks_per_month*months_per_year, &gd);
|
||||
CuAssertIntEquals(tc, 2, gd.year);
|
||||
CuAssertIntEquals(tc, 0, gd.season);
|
||||
CuAssertIntEquals(tc, 0, gd.month);
|
||||
CuAssertIntEquals(tc, 0, gd.week);
|
||||
|
||||
config_set_int("game.start", 42);
|
||||
get_gamedate(42, &gd);
|
||||
CuAssertIntEquals(tc, 1, gd.year);
|
||||
|
@ -43,6 +55,36 @@ static void test_calendar(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, gd.month);
|
||||
CuAssertIntEquals(tc, 0, gd.week);
|
||||
|
||||
first_month = 2;
|
||||
get_gamedate(42, &gd);
|
||||
CuAssertIntEquals(tc, 1, gd.year);
|
||||
CuAssertIntEquals(tc, 0, gd.season);
|
||||
CuAssertIntEquals(tc, 2, gd.month);
|
||||
CuAssertIntEquals(tc, 0, gd.week);
|
||||
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_calendar_season(CuTest * tc)
|
||||
{
|
||||
gamedate gd;
|
||||
|
||||
test_setup();
|
||||
month_season = calloc(months_per_year, sizeof(int));
|
||||
|
||||
get_gamedate(0, &gd);
|
||||
CuAssertIntEquals(tc, 1, gd.year);
|
||||
CuAssertIntEquals(tc, 0, gd.season);
|
||||
CuAssertIntEquals(tc, 0, gd.month);
|
||||
CuAssertIntEquals(tc, 0, gd.week);
|
||||
|
||||
month_season[1] = 1;
|
||||
get_gamedate(weeks_per_month + 1, &gd);
|
||||
CuAssertIntEquals(tc, 1, gd.year);
|
||||
CuAssertIntEquals(tc, 1, gd.season);
|
||||
CuAssertIntEquals(tc, 1, gd.month);
|
||||
CuAssertIntEquals(tc, 1, gd.week);
|
||||
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
|
@ -51,5 +93,6 @@ CuSuite *get_calendar_suite(void)
|
|||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_calendar_config);
|
||||
SUITE_ADD_TEST(suite, test_calendar);
|
||||
SUITE_ADD_TEST(suite, test_calendar_season);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "keyword.h"
|
||||
#include "prefix.h"
|
||||
#include "reports.h"
|
||||
#include "calendar.h"
|
||||
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/alliance.h>
|
||||
|
@ -206,6 +207,7 @@ static void test_reset(void) {
|
|||
free_resources();
|
||||
free_config();
|
||||
default_locale = 0;
|
||||
calendar_cleanup();
|
||||
close_orders();
|
||||
free_locales();
|
||||
free_spells();
|
||||
|
|
Loading…
Reference in New Issue