forked from github/server
add test for that weird function-lookup module before I refactor it.
This commit is contained in:
parent
8636762e73
commit
e272a00994
4 changed files with 25 additions and 11 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <util/base36_test.c>
|
||||
#include <util/quicklist_test.c>
|
||||
#include <util/functions_test.c>
|
||||
#include <kernel/move_test.c>
|
||||
#include <kernel/spell_test.c>
|
||||
#include <kernel/curse_test.c>
|
||||
|
@ -36,6 +37,7 @@ int RunAllTests(void)
|
|||
|
||||
CuSuiteAddSuite(suite, get_base36_suite());
|
||||
CuSuiteAddSuite(suite, get_quicklist_suite());
|
||||
CuSuiteAddSuite(suite, get_functions_suite());
|
||||
CuSuiteAddSuite(suite, get_curse_suite());
|
||||
CuSuiteAddSuite(suite, get_market_suite());
|
||||
CuSuiteAddSuite(suite, get_move_suite());
|
||||
|
|
|
@ -61,13 +61,3 @@ void register_function(pf_generic fun, const char *name)
|
|||
fl->name = strdup(name);
|
||||
functionlist = fl;
|
||||
}
|
||||
|
||||
void list_registered_functions(void)
|
||||
{
|
||||
function_list *fl = functionlist;
|
||||
|
||||
while (fl) {
|
||||
printf("%s\n", fl->name);
|
||||
fl = fl->next;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ extern "C" {
|
|||
extern const char *get_functionname(pf_generic fun);
|
||||
extern pf_generic get_function(const char *name);
|
||||
extern void register_function(pf_generic fun, const char *name);
|
||||
extern void list_registered_functions(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
23
src/util/functions_test.c
Normal file
23
src/util/functions_test.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <cutest/CuTest.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "functions.h"
|
||||
|
||||
|
||||
static void test_all(CuTest * tc)
|
||||
{
|
||||
pf_generic fun;
|
||||
|
||||
fun = get_function("herpderp");
|
||||
CuAssertTrue(tc, !fun);
|
||||
register_function((pf_generic)test_all, "herpderp");
|
||||
fun = get_function("herpderp");
|
||||
CuAssertTrue(tc, fun==(pf_generic)test_all);
|
||||
}
|
||||
|
||||
CuSuite *get_functions_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_all);
|
||||
return suite;
|
||||
}
|
Loading…
Reference in a new issue