aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check_util.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-06-16 14:07:51 +0200
committerJelmer Vernooij <jelmer@samba.org>2006-06-16 14:07:51 +0200
commit1fc2958b1e503b782081692c1a503bc7bba19fe1 (patch)
tree35c82559e1eb9de1a2bc8d7fe915ad00986cfcc7 /tests/check_util.c
parentc2fa8279933a103d6576d891e85c1801d90c65ef (diff)
Add checks for nick functions as well, fix bug where nick lengths weren't
being honored.
Diffstat (limited to 'tests/check_util.c')
-rw-r--r--tests/check_util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/check_util.c b/tests/check_util.c
index 52e8174c..e771238f 100644
--- a/tests/check_util.c
+++ b/tests/check_util.c
@@ -24,11 +24,30 @@ START_TEST(test_strip_linefeed)
}
END_TEST
+START_TEST(test_strip_newlines)
+{
+ int i;
+ const char *get[] = { "Test", "Test\r\n", "Test\nX\n", NULL };
+ const char *expected[] = { "Test", "Test ", "Test X ", NULL };
+
+ for (i = 0; get[i]; i++) {
+ char copy[20], *ret;
+ strcpy(copy, get[i]);
+ ret = strip_newlines(copy);
+ fail_unless (strcmp(copy, expected[i]) == 0,
+ "(%d) strip_newlines broken: %s -> %s (expected: %s)",
+ i, get[i], copy, expected[i]);
+ fail_unless (copy == ret, "Original string not returned");
+ }
+}
+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);
+ tcase_add_test (tc_core, test_strip_newlines);
return s;
}