Thu, 26 Mar 2009 07:27:05 +0000
Cast away a few compile warnings in our "make check" tests, and add
libpurple/plugins/one_time_password.c to POTFILES.in so that it can be
translatinated.
|
15950
0f01bb61c5d3
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
1 | #include <string.h> |
|
0f01bb61c5d3
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
2 | |
| 15104 | 3 | #include "tests.h" |
| 4 | #include "../util.h" | |
| 5 | ||
| 6 | START_TEST(test_util_base16_encode) | |
| 7 | { | |
|
26553
a1417d5cdedb
Cast away a few compile warnings in our "make check" tests, and add
Mark Doliner <markdoliner@pidgin.im>
parents:
22321
diff
changeset
|
8 | assert_string_equal_free("68656c6c6f2c20776f726c642100", purple_base16_encode((const unsigned char *)"hello, world!", 14)); |
| 15104 | 9 | } |
| 10 | END_TEST | |
| 11 | ||
| 12 | START_TEST(test_util_base16_decode) | |
| 13 | { | |
| 14 | gsize sz = 0; | |
| 15884 | 15 | guchar *out = purple_base16_decode("21646c726f77202c6f6c6c656800", &sz); |
| 15104 | 16 | fail_unless(sz == 14, NULL); |
|
26553
a1417d5cdedb
Cast away a few compile warnings in our "make check" tests, and add
Mark Doliner <markdoliner@pidgin.im>
parents:
22321
diff
changeset
|
17 | fail_unless(strcmp("!dlrow ,olleh", (const char *)out) == 0, NULL); |
| 15104 | 18 | g_free(out); |
| 19 | } | |
| 20 | END_TEST | |
| 21 | ||
| 22 | START_TEST(test_util_base64_encode) | |
| 23 | { | |
|
26553
a1417d5cdedb
Cast away a few compile warnings in our "make check" tests, and add
Mark Doliner <markdoliner@pidgin.im>
parents:
22321
diff
changeset
|
24 | assert_string_equal_free("Zm9ydHktdHdvAA==", purple_base64_encode((const unsigned char *)"forty-two", 10)); |
| 15104 | 25 | } |
| 26 | END_TEST | |
| 27 | ||
| 28 | START_TEST(test_util_base64_decode) | |
| 29 | { | |
| 30 | gsize sz; | |
| 15884 | 31 | guchar *out = purple_base64_decode("b3d0LXl0cm9mAA==", &sz); |
| 15104 | 32 | fail_unless(sz == 10, NULL); |
|
26553
a1417d5cdedb
Cast away a few compile warnings in our "make check" tests, and add
Mark Doliner <markdoliner@pidgin.im>
parents:
22321
diff
changeset
|
33 | fail_unless(strcmp("owt-ytrof", (const char *)out) == 0, NULL); |
| 15104 | 34 | g_free(out); |
| 35 | } | |
| 36 | END_TEST | |
| 37 | ||
| 38 | START_TEST(test_util_escape_filename) | |
| 39 | { | |
| 15884 | 40 | assert_string_equal("foo", purple_escape_filename("foo")); |
| 41 | assert_string_equal("@oo", purple_escape_filename("@oo")); | |
| 42 | assert_string_equal("#oo", purple_escape_filename("#oo")); | |
| 43 | assert_string_equal("-oo", purple_escape_filename("-oo")); | |
| 44 | assert_string_equal("_oo", purple_escape_filename("_oo")); | |
| 45 | assert_string_equal(".oo", purple_escape_filename(".oo")); | |
| 46 | assert_string_equal("%25oo", purple_escape_filename("%oo")); | |
| 47 | assert_string_equal("%21oo", purple_escape_filename("!oo")); | |
| 15104 | 48 | } |
| 49 | END_TEST | |
| 50 | ||
| 51 | START_TEST(test_util_unescape_filename) | |
| 52 | { | |
| 15884 | 53 | assert_string_equal("bar", purple_unescape_filename("bar")); |
| 54 | assert_string_equal("@ar", purple_unescape_filename("@ar")); | |
| 55 | assert_string_equal("!ar", purple_unescape_filename("!ar")); | |
| 56 | assert_string_equal("!ar", purple_unescape_filename("%21ar")); | |
| 57 | assert_string_equal("%ar", purple_unescape_filename("%25ar")); | |
| 15104 | 58 | } |
| 59 | END_TEST | |
| 60 | ||
| 61 | ||
| 62 | START_TEST(test_util_text_strip_mnemonic) | |
| 63 | { | |
| 15884 | 64 | assert_string_equal_free("", purple_text_strip_mnemonic("")); |
| 65 | assert_string_equal_free("foo", purple_text_strip_mnemonic("foo")); | |
| 66 | assert_string_equal_free("foo", purple_text_strip_mnemonic("_foo")); | |
| 15104 | 67 | |
| 68 | } | |
| 69 | END_TEST | |
| 70 | ||
| 71 | START_TEST(test_util_email_is_valid) | |
| 72 | { | |
| 15884 | 73 | fail_unless(purple_email_is_valid("purple-devel@lists.sf.net")); |
|
22319
a700bcb140b5
Add a few tets to make sure we're catching some invalid email formats
Mark Doliner <markdoliner@pidgin.im>
parents:
21697
diff
changeset
|
74 | fail_if(purple_email_is_valid("purple-devel@@lists.sf.net")); |
|
a700bcb140b5
Add a few tets to make sure we're catching some invalid email formats
Mark Doliner <markdoliner@pidgin.im>
parents:
21697
diff
changeset
|
75 | fail_if(purple_email_is_valid("purple@devel@lists.sf.net")); |
|
a700bcb140b5
Add a few tets to make sure we're catching some invalid email formats
Mark Doliner <markdoliner@pidgin.im>
parents:
21697
diff
changeset
|
76 | fail_if(purple_email_is_valid("purple-devel@list..sf.net")); |
|
a700bcb140b5
Add a few tets to make sure we're catching some invalid email formats
Mark Doliner <markdoliner@pidgin.im>
parents:
21697
diff
changeset
|
77 | fail_if(purple_email_is_valid("purple-devel")); |
|
22321
5b8f5f15cadc
One more test. This is actually the one I cared about. It passes,
Mark Doliner <markdoliner@pidgin.im>
parents:
22319
diff
changeset
|
78 | fail_if(purple_email_is_valid("purple-devel@")); |
|
22319
a700bcb140b5
Add a few tets to make sure we're catching some invalid email formats
Mark Doliner <markdoliner@pidgin.im>
parents:
21697
diff
changeset
|
79 | fail_if(purple_email_is_valid("@lists.sf.net")); |
|
a700bcb140b5
Add a few tets to make sure we're catching some invalid email formats
Mark Doliner <markdoliner@pidgin.im>
parents:
21697
diff
changeset
|
80 | fail_if(purple_email_is_valid("")); |
|
a700bcb140b5
Add a few tets to make sure we're catching some invalid email formats
Mark Doliner <markdoliner@pidgin.im>
parents:
21697
diff
changeset
|
81 | fail_if(purple_email_is_valid("totally bogus")); |
| 15104 | 82 | } |
| 83 | END_TEST | |
| 84 | ||
|
16065
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
85 | START_TEST(test_util_str_to_time) |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
86 | { |
|
21697
c865512e913f
Fix the bug in purple_str_to_time() that was causing 'make check' to fail.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20293
diff
changeset
|
87 | fail_unless(377182200 == purple_str_to_time("19811214T12:50:00", TRUE, NULL, NULL, NULL)); |
|
16065
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
88 | fail_unless(1175919261 == purple_str_to_time("20070407T04:14:21", TRUE, NULL, NULL, NULL)); |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
89 | } |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
90 | END_TEST |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
91 | |
|
20293
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
92 | START_TEST(test_markup_html_to_xhtml) |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
93 | { |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
94 | gchar *xhtml = NULL; |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
95 | gchar *plaintext = NULL; |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
96 | purple_markup_html_to_xhtml("<a>", &xhtml, &plaintext); |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
97 | fail_unless(strcmp("<a href=''></a>", xhtml) == 0, NULL); |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
98 | g_free(xhtml); |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
99 | fail_unless(strcmp("", plaintext) == 0, NULL); |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
100 | g_free(plaintext); |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
101 | } |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
102 | END_TEST |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
103 | |
| 15104 | 104 | Suite * |
| 105 | util_suite(void) | |
| 106 | { | |
| 107 | Suite *s = suite_create("Utility Functions"); | |
| 108 | ||
| 109 | TCase *tc = tcase_create("Base16"); | |
| 110 | tcase_add_test(tc, test_util_base16_encode); | |
| 111 | tcase_add_test(tc, test_util_base16_decode); | |
| 112 | suite_add_tcase(s, tc); | |
| 113 | ||
| 114 | tc = tcase_create("Base64"); | |
| 115 | tcase_add_test(tc, test_util_base64_encode); | |
| 116 | tcase_add_test(tc, test_util_base64_decode); | |
| 117 | suite_add_tcase(s, tc); | |
| 118 | ||
| 119 | tc = tcase_create("Filenames"); | |
| 120 | tcase_add_test(tc, test_util_escape_filename); | |
| 121 | tcase_add_test(tc, test_util_unescape_filename); | |
| 122 | suite_add_tcase(s, tc); | |
| 123 | ||
| 124 | tc = tcase_create("Strip Mnemonic"); | |
| 125 | tcase_add_test(tc, test_util_text_strip_mnemonic); | |
| 126 | suite_add_tcase(s, tc); | |
| 127 | ||
| 128 | tc = tcase_create("Email"); | |
| 129 | tcase_add_test(tc, test_util_email_is_valid); | |
| 130 | suite_add_tcase(s, tc); | |
| 131 | ||
|
16065
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
132 | tc = tcase_create("Time"); |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
133 | tcase_add_test(tc, test_util_str_to_time); |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
134 | suite_add_tcase(s, tc); |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
135 | |
|
20293
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
136 | tc = tcase_create("Markup"); |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
137 | tcase_add_test(tc, test_markup_html_to_xhtml); |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
138 | suite_add_tcase(s, tc); |
|
81d324f460bd
applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16065
diff
changeset
|
139 | |
| 15104 | 140 | return s; |
| 141 | } |