diff options
author | EuAndreh <eu@euandre.org> | 2024-06-02 09:52:32 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-06-02 20:27:30 -0300 |
commit | 0cbfbd63d86b63cef88f349119d1a4b551c0a862 (patch) | |
tree | a388138afaf1fe909ba701d5914c3c75834179c4 /tests | |
parent | tests/*.c: Use EXIT_FAILURE and EXIT_SUCCESS in main() functions (diff) | |
download | pindaiba-0cbfbd63d86b63cef88f349119d1a4b551c0a862.tar.gz pindaiba-0cbfbd63d86b63cef88f349119d1a4b551c0a862.tar.xz |
src/hash.c: Add thread safe initialization of SipHash seed
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hash.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/hash.c b/tests/hash.c new file mode 100644 index 0000000..652b4fd --- /dev/null +++ b/tests/hash.c @@ -0,0 +1,63 @@ +#include "../src/hash.c" + +#include <stdlib.h> + +#include "../src/testing.h" + + + +static void +test_HASH_OUTPUT_LENGTH(void) { + test_start("HASH_OUTPUT_LENGTH"); + + { + testing("Enforce we're always consistent with SipHash"); + + assert(HASH_OUTPUT_LENGTH == SIPHASH_OUTPUT_LENGTH); + + test_ok(); + } +} + +static int +test_hash_init(void) { + int rc = -1; + + test_start("hash_init()"); + + { + testing("INITIALIZED changes after calling hash_init()"); + + assert(INITIALIZED == false); + + if (hash_init()) { + logerr("hash_init()"); + goto out; + } + rc = 0; goto out; + + assert(INITIALIZED == true); + + test_ok(); + } + + rc = 0; +out: + return rc; +} + +int +main(void) { + int rc = EXIT_FAILURE; + + test_HASH_OUTPUT_LENGTH(); + + if (test_hash_init()) { + logerr("test_hash_init()"); + goto out; + } + + rc = EXIT_SUCCESS; +out: + return rc; +} |