diff options
author | hugbubby <hugbubby@protonmail.com> | 2018-07-15 18:12:16 -0700 |
---|---|---|
committer | hugbubby <hugbubby@protonmail.com> | 2018-07-18 13:55:30 -0700 |
commit | a592f0fa87c96f1c2dea1406e4dcbfa5cde4f8f1 (patch) | |
tree | c81dafd7a0cc359e66e0ba2b1aa09f9b123c0b0d /auto_tests | |
parent | 864d1c15e4a3b8df236af320312e8115c6bcd791 (diff) |
Wrong use of unsigned integer.
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/conference_test.c | 26 | ||||
-rw-r--r-- | auto_tests/conference_two_test.c | 6 | ||||
-rw-r--r-- | auto_tests/dht_test.c | 4 |
3 files changed, 18 insertions, 18 deletions
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c index 374274b8..706dad38 100644 --- a/auto_tests/conference_test.c +++ b/auto_tests/conference_test.c | |||
@@ -68,7 +68,7 @@ static void handle_conference_invite( | |||
68 | 68 | ||
69 | if (tox_self_get_friend_list_size(tox) > 1) { | 69 | if (tox_self_get_friend_list_size(tox) > 1) { |
70 | printf("tox #%d: inviting next friend\n", id); | 70 | printf("tox #%d: inviting next friend\n", id); |
71 | ck_assert_msg(tox_conference_invite(tox, 1, g_num, nullptr) != 0, "Failed to invite friend"); | 71 | ck_assert_msg(tox_conference_invite(tox, 1, g_num, nullptr) != 0, "failed to invite friend"); |
72 | } else { | 72 | } else { |
73 | printf("tox #%d was the last tox, no further invites happening\n", id); | 73 | printf("tox #%d was the last tox, no further invites happening\n", id); |
74 | } | 74 | } |
@@ -95,9 +95,9 @@ static void run_conference_tests(Tox **toxes, uint32_t *tox_index) | |||
95 | ck_assert_msg( | 95 | ck_assert_msg( |
96 | tox_conference_send_message( | 96 | tox_conference_send_message( |
97 | toxes[random_u32() % NUM_GROUP_TOX], 0, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)GROUP_MESSAGE, | 97 | toxes[random_u32() % NUM_GROUP_TOX], 0, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)GROUP_MESSAGE, |
98 | sizeof(GROUP_MESSAGE) - 1, &err) != 0, "Failed to send group message."); | 98 | sizeof(GROUP_MESSAGE) - 1, &err) != 0, "failed to send group message"); |
99 | ck_assert_msg( | 99 | ck_assert_msg( |
100 | err == TOX_ERR_CONFERENCE_SEND_MESSAGE_OK, "Failed to send group message."); | 100 | err == TOX_ERR_CONFERENCE_SEND_MESSAGE_OK, "failed to send group message"); |
101 | num_recv = 0; | 101 | num_recv = 0; |
102 | 102 | ||
103 | for (uint8_t j = 0; j < 20; ++j) { | 103 | for (uint8_t j = 0; j < 20; ++j) { |
@@ -109,7 +109,7 @@ static void run_conference_tests(Tox **toxes, uint32_t *tox_index) | |||
109 | } | 109 | } |
110 | 110 | ||
111 | c_sleep(25); | 111 | c_sleep(25); |
112 | ck_assert_msg(num_recv == NUM_GROUP_TOX, "Failed to recv group messages."); | 112 | ck_assert_msg(num_recv == NUM_GROUP_TOX, "failed to recv group messages"); |
113 | 113 | ||
114 | for (uint16_t k = NUM_GROUP_TOX; k != 0 ; --k) { | 114 | for (uint16_t k = NUM_GROUP_TOX; k != 0 ; --k) { |
115 | tox_conference_delete(toxes[k - 1], 0, nullptr); | 115 | tox_conference_delete(toxes[k - 1], 0, nullptr); |
@@ -149,7 +149,7 @@ static void test_many_group(void) | |||
149 | tox_index[i] = i + 1; | 149 | tox_index[i] = i + 1; |
150 | toxes[i] = tox_new_log(opts, &err, &tox_index[i]); | 150 | toxes[i] = tox_new_log(opts, &err, &tox_index[i]); |
151 | 151 | ||
152 | ck_assert_msg(toxes[i] != nullptr, "Failed to create tox instance %u: error %d", i, err); | 152 | ck_assert_msg(toxes[i] != nullptr, "failed to create tox instance %u: error %d", i, err); |
153 | tox_callback_self_connection_status(toxes[i], &handle_self_connection_status); | 153 | tox_callback_self_connection_status(toxes[i], &handle_self_connection_status); |
154 | tox_callback_friend_connection_status(toxes[i], &handle_friend_connection_status); | 154 | tox_callback_friend_connection_status(toxes[i], &handle_friend_connection_status); |
155 | tox_callback_conference_invite(toxes[i], &handle_conference_invite); | 155 | tox_callback_conference_invite(toxes[i], &handle_conference_invite); |
@@ -173,11 +173,11 @@ static void test_many_group(void) | |||
173 | 173 | ||
174 | tox_self_get_public_key(toxes[i - 1], key); | 174 | tox_self_get_public_key(toxes[i - 1], key); |
175 | tox_friend_add_norequest(toxes[i], key, &err); | 175 | tox_friend_add_norequest(toxes[i], key, &err); |
176 | ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "Failed to add friend: error %d", err); | 176 | ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "failed to add friend: error %d", err); |
177 | 177 | ||
178 | tox_self_get_public_key(toxes[i], key); | 178 | tox_self_get_public_key(toxes[i], key); |
179 | tox_friend_add_norequest(toxes[i - 1], key, &err); | 179 | tox_friend_add_norequest(toxes[i - 1], key, &err); |
180 | ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "Failed to add friend: error %d", err); | 180 | ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "failed to add friend: error %d", err); |
181 | } | 181 | } |
182 | 182 | ||
183 | printf("waiting for everyone to come online\n"); | 183 | printf("waiting for everyone to come online\n"); |
@@ -197,13 +197,13 @@ static void test_many_group(void) | |||
197 | c_sleep(1000); | 197 | c_sleep(1000); |
198 | } | 198 | } |
199 | 199 | ||
200 | printf("friends connected, took %d seconds\n", (uint16_t)(time(nullptr) - cur_time)); | 200 | printf("friends connected, took %d seconds\n", (int)(time(nullptr) - cur_time)); |
201 | 201 | ||
202 | ck_assert_msg(tox_conference_new(toxes[0], nullptr) != UINT32_MAX, "Failed to create group"); | 202 | ck_assert_msg(tox_conference_new(toxes[0], nullptr) != UINT32_MAX, "failed to create group"); |
203 | printf("tox #%d: inviting its first friend\n", tox_index[0]); | 203 | printf("tox #%d: inviting its first friend\n", tox_index[0]); |
204 | ck_assert_msg(tox_conference_invite(toxes[0], 0, 0, nullptr) != 0, "Failed to invite friend"); | 204 | ck_assert_msg(tox_conference_invite(toxes[0], 0, 0, nullptr) != 0, "failed to invite friend"); |
205 | ck_assert_msg(tox_conference_set_title(toxes[0], 0, (const uint8_t *)"Gentoo", sizeof("Gentoo") - 1, nullptr) != 0, | 205 | ck_assert_msg(tox_conference_set_title(toxes[0], 0, (const uint8_t *)"Gentoo", sizeof("Gentoo") - 1, nullptr) != 0, |
206 | "Failed to set group title"); | 206 | "failed to set group title"); |
207 | 207 | ||
208 | // One iteration for all the invitations to happen. | 208 | // One iteration for all the invitations to happen. |
209 | for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) { | 209 | for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) { |
@@ -250,7 +250,7 @@ static void test_many_group(void) | |||
250 | ck_assert_msg(memcmp("Gentoo", title, ret) == 0, "Wrong title"); | 250 | ck_assert_msg(memcmp("Gentoo", title, ret) == 0, "Wrong title"); |
251 | } | 251 | } |
252 | 252 | ||
253 | printf("group connected, took %d seconds\n", (uint16_t)(time(nullptr) - cur_time)); | 253 | printf("group connected, took %d seconds\n", (int)(time(nullptr) - cur_time)); |
254 | 254 | ||
255 | run_conference_tests(toxes, tox_index); | 255 | run_conference_tests(toxes, tox_index); |
256 | 256 | ||
@@ -260,7 +260,7 @@ static void test_many_group(void) | |||
260 | tox_kill(toxes[i]); | 260 | tox_kill(toxes[i]); |
261 | } | 261 | } |
262 | 262 | ||
263 | printf("test_many_group succeeded, took %d seconds\n", (uint16_t)(time(nullptr) - test_start_time)); | 263 | printf("test_many_group succeeded, took %d seconds\n", (int)(time(nullptr) - test_start_time)); |
264 | } | 264 | } |
265 | 265 | ||
266 | int main(void) | 266 | int main(void) |
diff --git a/auto_tests/conference_two_test.c b/auto_tests/conference_two_test.c index 8d834dc4..c3036165 100644 --- a/auto_tests/conference_two_test.c +++ b/auto_tests/conference_two_test.c | |||
@@ -14,15 +14,15 @@ | |||
14 | int main(void) | 14 | int main(void) |
15 | { | 15 | { |
16 | // Create toxes. | 16 | // Create toxes. |
17 | uint8_t id = 1; | 17 | uint32_t id = 1; |
18 | Tox *tox1 = tox_new_log(nullptr, nullptr, &id); | 18 | Tox *tox1 = tox_new_log(nullptr, nullptr, &id); |
19 | 19 | ||
20 | // Create two conferences and then exit. | 20 | // Create two conferences and then exit. |
21 | TOX_ERR_CONFERENCE_NEW err; | 21 | TOX_ERR_CONFERENCE_NEW err; |
22 | tox_conference_new(tox1, &err); | 22 | tox_conference_new(tox1, &err); |
23 | ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "Failed to create conference 1: %d.", err); | 23 | ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 1: %d", err); |
24 | tox_conference_new(tox1, &err); | 24 | tox_conference_new(tox1, &err); |
25 | ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "Failed to create conference 2: %d.", err); | 25 | ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 2: %d", err); |
26 | 26 | ||
27 | tox_kill(tox1); | 27 | tox_kill(tox1); |
28 | 28 | ||
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index dec803e5..1d519951 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c | |||
@@ -96,7 +96,7 @@ static int client_in_list(Client_data *list, uint32_t length, const uint8_t *pub | |||
96 | { | 96 | { |
97 | uint32_t i; | 97 | uint32_t i; |
98 | 98 | ||
99 | for (i = 0; i < (uint32_t)length; ++i) { | 99 | for (i = 0; i < length; ++i) { |
100 | if (id_equal(public_key, list[i].public_key)) { | 100 | if (id_equal(public_key, list[i].public_key)) { |
101 | return i; | 101 | return i; |
102 | } | 102 | } |
@@ -710,7 +710,7 @@ END_TEST | |||
710 | 710 | ||
711 | static void dht_pack_unpack(const Node_format *nodes, size_t size, uint8_t *data, size_t length) | 711 | static void dht_pack_unpack(const Node_format *nodes, size_t size, uint8_t *data, size_t length) |
712 | { | 712 | { |
713 | uint16_t packed_size = pack_nodes(data, length, nodes, size); | 713 | int16_t packed_size = pack_nodes(data, length, nodes, size); |
714 | ck_assert_msg(packed_size != -1, "Wrong pack_nodes result"); | 714 | ck_assert_msg(packed_size != -1, "Wrong pack_nodes result"); |
715 | 715 | ||
716 | uint16_t processed = 0; | 716 | uint16_t processed = 0; |