Skip to content

Commit

Permalink
Rename s/got/have/ in test/c
Browse files Browse the repository at this point in the history
  • Loading branch information
nigeltao committed Feb 24, 2020
1 parent ce50a39 commit 7b19911
Show file tree
Hide file tree
Showing 12 changed files with 422 additions and 414 deletions.
2 changes: 1 addition & 1 deletion test/c/mimiclib/deflate-gzip-zlib.c
Expand Up @@ -88,7 +88,7 @@ const char* mimic_zlib_decode(wuffs_base__io_buffer* dst,
rlimit, false);
}

const char* mimic_zlib_decode_with_dictionary(wuffs_base__io_buffer* got,
const char* mimic_zlib_decode_with_dictionary(wuffs_base__io_buffer* dst,
wuffs_base__io_buffer* src,
wuffs_base__slice_u8 dictionary) {
return "miniz does not implement zlib dictionaries";
Expand Down
18 changes: 9 additions & 9 deletions test/c/std/adler32.c
Expand Up @@ -144,7 +144,7 @@ const char* test_wuffs_adler32_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 {
Expand All @@ -156,15 +156,15 @@ const char* test_wuffs_adler32_golden() {
if ((j > 0) && (data.len > limit)) {
data.len = limit;
}
got = wuffs_adler32__hasher__update_u32(&checksum, data);
have = wuffs_adler32__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 "\n",
i, j, test_cases[i].filename, got, test_cases[i].want);
i, j, test_cases[i].filename, have, test_cases[i].want);
}
}
}
Expand All @@ -179,7 +179,7 @@ const char* test_wuffs_adler32_pi() {
"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.
Expand Down Expand Up @@ -212,13 +212,13 @@ const char* test_wuffs_adler32_pi() {
wuffs_adler32__hasher__initialize(
&checksum, sizeof checksum, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
uint32_t got = wuffs_adler32__hasher__update_u32(
uint32_t have = wuffs_adler32__hasher__update_u32(
&checksum, ((wuffs_base__slice_u8){
.ptr = (uint8_t*)(digits),
.len = i,
}));
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]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/c/std/bmp.c
Expand Up @@ -100,7 +100,7 @@ const char* test_wuffs_bmp_decode_frame_config() {
wuffs_base__status status =
wuffs_bmp__decoder__decode_frame_config(&dec, &fc, &src);
if (status.repr != wuffs_base__note__end_of_data) {
RETURN_FAIL("decode_frame_config #1: got \"%s\", want \"%s\"", status.repr,
RETURN_FAIL("decode_frame_config #1: have \"%s\", want \"%s\"", status.repr,
wuffs_base__note__end_of_data);
}
if (src.meta.ri != src.meta.wi) {
Expand Down
30 changes: 15 additions & 15 deletions test/c/std/crc32.c
Expand Up @@ -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 {
Expand All @@ -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);
}
}
}
Expand All @@ -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.
Expand Down Expand Up @@ -205,39 +205,39 @@ 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,
});

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;
CHECK_STATUS("initialize",
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]);
}
}
Expand Down

0 comments on commit 7b19911

Please sign in to comment.