mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed auto tests
This commit is contained in:
parent
d72f828d6f
commit
338da1fde7
|
@ -65,7 +65,7 @@ void parent_confirm_message(int num, uint8_t *data, uint16_t length)
|
|||
request_flags |= SECOND_FLAG;
|
||||
}
|
||||
|
||||
void parent_confirm_status(int num, USERSTATUS_KIND status, uint8_t *data, uint16_t length)
|
||||
void parent_confirm_status(int num, uint8_t *data, uint16_t length)
|
||||
{
|
||||
puts("OK");
|
||||
request_flags |= FIRST_FLAG;
|
||||
|
@ -110,7 +110,7 @@ void child_got_request(uint8_t *public_key, uint8_t *data, uint16_t length)
|
|||
request_flags |= FIRST_FLAG;
|
||||
}
|
||||
|
||||
void child_got_statuschange(int friend_num, USERSTATUS_KIND status, uint8_t *string, uint16_t length)
|
||||
void child_got_statuschange(int friend_num, uint8_t *string, uint16_t length)
|
||||
{
|
||||
request_flags |= SECOND_FLAG;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ int main(int argc, char *argv[])
|
|||
msync(child_id, crypto_box_PUBLICKEYBYTES, MS_SYNC);
|
||||
|
||||
m_callback_friendrequest(child_got_request);
|
||||
m_callback_userstatus(child_got_statuschange);
|
||||
m_callback_statusmessage(child_got_statuschange);
|
||||
|
||||
/* wait on the friend request */
|
||||
while(!(request_flags & FIRST_FLAG))
|
||||
|
@ -196,7 +196,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
msync(parent_id, crypto_box_PUBLICKEYBYTES, MS_SYNC);
|
||||
m_callback_userstatus(parent_confirm_status);
|
||||
m_callback_statusmessage(parent_confirm_status);
|
||||
m_callback_friendmessage(parent_confirm_message);
|
||||
|
||||
/* hacky way to give the child time to set up */
|
||||
|
|
|
@ -62,16 +62,16 @@ END_TEST
|
|||
START_TEST(test_m_get_userstatus_size)
|
||||
{
|
||||
int rc = 0;
|
||||
ck_assert_msg((m_get_userstatus_size(-1) == -1),
|
||||
"m_get_userstatus_size did NOT catch an argument of -1");
|
||||
ck_assert_msg((m_get_userstatus_size(REALLY_BIG_NUMBER) == -1),
|
||||
"m_get_userstatus_size did NOT catch the following argument: %d\n",
|
||||
ck_assert_msg((m_get_statusmessage_size(-1) == -1),
|
||||
"m_get_statusmessage_size did NOT catch an argument of -1");
|
||||
ck_assert_msg((m_get_statusmessage_size(REALLY_BIG_NUMBER) == -1),
|
||||
"m_get_statusmessage_size did NOT catch the following argument: %d\n",
|
||||
REALLY_BIG_NUMBER);
|
||||
rc = m_get_userstatus_size(friend_id_num);
|
||||
rc = m_get_statusmessage_size(friend_id_num);
|
||||
|
||||
/* this WILL error if the original m_addfriend_norequest() failed */
|
||||
ck_assert_msg((rc > 0 && rc <= MAX_USERSTATUS_LENGTH),
|
||||
"m_get_userstatus_size is returning out of range values!\n"
|
||||
ck_assert_msg((rc > 0 && rc <= MAX_STATUSMESSAGE_LENGTH),
|
||||
"m_get_statusmessage_size is returning out of range values!\n"
|
||||
"(this can be caused by the error of m_addfriend_norequest"
|
||||
" in the beginning of the suite)\n");
|
||||
}
|
||||
|
@ -83,15 +83,13 @@ START_TEST(test_m_set_userstatus)
|
|||
uint16_t good_length = strlen(status);
|
||||
uint16_t bad_length = REALLY_BIG_NUMBER;
|
||||
|
||||
if(m_set_userstatus(USERSTATUS_KIND_ONLINE,
|
||||
(uint8_t *)status, bad_length) != -1)
|
||||
if(m_set_statusmessage((uint8_t *)status, bad_length) != -1)
|
||||
ck_abort_msg("m_set_userstatus did NOT catch the following length: %d\n",
|
||||
REALLY_BIG_NUMBER);
|
||||
|
||||
if((m_set_userstatus(USERSTATUS_KIND_RETAIN,
|
||||
(uint8_t *)status, good_length)) != 0)
|
||||
if((m_set_statusmessage((uint8_t *)status, good_length)) != 0)
|
||||
ck_abort_msg("m_set_userstatus did NOT return 0 on the following length: %d\n"
|
||||
"MAX_USERSTATUS_LENGTH: %d\n", good_length, MAX_USERSTATUS_LENGTH);
|
||||
"MAX_STATUSMESSAGE_LENGTH: %d\n", good_length, MAX_STATUSMESSAGE_LENGTH);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user