Tue, 01 May 2007 04:49:01 +0000
Initialize docklet from pidgin_ui_init. This ensures docklet prefs are
created prior to prefs migration. Fixes ticket #405.
|
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 | { | |
| 15884 | 8 | assert_string_equal_free("68656c6c6f2c20776f726c642100", purple_base16_encode("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); |
| 17 | fail_unless(strcmp("!dlrow ,olleh", out) == 0, NULL); | |
| 18 | g_free(out); | |
| 19 | } | |
| 20 | END_TEST | |
| 21 | ||
| 22 | START_TEST(test_util_base64_encode) | |
| 23 | { | |
| 15884 | 24 | assert_string_equal_free("Zm9ydHktdHdvAA==", purple_base64_encode("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); |
| 33 | fail_unless(strcmp("owt-ytrof", out) == 0, NULL); | |
| 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")); |
| 15104 | 74 | } |
| 75 | END_TEST | |
| 76 | ||
|
16065
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
77 | 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
|
78 | { |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
79 | fail_unless(377185800 == purple_str_to_time("19811214T12:50:00", 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
|
80 | 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
|
81 | } |
|
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
82 | 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
|
83 | |
| 15104 | 84 | Suite * |
| 85 | util_suite(void) | |
| 86 | { | |
| 87 | Suite *s = suite_create("Utility Functions"); | |
| 88 | ||
| 89 | TCase *tc = tcase_create("Base16"); | |
| 90 | tcase_add_test(tc, test_util_base16_encode); | |
| 91 | tcase_add_test(tc, test_util_base16_decode); | |
| 92 | suite_add_tcase(s, tc); | |
| 93 | ||
| 94 | tc = tcase_create("Base64"); | |
| 95 | tcase_add_test(tc, test_util_base64_encode); | |
| 96 | tcase_add_test(tc, test_util_base64_decode); | |
| 97 | suite_add_tcase(s, tc); | |
| 98 | ||
| 99 | tc = tcase_create("Filenames"); | |
| 100 | tcase_add_test(tc, test_util_escape_filename); | |
| 101 | tcase_add_test(tc, test_util_unescape_filename); | |
| 102 | suite_add_tcase(s, tc); | |
| 103 | ||
| 104 | tc = tcase_create("Strip Mnemonic"); | |
| 105 | tcase_add_test(tc, test_util_text_strip_mnemonic); | |
| 106 | suite_add_tcase(s, tc); | |
| 107 | ||
| 108 | tc = tcase_create("Email"); | |
| 109 | tcase_add_test(tc, test_util_email_is_valid); | |
| 110 | suite_add_tcase(s, tc); | |
| 111 | ||
|
16065
85316ed3bcc4
fix our string-to-time function, and add a couple tests for it
Nathan Walp <nwalp@pidgin.im>
parents:
15950
diff
changeset
|
112 | 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
|
113 | 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
|
114 | 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
|
115 | |
| 15104 | 116 | return s; |
| 117 | } |