- Timestamp:
- 2019-11-19T12:51:39Z (5 years ago)
- Branches:
- master
- Children:
- b504415
- Parents:
- bcd8f52
- Location:
- tests
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/check_arc.c
rbcd8f52 r6ff651b 18 18 }; 19 19 20 static void check_codec(int l)20 START_TEST(check_codec) 21 21 { 22 22 int i; … … 38 38 } 39 39 } 40 END_TEST 40 41 41 42 struct { … … 73 74 }; 74 75 75 static void check_decod(int l)76 START_TEST(check_decod) 76 77 { 77 78 int i; … … 93 94 } 94 95 } 96 END_TEST 95 97 96 98 Suite *arc_suite(void) -
tests/check_help.c
rbcd8f52 r6ff651b 8 8 9 9 START_TEST(test_help_initfree) 10 help_t * h, *r; 11 r = help_init(&h, "/dev/null"); 12 fail_if(r == NULL); 13 fail_if(r != h); 10 { 11 help_t * h, *r; 12 r = help_init(&h, "/dev/null"); 13 fail_if(r == NULL); 14 fail_if(r != h); 14 15 15 help_free(&h); 16 fail_if(h != NULL); 16 help_free(&h); 17 fail_if(h != NULL); 18 } 17 19 END_TEST 18 20 19 21 START_TEST(test_help_nonexistent) 20 help_t * h, *r; 21 r = help_init(&h, "/dev/null"); 22 fail_unless(help_get(&h, "nonexistent") == NULL); 23 fail_if(r == NULL); 22 { 23 help_t * h, *r; 24 r = help_init(&h, "/dev/null"); 25 fail_unless(help_get(&h, "nonexistent") == NULL); 26 fail_if(r == NULL); 27 } 24 28 END_TEST 25 29 -
tests/check_irc.c
rbcd8f52 r6ff651b 9 9 10 10 START_TEST(test_connect) 11 GIOChannel * ch1, *ch2; 12 irc_t *irc; 13 char *raw; 14 fail_unless(g_io_channel_pair(&ch1, &ch2)); 11 { 12 GIOChannel * ch1, *ch2; 13 irc_t *irc; 14 char *raw; 15 fail_unless(g_io_channel_pair(&ch1, &ch2)); 15 16 16 irc = irc_new(g_io_channel_unix_get_fd(ch1));17 irc = irc_new(g_io_channel_unix_get_fd(ch1)); 17 18 18 irc_free(irc);19 irc_free(irc); 19 20 20 fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL);21 fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL); 21 22 22 fail_if(strcmp(raw, "") != 0);23 fail_if(strcmp(raw, "") != 0); 23 24 24 g_free(raw); 25 g_free(raw); 26 } 25 27 END_TEST 26 28 27 29 START_TEST(test_login) 28 GIOChannel * ch1, *ch2; 29 irc_t *irc; 30 char *raw; 31 fail_unless(g_io_channel_pair(&ch1, &ch2)); 30 { 31 GIOChannel * ch1, *ch2; 32 irc_t *irc; 33 char *raw; 34 fail_unless(g_io_channel_pair(&ch1, &ch2)); 32 35 33 g_io_channel_set_flags(ch1, G_IO_FLAG_NONBLOCK, NULL);34 g_io_channel_set_flags(ch2, G_IO_FLAG_NONBLOCK, NULL);36 g_io_channel_set_flags(ch1, G_IO_FLAG_NONBLOCK, NULL); 37 g_io_channel_set_flags(ch2, G_IO_FLAG_NONBLOCK, NULL); 35 38 36 irc = irc_new(g_io_channel_unix_get_fd(ch1));39 irc = irc_new(g_io_channel_unix_get_fd(ch1)); 37 40 38 fail_unless(g_io_channel_write_chars(ch2, "NICK bla\r\r\n"39 40 fail_unless(g_io_channel_flush(ch2, NULL) == G_IO_STATUS_NORMAL);41 fail_unless(g_io_channel_write_chars(ch2, "NICK bla\r\r\n" 42 "USER a a a a\n", -1, NULL, NULL) == G_IO_STATUS_NORMAL); 43 fail_unless(g_io_channel_flush(ch2, NULL) == G_IO_STATUS_NORMAL); 41 44 42 g_main_iteration(FALSE);43 irc_free(irc);45 g_main_iteration(FALSE); 46 irc_free(irc); 44 47 45 fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL);48 fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL); 46 49 47 fail_unless(strstr(raw, "001") != NULL);48 fail_unless(strstr(raw, "002") != NULL);49 fail_unless(strstr(raw, "003") != NULL);50 fail_unless(strstr(raw, "004") != NULL);51 fail_unless(strstr(raw, "005") != NULL);50 fail_unless(strstr(raw, "001") != NULL); 51 fail_unless(strstr(raw, "002") != NULL); 52 fail_unless(strstr(raw, "003") != NULL); 53 fail_unless(strstr(raw, "004") != NULL); 54 fail_unless(strstr(raw, "005") != NULL); 52 55 53 g_free(raw); 56 g_free(raw); 57 } 54 58 END_TEST 55 59 -
tests/check_jabber_sasl.c
rbcd8f52 r6ff651b 78 78 }; 79 79 80 static void check_get_part(int l)80 START_TEST(check_get_part) 81 81 { 82 82 int i; … … 104 104 } 105 105 } 106 END_TEST 106 107 107 108 Suite *jabber_sasl_suite(void) -
tests/check_jabber_util.c
rbcd8f52 r6ff651b 9 9 static struct im_connection *ic; 10 10 11 static void check_buddy_add(int l)11 START_TEST(check_buddy_add) 12 12 { 13 13 struct jabber_buddy *budw1, *budw2, *budw3, *budn, *bud; … … 94 94 fail_unless(jabber_buddy_remove(ic, "bugtest@google.com/C")); 95 95 } 96 END_TEST 96 97 97 static void check_compareJID(int l)98 START_TEST(check_compareJID) 98 99 { 99 100 fail_unless(jabber_compare_jid("bugtest@google.com/B", "bugtest@google.com/A")); … … 106 107 fail_if(jabber_compare_jid("", NULL)); 107 108 } 109 END_TEST 108 110 109 static void check_hipchat_slug(int l)111 START_TEST(check_hipchat_slug) 110 112 { 111 113 int i; … … 125 127 } 126 128 } 129 END_TEST 127 130 128 131 Suite *jabber_util_suite(void) -
tests/check_md5.c
rbcd8f52 r6ff651b 30 30 }; 31 31 32 static void check_sums(int l)32 START_TEST(check_sums) 33 33 { 34 34 int i; … … 46 46 } 47 47 } 48 END_TEST 48 49 49 50 Suite *md5_suite(void) -
tests/check_set.c
rbcd8f52 r6ff651b 8 8 9 9 START_TEST(test_set_add) 10 void *data = "data"; 11 set_t *s = NULL, *t; 12 t = set_add(&s, "name", "default", NULL, data); 13 fail_unless(s == t); 14 fail_unless(t->data == data); 15 fail_unless(strcmp(t->def, "default") == 0); 10 { 11 void *data = "data"; 12 set_t *s = NULL, *t; 13 t = set_add(&s, "name", "default", NULL, data); 14 fail_unless(s == t); 15 fail_unless(t->data == data); 16 fail_unless(strcmp(t->def, "default") == 0); 17 } 16 18 END_TEST 17 19 18 20 START_TEST(test_set_add_existing) 19 void *data = "data"; 20 set_t *s = NULL, *t; 21 t = set_add(&s, "name", "default", NULL, data); 22 t = set_add(&s, "name", "newdefault", NULL, data); 23 fail_unless(s == t); 24 fail_unless(strcmp(t->def, "newdefault") == 0); 21 { 22 void *data = "data"; 23 set_t *s = NULL, *t; 24 t = set_add(&s, "name", "default", NULL, data); 25 t = set_add(&s, "name", "newdefault", NULL, data); 26 fail_unless(s == t); 27 fail_unless(strcmp(t->def, "newdefault") == 0); 28 } 25 29 END_TEST 26 30 27 31 START_TEST(test_set_find_unknown) 28 set_t * s = NULL; 29 fail_unless(set_find(&s, "foo") == NULL); 32 { 33 set_t * s = NULL; 34 fail_unless(set_find(&s, "foo") == NULL); 35 } 30 36 END_TEST 31 37 32 38 START_TEST(test_set_find) 33 void *data = "data"; 34 set_t *s = NULL, *t; 35 t = set_add(&s, "name", "default", NULL, data); 36 fail_unless(s == t); 37 fail_unless(set_find(&s, "name") == t); 39 { 40 void *data = "data"; 41 set_t *s = NULL, *t; 42 t = set_add(&s, "name", "default", NULL, data); 43 fail_unless(s == t); 44 fail_unless(set_find(&s, "name") == t); 45 } 38 46 END_TEST 39 47 40 48 START_TEST(test_set_get_str_default) 41 void *data = "data"; 42 set_t *s = NULL, *t; 43 t = set_add(&s, "name", "default", NULL, data); 44 fail_unless(s == t); 45 fail_unless(strcmp(set_getstr(&s, "name"), "default") == 0); 49 { 50 void *data = "data"; 51 set_t *s = NULL, *t; 52 t = set_add(&s, "name", "default", NULL, data); 53 fail_unless(s == t); 54 fail_unless(strcmp(set_getstr(&s, "name"), "default") == 0); 55 } 46 56 END_TEST 47 57 48 58 START_TEST(test_set_get_bool_default) 49 void *data = "data"; 50 set_t *s = NULL, *t; 51 t = set_add(&s, "name", "true", NULL, data); 52 fail_unless(s == t); 53 fail_unless(set_getbool(&s, "name")); 59 { 60 void *data = "data"; 61 set_t *s = NULL, *t; 62 t = set_add(&s, "name", "true", NULL, data); 63 fail_unless(s == t); 64 fail_unless(set_getbool(&s, "name")); 65 } 54 66 END_TEST 55 67 56 68 START_TEST(test_set_get_bool_integer) 57 void *data = "data"; 58 set_t *s = NULL, *t; 59 t = set_add(&s, "name", "3", NULL, data); 60 fail_unless(s == t); 61 fail_unless(set_getbool(&s, "name") == 3); 69 { 70 void *data = "data"; 71 set_t *s = NULL, *t; 72 t = set_add(&s, "name", "3", NULL, data); 73 fail_unless(s == t); 74 fail_unless(set_getbool(&s, "name") == 3); 75 } 62 76 END_TEST 63 77 64 78 START_TEST(test_set_get_bool_unknown) 65 set_t * s = NULL; 66 fail_unless(set_getbool(&s, "name") == 0); 79 { 80 set_t * s = NULL; 81 fail_unless(set_getbool(&s, "name") == 0); 82 } 67 83 END_TEST 68 84 69 85 START_TEST(test_set_get_str_value) 70 void *data = "data"; 71 set_t *s = NULL; 72 set_add(&s, "name", "default", NULL, data); 73 set_setstr(&s, "name", "foo"); 74 fail_unless(strcmp(set_getstr(&s, "name"), "foo") == 0); 86 { 87 void *data = "data"; 88 set_t *s = NULL; 89 set_add(&s, "name", "default", NULL, data); 90 set_setstr(&s, "name", "foo"); 91 fail_unless(strcmp(set_getstr(&s, "name"), "foo") == 0); 92 } 75 93 END_TEST 76 94 77 95 START_TEST(test_set_get_str_unknown) 78 set_t * s = NULL; 79 fail_unless(set_getstr(&s, "name") == NULL); 96 { 97 set_t * s = NULL; 98 fail_unless(set_getstr(&s, "name") == NULL); 99 } 80 100 END_TEST 81 101 82 102 START_TEST(test_setint) 83 void *data = "data"; 84 set_t *s = NULL; 85 set_add(&s, "name", "10", NULL, data); 86 set_setint(&s, "name", 3); 87 fail_unless(set_getint(&s, "name") == 3); 103 { 104 void *data = "data"; 105 set_t *s = NULL; 106 set_add(&s, "name", "10", NULL, data); 107 set_setint(&s, "name", 3); 108 fail_unless(set_getint(&s, "name") == 3); 109 } 88 110 END_TEST 89 111 90 112 START_TEST(test_setstr) 91 void *data = "data"; 92 set_t *s = NULL; 93 set_add(&s, "name", "foo", NULL, data); 94 set_setstr(&s, "name", "bloe"); 95 fail_unless(strcmp(set_getstr(&s, "name"), "bloe") == 0); 113 { 114 void *data = "data"; 115 set_t *s = NULL; 116 set_add(&s, "name", "foo", NULL, data); 117 set_setstr(&s, "name", "bloe"); 118 fail_unless(strcmp(set_getstr(&s, "name"), "bloe") == 0); 119 } 96 120 END_TEST 97 121 98 122 START_TEST(test_set_get_int_unknown) 99 set_t * s = NULL; 100 fail_unless(set_getint(&s, "foo") == 0); 123 { 124 set_t * s = NULL; 125 fail_unless(set_getint(&s, "foo") == 0); 126 } 101 127 END_TEST 102 128 -
tests/check_util.c
rbcd8f52 r6ff651b 9 9 #include "url.h" 10 10 11 START_TEST(test_strip_linefeed){ 11 START_TEST(test_strip_linefeed) 12 { 12 13 int i; 13 14 const char *get[] = { "Test", "Test\r", "Test\rX\r", NULL }; … … 44 45 45 46 START_TEST(test_set_url_http) 46 url_t url; 47 48 fail_if(0 == url_set(&url, "http://host/")); 49 fail_unless(!strcmp(url.host, "host")); 50 fail_unless(!strcmp(url.file, "/")); 51 fail_unless(!strcmp(url.user, "")); 52 fail_unless(!strcmp(url.pass, "")); 53 fail_unless(url.proto == PROTO_HTTP); 54 fail_unless(url.port == 80); 47 { 48 url_t url; 49 50 fail_if(0 == url_set(&url, "http://host/")); 51 fail_unless(!strcmp(url.host, "host")); 52 fail_unless(!strcmp(url.file, "/")); 53 fail_unless(!strcmp(url.user, "")); 54 fail_unless(!strcmp(url.pass, "")); 55 fail_unless(url.proto == PROTO_HTTP); 56 fail_unless(url.port == 80); 57 } 55 58 END_TEST 56 59 57 60 START_TEST(test_set_url_https) 58 url_t url; 59 60 fail_if(0 == url_set(&url, "https://ahost/AimeeMann")); 61 fail_unless(!strcmp(url.host, "ahost")); 62 fail_unless(!strcmp(url.file, "/AimeeMann")); 63 fail_unless(!strcmp(url.user, "")); 64 fail_unless(!strcmp(url.pass, "")); 65 fail_unless(url.proto == PROTO_HTTPS); 66 fail_unless(url.port == 443); 61 { 62 url_t url; 63 64 fail_if(0 == url_set(&url, "https://ahost/AimeeMann")); 65 fail_unless(!strcmp(url.host, "ahost")); 66 fail_unless(!strcmp(url.file, "/AimeeMann")); 67 fail_unless(!strcmp(url.user, "")); 68 fail_unless(!strcmp(url.pass, "")); 69 fail_unless(url.proto == PROTO_HTTPS); 70 fail_unless(url.port == 443); 71 } 67 72 END_TEST 68 73 69 74 START_TEST(test_set_url_port) 70 url_t url; 71 72 fail_if(0 == url_set(&url, "https://ahost:200/Lost/In/Space")); 73 fail_unless(!strcmp(url.host, "ahost")); 74 fail_unless(!strcmp(url.file, "/Lost/In/Space")); 75 fail_unless(!strcmp(url.user, "")); 76 fail_unless(!strcmp(url.pass, "")); 77 fail_unless(url.proto == PROTO_HTTPS); 78 fail_unless(url.port == 200); 75 { 76 url_t url; 77 78 fail_if(0 == url_set(&url, "https://ahost:200/Lost/In/Space")); 79 fail_unless(!strcmp(url.host, "ahost")); 80 fail_unless(!strcmp(url.file, "/Lost/In/Space")); 81 fail_unless(!strcmp(url.user, "")); 82 fail_unless(!strcmp(url.pass, "")); 83 fail_unless(url.proto == PROTO_HTTPS); 84 fail_unless(url.port == 200); 85 } 79 86 END_TEST 80 87 81 88 START_TEST(test_set_url_username) 82 url_t url; 83 84 fail_if(0 == url_set(&url, "socks4://user@ahost/Space")); 85 fail_unless(!strcmp(url.host, "ahost")); 86 fail_unless(!strcmp(url.file, "/Space")); 87 fail_unless(!strcmp(url.user, "user")); 88 fail_unless(!strcmp(url.pass, "")); 89 fail_unless(url.proto == PROTO_SOCKS4); 90 fail_unless(url.port == 1080); 89 { 90 url_t url; 91 92 fail_if(0 == url_set(&url, "socks4://user@ahost/Space")); 93 fail_unless(!strcmp(url.host, "ahost")); 94 fail_unless(!strcmp(url.file, "/Space")); 95 fail_unless(!strcmp(url.user, "user")); 96 fail_unless(!strcmp(url.pass, "")); 97 fail_unless(url.proto == PROTO_SOCKS4); 98 fail_unless(url.port == 1080); 99 } 91 100 END_TEST 92 101 93 102 START_TEST(test_set_url_username_pwd) 94 url_t url; 95 96 fail_if(0 == url_set(&url, "socks5://user:pass@ahost/")); 97 fail_unless(!strcmp(url.host, "ahost")); 98 fail_unless(!strcmp(url.file, "/")); 99 fail_unless(!strcmp(url.user, "user")); 100 fail_unless(!strcmp(url.pass, "pass")); 101 fail_unless(url.proto == PROTO_SOCKS5); 102 fail_unless(url.port == 1080); 103 { 104 url_t url; 105 106 fail_if(0 == url_set(&url, "socks5://user:pass@ahost/")); 107 fail_unless(!strcmp(url.host, "ahost")); 108 fail_unless(!strcmp(url.file, "/")); 109 fail_unless(!strcmp(url.user, "user")); 110 fail_unless(!strcmp(url.pass, "pass")); 111 fail_unless(url.proto == PROTO_SOCKS5); 112 fail_unless(url.port == 1080); 113 } 103 114 END_TEST 104 115 … … 149 160 150 161 START_TEST(test_word_wrap) 151 int i; 152 153 for (i = 0; word_wrap_tests[i].orig && *word_wrap_tests[i].orig; i++) { 154 char *wrapped = word_wrap(word_wrap_tests[i].orig, word_wrap_tests[i].line_len); 155 156 fail_unless(strcmp(word_wrap_tests[i].wrapped, wrapped) == 0, 157 "%s (line_len = %d) should wrap to `%s', not to `%s'", 158 word_wrap_tests[i].orig, word_wrap_tests[i].line_len, 159 word_wrap_tests[i].wrapped, wrapped); 160 161 g_free(wrapped); 162 { 163 int i; 164 165 for (i = 0; word_wrap_tests[i].orig && *word_wrap_tests[i].orig; i++) { 166 char *wrapped = word_wrap(word_wrap_tests[i].orig, word_wrap_tests[i].line_len); 167 168 fail_unless(strcmp(word_wrap_tests[i].wrapped, wrapped) == 0, 169 "%s (line_len = %d) should wrap to `%s', not to `%s'", 170 word_wrap_tests[i].orig, word_wrap_tests[i].line_len, 171 word_wrap_tests[i].wrapped, wrapped); 172 173 g_free(wrapped); 174 } 162 175 } 163 176 END_TEST 164 177 165 178 START_TEST(test_http_encode) 166 char s[80]; 167 168 strcpy(s, "ee\xc3" "\xab" "ee!!..."); 169 http_encode(s); 170 fail_unless(strcmp(s, "ee%C3%ABee%21%21...") == 0); 179 { 180 char s[80]; 181 182 strcpy(s, "ee\xc3" "\xab" "ee!!..."); 183 http_encode(s); 184 fail_unless(strcmp(s, "ee%C3%ABee%21%21...") == 0); 185 } 171 186 END_TEST 172 187 … … 199 214 200 215 START_TEST(test_split_command_parts) 201 int i; 202 for (i = 0; split_tests[i].command; i++) { 203 char *cmd = g_strdup(split_tests[i].command); 204 char **split = split_command_parts(cmd, split_tests[i].limit); 205 char **expected = split_tests[i].expected; 206 207 int j; 208 for (j = 0; split[j] && expected[j]; j++) { 209 fail_unless(strcmp(split[j], expected[j]) == 0, 210 "(%d) split_command_parts broken: split(\"%s\")[%d] -> %s (expected: %s)", 211 i, split_tests[i].command, j, split[j], expected[j]); 212 } 213 g_free(cmd); 216 { 217 int i; 218 for (i = 0; split_tests[i].command; i++) { 219 char *cmd = g_strdup(split_tests[i].command); 220 char **split = split_command_parts(cmd, split_tests[i].limit); 221 char **expected = split_tests[i].expected; 222 223 int j; 224 for (j = 0; split[j] && expected[j]; j++) { 225 fail_unless(strcmp(split[j], expected[j]) == 0, 226 "(%d) split_command_parts broken: split(\"%s\")[%d] -> %s (expected: %s)", 227 i, split_tests[i].command, j, split[j], expected[j]); 228 } 229 g_free(cmd); 230 } 214 231 } 215 232 END_TEST
Note: See TracChangeset
for help on using the changeset viewer.