Files
grenzland-mud/src/test/testrunner.c
welcor c8fc70bf43 Refactor: fixtures in its own files.
Added readme for creating tests.
Found and fixed interesting bugs in destroy_db when there is no world.
renamed the testfile to testrunner to make it clear it is actually running the texts. Also, made testrunner more focused on the actual running of the tests.
Added debug target to test makefile.
2024-06-27 00:31:54 +02:00

57 lines
1.5 KiB
C

#include "testrunner.h"
#include "test.handler.h"
#include "test.act.item.h"
#include "test.example.h"
static MunitSuite suites[] = {
{ "/handler.c", handler_c_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE },
{ "/act.item.c", act_item_c_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE },
{ "/test.example.c", test_example_c_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE },
{ NULL, NULL, NULL, 0, MUNIT_SUITE_OPTION_NONE }
};
static const MunitSuite test_suite = {
(char*) "",
/* The first parameter is the array of test suites. */
NULL,
/* The second an array of suites to trigger from this one */
suites,
MUNIT_SUITE_OPTION_NONE
};
int main(int argc, char* argv[MUNIT_ARRAY_PARAM(argc + 1)]) {
logfile = stderr;
return munit_suite_main(&test_suite, (void*) "µnit", argc, argv);
}
static char testbuf[MAX_OUTPUT_BUFFER];
static int testbuf_size = 0;
size_t __wrap_send_to_char(struct char_data *ch, const char *messg, ...)
{
int size = testbuf_size;
va_list args;
va_start(args, messg);
testbuf_size += vsnprintf(testbuf + size, MAX_OUTPUT_BUFFER - size, messg, args);
va_end(args);
return testbuf_size;
}
size_t __wrap_vwrite_to_output(struct descriptor_data *t, const char *format, va_list args)
{
int size = testbuf_size;
testbuf_size += vsnprintf(testbuf + size, MAX_OUTPUT_BUFFER - size, format, args);
return testbuf_size;
}
char *get_last_messages()
{
char *stored_response = strdup(testbuf);
testbuf_size = 0;
*testbuf = '\0';
return stored_response;
}