diff options
author | irungentoo <irungentoo@gmail.com> | 2015-03-18 15:32:53 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-03-18 15:32:53 -0400 |
commit | d71136262227d68b649ce9fd8e020597c69cce07 (patch) | |
tree | 3ac7150c848986e3d2043bb9ac074e679d82d27c /auto_tests | |
parent | b9e747fd50a81496626deaaf4878f06630abc75a (diff) |
Merged normal message function and send action function into one
messaging function.
This removes code duplication and allows us to easily add new message
types to the api without having to add new functions.
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/messenger_test.c | 8 | ||||
-rw-r--r-- | auto_tests/tox_test.c | 11 |
2 files changed, 12 insertions, 7 deletions
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c index 2e1fe92a..2a813c9b 100644 --- a/auto_tests/messenger_test.c +++ b/auto_tests/messenger_test.c | |||
@@ -50,10 +50,10 @@ START_TEST(test_m_sendmesage) | |||
50 | int bad_len = MAX_CRYPTO_PACKET_SIZE; | 50 | int bad_len = MAX_CRYPTO_PACKET_SIZE; |
51 | 51 | ||
52 | 52 | ||
53 | ck_assert(m_sendmessage(m, -1, (uint8_t *)message, good_len, 0) == -1); | 53 | ck_assert(m_send_message_generic(m, -1, MESSAGE_NORMAL, (uint8_t *)message, good_len, 0) == -1); |
54 | ck_assert(m_sendmessage(m, REALLY_BIG_NUMBER, (uint8_t *)message, good_len, 0) == -1); | 54 | ck_assert(m_send_message_generic(m, REALLY_BIG_NUMBER, MESSAGE_NORMAL, (uint8_t *)message, good_len, 0) == -1); |
55 | ck_assert(m_sendmessage(m, 17, (uint8_t *)message, good_len, 0) == -1); | 55 | ck_assert(m_send_message_generic(m, 17, MESSAGE_NORMAL, (uint8_t *)message, good_len, 0) == -1); |
56 | ck_assert(m_sendmessage(m, friend_id_num, (uint8_t *)message, bad_len, 0) == -2); | 56 | ck_assert(m_send_message_generic(m, friend_id_num, MESSAGE_NORMAL, (uint8_t *)message, bad_len, 0) == -2); |
57 | } | 57 | } |
58 | END_TEST | 58 | END_TEST |
59 | 59 | ||
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 6a318fe0..abffafeb 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -33,11 +33,16 @@ void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *dat | |||
33 | } | 33 | } |
34 | uint32_t messages_received; | 34 | uint32_t messages_received; |
35 | 35 | ||
36 | void print_message(Tox *m, uint32_t friendnumber, const uint8_t *string, size_t length, void *userdata) | 36 | void print_message(Tox *m, uint32_t friendnumber, TOX_MESSAGE_TYPE type, const uint8_t *string, size_t length, |
37 | void *userdata) | ||
37 | { | 38 | { |
38 | if (*((uint32_t *)userdata) != 974536) | 39 | if (*((uint32_t *)userdata) != 974536) |
39 | return; | 40 | return; |
40 | 41 | ||
42 | if (type != TOX_MESSAGE_TYPE_MESSAGE) { | ||
43 | ck_abort_msg("Bad type"); | ||
44 | } | ||
45 | |||
41 | uint8_t cmp_msg[TOX_MAX_MESSAGE_LENGTH]; | 46 | uint8_t cmp_msg[TOX_MAX_MESSAGE_LENGTH]; |
42 | memset(cmp_msg, 'G', sizeof(cmp_msg)); | 47 | memset(cmp_msg, 'G', sizeof(cmp_msg)); |
43 | 48 | ||
@@ -395,9 +400,9 @@ START_TEST(test_few_clients) | |||
395 | uint8_t msgs[TOX_MAX_MESSAGE_LENGTH + 1]; | 400 | uint8_t msgs[TOX_MAX_MESSAGE_LENGTH + 1]; |
396 | memset(msgs, 'G', sizeof(msgs)); | 401 | memset(msgs, 'G', sizeof(msgs)); |
397 | TOX_ERR_FRIEND_SEND_MESSAGE errm; | 402 | TOX_ERR_FRIEND_SEND_MESSAGE errm; |
398 | tox_friend_send_message(tox2, 0, msgs, TOX_MAX_MESSAGE_LENGTH + 1, &errm); | 403 | tox_friend_send_message(tox2, 0, TOX_MESSAGE_TYPE_MESSAGE, msgs, TOX_MAX_MESSAGE_LENGTH + 1, &errm); |
399 | ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_TOO_LONG, "TOX_MAX_MESSAGE_LENGTH is too small\n"); | 404 | ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_TOO_LONG, "TOX_MAX_MESSAGE_LENGTH is too small\n"); |
400 | tox_friend_send_message(tox2, 0, msgs, TOX_MAX_MESSAGE_LENGTH, &errm); | 405 | tox_friend_send_message(tox2, 0, TOX_MESSAGE_TYPE_MESSAGE, msgs, TOX_MAX_MESSAGE_LENGTH, &errm); |
401 | ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_OK, "TOX_MAX_MESSAGE_LENGTH is too big\n"); | 406 | ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_OK, "TOX_MAX_MESSAGE_LENGTH is too big\n"); |
402 | 407 | ||
403 | while (1) { | 408 | while (1) { |