From c2fa8279933a103d6576d891e85c1801d90c65ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 16 Jun 2006 13:48:52 +0200 Subject: Add unit testing infrastructure. --- tests/check_util.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/check_util.c (limited to 'tests/check_util.c') 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 +#include +#include +#include +#include +#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; +} -- cgit v1.2.3