diff options
| -rw-r--r-- | .bzrignore | 1 | ||||
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | tests/Makefile | 14 | ||||
| -rw-r--r-- | tests/check.c | 17 | ||||
| -rw-r--r-- | tests/check_util.c | 34 | 
5 files changed, 69 insertions, 0 deletions
| @@ -11,3 +11,4 @@ decode  encode  bitlbee.pc  .gdb_history +tests/check @@ -44,6 +44,9 @@ distclean: clean $(subdirs)  	rm -f Makefile.settings config.h  	find . -name 'DEADJOE' -o -name '*.orig' -o -name '*.rej' -o -name '*~' -exec rm -f {} \; +check: +	$(MAKE) -C tests +  install-doc:  	$(MAKE) -C doc install diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 00000000..3a27a430 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,14 @@ +include ../Makefile.settings + +LFLAGS +=-lcheck + +all: check +	./check + +check: check.o check_util.o ../util.o +	@echo '*' Linking $@ +	@$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(EFLAGS) + +%.o: %.c +	@echo '*' Compiling $< +	@$(CC) -c $(CFLAGS) $< -o $@ diff --git a/tests/check.c b/tests/check.c new file mode 100644 index 00000000..999da16a --- /dev/null +++ b/tests/check.c @@ -0,0 +1,17 @@ +#include <stdlib.h> +#include <glib.h> +#include <gmodule.h> +#include <check.h> + +/* From check_util.c */ +Suite *util_suite(void); + +int main (void) +{ +	int nf; +	SRunner *sr = srunner_create(util_suite()); +	srunner_run_all (sr, CK_NORMAL); +	nf = srunner_ntests_failed(sr); +	srunner_free(sr); +	return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/tests/check_util.c b/tests/check_util.c new file mode 100644 index 00000000..52e8174c --- /dev/null +++ b/tests/check_util.c @@ -0,0 +1,34 @@ +#include <stdlib.h> +#include <glib.h> +#include <gmodule.h> +#include <check.h> +#include <string.h> +#include "irc.h" +#include "set.h" +#include "util.h" + +START_TEST(test_strip_linefeed) +{ +	int i; +	const char *get[] = { "Test", "Test\r", "Test\rX\r", NULL }; +	const char *expected[] = { "Test", "Test", "TestX", NULL }; + +	for (i = 0; get[i]; i++) { +		char copy[20]; +		strcpy(copy, get[i]); +		strip_linefeed(copy); +		fail_unless (strcmp(copy, expected[i]) == 0,  +					 "(%d) strip_linefeed broken: %s -> %s (expected: %s)",  +					 i, get[i], copy, expected[i]); +	} +} +END_TEST + +Suite *util_suite (void) +{ +	Suite *s = suite_create("Util"); +	TCase *tc_core = tcase_create("Core"); +	suite_add_tcase (s, tc_core); +	tcase_add_test (tc_core, test_strip_linefeed); +	return s; +} | 
