mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Merge pull request #483 from fhahn/small-test-improvements
Small test improvements
This commit is contained in:
commit
12564b1f12
|
@ -87,13 +87,13 @@ START_TEST(test_m_set_userstatus)
|
|||
uint16_t good_length = strlen(status);
|
||||
uint16_t bad_length = REALLY_BIG_NUMBER;
|
||||
|
||||
if (m_set_statusmessage(m, (uint8_t *)status, bad_length) != -1)
|
||||
ck_abort_msg("m_set_userstatus did NOT catch the following length: %d\n",
|
||||
REALLY_BIG_NUMBER);
|
||||
ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, bad_length) == -1),
|
||||
"m_set_userstatus did NOT catch the following length: %d\n",
|
||||
REALLY_BIG_NUMBER);
|
||||
|
||||
if ((m_set_statusmessage(m, (uint8_t *)status, good_length)) != 0)
|
||||
ck_abort_msg("m_set_userstatus did NOT return 0 on the following length: %d\n"
|
||||
"MAX_STATUSMESSAGE_LENGTH: %d\n", good_length, MAX_STATUSMESSAGE_LENGTH);
|
||||
ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, good_length) == 0),
|
||||
"m_set_userstatus did NOT return 0 on the following length: %d\n"
|
||||
"MAX_STATUSMESSAGE_LENGTH: %d\n", good_length, MAX_STATUSMESSAGE_LENGTH);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
@ -156,12 +156,11 @@ START_TEST(test_setname)
|
|||
int good_length = strlen(good_name);
|
||||
int bad_length = REALLY_BIG_NUMBER;
|
||||
|
||||
if (setname(m, (uint8_t *)good_name, bad_length) != -1)
|
||||
ck_abort_msg("setname() did NOT error on %d as a length argument!\n",
|
||||
bad_length);
|
||||
ck_assert_msg((setname(m, (uint8_t *)good_name, bad_length) == -1),
|
||||
"setname() did NOT error on %d as a length argument!\n", bad_length);
|
||||
|
||||
if (setname(m, (uint8_t *)good_name, good_length) != 0)
|
||||
ck_abort_msg("setname() did NOT return 0 on good arguments!\n");
|
||||
ck_assert_msg((setname(m, (uint8_t *)good_name, good_length) == 0),
|
||||
"setname() did NOT return 0 on good arguments!\n");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
@ -197,24 +196,20 @@ START_TEST(test_m_copy_userstatus)
|
|||
END_TEST
|
||||
*/
|
||||
|
||||
/* this test is excluded for now, due to lack of a way
|
||||
* to set a friend's nickname for now.
|
||||
* ideas:
|
||||
* if we have access to the friends list, we could
|
||||
* just add a name manually ourselves. */
|
||||
/*
|
||||
START_TEST(test_getname)
|
||||
{
|
||||
uint8_t name_buf[MAX_NAME_LENGTH];
|
||||
uint8_t test_name[] = {'f', 'o', 'o'};
|
||||
|
||||
assert(getname(-1, name_buf) == -1);
|
||||
assert(getname(REALLY_BIG_NUMBER, name_buf) == -1);
|
||||
ck_assert(getname(m, -1, name_buf) == -1);
|
||||
ck_assert(getname(m, REALLY_BIG_NUMBER, name_buf) == -1);
|
||||
|
||||
getname(friend_id_num, name_buf);
|
||||
assert(name_buf[MAX_NAME_LENGTH] == '\0'); // something like this
|
||||
memcpy(m->friendlist[0].name, &test_name[0], 3);
|
||||
getname(m, 0, &name_buf[0]);
|
||||
|
||||
ck_assert(strcmp((char *)&name_buf[0], "foo") == 0);
|
||||
}
|
||||
END_TEST
|
||||
*/
|
||||
|
||||
Suite *messenger_suite(void)
|
||||
{
|
||||
|
@ -228,6 +223,7 @@ Suite *messenger_suite(void)
|
|||
TCase *delfriend = tcase_create("delfriend");
|
||||
//TCase *addfriend = tcase_create("addfriend");
|
||||
TCase *setname = tcase_create("setname");
|
||||
TCase *getname = tcase_create("getname");
|
||||
|
||||
tcase_add_test(userstatus_size, test_m_get_userstatus_size);
|
||||
tcase_add_test(set_userstatus, test_m_set_userstatus);
|
||||
|
@ -236,6 +232,7 @@ Suite *messenger_suite(void)
|
|||
tcase_add_test(send_message, test_m_sendmesage);
|
||||
tcase_add_test(delfriend, test_m_delfriend);
|
||||
//tcase_add_test(addfriend, test_m_addfriend);
|
||||
tcase_add_test(setname, test_getname);
|
||||
tcase_add_test(setname, test_setname);
|
||||
|
||||
suite_add_tcase(s, userstatus_size);
|
||||
|
@ -245,6 +242,7 @@ Suite *messenger_suite(void)
|
|||
suite_add_tcase(s, getself_name);
|
||||
suite_add_tcase(s, delfriend);
|
||||
//suite_add_tcase(s, addfriend);
|
||||
suite_add_tcase(s, getname);
|
||||
suite_add_tcase(s, setname);
|
||||
|
||||
return s;
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/bash
|
||||
# run_tests - run the current tests for tox core
|
||||
set -e
|
||||
|
||||
./messenger_test && ./friends_test && ./crypto_test
|
Loading…
Reference in New Issue
Block a user