Skip to content

Commit 606e5d4

Browse files
committed
force use constants
1 parent fd67f71 commit 606e5d4

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

hash/hash_adler32.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ uint32_t adler32(const char* s)
3636
*/
3737
void test_adler32()
3838
{
39-
assert(adler32("Hello World") == (const uint32_t)403375133);
40-
assert(adler32("Hello World!") == (const uint32_t)474547262);
41-
assert(adler32("Hello world") == (const uint32_t)413860925);
42-
assert(adler32("Hello world!") == (const uint32_t)487130206);
39+
const uint32_t test1 = 403375133;
40+
assert(adler32("Hello World") == test1);
41+
const uint32_t test2 = 474547262;
42+
assert(adler32("Hello World!") == test2);
43+
const uint32_t test3 = 413860925;
44+
assert(adler32("Hello world") == test3);
45+
const uint32_t test4 = 487130206;
46+
assert(adler32("Hello world!") == test4);
4347
printf("Tests passed\n");
4448
}
4549

hash/hash_crc32.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ uint32_t crc32(const char* s)
3838
*/
3939
void test_crc32()
4040
{
41-
assert(crc32("Hello World") == (const uint32_t)1243066710);
42-
assert(crc32("Hello World!") == (const uint32_t)472456355);
43-
assert(crc32("Hello world") == (const uint32_t)2346098258);
44-
assert(crc32("Hello world!") == (const uint32_t)461707669);
41+
const uint32_t test1 = 1243066710;
42+
assert(crc32("Hello World") == test1);
43+
const uint32_t test2 = 472456355;
44+
assert(crc32("Hello World!") == test2);
45+
const uint32_t test3 = 2346098258;
46+
assert(crc32("Hello world") == test3);
47+
const uint32_t test4 = 461707669;
48+
assert(crc32("Hello world!") == test4);
4549
// printf("%" PRIu32 "\n", crc32("Hello World"));
4650
// printf("%" PRIu32 "\n", crc32("Hello World!"));
4751
// printf("%" PRIu32 "\n", crc32("Hello world"));

hash/hash_djb2.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ uint64_t djb2(const char* s)
3232
*/
3333
void test_djb2()
3434
{
35-
assert(djb2("Hello World") == (const uint64_t)13827776004929097857);
36-
assert(djb2("Hello World!") == (const uint64_t)13594750393630990530);
37-
assert(djb2("Hello world") == (const uint64_t)13827776004967047329);
38-
assert(djb2("Hello world!") == (const uint64_t)13594750394883323106);
35+
const uint64_t test1 = 13827776004929097857;
36+
assert(djb2("Hello World") == test1);
37+
const uint64_t test2 = 13594750393630990530;
38+
assert(djb2("Hello World!") == test2);
39+
const uint64_t test3 = 13827776004967047329;
40+
assert(djb2("Hello world") == test3);
41+
const uint64_t test4 = 13594750394883323106;
42+
assert(djb2("Hello world!") == test4);
3943
printf("Tests passed\n");
4044
}
4145

hash/hash_sdbm.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ uint64_t sdbm(const char* s)
3232
*/
3333
void test_sdbm()
3434
{
35-
assert(sdbm("Hello World") == (const uint64_t)12881824461405877380);
36-
assert(sdbm("Hello World!") == (const uint64_t)7903571203300273309);
37-
assert(sdbm("Hello world") == (const uint64_t)15154913742888948900);
38-
assert(sdbm("Hello world!") == (const uint64_t)15254999417003201661);
35+
const uint64_t test1 = 12881824461405877380;
36+
assert(sdbm("Hello World") == test1);
37+
const uint64_t test2 = 7903571203300273309;
38+
assert(sdbm("Hello World!") == test2);
39+
const uint64_t test3 = 15154913742888948900;
40+
assert(sdbm("Hello world") == test3);
41+
const uint64_t test4 = 15254999417003201661;
42+
assert(sdbm("Hello world!") == test4);
3943
printf("Tests passed\n");
4044
}
4145

0 commit comments

Comments
 (0)