forked from github/server
WIP: add a simple test for summary, add a simple dtor for them (it is still leaking stuff).
This commit is contained in:
parent
053f8a6e09
commit
5864651b28
6 changed files with 38 additions and 1 deletions
|
@ -194,6 +194,7 @@ set(TESTS_SRC
|
|||
volcano.test.c
|
||||
reports.test.c
|
||||
seen.test.c
|
||||
summary.test.c
|
||||
travelthru.test.c
|
||||
callback.test.c
|
||||
direction.test.c
|
||||
|
|
|
@ -566,6 +566,9 @@ static int tolua_write_summary(lua_State * L)
|
|||
struct summary *sum_end = make_summary();
|
||||
report_summary(sum_end, sum_begin, false);
|
||||
report_summary(sum_end, sum_begin, true);
|
||||
free_summary(sum_end);
|
||||
free_summary(sum_begin);
|
||||
sum_begin = 0;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <util/lists.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
@ -142,6 +143,8 @@ static char *gamedate2(const struct locale *lang)
|
|||
static char buf[256];
|
||||
gamedate gd;
|
||||
|
||||
assert(weeknames2);
|
||||
assert(monthnames);
|
||||
get_gamedate(turn, &gd);
|
||||
sprintf(buf, "in %s des Monats %s im Jahre %d %s.",
|
||||
LOC(lang, weeknames2[gd.week]),
|
||||
|
@ -350,6 +353,10 @@ void report_summary(summary * s, summary * o, bool full)
|
|||
nmrs = NULL;
|
||||
}
|
||||
|
||||
void free_summary(summary *sum) {
|
||||
free(sum);
|
||||
}
|
||||
|
||||
summary *make_summary(void)
|
||||
{
|
||||
faction *f;
|
||||
|
|
|
@ -19,7 +19,7 @@ extern "C" {
|
|||
|
||||
void report_summary(struct summary *n, struct summary *o, bool full);
|
||||
struct summary *make_summary(void);
|
||||
|
||||
void free_summary(struct summary *sum);
|
||||
int update_nmrs(void);
|
||||
extern int* nmrs;
|
||||
|
||||
|
|
25
src/summary.test.c
Normal file
25
src/summary.test.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include <platform.h>
|
||||
|
||||
#include "summary.h"
|
||||
#include "calendar.h"
|
||||
|
||||
#include <CuTest.h>
|
||||
#include "tests.h"
|
||||
|
||||
static void test_summary(CuTest * tc)
|
||||
{
|
||||
struct summary *sum;
|
||||
test_setup();
|
||||
sum = make_summary();
|
||||
report_summary(sum, sum, true);
|
||||
CuAssertIntEquals(tc, 0, remove("parteien.full"));
|
||||
free_summary(sum);
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
CuSuite *get_summary_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_summary);
|
||||
return suite;
|
||||
}
|
|
@ -112,6 +112,7 @@ int RunAllTests(int argc, char *argv[])
|
|||
ADD_SUITE(messages);
|
||||
/* gamecode */
|
||||
ADD_SUITE(prefix);
|
||||
ADD_SUITE(summary);
|
||||
ADD_SUITE(names);
|
||||
ADD_SUITE(battle);
|
||||
ADD_SUITE(volcano);
|
||||
|
|
Loading…
Reference in a new issue