summaryrefslogtreecommitdiff
path: root/auto_tests/save_friend_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'auto_tests/save_friend_test.c')
-rw-r--r--auto_tests/save_friend_test.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/auto_tests/save_friend_test.c b/auto_tests/save_friend_test.c
index 061425bd..a7a62c87 100644
--- a/auto_tests/save_friend_test.c
+++ b/auto_tests/save_friend_test.c
@@ -1,7 +1,9 @@
1/* Auto Tests: Save and load friends. 1/* Auto Tests: Save and load friends.
2 */ 2 */
3 3
4#ifndef _XOPEN_SOURCE
4#define _XOPEN_SOURCE 600 5#define _XOPEN_SOURCE 600
6#endif
5 7
6#include "helpers.h" 8#include "helpers.h"
7#include "../toxcore/ccompat.h" 9#include "../toxcore/ccompat.h"
@@ -28,7 +30,7 @@ static void set_random(Tox *m, bool (*setter)(Tox *, const uint8_t *, size_t, TO
28 text[i] = rand(); 30 text[i] = rand();
29 } 31 }
30 32
31 setter(m, text, SIZEOF_VLA(text), 0); 33 setter(m, text, SIZEOF_VLA(text), nullptr);
32} 34}
33 35
34void namechange_callback(Tox *tox, uint32_t friend_number, const uint8_t *name, size_t length, void *user_data) 36void namechange_callback(Tox *tox, uint32_t friend_number, const uint8_t *name, size_t length, void *user_data)
@@ -47,16 +49,16 @@ void statuschange_callback(Tox *tox, uint32_t friend_number, const uint8_t *mess
47 49
48int main(int argc, char *argv[]) 50int main(int argc, char *argv[])
49{ 51{
50 Tox *tox1 = tox_new_log(0, 0, 0); 52 Tox *tox1 = tox_new_log(nullptr, nullptr, nullptr);
51 Tox *tox2 = tox_new_log(0, 0, 0); 53 Tox *tox2 = tox_new_log(nullptr, nullptr, nullptr);
52 54
53 struct test_data to_compare = { { 0 } }; 55 struct test_data to_compare = { { 0 } };
54 56
55 uint8_t public_key[TOX_PUBLIC_KEY_SIZE]; 57 uint8_t public_key[TOX_PUBLIC_KEY_SIZE];
56 tox_self_get_public_key(tox1, public_key); 58 tox_self_get_public_key(tox1, public_key);
57 tox_friend_add_norequest(tox2, public_key, NULL); 59 tox_friend_add_norequest(tox2, public_key, nullptr);
58 tox_self_get_public_key(tox2, public_key); 60 tox_self_get_public_key(tox2, public_key);
59 tox_friend_add_norequest(tox1, public_key, NULL); 61 tox_friend_add_norequest(tox1, public_key, nullptr);
60 62
61 uint8_t reference_name[TOX_MAX_NAME_LENGTH] = { 0 }; 63 uint8_t reference_name[TOX_MAX_NAME_LENGTH] = { 0 };
62 uint8_t reference_status[TOX_MAX_STATUS_MESSAGE_LENGTH] = { 0 }; 64 uint8_t reference_status[TOX_MAX_STATUS_MESSAGE_LENGTH] = { 0 };
@@ -75,13 +77,13 @@ int main(int argc, char *argv[])
75 while (true) { 77 while (true) {
76 if (tox_self_get_connection_status(tox1) && 78 if (tox_self_get_connection_status(tox1) &&
77 tox_self_get_connection_status(tox2) && 79 tox_self_get_connection_status(tox2) &&
78 tox_friend_get_connection_status(tox1, 0, 0) == TOX_CONNECTION_UDP) { 80 tox_friend_get_connection_status(tox1, 0, nullptr) == TOX_CONNECTION_UDP) {
79 printf("Connected.\n"); 81 printf("Connected.\n");
80 break; 82 break;
81 } 83 }
82 84
83 tox_iterate(tox1, &to_compare); 85 tox_iterate(tox1, &to_compare);
84 tox_iterate(tox2, NULL); 86 tox_iterate(tox2, nullptr);
85 87
86 c_sleep(tox_iteration_interval(tox1)); 88 c_sleep(tox_iteration_interval(tox1));
87 } 89 }
@@ -93,7 +95,7 @@ int main(int argc, char *argv[])
93 } 95 }
94 96
95 tox_iterate(tox1, &to_compare); 97 tox_iterate(tox1, &to_compare);
96 tox_iterate(tox2, NULL); 98 tox_iterate(tox2, nullptr);
97 99
98 c_sleep(tox_iteration_interval(tox1)); 100 c_sleep(tox_iteration_interval(tox1));
99 } 101 }
@@ -102,14 +104,14 @@ int main(int argc, char *argv[])
102 VLA(uint8_t, savedata, save_size); 104 VLA(uint8_t, savedata, save_size);
103 tox_get_savedata(tox1, savedata); 105 tox_get_savedata(tox1, savedata);
104 106
105 struct Tox_Options *options = tox_options_new(NULL); 107 struct Tox_Options *options = tox_options_new(nullptr);
106 tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); 108 tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
107 tox_options_set_savedata_data(options, savedata, save_size); 109 tox_options_set_savedata_data(options, savedata, save_size);
108 110
109 Tox *tox_to_compare = tox_new(options, 0); 111 Tox *tox_to_compare = tox_new(options, nullptr);
110 112
111 tox_friend_get_name(tox_to_compare, 0, to_compare.name, 0); 113 tox_friend_get_name(tox_to_compare, 0, to_compare.name, nullptr);
112 tox_friend_get_status_message(tox_to_compare, 0, to_compare.status_message, 0); 114 tox_friend_get_status_message(tox_to_compare, 0, to_compare.status_message, nullptr);
113 115
114 assert(memcmp(reference_name, to_compare.name, TOX_MAX_NAME_LENGTH) == 0); 116 assert(memcmp(reference_name, to_compare.name, TOX_MAX_NAME_LENGTH) == 0);
115 assert(memcmp(reference_status, to_compare.status_message, TOX_MAX_STATUS_MESSAGE_LENGTH) == 0); 117 assert(memcmp(reference_status, to_compare.status_message, TOX_MAX_STATUS_MESSAGE_LENGTH) == 0);