diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-08-19 22:58:04 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-08-19 23:15:01 +0000 |
commit | 7aa57afebad031993825b0bd1ef0760f524e1442 (patch) | |
tree | 3e7db61a8c138215c339277d1e3b2a9227570a22 /auto_tests | |
parent | 0e7cc197f4da06b62de1ca200e8c2ae02c4a8818 (diff) |
Avoid redefining macros from different files.
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/save_compatibility_test.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/auto_tests/save_compatibility_test.c b/auto_tests/save_compatibility_test.c index 08ac9e17..07ffc52a 100644 --- a/auto_tests/save_compatibility_test.c +++ b/auto_tests/save_compatibility_test.c | |||
@@ -6,16 +6,16 @@ | |||
6 | 6 | ||
7 | #include <string.h> | 7 | #include <string.h> |
8 | 8 | ||
9 | #define SAVE_FILE "../auto_tests/data/save.tox" | 9 | #define LOADED_SAVE_FILE "../auto_tests/data/save.tox" |
10 | 10 | ||
11 | // Information from the save file | 11 | // Information from the save file |
12 | #define NAME "name" | 12 | #define EXPECTED_NAME "name" |
13 | #define NAME_SIZE strlen(NAME) | 13 | #define EXPECTED_NAME_SIZE strlen(EXPECTED_NAME) |
14 | #define STATUS_MESSAGE "Hello World" | 14 | #define EXPECTED_STATUS_MESSAGE "Hello World" |
15 | #define STATUS_MESSAGE_SIZE strlen(STATUS_MESSAGE) | 15 | #define EXPECTED_STATUS_MESSAGE_SIZE strlen(EXPECTED_STATUS_MESSAGE) |
16 | #define NUM_FRIENDS 1 | 16 | #define EXPECTED_NUM_FRIENDS 1 |
17 | #define NOSPAM "4C762C7D" | 17 | #define EXPECTED_NOSPAM "4C762C7D" |
18 | #define TOX_ID "B70E97D41F69B7F4C42A5BC7BD7A76B95B8030BE1B7C0E9E6FC19FC4ABEB195B4C762C7D800B" | 18 | #define EXPECTED_TOX_ID "B70E97D41F69B7F4C42A5BC7BD7A76B95B8030BE1B7C0E9E6FC19FC4ABEB195B4C762C7D800B" |
19 | 19 | ||
20 | static size_t get_file_size(const char *save_path) | 20 | static size_t get_file_size(const char *save_path) |
21 | { | 21 | { |
@@ -83,38 +83,41 @@ static void test_save_compatibility(const char *save_path) | |||
83 | free(save_data); | 83 | free(save_data); |
84 | 84 | ||
85 | const size_t name_size = tox_self_get_name_size(tox); | 85 | const size_t name_size = tox_self_get_name_size(tox); |
86 | ck_assert_msg(name_size == NAME_SIZE, "name sizes do not match expected %zu got %zu", NAME_SIZE, name_size); | 86 | ck_assert_msg(name_size == EXPECTED_NAME_SIZE, "name sizes do not match expected %zu got %zu", EXPECTED_NAME_SIZE, |
87 | name_size); | ||
87 | 88 | ||
88 | uint8_t name[TOX_MAX_NAME_LENGTH]; | 89 | uint8_t name[TOX_MAX_NAME_LENGTH]; |
89 | tox_self_get_name(tox, name); | 90 | tox_self_get_name(tox, name); |
90 | ck_assert_msg(strncmp((const char *)name, NAME, name_size) == 0, "names do not match, expected %s got %s", NAME, name); | 91 | ck_assert_msg(strncmp((const char *)name, EXPECTED_NAME, name_size) == 0, |
92 | "names do not match, expected %s got %s", EXPECTED_NAME, name); | ||
91 | 93 | ||
92 | const size_t status_message_size = tox_self_get_status_message_size(tox); | 94 | const size_t status_message_size = tox_self_get_status_message_size(tox); |
93 | ck_assert_msg(status_message_size == STATUS_MESSAGE_SIZE, "status message sizes do not match, expected %zu got %zu", | 95 | ck_assert_msg(status_message_size == EXPECTED_STATUS_MESSAGE_SIZE, |
94 | STATUS_MESSAGE_SIZE, status_message_size); | 96 | "status message sizes do not match, expected %zu got %zu", EXPECTED_STATUS_MESSAGE_SIZE, status_message_size); |
95 | 97 | ||
96 | uint8_t status_message[TOX_MAX_STATUS_MESSAGE_LENGTH]; | 98 | uint8_t status_message[TOX_MAX_STATUS_MESSAGE_LENGTH]; |
97 | tox_self_get_status_message(tox, status_message); | 99 | tox_self_get_status_message(tox, status_message); |
98 | ck_assert_msg(strncmp((const char *)status_message, STATUS_MESSAGE, status_message_size) == 0, | 100 | ck_assert_msg(strncmp((const char *)status_message, EXPECTED_STATUS_MESSAGE, status_message_size) == 0, |
99 | "status messages do not match, expected %s got %s", | 101 | "status messages do not match, expected %s got %s", |
100 | STATUS_MESSAGE, status_message); | 102 | EXPECTED_STATUS_MESSAGE, status_message); |
101 | 103 | ||
102 | const size_t num_friends = tox_self_get_friend_list_size(tox); | 104 | const size_t num_friends = tox_self_get_friend_list_size(tox); |
103 | ck_assert_msg(num_friends == NUM_FRIENDS, "number of friends do not match, expected %d got %zu", NUM_FRIENDS, | 105 | ck_assert_msg(num_friends == EXPECTED_NUM_FRIENDS, |
104 | num_friends); | 106 | "number of friends do not match, expected %d got %zu", EXPECTED_NUM_FRIENDS, num_friends); |
105 | 107 | ||
106 | const uint32_t nospam = tox_self_get_nospam(tox); | 108 | const uint32_t nospam = tox_self_get_nospam(tox); |
107 | char nospam_str[(TOX_NOSPAM_SIZE * 2) + 1]; | 109 | char nospam_str[(TOX_NOSPAM_SIZE * 2) + 1]; |
108 | const size_t length = snprintf(nospam_str, sizeof(nospam_str), "%08X", nospam); | 110 | const size_t length = snprintf(nospam_str, sizeof(nospam_str), "%08X", nospam); |
109 | nospam_str[length] = '\0'; | 111 | nospam_str[length] = '\0'; |
110 | ck_assert_msg(strcmp(nospam_str, NOSPAM) == 0, "nospam does not match, expected %s got %s", NOSPAM, nospam_str); | 112 | ck_assert_msg(strcmp(nospam_str, EXPECTED_NOSPAM) == 0, |
113 | "nospam does not match, expected %s got %s", EXPECTED_NOSPAM, nospam_str); | ||
111 | 114 | ||
112 | uint8_t tox_id[TOX_ADDRESS_SIZE]; | 115 | uint8_t tox_id[TOX_ADDRESS_SIZE]; |
113 | char tox_id_str[TOX_ADDRESS_SIZE * 2]; | 116 | char tox_id_str[TOX_ADDRESS_SIZE * 2]; |
114 | tox_self_get_address(tox, tox_id); | 117 | tox_self_get_address(tox, tox_id); |
115 | to_hex(tox_id_str, tox_id, TOX_ADDRESS_SIZE); | 118 | to_hex(tox_id_str, tox_id, TOX_ADDRESS_SIZE); |
116 | ck_assert_msg(strncmp(tox_id_str, TOX_ID, TOX_ADDRESS_SIZE * 2) == 0, "tox ids do not match, expected %s got %s", | 119 | ck_assert_msg(strncmp(tox_id_str, EXPECTED_TOX_ID, TOX_ADDRESS_SIZE * 2) == 0, |
117 | TOX_ID, tox_id_str); | 120 | "tox ids do not match, expected %s got %s", EXPECTED_TOX_ID, tox_id_str); |
118 | 121 | ||
119 | tox_kill(tox); | 122 | tox_kill(tox); |
120 | } | 123 | } |
@@ -133,7 +136,7 @@ int main(int argc, char *argv[]) | |||
133 | } | 136 | } |
134 | 137 | ||
135 | char save_path[4096]; | 138 | char save_path[4096]; |
136 | snprintf(save_path, sizeof(save_path), "%s/%s", base_path, SAVE_FILE); | 139 | snprintf(save_path, sizeof(save_path), "%s/%s", base_path, LOADED_SAVE_FILE); |
137 | 140 | ||
138 | test_save_compatibility(save_path); | 141 | test_save_compatibility(save_path); |
139 | 142 | ||