diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-08-26 09:42:08 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-08-26 17:32:19 +0000 |
commit | a1035cf81494c3ab22c49b01788ca8ad933c5eb0 (patch) | |
tree | fee86f8751cc93eca9702fd50c3380483ff0f86a /testing | |
parent | 64ddb7fff21e8cfcd197ba31bbb08ee6d3964c54 (diff) |
Add some tests for `ping_array`.
No timeout test here yet, because we don't yet have the ability to
manipulate time at will, so we would have to actually sleep.
Diffstat (limited to 'testing')
-rw-r--r-- | testing/random_testing.cc | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/testing/random_testing.cc b/testing/random_testing.cc index 5ea0bc9d..6211630e 100644 --- a/testing/random_testing.cc +++ b/testing/random_testing.cc | |||
@@ -283,7 +283,8 @@ bool attempt_action(Global_State *toxes, std::mt19937 *rng) { | |||
283 | int main() { | 283 | int main() { |
284 | std::vector<Action> const actions = { | 284 | std::vector<Action> const actions = { |
285 | { | 285 | { |
286 | 10, "creates a new conference", | 286 | 10, |
287 | "creates a new conference", | ||
287 | [](Local_State const &state) { | 288 | [](Local_State const &state) { |
288 | 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; |
289 | }, | 290 | }, |
@@ -294,7 +295,8 @@ int main() { | |||
294 | }, | 295 | }, |
295 | }, | 296 | }, |
296 | { | 297 | { |
297 | 10, "invites a random friend to a conference", | 298 | 10, |
299 | "invites a random friend to a conference", | ||
298 | [](Local_State const &state) { | 300 | [](Local_State const &state) { |
299 | return tox_conference_get_chatlist_size(state.tox()) != 0; | 301 | return tox_conference_get_chatlist_size(state.tox()) != 0; |
300 | }, | 302 | }, |
@@ -302,15 +304,15 @@ int main() { | |||
302 | size_t chat_count = tox_conference_get_chatlist_size(state->tox()); | 304 | size_t chat_count = tox_conference_get_chatlist_size(state->tox()); |
303 | assert(chat_count != 0); // Condition above. | 305 | assert(chat_count != 0); // Condition above. |
304 | TOX_ERR_CONFERENCE_INVITE err; | 306 | TOX_ERR_CONFERENCE_INVITE err; |
305 | tox_conference_invite( | 307 | tox_conference_invite(state->tox(), rnd->friend_selector(*rng), |
306 | state->tox(), rnd->friend_selector(*rng), | 308 | state->next_invite % chat_count, &err); |
307 | state->next_invite % chat_count, &err); | ||
308 | state->next_invite++; | 309 | state->next_invite++; |
309 | assert(err == TOX_ERR_CONFERENCE_INVITE_OK); | 310 | assert(err == TOX_ERR_CONFERENCE_INVITE_OK); |
310 | }, | 311 | }, |
311 | }, | 312 | }, |
312 | { | 313 | { |
313 | 10, "deletes the last conference", | 314 | 10, |
315 | "deletes the last conference", | ||
314 | [](Local_State const &state) { | 316 | [](Local_State const &state) { |
315 | return tox_conference_get_chatlist_size(state.tox()) != 0; | 317 | return tox_conference_get_chatlist_size(state.tox()) != 0; |
316 | }, | 318 | }, |
@@ -322,7 +324,8 @@ int main() { | |||
322 | }, | 324 | }, |
323 | }, | 325 | }, |
324 | { | 326 | { |
325 | 10, "sends a message to the last conference", | 327 | 10, |
328 | "sends a message to the last conference", | ||
326 | [](Local_State const &state) { | 329 | [](Local_State const &state) { |
327 | return tox_conference_get_chatlist_size(state.tox()) != 0; | 330 | return tox_conference_get_chatlist_size(state.tox()) != 0; |
328 | }, | 331 | }, |
@@ -344,7 +347,9 @@ int main() { | |||
344 | }, | 347 | }, |
345 | }, | 348 | }, |
346 | { | 349 | { |
347 | 10, "changes their name", [](Local_State const &state) { return true; }, | 350 | 10, |
351 | "changes their name", | ||
352 | [](Local_State const &state) { return true; }, | ||
348 | [](Local_State *state, Random *rnd, std::mt19937 *rng) { | 353 | [](Local_State *state, Random *rnd, std::mt19937 *rng) { |
349 | std::vector<uint8_t> name(rnd->name_length_selector(*rng)); | 354 | std::vector<uint8_t> name(rnd->name_length_selector(*rng)); |
350 | for (uint8_t &byte : name) { | 355 | for (uint8_t &byte : name) { |
@@ -359,7 +364,9 @@ int main() { | |||
359 | }, | 364 | }, |
360 | }, | 365 | }, |
361 | { | 366 | { |
362 | 10, "sets their name to empty", [](Local_State const &state) { return true; }, | 367 | 10, |
368 | "sets their name to empty", | ||
369 | [](Local_State const &state) { return true; }, | ||
363 | [](Local_State *state, Random *rnd, std::mt19937 *rng) { | 370 | [](Local_State *state, Random *rnd, std::mt19937 *rng) { |
364 | TOX_ERR_SET_INFO err; | 371 | TOX_ERR_SET_INFO err; |
365 | tox_self_set_name(state->tox(), nullptr, 0, &err); | 372 | tox_self_set_name(state->tox(), nullptr, 0, &err); |