summaryrefslogtreecommitdiff
path: root/testing/random_testing.cc
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-10-08 21:05:14 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-10-09 17:33:37 +0000
commit605dfe882c52bfad4dee9678a69e4b816d93431d (patch)
tree10432adc5d3716cb28b833c6e156218b67c23494 /testing/random_testing.cc
parent77e025fae48a4f9cf6cf19a359b6c423545f3cc7 (diff)
Consistently use camel case enum names.
Including in tests and implementation files.
Diffstat (limited to 'testing/random_testing.cc')
-rw-r--r--testing/random_testing.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/testing/random_testing.cc b/testing/random_testing.cc
index 6211630e..463a4fb3 100644
--- a/testing/random_testing.cc
+++ b/testing/random_testing.cc
@@ -119,7 +119,7 @@ struct Global_State : std::vector<Local_State> {
119Global_State::~Global_State() {} 119Global_State::~Global_State() {}
120 120
121void handle_friend_connection_status(Tox *tox, uint32_t friend_number, 121void handle_friend_connection_status(Tox *tox, uint32_t friend_number,
122 TOX_CONNECTION connection_status, void *user_data) { 122 Tox_Connection connection_status, void *user_data) {
123 Local_State *state = static_cast<Local_State *>(user_data); 123 Local_State *state = static_cast<Local_State *>(user_data);
124 124
125 if (connection_status == TOX_CONNECTION_NONE) { 125 if (connection_status == TOX_CONNECTION_NONE) {
@@ -130,7 +130,7 @@ void handle_friend_connection_status(Tox *tox, uint32_t friend_number,
130 } 130 }
131} 131}
132 132
133void handle_conference_invite(Tox *tox, uint32_t friend_number, TOX_CONFERENCE_TYPE type, 133void handle_conference_invite(Tox *tox, uint32_t friend_number, Tox_Conference_Type type,
134 const uint8_t *cookie, size_t length, void *user_data) { 134 const uint8_t *cookie, size_t length, void *user_data) {
135 Local_State *state = static_cast<Local_State *>(user_data); 135 Local_State *state = static_cast<Local_State *>(user_data);
136 136
@@ -138,13 +138,13 @@ void handle_conference_invite(Tox *tox, uint32_t friend_number, TOX_CONFERENCE_T
138 std::printf("Tox #%u joins the conference it was invited to\n", state->id()); 138 std::printf("Tox #%u joins the conference it was invited to\n", state->id());
139 } 139 }
140 140
141 TOX_ERR_CONFERENCE_JOIN err; 141 Tox_Err_Conference_Join err;
142 tox_conference_join(tox, friend_number, cookie, length, &err); 142 tox_conference_join(tox, friend_number, cookie, length, &err);
143 assert(err == TOX_ERR_CONFERENCE_JOIN_OK); 143 assert(err == TOX_ERR_CONFERENCE_JOIN_OK);
144} 144}
145 145
146void handle_conference_message(Tox *tox, uint32_t conference_number, uint32_t peer_number, 146void handle_conference_message(Tox *tox, uint32_t conference_number, uint32_t peer_number,
147 TOX_MESSAGE_TYPE type, const uint8_t *message, size_t length, 147 Tox_Message_Type type, const uint8_t *message, size_t length,
148 void *user_data) { 148 void *user_data) {
149 Local_State *state = static_cast<Local_State *>(user_data); 149 Local_State *state = static_cast<Local_State *>(user_data);
150 150
@@ -161,7 +161,7 @@ void handle_conference_peer_list_changed(Tox *tox, uint32_t conference_number, v
161 std::printf("Tox #%u rebuilds peer list for conference %u\n", state->id(), conference_number); 161 std::printf("Tox #%u rebuilds peer list for conference %u\n", state->id(), conference_number);
162 } 162 }
163 163
164 TOX_ERR_CONFERENCE_PEER_QUERY err; 164 Tox_Err_Conference_Peer_Query err;
165 uint32_t const count = tox_conference_peer_count(tox, conference_number, &err); 165 uint32_t const count = tox_conference_peer_count(tox, conference_number, &err);
166 assert(err == TOX_ERR_CONFERENCE_PEER_QUERY_OK); 166 assert(err == TOX_ERR_CONFERENCE_PEER_QUERY_OK);
167 167
@@ -182,7 +182,7 @@ Global_State make_toxes(std::vector<Action> const &actions) {
182 tox_options_set_local_discovery_enabled(options.get(), false); 182 tox_options_set_local_discovery_enabled(options.get(), false);
183 183
184 for (uint32_t i = 0; i < NUM_TOXES; i++) { 184 for (uint32_t i = 0; i < NUM_TOXES; i++) {
185 TOX_ERR_NEW err; 185 Tox_Err_New err;
186 toxes.emplace_back(Tox_Ptr(tox_new(options.get(), &err)), i); 186 toxes.emplace_back(Tox_Ptr(tox_new(options.get(), &err)), i);
187 assert(err == TOX_ERR_NEW_OK); 187 assert(err == TOX_ERR_NEW_OK);
188 assert(toxes.back().tox() != nullptr); 188 assert(toxes.back().tox() != nullptr);
@@ -201,7 +201,7 @@ Global_State make_toxes(std::vector<Action> const &actions) {
201 const uint16_t dht_port = tox_self_get_udp_port(toxes.front().tox(), nullptr); 201 const uint16_t dht_port = tox_self_get_udp_port(toxes.front().tox(), nullptr);
202 202
203 for (Local_State const &state : toxes) { 203 for (Local_State const &state : toxes) {
204 TOX_ERR_BOOTSTRAP err; 204 Tox_Err_Bootstrap err;
205 tox_bootstrap(state.tox(), "localhost", dht_port, dht_key, &err); 205 tox_bootstrap(state.tox(), "localhost", dht_port, dht_key, &err);
206 assert(err == TOX_ERR_BOOTSTRAP_OK); 206 assert(err == TOX_ERR_BOOTSTRAP_OK);
207 } 207 }
@@ -211,7 +211,7 @@ Global_State make_toxes(std::vector<Action> const &actions) {
211 for (Local_State const &state1 : toxes) { 211 for (Local_State const &state1 : toxes) {
212 for (Local_State const &state2 : toxes) { 212 for (Local_State const &state2 : toxes) {
213 if (state1.tox() != state2.tox()) { 213 if (state1.tox() != state2.tox()) {
214 TOX_ERR_FRIEND_ADD err; 214 Tox_Err_Friend_Add err;
215 uint8_t key[TOX_PUBLIC_KEY_SIZE]; 215 uint8_t key[TOX_PUBLIC_KEY_SIZE];
216 216
217 tox_self_get_public_key(state1.tox(), key); 217 tox_self_get_public_key(state1.tox(), key);
@@ -289,7 +289,7 @@ int main() {
289 return tox_conference_get_chatlist_size(state.tox()) < MAX_CONFERENCES_PER_USER; 289 return tox_conference_get_chatlist_size(state.tox()) < MAX_CONFERENCES_PER_USER;
290 }, 290 },
291 [](Local_State *state, Random *rnd, std::mt19937 *rng) { 291 [](Local_State *state, Random *rnd, std::mt19937 *rng) {
292 TOX_ERR_CONFERENCE_NEW err; 292 Tox_Err_Conference_New err;
293 tox_conference_new(state->tox(), &err); 293 tox_conference_new(state->tox(), &err);
294 assert(err == TOX_ERR_CONFERENCE_NEW_OK); 294 assert(err == TOX_ERR_CONFERENCE_NEW_OK);
295 }, 295 },
@@ -303,7 +303,7 @@ int main() {
303 [](Local_State *state, Random *rnd, std::mt19937 *rng) { 303 [](Local_State *state, Random *rnd, std::mt19937 *rng) {
304 size_t chat_count = tox_conference_get_chatlist_size(state->tox()); 304 size_t chat_count = tox_conference_get_chatlist_size(state->tox());
305 assert(chat_count != 0); // Condition above. 305 assert(chat_count != 0); // Condition above.
306 TOX_ERR_CONFERENCE_INVITE err; 306 Tox_Err_Conference_Invite err;
307 tox_conference_invite(state->tox(), rnd->friend_selector(*rng), 307 tox_conference_invite(state->tox(), rnd->friend_selector(*rng),
308 state->next_invite % chat_count, &err); 308 state->next_invite % chat_count, &err);
309 state->next_invite++; 309 state->next_invite++;
@@ -317,7 +317,7 @@ int main() {
317 return tox_conference_get_chatlist_size(state.tox()) != 0; 317 return tox_conference_get_chatlist_size(state.tox()) != 0;
318 }, 318 },
319 [](Local_State *state, Random *rnd, std::mt19937 *rng) { 319 [](Local_State *state, Random *rnd, std::mt19937 *rng) {
320 TOX_ERR_CONFERENCE_DELETE err; 320 Tox_Err_Conference_Delete err;
321 tox_conference_delete(state->tox(), tox_conference_get_chatlist_size(state->tox()) - 1, 321 tox_conference_delete(state->tox(), tox_conference_get_chatlist_size(state->tox()) - 1,
322 &err); 322 &err);
323 assert(err == TOX_ERR_CONFERENCE_DELETE_OK); 323 assert(err == TOX_ERR_CONFERENCE_DELETE_OK);
@@ -335,7 +335,7 @@ int main() {
335 byte = rnd->byte_selector(*rng); 335 byte = rnd->byte_selector(*rng);
336 } 336 }
337 337
338 TOX_ERR_CONFERENCE_SEND_MESSAGE err; 338 Tox_Err_Conference_Send_Message err;
339 tox_conference_send_message( 339 tox_conference_send_message(
340 state->tox(), tox_conference_get_chatlist_size(state->tox()) - 1, 340 state->tox(), tox_conference_get_chatlist_size(state->tox()) - 1,
341 TOX_MESSAGE_TYPE_NORMAL, message.data(), message.size(), &err); 341 TOX_MESSAGE_TYPE_NORMAL, message.data(), message.size(), &err);
@@ -356,7 +356,7 @@ int main() {
356 byte = rnd->byte_selector(*rng); 356 byte = rnd->byte_selector(*rng);
357 } 357 }
358 358
359 TOX_ERR_SET_INFO err; 359 Tox_Err_Set_Info err;
360 tox_self_set_name(state->tox(), name.data(), name.size(), &err); 360 tox_self_set_name(state->tox(), name.data(), name.size(), &err);
361 assert(err == TOX_ERR_SET_INFO_OK); 361 assert(err == TOX_ERR_SET_INFO_OK);
362 362
@@ -368,7 +368,7 @@ int main() {
368 "sets their name to empty", 368 "sets their name to empty",
369 [](Local_State const &state) { return true; }, 369 [](Local_State const &state) { return true; },
370 [](Local_State *state, Random *rnd, std::mt19937 *rng) { 370 [](Local_State *state, Random *rnd, std::mt19937 *rng) {
371 TOX_ERR_SET_INFO err; 371 Tox_Err_Set_Info err;
372 tox_self_set_name(state->tox(), nullptr, 0, &err); 372 tox_self_set_name(state->tox(), nullptr, 0, &err);
373 assert(err == TOX_ERR_SET_INFO_OK); 373 assert(err == TOX_ERR_SET_INFO_OK);
374 }, 374 },