diff options
-rw-r--r-- | auto_tests/messenger_test.c | 42 | ||||
-rwxr-xr-x | auto_tests/run_tests | 5 |
2 files changed, 20 insertions, 27 deletions
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c index 374bc5a6..3ca89152 100644 --- a/auto_tests/messenger_test.c +++ b/auto_tests/messenger_test.c | |||
@@ -87,13 +87,13 @@ START_TEST(test_m_set_userstatus) | |||
87 | uint16_t good_length = strlen(status); | 87 | uint16_t good_length = strlen(status); |
88 | uint16_t bad_length = REALLY_BIG_NUMBER; | 88 | uint16_t bad_length = REALLY_BIG_NUMBER; |
89 | 89 | ||
90 | if (m_set_statusmessage(m, (uint8_t *)status, bad_length) != -1) | 90 | ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, bad_length) == -1), |
91 | ck_abort_msg("m_set_userstatus did NOT catch the following length: %d\n", | 91 | "m_set_userstatus did NOT catch the following length: %d\n", |
92 | REALLY_BIG_NUMBER); | 92 | REALLY_BIG_NUMBER); |
93 | 93 | ||
94 | if ((m_set_statusmessage(m, (uint8_t *)status, good_length)) != 0) | 94 | ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, good_length) == 0), |
95 | ck_abort_msg("m_set_userstatus did NOT return 0 on the following length: %d\n" | 95 | "m_set_userstatus did NOT return 0 on the following length: %d\n" |
96 | "MAX_STATUSMESSAGE_LENGTH: %d\n", good_length, MAX_STATUSMESSAGE_LENGTH); | 96 | "MAX_STATUSMESSAGE_LENGTH: %d\n", good_length, MAX_STATUSMESSAGE_LENGTH); |
97 | } | 97 | } |
98 | END_TEST | 98 | END_TEST |
99 | 99 | ||
@@ -156,12 +156,11 @@ START_TEST(test_setname) | |||
156 | int good_length = strlen(good_name); | 156 | int good_length = strlen(good_name); |
157 | int bad_length = REALLY_BIG_NUMBER; | 157 | int bad_length = REALLY_BIG_NUMBER; |
158 | 158 | ||
159 | if (setname(m, (uint8_t *)good_name, bad_length) != -1) | 159 | ck_assert_msg((setname(m, (uint8_t *)good_name, bad_length) == -1), |
160 | ck_abort_msg("setname() did NOT error on %d as a length argument!\n", | 160 | "setname() did NOT error on %d as a length argument!\n", bad_length); |
161 | bad_length); | ||
162 | 161 | ||
163 | if (setname(m, (uint8_t *)good_name, good_length) != 0) | 162 | ck_assert_msg((setname(m, (uint8_t *)good_name, good_length) == 0), |
164 | ck_abort_msg("setname() did NOT return 0 on good arguments!\n"); | 163 | "setname() did NOT return 0 on good arguments!\n"); |
165 | } | 164 | } |
166 | END_TEST | 165 | END_TEST |
167 | 166 | ||
@@ -197,24 +196,20 @@ START_TEST(test_m_copy_userstatus) | |||
197 | END_TEST | 196 | END_TEST |
198 | */ | 197 | */ |
199 | 198 | ||
200 | /* this test is excluded for now, due to lack of a way | ||
201 | * to set a friend's nickname for now. | ||
202 | * ideas: | ||
203 | * if we have access to the friends list, we could | ||
204 | * just add a name manually ourselves. */ | ||
205 | /* | ||
206 | START_TEST(test_getname) | 199 | START_TEST(test_getname) |
207 | { | 200 | { |
208 | uint8_t name_buf[MAX_NAME_LENGTH]; | 201 | uint8_t name_buf[MAX_NAME_LENGTH]; |
202 | uint8_t test_name[] = {'f', 'o', 'o'}; | ||
203 | |||
204 | ck_assert(getname(m, -1, name_buf) == -1); | ||
205 | ck_assert(getname(m, REALLY_BIG_NUMBER, name_buf) == -1); | ||
209 | 206 | ||
210 | assert(getname(-1, name_buf) == -1); | 207 | memcpy(m->friendlist[0].name, &test_name[0], 3); |
211 | assert(getname(REALLY_BIG_NUMBER, name_buf) == -1); | 208 | getname(m, 0, &name_buf[0]); |
212 | 209 | ||
213 | getname(friend_id_num, name_buf); | 210 | ck_assert(strcmp((char *)&name_buf[0], "foo") == 0); |
214 | assert(name_buf[MAX_NAME_LENGTH] == '\0'); // something like this | ||
215 | } | 211 | } |
216 | END_TEST | 212 | END_TEST |
217 | */ | ||
218 | 213 | ||
219 | Suite *messenger_suite(void) | 214 | Suite *messenger_suite(void) |
220 | { | 215 | { |
@@ -228,6 +223,7 @@ Suite *messenger_suite(void) | |||
228 | TCase *delfriend = tcase_create("delfriend"); | 223 | TCase *delfriend = tcase_create("delfriend"); |
229 | //TCase *addfriend = tcase_create("addfriend"); | 224 | //TCase *addfriend = tcase_create("addfriend"); |
230 | TCase *setname = tcase_create("setname"); | 225 | TCase *setname = tcase_create("setname"); |
226 | TCase *getname = tcase_create("getname"); | ||
231 | 227 | ||
232 | tcase_add_test(userstatus_size, test_m_get_userstatus_size); | 228 | tcase_add_test(userstatus_size, test_m_get_userstatus_size); |
233 | tcase_add_test(set_userstatus, test_m_set_userstatus); | 229 | tcase_add_test(set_userstatus, test_m_set_userstatus); |
@@ -236,6 +232,7 @@ Suite *messenger_suite(void) | |||
236 | tcase_add_test(send_message, test_m_sendmesage); | 232 | tcase_add_test(send_message, test_m_sendmesage); |
237 | tcase_add_test(delfriend, test_m_delfriend); | 233 | tcase_add_test(delfriend, test_m_delfriend); |
238 | //tcase_add_test(addfriend, test_m_addfriend); | 234 | //tcase_add_test(addfriend, test_m_addfriend); |
235 | tcase_add_test(setname, test_getname); | ||
239 | tcase_add_test(setname, test_setname); | 236 | tcase_add_test(setname, test_setname); |
240 | 237 | ||
241 | suite_add_tcase(s, userstatus_size); | 238 | suite_add_tcase(s, userstatus_size); |
@@ -245,6 +242,7 @@ Suite *messenger_suite(void) | |||
245 | suite_add_tcase(s, getself_name); | 242 | suite_add_tcase(s, getself_name); |
246 | suite_add_tcase(s, delfriend); | 243 | suite_add_tcase(s, delfriend); |
247 | //suite_add_tcase(s, addfriend); | 244 | //suite_add_tcase(s, addfriend); |
245 | suite_add_tcase(s, getname); | ||
248 | suite_add_tcase(s, setname); | 246 | suite_add_tcase(s, setname); |
249 | 247 | ||
250 | return s; | 248 | return s; |
diff --git a/auto_tests/run_tests b/auto_tests/run_tests deleted file mode 100755 index 1899f354..00000000 --- a/auto_tests/run_tests +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | # run_tests - run the current tests for tox core | ||
3 | set -e | ||
4 | |||
5 | ./messenger_test && ./friends_test && ./crypto_test | ||