Rename s/got/have/ in test/c

This commit is contained in:
Nigel Tao committed 2020-02-24 21:23:58 +11:00
1 parent ce50a39f85
commit 7b199116b0
12 files changed
+422 -414

No files matched your search

+15 -15
View File
@@ -144,7 +144,7 @@ const char* test_wuffs_crc32_ieee_golden() {
&checksum, sizeof checksum, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
uint32_t got = 0;
uint32_t have = 0;
size_t num_fragments = 0;
size_t num_bytes = 0;
do {
@@ -156,15 +156,15 @@ const char* test_wuffs_crc32_ieee_golden() {
if ((j > 0) && (data.len > limit)) {
data.len = limit;
}
got = wuffs_crc32__ieee_hasher__update_u32(&checksum, data);
have = wuffs_crc32__ieee_hasher__update_u32(&checksum, data);
num_fragments++;
num_bytes += data.len;
} while (num_bytes < src.meta.wi);
if (got != test_cases[i].want) {
RETURN_FAIL("i=%d, j=%d, filename=\"%s\": got 0x%08" PRIX32
if (have != test_cases[i].want) {
RETURN_FAIL("i=%d, j=%d, filename=\"%s\": have 0x%08" PRIX32
", want 0x%08" PRIX32,
i, j, test_cases[i].filename, got, test_cases[i].want);
i, j, test_cases[i].filename, have, test_cases[i].want);
}
}
}
@@ -177,7 +177,7 @@ const char* do_test_xxxxx_crc32_ieee_pi(bool mimic) {
"141592653589793238462643383279502884197169399375105820974944592307816406"
"2862089986280348253421170";
if (strlen(digits) != 99) {
RETURN_FAIL("strlen(digits): got %d, want 99", (int)(strlen(digits)));
RETURN_FAIL("strlen(digits): have %d, want 99", (int)(strlen(digits)));
}
// The want values are determined by script/checksum.go.
@@ -205,7 +205,7 @@ const char* do_test_xxxxx_crc32_ieee_pi(bool mimic) {
int i;
for (i = 0; i < 100; i++) {
uint32_t got;
uint32_t have;
wuffs_base__slice_u8 data = ((wuffs_base__slice_u8){
.ptr = (uint8_t*)(digits),
.len = i,
@@ -213,19 +213,19 @@ const char* do_test_xxxxx_crc32_ieee_pi(bool mimic) {
if (mimic) {
// A simple, slow CRC-32 IEEE implementation, 1 bit at a time.
got = 0xFFFFFFFF;
have = 0xFFFFFFFF;
while (data.len--) {
uint8_t byte = *data.ptr++;
for (int i = 0; i < 8; i++) {
if ((got ^ byte) & 1) {
got = (got >> 1) ^ 0xEDB88320;
if ((have ^ byte) & 1) {
have = (have >> 1) ^ 0xEDB88320;
} else {
got = (got >> 1);
have = (have >> 1);
}
byte >>= 1;
}
}
got ^= 0xFFFFFFFF;
have ^= 0xFFFFFFFF;
} else {
wuffs_crc32__ieee_hasher checksum;
@@ -233,11 +233,11 @@ const char* do_test_xxxxx_crc32_ieee_pi(bool mimic) {
wuffs_crc32__ieee_hasher__initialize(
&checksum, sizeof checksum, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
got = wuffs_crc32__ieee_hasher__update_u32(&checksum, data);
have = wuffs_crc32__ieee_hasher__update_u32(&checksum, data);
}
if (got != wants[i]) {
RETURN_FAIL("i=%d: got 0x%08" PRIX32 ", want 0x%08" PRIX32, i, got,
if (have != wants[i]) {
RETURN_FAIL("i=%d: have 0x%08" PRIX32 ", want 0x%08" PRIX32, i, have,
wants[i]);
}
}