2014-07-06 05:14:11 +02:00
|
|
|
#include <platform.h>
|
2015-01-12 08:18:41 +01:00
|
|
|
#include <eressea.h>
|
2014-07-06 05:14:11 +02:00
|
|
|
#include <kernel/config.h>
|
2014-02-18 05:45:00 +01:00
|
|
|
#include <CuTest.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <util/log.h>
|
|
|
|
|
2014-08-25 00:35:49 +02:00
|
|
|
#pragma warning(disable: 4210)
|
2014-12-12 12:17:41 +01:00
|
|
|
|
|
|
|
void RunTests(CuSuite * suite, const char *name) {
|
|
|
|
CuString *output = CuStringNew();
|
|
|
|
|
|
|
|
CuSuiteRun(suite);
|
|
|
|
CuSuiteDetails(suite, output);
|
|
|
|
if (suite->failCount) CuSuiteSummary(suite, output);
|
|
|
|
printf("%s: %s", name, output->buffer);
|
|
|
|
CuStringDelete(output);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RUN_TESTS(suite, name) \
|
|
|
|
CuSuite *get_##name##_suite(void); \
|
|
|
|
CuSuite *name = get_##name##_suite(); \
|
|
|
|
RunTests(name, #name); \
|
|
|
|
suite->failCount += name->failCount; \
|
|
|
|
suite->count += name->count; \
|
|
|
|
CuSuiteDelete(name);
|
2014-08-14 05:06:36 +02:00
|
|
|
|
2014-02-18 05:45:00 +01:00
|
|
|
int RunAllTests(void)
|
|
|
|
{
|
|
|
|
CuSuite *suite = CuSuiteNew();
|
2014-12-12 12:17:41 +01:00
|
|
|
int fail_count, flags = log_flags;
|
2014-02-18 05:45:00 +01:00
|
|
|
|
|
|
|
log_flags = LOG_FLUSH | LOG_CPERROR;
|
2015-01-12 08:18:41 +01:00
|
|
|
game_init();
|
2014-02-18 05:45:00 +01:00
|
|
|
|
|
|
|
/* self-test */
|
2014-12-12 12:17:41 +01:00
|
|
|
RUN_TESTS(suite, tests);
|
|
|
|
RUN_TESTS(suite, callback);
|
|
|
|
RUN_TESTS(suite, json);
|
|
|
|
RUN_TESTS(suite, jsonconf);
|
|
|
|
RUN_TESTS(suite, direction);
|
|
|
|
RUN_TESTS(suite, skill);
|
|
|
|
RUN_TESTS(suite, keyword);
|
|
|
|
RUN_TESTS(suite, order);
|
|
|
|
RUN_TESTS(suite, race);
|
2014-02-18 05:45:00 +01:00
|
|
|
/* util */
|
2014-12-12 12:17:41 +01:00
|
|
|
RUN_TESTS(suite, config);
|
|
|
|
RUN_TESTS(suite, attrib);
|
|
|
|
RUN_TESTS(suite, base36);
|
|
|
|
RUN_TESTS(suite, bsdstring);
|
|
|
|
RUN_TESTS(suite, functions);
|
2014-12-22 14:21:24 +01:00
|
|
|
RUN_TESTS(suite, parser);
|
2014-12-12 12:17:41 +01:00
|
|
|
RUN_TESTS(suite, umlaut);
|
|
|
|
RUN_TESTS(suite, unicode);
|
|
|
|
RUN_TESTS(suite, strings);
|
2015-01-14 22:33:58 +01:00
|
|
|
RUN_TESTS(suite, rng);
|
2014-02-18 05:45:00 +01:00
|
|
|
/* kernel */
|
2014-12-12 12:17:41 +01:00
|
|
|
RUN_TESTS(suite, alliance);
|
|
|
|
RUN_TESTS(suite, unit);
|
|
|
|
RUN_TESTS(suite, faction);
|
|
|
|
RUN_TESTS(suite, group);
|
|
|
|
RUN_TESTS(suite, build);
|
|
|
|
RUN_TESTS(suite, pool);
|
|
|
|
RUN_TESTS(suite, curse);
|
|
|
|
RUN_TESTS(suite, equipment);
|
|
|
|
RUN_TESTS(suite, item);
|
|
|
|
RUN_TESTS(suite, magic);
|
|
|
|
RUN_TESTS(suite, reports);
|
|
|
|
RUN_TESTS(suite, save);
|
|
|
|
RUN_TESTS(suite, ship);
|
|
|
|
RUN_TESTS(suite, spellbook);
|
|
|
|
RUN_TESTS(suite, building);
|
|
|
|
RUN_TESTS(suite, spell);
|
|
|
|
RUN_TESTS(suite, ally);
|
2015-01-15 16:40:19 +01:00
|
|
|
RUN_TESTS(suite, messages);
|
2014-02-18 05:45:00 +01:00
|
|
|
/* gamecode */
|
2014-12-12 12:17:41 +01:00
|
|
|
RUN_TESTS(suite, battle);
|
|
|
|
RUN_TESTS(suite, economy);
|
|
|
|
RUN_TESTS(suite, give);
|
|
|
|
RUN_TESTS(suite, laws);
|
|
|
|
RUN_TESTS(suite, market);
|
|
|
|
RUN_TESTS(suite, move);
|
|
|
|
RUN_TESTS(suite, stealth);
|
|
|
|
RUN_TESTS(suite, upkeep);
|
|
|
|
RUN_TESTS(suite, vortex);
|
|
|
|
RUN_TESTS(suite, wormhole);
|
2014-02-18 05:45:00 +01:00
|
|
|
|
2014-12-12 12:17:41 +01:00
|
|
|
printf("\ntest summary: %d tests, %d failed\n", suite->count, suite->failCount);
|
2014-02-18 05:45:00 +01:00
|
|
|
log_flags = flags;
|
2014-12-12 12:17:41 +01:00
|
|
|
fail_count = suite->failCount;
|
|
|
|
CuSuiteDelete(suite);
|
2015-01-12 08:18:41 +01:00
|
|
|
game_done();
|
2014-12-12 12:17:41 +01:00
|
|
|
return fail_count;
|
2014-02-18 05:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
2014-06-13 07:14:07 +02:00
|
|
|
log_stderr = 0;
|
|
|
|
return RunAllTests();
|
2014-02-18 05:45:00 +01:00
|
|
|
}
|