diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-06-25 21:43:14 +0200 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-06-25 21:43:14 +0200 | 
| commit | fd037705664ea03d7a0574c44161ae03b000fb2c (patch) | |
| tree | 9a0ab46f16689de3005500db479fab7ab4ee5d95 /tests/check_util.c | |
| parent | 6ee9d2d65ec05d3871e69c2b03b860c6bdd509e9 (diff) | |
| parent | 9b63df67847e72abb00246fdfc82830137153c3c (diff) | |
Merging from devel/Jelmer.
Diffstat (limited to 'tests/check_util.c')
| -rw-r--r-- | tests/check_util.c | 53 | 
1 files changed, 53 insertions, 0 deletions
| diff --git a/tests/check_util.c b/tests/check_util.c new file mode 100644 index 00000000..e771238f --- /dev/null +++ b/tests/check_util.c @@ -0,0 +1,53 @@ +#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 + +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; +} | 
