mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Astyled and added tests.
This commit is contained in:
parent
472ab51bc5
commit
62ef4ed95d
|
@ -112,7 +112,8 @@ START_TEST(test_ip_equal)
|
|||
ip2.ip6.uint32[2] = htonl(0xFFFF);
|
||||
ip2.ip6.uint32[3] = htonl(0x7F000001);
|
||||
|
||||
ck_assert_msg(IN6_IS_ADDR_V4MAPPED(&ip2.ip6.in6_addr) != 0, "IN6_IS_ADDR_V4MAPPED(::ffff:127.0.0.1): expected != 0, got 0.");
|
||||
ck_assert_msg(IN6_IS_ADDR_V4MAPPED(&ip2.ip6.in6_addr) != 0,
|
||||
"IN6_IS_ADDR_V4MAPPED(::ffff:127.0.0.1): expected != 0, got 0.");
|
||||
|
||||
res = ip_equal(&ip1, &ip2);
|
||||
ck_assert_msg(res != 0, "ip_equal( {AF_INET, 127.0.0.1}, {AF_INET6, ::ffff:127.0.0.1} ): expected result != 0, got 0.");
|
||||
|
|
|
@ -49,6 +49,19 @@ void print_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length
|
|||
++name_changes;
|
||||
}
|
||||
|
||||
uint32_t typing_changes;
|
||||
|
||||
void print_typingchange(Tox *m, int friendnumber, int typing, void *userdata)
|
||||
{
|
||||
if (*((uint32_t *)userdata) != 974536)
|
||||
return;
|
||||
|
||||
if (!typing)
|
||||
typing_changes = 1;
|
||||
else
|
||||
typing_changes = 2;
|
||||
}
|
||||
|
||||
START_TEST(test_few_clients)
|
||||
{
|
||||
long long unsigned int cur_time = time(NULL);
|
||||
|
@ -118,6 +131,43 @@ START_TEST(test_few_clients)
|
|||
uint8_t temp_name[sizeof("Gentoo")];
|
||||
tox_get_name(tox3, 0, temp_name);
|
||||
ck_assert_msg(memcmp(temp_name, "Gentoo", sizeof("Gentoo")) == 0, "Name not correct");
|
||||
|
||||
tox_callback_typing_change(tox2, &print_typingchange, &to_compare);
|
||||
tox_set_user_is_typing(tox3, 0, 1);
|
||||
|
||||
while (1) {
|
||||
typing_changes = 0;
|
||||
tox_do(tox1);
|
||||
tox_do(tox2);
|
||||
tox_do(tox3);
|
||||
|
||||
|
||||
if (typing_changes == 2)
|
||||
break;
|
||||
else
|
||||
ck_assert_msg(typing_changes == 0, "Typing fail");
|
||||
|
||||
c_sleep(50);
|
||||
}
|
||||
|
||||
ck_assert_msg(tox_get_is_typing(tox2, 0) == 1, "Typing fail");
|
||||
tox_set_user_is_typing(tox3, 0, 0);
|
||||
|
||||
while (1) {
|
||||
typing_changes = 0;
|
||||
tox_do(tox1);
|
||||
tox_do(tox2);
|
||||
tox_do(tox3);
|
||||
|
||||
if (typing_changes == 1)
|
||||
break;
|
||||
else
|
||||
ck_assert_msg(typing_changes == 0, "Typing fail");
|
||||
|
||||
c_sleep(50);
|
||||
}
|
||||
|
||||
ck_assert_msg(tox_get_is_typing(tox2, 0) == 0, "Typing fail");
|
||||
printf("test_few_clients succeeded, took %llu seconds\n", time(NULL) - cur_time);
|
||||
}
|
||||
END_TEST
|
||||
|
|
|
@ -1939,8 +1939,8 @@ void do_friends(Messenger *m)
|
|||
if (m->friend_typingchange)
|
||||
m->friend_typingchange(m, i, typing, m->friend_typingchange_userdata);
|
||||
|
||||
set_friend_typing(m, i, typing);
|
||||
break;
|
||||
set_friend_typing(m, i, typing);
|
||||
break;
|
||||
}
|
||||
|
||||
case PACKET_ID_MESSAGE: {
|
||||
|
|
Loading…
Reference in New Issue
Block a user