interpret large numbers as specific types

This commit is contained in:
Krishna Vedala 2020-07-22 13:38:04 -04:00
parent a5c0083954
commit 60a21da8f0
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7
4 changed files with 16 additions and 16 deletions

View File

@ -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");
}

View File

@ -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"));

View File

@ -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");
}

View File

@ -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");
}