summaryrefslogtreecommitdiff
path: root/auto_tests/conference_test.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-01-28 21:30:39 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-01-30 23:35:50 +0000
commit92ffad1a72bc8c422426d52ac408bd71242dd047 (patch)
treef592f353068dd2043525dd2cc04d6124a4ed4bc4 /auto_tests/conference_test.c
parent623e9ac331df7323660e21c8a2226523a5ee713b (diff)
Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
Diffstat (limited to 'auto_tests/conference_test.c')
-rw-r--r--auto_tests/conference_test.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c
index 0b3e2e69..1826324e 100644
--- a/auto_tests/conference_test.c
+++ b/auto_tests/conference_test.c
@@ -1,7 +1,9 @@
1/* Auto Tests: Conferences. 1/* Auto Tests: Conferences.
2 */ 2 */
3 3
4#ifndef _XOPEN_SOURCE
4#define _XOPEN_SOURCE 600 5#define _XOPEN_SOURCE 600
6#endif
5 7
6#ifdef HAVE_CONFIG_H 8#ifdef HAVE_CONFIG_H
7#include "config.h" 9#include "config.h"
@@ -28,7 +30,7 @@ static void g_accept_friend_request(Tox *m, const uint8_t *public_key, const uin
28 } 30 }
29 31
30 if (length == 7 && memcmp("Gentoo", data, 7) == 0) { 32 if (length == 7 && memcmp("Gentoo", data, 7) == 0) {
31 tox_friend_add_norequest(m, public_key, 0); 33 tox_friend_add_norequest(m, public_key, nullptr);
32 } 34 }
33} 35}
34 36
@@ -49,12 +51,12 @@ static void print_group_invite_callback(Tox *tox, uint32_t friendnumber, TOX_CON
49 51
50 uint32_t g_num; 52 uint32_t g_num;
51 53
52 if ((g_num = tox_conference_join(tox, friendnumber, data, length, NULL)) == UINT32_MAX) { 54 if ((g_num = tox_conference_join(tox, friendnumber, data, length, nullptr)) == UINT32_MAX) {
53 return; 55 return;
54 } 56 }
55 57
56 ck_assert_msg(g_num == 0, "Group number was not 0"); 58 ck_assert_msg(g_num == 0, "Group number was not 0");
57 ck_assert_msg(tox_conference_join(tox, friendnumber, data, length, NULL) == -1, 59 ck_assert_msg(tox_conference_join(tox, friendnumber, data, length, nullptr) == -1,
58 "Joining groupchat twice should be impossible."); 60 "Joining groupchat twice should be impossible.");
59 61
60 invite_tox = tox; 62 invite_tox = tox;
@@ -78,7 +80,7 @@ static void print_group_message(Tox *tox, uint32_t groupnumber, uint32_t peernum
78 80
79START_TEST(test_many_group) 81START_TEST(test_many_group)
80{ 82{
81 long long unsigned int test_start_time = time(NULL); 83 long long unsigned int test_start_time = time(nullptr);
82 84
83group_test_restart: 85group_test_restart:
84 ; 86 ;
@@ -88,16 +90,16 @@ group_test_restart:
88 unsigned int i, j, k; 90 unsigned int i, j, k;
89 uint32_t to_comp = 234212; 91 uint32_t to_comp = 234212;
90 int test_run = 0; 92 int test_run = 0;
91 long long unsigned int cur_time = time(NULL); 93 long long unsigned int cur_time = time(nullptr);
92 struct Tox_Options *opts = tox_options_new(NULL); 94 struct Tox_Options *opts = tox_options_new(nullptr);
93 /* FIXME: Currently here is problems with IPv6 */ 95 /* FIXME: Currently here is problems with IPv6 */
94 tox_options_set_ipv6_enabled(opts, false); 96 tox_options_set_ipv6_enabled(opts, false);
95 97
96 for (i = 0; i < NUM_GROUP_TOX; ++i) { 98 for (i = 0; i < NUM_GROUP_TOX; ++i) {
97 tox_index[i] = i + 1; 99 tox_index[i] = i + 1;
98 toxes[i] = tox_new_log(opts, 0, &tox_index[i]); 100 toxes[i] = tox_new_log(opts, nullptr, &tox_index[i]);
99 101
100 ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); 102 ck_assert_msg(toxes[i] != nullptr, "Failed to create tox instances %u", i);
101 tox_callback_friend_request(toxes[i], &g_accept_friend_request); 103 tox_callback_friend_request(toxes[i], &g_accept_friend_request);
102 tox_callback_conference_invite(toxes[i], &print_group_invite_callback); 104 tox_callback_conference_invite(toxes[i], &print_group_invite_callback);
103 } 105 }
@@ -116,14 +118,14 @@ group_test_restart:
116 tox_self_get_address(toxes[NUM_GROUP_TOX - 1], address); 118 tox_self_get_address(toxes[NUM_GROUP_TOX - 1], address);
117 119
118 for (i = 0; i < NUM_GROUP_TOX; ++i) { 120 for (i = 0; i < NUM_GROUP_TOX; ++i) {
119 ck_assert_msg(tox_friend_add(toxes[i], address, (const uint8_t *)"Gentoo", 7, 0) == 0, "Failed to add friend"); 121 ck_assert_msg(tox_friend_add(toxes[i], address, (const uint8_t *)"Gentoo", 7, nullptr) == 0, "Failed to add friend");
120 122
121 tox_self_get_address(toxes[i], address); 123 tox_self_get_address(toxes[i], address);
122 } 124 }
123 125
124 while (1) { 126 while (1) {
125 for (i = 0; i < NUM_GROUP_TOX; ++i) { 127 for (i = 0; i < NUM_GROUP_TOX; ++i) {
126 if (tox_friend_get_connection_status(toxes[i], 0, 0) != TOX_CONNECTION_UDP) { 128 if (tox_friend_get_connection_status(toxes[i], 0, nullptr) != TOX_CONNECTION_UDP) {
127 break; 129 break;
128 } 130 }
129 } 131 }
@@ -139,11 +141,11 @@ group_test_restart:
139 c_sleep(25); 141 c_sleep(25);
140 } 142 }
141 143
142 printf("friends connected, took %llu seconds\n", time(NULL) - cur_time); 144 printf("friends connected, took %llu seconds\n", time(nullptr) - cur_time);
143 145
144 ck_assert_msg(tox_conference_new(toxes[0], NULL) != UINT32_MAX, "Failed to create group"); 146 ck_assert_msg(tox_conference_new(toxes[0], nullptr) != UINT32_MAX, "Failed to create group");
145 ck_assert_msg(tox_conference_invite(toxes[0], 0, 0, NULL) != 0, "Failed to invite friend"); 147 ck_assert_msg(tox_conference_invite(toxes[0], 0, 0, nullptr) != 0, "Failed to invite friend");
146 ck_assert_msg(tox_conference_set_title(toxes[0], 0, (const uint8_t *)"Gentoo", sizeof("Gentoo") - 1, NULL) != 0, 148 ck_assert_msg(tox_conference_set_title(toxes[0], 0, (const uint8_t *)"Gentoo", sizeof("Gentoo") - 1, nullptr) != 0,
147 "Failed to set group title"); 149 "Failed to set group title");
148 invite_counter = ~0; 150 invite_counter = ~0;
149 151
@@ -156,7 +158,7 @@ group_test_restart:
156 } 158 }
157 159
158 if (!invite_counter) { 160 if (!invite_counter) {
159 ck_assert_msg(tox_conference_invite(invite_tox, 0, 0, NULL) != 0, "Failed to invite friend"); 161 ck_assert_msg(tox_conference_invite(invite_tox, 0, 0, nullptr) != 0, "Failed to invite friend");
160 } 162 }
161 163
162 if (done == invite_counter) { 164 if (done == invite_counter) {
@@ -168,7 +170,7 @@ group_test_restart:
168 } 170 }
169 171
170 for (i = 0; i < NUM_GROUP_TOX; ++i) { 172 for (i = 0; i < NUM_GROUP_TOX; ++i) {
171 uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, NULL); 173 uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, nullptr);
172 174
173 /** 175 /**
174 * Group chats fail unpredictably, currently they'll rerun as many times 176 * Group chats fail unpredictably, currently they'll rerun as many times
@@ -199,9 +201,9 @@ group_test_restart:
199 NUM_GROUP_TOX, i, peer_count); 201 NUM_GROUP_TOX, i, peer_count);
200 202
201 uint8_t title[2048]; 203 uint8_t title[2048];
202 size_t ret = tox_conference_get_title_size(toxes[i], 0, NULL); 204 size_t ret = tox_conference_get_title_size(toxes[i], 0, nullptr);
203 ck_assert_msg(ret == sizeof("Gentoo") - 1, "Wrong title length"); 205 ck_assert_msg(ret == sizeof("Gentoo") - 1, "Wrong title length");
204 tox_conference_get_title(toxes[i], 0, title, NULL); 206 tox_conference_get_title(toxes[i], 0, title, nullptr);
205 ck_assert_msg(memcmp("Gentoo", title, ret) == 0, "Wrong title"); 207 ck_assert_msg(memcmp("Gentoo", title, ret) == 0, "Wrong title");
206 } 208 }
207 209
@@ -232,7 +234,7 @@ group_test_restart:
232 ck_assert_msg(num_recv == NUM_GROUP_TOX, "Failed to recv group messages."); 234 ck_assert_msg(num_recv == NUM_GROUP_TOX, "Failed to recv group messages.");
233 235
234 for (k = NUM_GROUP_TOX; k != 0 ; --k) { 236 for (k = NUM_GROUP_TOX; k != 0 ; --k) {
235 tox_conference_delete(toxes[k - 1], 0, NULL); 237 tox_conference_delete(toxes[k - 1], 0, nullptr);
236 238
237 for (j = 0; j < 10; ++j) { 239 for (j = 0; j < 10; ++j) {
238 for (i = 0; i < NUM_GROUP_TOX; ++i) { 240 for (i = 0; i < NUM_GROUP_TOX; ++i) {
@@ -243,7 +245,7 @@ group_test_restart:
243 } 245 }
244 246
245 for (i = 0; i < (k - 1); ++i) { 247 for (i = 0; i < (k - 1); ++i) {
246 uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, NULL); 248 uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, nullptr);
247 ck_assert_msg(peer_count == (k - 1), "\n\tBad number of group peers (post check)." 249 ck_assert_msg(peer_count == (k - 1), "\n\tBad number of group peers (post check)."
248 "\n\t\t\tExpected: %u but tox_instance(%u) only has: %" PRIu32 "\n\n", 250 "\n\t\t\tExpected: %u but tox_instance(%u) only has: %" PRIu32 "\n\n",
249 (k - 1), i, peer_count); 251 (k - 1), i, peer_count);
@@ -254,7 +256,7 @@ group_test_restart:
254 tox_kill(toxes[i]); 256 tox_kill(toxes[i]);
255 } 257 }
256 258
257 printf("test_many_group succeeded, took %llu seconds\n", time(NULL) - test_start_time); 259 printf("test_many_group succeeded, took %llu seconds\n", time(nullptr) - test_start_time);
258} 260}
259END_TEST 261END_TEST
260 262
@@ -275,7 +277,7 @@ static Suite *tox_suite(void)
275 277
276int main(int argc, char *argv[]) 278int main(int argc, char *argv[])
277{ 279{
278 srand((unsigned int) time(NULL)); 280 srand((unsigned int) time(nullptr));
279 281
280 Suite *tox = tox_suite(); 282 Suite *tox = tox_suite();
281 SRunner *test_runner = srunner_create(tox); 283 SRunner *test_runner = srunner_create(tox);