From f65912600fc301cbdbb613f1df0dc29820f1da35 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 18 Aug 2022 13:18:52 -0400 Subject: Use conventional test executable names --- test/digest_test.c | 129 ----------------------------------------------------- 1 file changed, 129 deletions(-) delete mode 100644 test/digest_test.c (limited to 'test/digest_test.c') 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 -// SPDX-License-Identifier: ISC - -#undef NDEBUG - -#include "zix/digest.h" - -#include -#include - -// 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; -} -- cgit v1.2.1