mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
interpret large numbers as specific types
This commit is contained in:
parent
a5c0083954
commit
60a21da8f0
@ -36,10 +36,10 @@ uint32_t adler32(const char* s)
|
||||
*/
|
||||
void test_adler32()
|
||||
{
|
||||
assert(adler32("Hello World") == 403375133);
|
||||
assert(adler32("Hello World!") == 474547262);
|
||||
assert(adler32("Hello world") == 413860925);
|
||||
assert(adler32("Hello world!") == 487130206);
|
||||
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);
|
||||
printf("Tests passed\n");
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,10 @@ uint32_t crc32(const char* s)
|
||||
*/
|
||||
void test_crc32()
|
||||
{
|
||||
assert(crc32("Hello World") == 1243066710);
|
||||
assert(crc32("Hello World!") == 472456355);
|
||||
assert(crc32("Hello world") == 2346098258);
|
||||
assert(crc32("Hello world!") == 461707669);
|
||||
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);
|
||||
// printf("%" PRIu32 "\n", crc32("Hello World"));
|
||||
// printf("%" PRIu32 "\n", crc32("Hello World!"));
|
||||
// printf("%" PRIu32 "\n", crc32("Hello world"));
|
||||
|
@ -32,10 +32,10 @@ uint64_t djb2(const char* s)
|
||||
*/
|
||||
void test_djb2()
|
||||
{
|
||||
assert(djb2("Hello World") == 13827776004929097857);
|
||||
assert(djb2("Hello World!") == 13594750393630990530);
|
||||
assert(djb2("Hello world") == 13827776004967047329);
|
||||
assert(djb2("Hello world!") == 13594750394883323106);
|
||||
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);
|
||||
printf("Tests passed\n");
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,10 @@ uint64_t sdbm(const char* s)
|
||||
*/
|
||||
void test_sdbm()
|
||||
{
|
||||
assert(sdbm("Hello World") == 12881824461405877380);
|
||||
assert(sdbm("Hello World!") == 7903571203300273309);
|
||||
assert(sdbm("Hello world") == 15154913742888948900);
|
||||
assert(sdbm("Hello world!") == 15254999417003201661);
|
||||
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);
|
||||
printf("Tests passed\n");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user