diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-20 19:47:46 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-21 00:14:43 +0000 |
commit | 822dd2fac282c5c92c3bb8dc42a190e47d93d9c7 (patch) | |
tree | e46e0c25fd85613420b8984d2de96aa219cef958 | |
parent | 98febe0589db3f6fedba03bfdc1d246f723d2f25 (diff) |
Don't allocate or dereference Tox_Options in tests.
This struct will soon become opaque.
-rw-r--r-- | auto_tests/file_saving_test.c | 18 | ||||
-rw-r--r-- | auto_tests/self_conference_title_change_test.c | 6 | ||||
-rw-r--r-- | auto_tests/selfname_change_conference_test.c | 6 | ||||
-rw-r--r-- | testing/av_test.c | 16 |
4 files changed, 24 insertions, 22 deletions
diff --git a/auto_tests/file_saving_test.c b/auto_tests/file_saving_test.c index 582013aa..8c3f10d4 100644 --- a/auto_tests/file_saving_test.c +++ b/auto_tests/file_saving_test.c | |||
@@ -34,9 +34,9 @@ static const char *pphrase = "bar", *name = "foo", *savefile = "./save"; | |||
34 | 34 | ||
35 | static void save_data_encrypted(void) | 35 | static void save_data_encrypted(void) |
36 | { | 36 | { |
37 | struct Tox_Options options; | 37 | struct Tox_Options *options = tox_options_new(NULL); |
38 | tox_options_default(&options); | 38 | Tox *t = tox_new(options, NULL); |
39 | Tox *t = tox_new(&options, NULL); | 39 | tox_options_free(options); |
40 | 40 | ||
41 | tox_self_set_name(t, (const uint8_t *)name, strlen(name), NULL); | 41 | tox_self_set_name(t, (const uint8_t *)name, strlen(name), NULL); |
42 | 42 | ||
@@ -87,17 +87,17 @@ static void load_data_decrypted(void) | |||
87 | exit(3); | 87 | exit(3); |
88 | } | 88 | } |
89 | 89 | ||
90 | struct Tox_Options options; | 90 | struct Tox_Options *options = tox_options_new(NULL); |
91 | 91 | ||
92 | tox_options_default(&options); | 92 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); |
93 | 93 | ||
94 | tox_options_set_savedata_type(&options, TOX_SAVEDATA_TYPE_TOX_SAVE); | 94 | tox_options_set_savedata_data(options, clear, size); |
95 | |||
96 | tox_options_set_savedata_data(&options, clear, size); | ||
97 | 95 | ||
98 | TOX_ERR_NEW err; | 96 | TOX_ERR_NEW err; |
99 | 97 | ||
100 | Tox *t = tox_new(&options, &err); | 98 | Tox *t = tox_new(options, &err); |
99 | |||
100 | tox_options_free(options); | ||
101 | 101 | ||
102 | if (t == NULL) { | 102 | if (t == NULL) { |
103 | fprintf(stderr, "error: tox_new returned the error value %d\n", err); | 103 | fprintf(stderr, "error: tox_new returned the error value %d\n", err); |
diff --git a/auto_tests/self_conference_title_change_test.c b/auto_tests/self_conference_title_change_test.c index a91aa0b4..c780f320 100644 --- a/auto_tests/self_conference_title_change_test.c +++ b/auto_tests/self_conference_title_change_test.c | |||
@@ -47,13 +47,13 @@ static void cbtitlechange(Tox *tox, uint32_t conference_number, uint32_t peer_nu | |||
47 | int main(void) | 47 | int main(void) |
48 | { | 48 | { |
49 | uint32_t conference_number; | 49 | uint32_t conference_number; |
50 | struct Tox_Options to; | 50 | struct Tox_Options *to = tox_options_new(NULL); |
51 | Tox *t; | 51 | Tox *t; |
52 | TOX_ERR_CONFERENCE_NEW conference_err; | 52 | TOX_ERR_CONFERENCE_NEW conference_err; |
53 | TOX_ERR_CONFERENCE_TITLE title_err; | 53 | TOX_ERR_CONFERENCE_TITLE title_err; |
54 | 54 | ||
55 | tox_options_default(&to); | 55 | t = tox_new(to, NULL); |
56 | t = tox_new(&to, NULL); | 56 | tox_options_free(to); |
57 | 57 | ||
58 | tox_callback_conference_title(t, &cbtitlechange); | 58 | tox_callback_conference_title(t, &cbtitlechange); |
59 | 59 | ||
diff --git a/auto_tests/selfname_change_conference_test.c b/auto_tests/selfname_change_conference_test.c index bc9c0e88..3d2436b5 100644 --- a/auto_tests/selfname_change_conference_test.c +++ b/auto_tests/selfname_change_conference_test.c | |||
@@ -57,13 +57,13 @@ static void cbconfmembers(Tox *tox, uint32_t conference_number, uint32_t peer_nu | |||
57 | 57 | ||
58 | int main(void) | 58 | int main(void) |
59 | { | 59 | { |
60 | struct Tox_Options to; | 60 | struct Tox_Options *to = tox_options_new(NULL); |
61 | Tox *t; | 61 | Tox *t; |
62 | TOX_ERR_CONFERENCE_NEW conference_err; | 62 | TOX_ERR_CONFERENCE_NEW conference_err; |
63 | TOX_ERR_SET_INFO name_err; | 63 | TOX_ERR_SET_INFO name_err; |
64 | 64 | ||
65 | tox_options_default(&to); | 65 | t = tox_new(to, NULL); |
66 | t = tox_new(&to, NULL); | 66 | tox_options_free(to); |
67 | 67 | ||
68 | tox_callback_conference_namelist_change(t, cbconfmembers); | 68 | tox_callback_conference_namelist_change(t, cbconfmembers); |
69 | 69 | ||
diff --git a/testing/av_test.c b/testing/av_test.c index 4d09d023..d6c880c5 100644 --- a/testing/av_test.c +++ b/testing/av_test.c | |||
@@ -231,28 +231,30 @@ static void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceC | |||
231 | Tox *Alice; | 231 | Tox *Alice; |
232 | Tox *Bob; | 232 | Tox *Bob; |
233 | 233 | ||
234 | struct Tox_Options opts; | 234 | struct Tox_Options *opts = tox_options_new(NULL); |
235 | tox_options_default(&opts); | 235 | assert(opts != NULL); |
236 | 236 | ||
237 | opts.end_port = 0; | 237 | tox_options_set_end_port(opts, 0); |
238 | opts.ipv6_enabled = false; | 238 | tox_options_set_ipv6_enabled(opts, false); |
239 | 239 | ||
240 | { | 240 | { |
241 | TOX_ERR_NEW error; | 241 | TOX_ERR_NEW error; |
242 | 242 | ||
243 | opts.start_port = 33445; | 243 | tox_options_set_start_port(opts, 33445); |
244 | *bootstrap = tox_new(&opts, &error); | 244 | *bootstrap = tox_new(&opts, &error); |
245 | assert(error == TOX_ERR_NEW_OK); | 245 | assert(error == TOX_ERR_NEW_OK); |
246 | 246 | ||
247 | opts.start_port = 33455; | 247 | tox_options_set_start_port(opts, 33455); |
248 | Alice = tox_new(&opts, &error); | 248 | Alice = tox_new(&opts, &error); |
249 | assert(error == TOX_ERR_NEW_OK); | 249 | assert(error == TOX_ERR_NEW_OK); |
250 | 250 | ||
251 | opts.start_port = 33465; | 251 | tox_options_set_start_port(opts, 33465); |
252 | Bob = tox_new(&opts, &error); | 252 | Bob = tox_new(&opts, &error); |
253 | assert(error == TOX_ERR_NEW_OK); | 253 | assert(error == TOX_ERR_NEW_OK); |
254 | } | 254 | } |
255 | 255 | ||
256 | tox_options_free(opts); | ||
257 | |||
256 | printf("Created 3 instances of Tox\n"); | 258 | printf("Created 3 instances of Tox\n"); |
257 | printf("Preparing network...\n"); | 259 | printf("Preparing network...\n"); |
258 | long long unsigned int cur_time = time(NULL); | 260 | long long unsigned int cur_time = time(NULL); |