diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-12-24 20:35:13 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2006-12-24 20:35:13 +0100 |
commit | c227706bc921c3bb426eb315c0d097df30aa9d16 (patch) | |
tree | 1af13b2b2fd26691691e2f802ca85514b1a2b925 /tests | |
parent | 9225e08f377026e653e31468d53df9d328dd7951 (diff) |
Refactor the help code to take a filename rather than using the global struct.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 2 | ||||
-rw-r--r-- | tests/check.c | 4 | ||||
-rw-r--r-- | tests/check_help.c | 30 |
3 files changed, 35 insertions, 1 deletions
diff --git a/tests/Makefile b/tests/Makefile index 9dd3df7c..3ddd1570 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -10,7 +10,7 @@ clean: main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o -test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o +test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o @echo '*' Linking $@ diff --git a/tests/check.c b/tests/check.c index f70ccae7..069b3c57 100644 --- a/tests/check.c +++ b/tests/check.c @@ -40,6 +40,9 @@ Suite *md5_suite(void); /* From check_irc.c */ Suite *irc_suite(void); +/* From check_help.c */ +Suite *help_suite(void); + int main (int argc, char **argv) { int nf; @@ -80,6 +83,7 @@ int main (int argc, char **argv) srunner_add_suite(sr, nick_suite()); srunner_add_suite(sr, md5_suite()); srunner_add_suite(sr, irc_suite()); + srunner_add_suite(sr, help_suite()); if (no_fork) srunner_set_fork_status(sr, CK_NOFORK); srunner_run_all (sr, verbose?CK_VERBOSE:CK_NORMAL); diff --git a/tests/check_help.c b/tests/check_help.c new file mode 100644 index 00000000..7e5283e3 --- /dev/null +++ b/tests/check_help.c @@ -0,0 +1,30 @@ +#include <stdlib.h> +#include <glib.h> +#include <gmodule.h> +#include <check.h> +#include <string.h> +#include <stdio.h> +#include "help.h" + +START_TEST(test_help_none) + help_t *h, *r; + r = help_init(&h, "/dev/null"); + fail_if(r == NULL); + fail_if(r != h); +END_TEST + +START_TEST(test_help_nonexistent) + help_t *h, *r; + r = help_init(&h, "/dev/null"); + fail_unless(help_get(&h, "nonexistent") == NULL); +END_TEST + +Suite *help_suite (void) +{ + Suite *s = suite_create("Help"); + TCase *tc_core = tcase_create("Core"); + suite_add_tcase (s, tc_core); + tcase_add_test (tc_core, test_help_none); + tcase_add_test (tc_core, test_help_nonexistent); + return s; +} |