mirror of https://github.com/TheAlgorithms/C
force use constants
This commit is contained in:
parent
fd67f71013
commit
606e5d4fce
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue