From 606e5d4fcebd2645e634de7c03cccb20156ba2fc Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Wed, 22 Jul 2020 13:47:29 -0400 Subject: [PATCH] force use constants --- hash/hash_adler32.c | 12 ++++++++---- hash/hash_crc32.c | 12 ++++++++---- hash/hash_djb2.c | 12 ++++++++---- hash/hash_sdbm.c | 12 ++++++++---- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/hash/hash_adler32.c b/hash/hash_adler32.c index 3e3dd751..63825318 100644 --- a/hash/hash_adler32.c +++ b/hash/hash_adler32.c @@ -36,10 +36,14 @@ uint32_t adler32(const char* s) */ void test_adler32() { - assert(adler32("Hello World") == (const uint32_t)403375133); - assert(adler32("Hello World!") == (const uint32_t)474547262); - assert(adler32("Hello world") == (const uint32_t)413860925); - assert(adler32("Hello world!") == (const uint32_t)487130206); + const uint32_t test1 = 403375133; + assert(adler32("Hello World") == test1); + const uint32_t test2 = 474547262; + assert(adler32("Hello World!") == test2); + const uint32_t test3 = 413860925; + assert(adler32("Hello world") == test3); + const uint32_t test4 = 487130206; + assert(adler32("Hello world!") == test4); printf("Tests passed\n"); } diff --git a/hash/hash_crc32.c b/hash/hash_crc32.c index ebab97a1..6bb75433 100644 --- a/hash/hash_crc32.c +++ b/hash/hash_crc32.c @@ -38,10 +38,14 @@ uint32_t crc32(const char* s) */ void test_crc32() { - assert(crc32("Hello World") == (const uint32_t)1243066710); - assert(crc32("Hello World!") == (const uint32_t)472456355); - assert(crc32("Hello world") == (const uint32_t)2346098258); - assert(crc32("Hello world!") == (const uint32_t)461707669); + const uint32_t test1 = 1243066710; + assert(crc32("Hello World") == test1); + const uint32_t test2 = 472456355; + assert(crc32("Hello World!") == test2); + const uint32_t test3 = 2346098258; + assert(crc32("Hello world") == test3); + const uint32_t test4 = 461707669; + assert(crc32("Hello world!") == test4); // printf("%" PRIu32 "\n", crc32("Hello World")); // printf("%" PRIu32 "\n", crc32("Hello World!")); // printf("%" PRIu32 "\n", crc32("Hello world")); diff --git a/hash/hash_djb2.c b/hash/hash_djb2.c index a880685a..05166547 100644 --- a/hash/hash_djb2.c +++ b/hash/hash_djb2.c @@ -32,10 +32,14 @@ uint64_t djb2(const char* s) */ void test_djb2() { - assert(djb2("Hello World") == (const uint64_t)13827776004929097857); - assert(djb2("Hello World!") == (const uint64_t)13594750393630990530); - assert(djb2("Hello world") == (const uint64_t)13827776004967047329); - assert(djb2("Hello world!") == (const uint64_t)13594750394883323106); + const uint64_t test1 = 13827776004929097857; + assert(djb2("Hello World") == test1); + const uint64_t test2 = 13594750393630990530; + assert(djb2("Hello World!") == test2); + const uint64_t test3 = 13827776004967047329; + assert(djb2("Hello world") == test3); + const uint64_t test4 = 13594750394883323106; + assert(djb2("Hello world!") == test4); printf("Tests passed\n"); } diff --git a/hash/hash_sdbm.c b/hash/hash_sdbm.c index 36042c50..dda53eaa 100644 --- a/hash/hash_sdbm.c +++ b/hash/hash_sdbm.c @@ -32,10 +32,14 @@ uint64_t sdbm(const char* s) */ void test_sdbm() { - assert(sdbm("Hello World") == (const uint64_t)12881824461405877380); - assert(sdbm("Hello World!") == (const uint64_t)7903571203300273309); - assert(sdbm("Hello world") == (const uint64_t)15154913742888948900); - assert(sdbm("Hello world!") == (const uint64_t)15254999417003201661); + const uint64_t test1 = 12881824461405877380; + assert(sdbm("Hello World") == test1); + const uint64_t test2 = 7903571203300273309; + assert(sdbm("Hello World!") == test2); + const uint64_t test3 = 15154913742888948900; + assert(sdbm("Hello world") == test3); + const uint64_t test4 = 15254999417003201661; + assert(sdbm("Hello world!") == test4); printf("Tests passed\n"); }