diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-07-05 10:31:29 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-05 23:09:28 +0000 |
commit | 8739f7fccb7cafc54ca0f5fa074c9a740f7048ba (patch) | |
tree | 88e9f53fa6e734cd8095487d1896c56f844c782c /auto_tests/messenger_test.c | |
parent | 64d0297acc7d6a1697683052e15cc76383312c38 (diff) |
Make tox.c unambiguously parseable.
Rules:
1. Constants are uppercase names: THE_CONSTANT.
2. SUE[1] types start with an uppercase letter and have at least one
lowercase letter in it: The_Type, THE_Type.
3. Function types end in "_cb": tox_friend_connection_cb.
4. Variable and function names are all lowercase: the_function.
This makes it easier for humans reading the code to determine what an
identifier means. I'm not convinced by the enum type name change, but I
don't know a better rule. Currently, a lot of enum types are spelled like
constants, which is confusing.
[1] struct/union/enum
Diffstat (limited to 'auto_tests/messenger_test.c')
-rw-r--r-- | auto_tests/messenger_test.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c index d7344f4d..cf42de49 100644 --- a/auto_tests/messenger_test.c +++ b/auto_tests/messenger_test.c | |||
@@ -241,18 +241,18 @@ START_TEST(test_dht_state_saveloadsave) | |||
241 | * c) a second save() is of equal size | 241 | * c) a second save() is of equal size |
242 | * d) the second save() is of equal content */ | 242 | * d) the second save() is of equal content */ |
243 | const size_t extra = 64; | 243 | const size_t extra = 64; |
244 | const size_t size = DHT_size(m->dht); | 244 | const size_t size = dht_size(m->dht); |
245 | VLA(uint8_t, buffer, size + 2 * extra); | 245 | VLA(uint8_t, buffer, size + 2 * extra); |
246 | memset(buffer, 0xCD, extra); | 246 | memset(buffer, 0xCD, extra); |
247 | memset(buffer + extra + size, 0xCD, extra); | 247 | memset(buffer + extra + size, 0xCD, extra); |
248 | DHT_save(m->dht, buffer + extra); | 248 | dht_save(m->dht, buffer + extra); |
249 | 249 | ||
250 | for (size_t i = 0; i < extra; i++) { | 250 | for (size_t i = 0; i < extra; i++) { |
251 | ck_assert_msg(buffer[i] == 0xCD, "Buffer underwritten from DHT_save() @%u", (unsigned)i); | 251 | ck_assert_msg(buffer[i] == 0xCD, "Buffer underwritten from dht_save() @%u", (unsigned)i); |
252 | ck_assert_msg(buffer[extra + size + i] == 0xCD, "Buffer overwritten from DHT_save() @%u", (unsigned)i); | 252 | ck_assert_msg(buffer[extra + size + i] == 0xCD, "Buffer overwritten from dht_save() @%u", (unsigned)i); |
253 | } | 253 | } |
254 | 254 | ||
255 | const int res = DHT_load(m->dht, buffer + extra, size); | 255 | const int res = dht_load(m->dht, buffer + extra, size); |
256 | 256 | ||
257 | if (res == -1) { | 257 | if (res == -1) { |
258 | ck_assert_msg(res == 0, "Failed to load back stored buffer: res == -1"); | 258 | ck_assert_msg(res == 0, "Failed to load back stored buffer: res == -1"); |
@@ -264,12 +264,12 @@ START_TEST(test_dht_state_saveloadsave) | |||
264 | (unsigned)offset, (unsigned)size, res & 0x0F); | 264 | (unsigned)offset, (unsigned)size, res & 0x0F); |
265 | } | 265 | } |
266 | 266 | ||
267 | const size_t size2 = DHT_size(m->dht); | 267 | const size_t size2 = dht_size(m->dht); |
268 | ck_assert_msg(size == size2, "Messenger \"grew\" in size from a store/load cycle: %u -> %u", (unsigned)size, | 268 | ck_assert_msg(size == size2, "Messenger \"grew\" in size from a store/load cycle: %u -> %u", (unsigned)size, |
269 | (unsigned)size2); | 269 | (unsigned)size2); |
270 | 270 | ||
271 | VLA(uint8_t, buffer2, size2); | 271 | VLA(uint8_t, buffer2, size2); |
272 | DHT_save(m->dht, buffer2); | 272 | dht_save(m->dht, buffer2); |
273 | 273 | ||
274 | ck_assert_msg(!memcmp(buffer + extra, buffer2, size), "DHT state changed by store/load/store cycle"); | 274 | ck_assert_msg(!memcmp(buffer + extra, buffer2, size), "DHT state changed by store/load/store cycle"); |
275 | } | 275 | } |