From a1035cf81494c3ab22c49b01788ca8ad933c5eb0 Mon Sep 17 00:00:00 2001 From: iphydf Date: Sun, 26 Aug 2018 09:42:08 +0000 Subject: 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. --- testing/random_testing.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'testing') 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) { int main() { std::vector const actions = { { - 10, "creates a new conference", + 10, + "creates a new conference", [](Local_State const &state) { return tox_conference_get_chatlist_size(state.tox()) < MAX_CONFERENCES_PER_USER; }, @@ -294,7 +295,8 @@ int main() { }, }, { - 10, "invites a random friend to a conference", + 10, + "invites a random friend to a conference", [](Local_State const &state) { return tox_conference_get_chatlist_size(state.tox()) != 0; }, @@ -302,15 +304,15 @@ int main() { size_t chat_count = tox_conference_get_chatlist_size(state->tox()); assert(chat_count != 0); // Condition above. TOX_ERR_CONFERENCE_INVITE err; - tox_conference_invite( - state->tox(), rnd->friend_selector(*rng), - state->next_invite % chat_count, &err); + tox_conference_invite(state->tox(), rnd->friend_selector(*rng), + state->next_invite % chat_count, &err); state->next_invite++; assert(err == TOX_ERR_CONFERENCE_INVITE_OK); }, }, { - 10, "deletes the last conference", + 10, + "deletes the last conference", [](Local_State const &state) { return tox_conference_get_chatlist_size(state.tox()) != 0; }, @@ -322,7 +324,8 @@ int main() { }, }, { - 10, "sends a message to the last conference", + 10, + "sends a message to the last conference", [](Local_State const &state) { return tox_conference_get_chatlist_size(state.tox()) != 0; }, @@ -344,7 +347,9 @@ int main() { }, }, { - 10, "changes their name", [](Local_State const &state) { return true; }, + 10, + "changes their name", + [](Local_State const &state) { return true; }, [](Local_State *state, Random *rnd, std::mt19937 *rng) { std::vector name(rnd->name_length_selector(*rng)); for (uint8_t &byte : name) { @@ -359,7 +364,9 @@ int main() { }, }, { - 10, "sets their name to empty", [](Local_State const &state) { return true; }, + 10, + "sets their name to empty", + [](Local_State const &state) { return true; }, [](Local_State *state, Random *rnd, std::mt19937 *rng) { TOX_ERR_SET_INFO err; tox_self_set_name(state->tox(), nullptr, 0, &err); -- cgit v1.2.3