Fix int-truncation in test_merkle and test_dict Debug builds
uc2_merkle_root() and uc2_dict_id() return uint64_t; the int _r temporaries from 97e05ad's NDEBUG fix truncated the high 32 bits. Under Release the assertion was stripped, hiding the bug; under Debug the truncated _r never matched the second uint64_t call.
This commit is contained in:
@@ -27,7 +27,7 @@ static void test_id_deterministic(void)
|
||||
struct uc2_dict d1, d2;
|
||||
uc2_dict_create(&d1, data, sizeof data);
|
||||
uc2_dict_create(&d2, data, sizeof data);
|
||||
{ int _r = uc2_dict_id(&d1); (void)_r; assert(_r == uc2_dict_id(&d2)); }
|
||||
{ uint64_t _r = uc2_dict_id(&d1); (void)_r; assert(_r == uc2_dict_id(&d2)); }
|
||||
assert(uc2_dict_match(&d1, &d2));
|
||||
uc2_dict_free(&d1);
|
||||
uc2_dict_free(&d2);
|
||||
|
||||
@@ -32,7 +32,7 @@ static void test_build_empty(void)
|
||||
struct uc2_merkle tree;
|
||||
uc2_merkle_build(&tree, NULL, 0, 13);
|
||||
assert(tree.nchunks == 0);
|
||||
{ int _r = uc2_merkle_root(&tree); (void)_r; assert(_r == 0); }
|
||||
{ uint64_t _r = uc2_merkle_root(&tree); (void)_r; assert(_r == 0); }
|
||||
uc2_merkle_free(&tree);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ static void test_identical_files(void)
|
||||
uc2_merkle_build(&t1, data, len, 13);
|
||||
uc2_merkle_build(&t2, data, len, 13);
|
||||
|
||||
{ int _r = uc2_merkle_root(&t1); (void)_r; assert(_r == uc2_merkle_root(&t2)); }
|
||||
{ uint64_t _r = uc2_merkle_root(&t1); (void)_r; assert(_r == uc2_merkle_root(&t2)); }
|
||||
assert(t1.nchunks == t2.nchunks);
|
||||
{ int _r = uc2_merkle_common(&t1, &t2); (void)_r; assert(_r == t1.nchunks); }
|
||||
assert(fabs(uc2_merkle_similarity(&t1, &t2) - 1.0) < 0.001);
|
||||
|
||||
Reference in New Issue
Block a user