diff options
author | David Robillard <d@drobilla.net> | 2022-08-18 13:18:52 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-18 14:33:37 -0400 |
commit | f65912600fc301cbdbb613f1df0dc29820f1da35 (patch) | |
tree | 43db69627433fbb8f5acd13c6cf0ef8a3c3b829d /test/digest_test.c | |
parent | c4b8ca3dc222b06c40ebcb416d653e17e88de858 (diff) | |
download | zix-f65912600fc301cbdbb613f1df0dc29820f1da35.tar.gz zix-f65912600fc301cbdbb613f1df0dc29820f1da35.tar.bz2 zix-f65912600fc301cbdbb613f1df0dc29820f1da35.zip |
Use conventional test executable names
Diffstat (limited to 'test/digest_test.c')
-rw-r--r-- | test/digest_test.c | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/test/digest_test.c b/test/digest_test.c deleted file mode 100644 index c1a16a8..0000000 --- a/test/digest_test.c +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2020-2021 David Robillard <d@drobilla.net> -// SPDX-License-Identifier: ISC - -#undef NDEBUG - -#include "zix/digest.h" - -#include <assert.h> -#include <stddef.h> - -// Just basic smoke tests to ensure the hash functions are reacting to data - -static void -test_digest(void) -{ - static const uint8_t data[] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; - - size_t last = 0U; - - for (size_t offset = 0; offset < 7; ++offset) { - const size_t len = 8U - offset; - for (size_t i = offset; i < 8; ++i) { - const size_t h = zix_digest(0U, &data[i], len); - assert(h != last); - last = h; - } - } -} - -static void -test_digest32(void) -{ - static const uint8_t data[] = {1, 2, 3, 4, 5, 6, 7, 8}; - - uint32_t last = 0U; - - for (size_t offset = 0; offset < 3; ++offset) { - for (size_t i = offset; i < 4; ++i) { - const uint32_t h = zix_digest32(0U, &data[i], 4); - assert(h != last); - last = h; - } - } -} - -static void -test_digest64(void) -{ - static const uint8_t data[] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; - - uint64_t last = 0U; - - for (size_t offset = 0; offset < 7; ++offset) { - for (size_t i = offset; i < 8; ++i) { - const uint64_t h = zix_digest64(0U, &data[i], 8); - assert(h != last); - last = h; - } - } -} - -static void -test_digest32_aligned(void) -{ - static const uint32_t data[] = {1, 2, 3, 4, 5, 6, 7, 8}; - - uint32_t last = 0U; - - for (size_t offset = 0; offset < 3; ++offset) { - const size_t len = 4U - offset; - for (size_t i = offset; i < 4; ++i) { - const uint32_t h = - zix_digest32_aligned(0U, &data[i], len * sizeof(uint32_t)); - assert(h != last); - last = h; - } - } -} - -static void -test_digest64_aligned(void) -{ - static const uint64_t data[] = {1, 2, 3, 4, 5, 6, 7, 8}; - - uint64_t last = 0U; - - for (size_t offset = 0; offset < 3; ++offset) { - const size_t len = 4U - offset; - for (size_t i = offset; i < 4; ++i) { - const uint64_t h = - zix_digest64_aligned(0U, &data[i], len * sizeof(uint64_t)); - assert(h != last); - last = h; - } - } -} - -static void -test_digest_aligned(void) -{ - static const size_t data[] = {1, 2, 3, 4, 5, 6, 7, 8}; - - size_t last = 0U; - - for (size_t offset = 0; offset < 3; ++offset) { - const size_t len = 4U - offset; - for (size_t i = offset; i < 4; ++i) { - const size_t h = zix_digest_aligned(0U, &data[i], len * sizeof(size_t)); - assert(h != last); - last = h; - } - } -} - -ZIX_PURE_FUNC int -main(void) -{ - test_digest32(); - test_digest64(); - test_digest(); - - test_digest32_aligned(); - test_digest64_aligned(); - test_digest_aligned(); - - return 0; -} |