diff options
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/tox_test.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 3240f29a..2c157b1c 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -166,6 +166,31 @@ START_TEST(test_one) | |||
166 | ck_assert_msg(tox_add_friend(tox1, address, message, TOX_MAX_FRIENDREQUEST_LENGTH) == TOX_FAERR_ALREADYSENT, | 166 | ck_assert_msg(tox_add_friend(tox1, address, message, TOX_MAX_FRIENDREQUEST_LENGTH) == TOX_FAERR_ALREADYSENT, |
167 | "Adding friend twice worked."); | 167 | "Adding friend twice worked."); |
168 | 168 | ||
169 | uint8_t name[TOX_MAX_NAME_LENGTH]; | ||
170 | int i; | ||
171 | |||
172 | for (i = 0; i < TOX_MAX_NAME_LENGTH; ++i) { | ||
173 | name[i] = rand(); | ||
174 | } | ||
175 | |||
176 | tox_set_name(tox1, name, sizeof(name)); | ||
177 | ck_assert_msg(tox_get_self_name_size(tox1) == sizeof(name), "Can't set name of TOX_MAX_NAME_LENGTH"); | ||
178 | |||
179 | size_t save_size = tox_size(tox1); | ||
180 | uint8_t data[save_size]; | ||
181 | tox_save(tox1, data); | ||
182 | |||
183 | tox_kill(tox2); | ||
184 | tox2 = tox_new(0); | ||
185 | ck_assert_msg(tox_load(tox2, data, save_size) == 0, "Load failed"); | ||
186 | |||
187 | size_t length = tox_get_self_name_size(tox2); | ||
188 | ck_assert_msg(tox_get_self_name_size(tox2) == sizeof name, "Wrong name size."); | ||
189 | |||
190 | uint8_t new_name[TOX_MAX_NAME_LENGTH] = { 0 }; | ||
191 | ck_assert_msg(tox_get_self_name(tox2, new_name) == TOX_MAX_NAME_LENGTH, "Wrong name length"); | ||
192 | ck_assert_msg(memcmp(name, new_name, TOX_MAX_NAME_LENGTH) == 0, "Wrong name"); | ||
193 | |||
169 | tox_kill(tox1); | 194 | tox_kill(tox1); |
170 | tox_kill(tox2); | 195 | tox_kill(tox2); |
171 | } | 196 | } |