aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check_util.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2007-10-12 01:08:58 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2007-10-12 01:08:58 +0100
commiteda54e40d04c83028d84e91c895a550c1929b436 (patch)
tree878f985af2ab5d2b9c59e8c955448bc4e9ddec17 /tests/check_util.c
parent82135c7178b6379f35741991f6c06bb308143194 (diff)
parentd444c09e6c7ac6fc3c1686af0e63c09805d8cd00 (diff)
Merge from devel.
Diffstat (limited to 'tests/check_util.c')
-rw-r--r--tests/check_util.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/check_util.c b/tests/check_util.c
index 284ddba3..b00d645b 100644
--- a/tests/check_util.c
+++ b/tests/check_util.c
@@ -103,6 +103,63 @@ START_TEST(test_set_url_username_pwd)
fail_unless (url.port == 1080);
END_TEST
+struct
+{
+ char *orig;
+ int line_len;
+ char *wrapped;
+} word_wrap_tests[] = {
+ {
+ "Line-wrapping is not as easy as it seems?",
+ 16,
+ "Line-wrapping is\nnot as easy as\nit seems?"
+ },
+ {
+ "Line-wrapping is not as easy as it seems?",
+ 8,
+ "Line-\nwrapping\nis not\nas easy\nas it\nseems?"
+ },
+ {
+ "Line-wrapping is\nnot as easy as it seems?",
+ 8,
+ "Line-\nwrapping\nis\nnot as\neasy as\nit\nseems?"
+ },
+ {
+ "a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa",
+ 5,
+ "a aa\naaa\naaaa\naaaaa\naaaaa\na\naaaaa\naa\naaaaa\naaa",
+ },
+ {
+ "aaaaaaaa aaaaaaa aaaaaa aaaaa aaaa aaa aa a",
+ 5,
+ "aaaaa\naaa\naaaaa\naa\naaaaa\na\naaaaa\naaaa\naaa\naa a",
+ },
+ {
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ 5,
+ "aaaaa\naaaaa\naaaaa\naaaaa\naaaaa\naaaaa\naaaaa\na",
+ },
+ {
+ NULL
+ }
+};
+
+START_TEST(test_word_wrap)
+ int i;
+
+ for( i = 0; word_wrap_tests[i].orig && *word_wrap_tests[i].orig; i ++ )
+ {
+ char *wrapped = word_wrap( word_wrap_tests[i].orig, word_wrap_tests[i].line_len );
+
+ fail_unless( strcmp( word_wrap_tests[i].wrapped, wrapped ) == 0,
+ "%s (line_len = %d) should wrap to `%s', not to `%s'",
+ word_wrap_tests[i].orig, word_wrap_tests[i].line_len,
+ word_wrap_tests[i].wrapped, wrapped );
+
+ g_free( wrapped );
+ }
+END_TEST
+
Suite *util_suite (void)
{
Suite *s = suite_create("Util");
@@ -115,5 +172,6 @@ Suite *util_suite (void)
tcase_add_test (tc_core, test_set_url_port);
tcase_add_test (tc_core, test_set_url_username);
tcase_add_test (tc_core, test_set_url_username_pwd);
+ tcase_add_test (tc_core, test_word_wrap);
return s;
}