Skip to content

Commit

Permalink
vnum: Add test coverage for 32bit unsigned limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Dridi committed Apr 4, 2024
1 parent 0e75d46 commit 758dad0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/libvarnish/vnum.c
Expand Up @@ -486,7 +486,7 @@ static struct test_case {
uintmax_t rel;
uintmax_t val;
const char *err;
} test_cases[] = {
} test_vnum_2bytes[] = {
{ "1", (uintmax_t)0, (uintmax_t)1 },
{ "1B", (uintmax_t)0, (uintmax_t)1<<0 },
{ "1 B", (uintmax_t)0, (uintmax_t)1<<0 },
Expand Down Expand Up @@ -530,6 +530,10 @@ static struct test_case {
{ "2%", (uintmax_t)1024, (uintmax_t)20 },
{ "3%", (uintmax_t)1024, (uintmax_t)30 },

/* 32bit limits */
{ "4294967295b", (uintmax_t)0, (uintmax_t)4294967295ULL},
{ "4294967294b", (uintmax_t)0, (uintmax_t)4294967294ULL},

/* Check the error checks */
{ "", 0, 0, err_invalid_num },
{ "-1", 0, 0, err_invalid_num },
Expand Down Expand Up @@ -674,7 +678,7 @@ main(int argc, char *argv[])
}
}

for (tc = test_cases; tc->str; ++tc) {
for (tc = test_vnum_2bytes; tc->str; ++tc) {
e = VNUM_2bytes(tc->str, &val, tc->rel);
if (e != NULL)
val = 0;
Expand Down

0 comments on commit 758dad0

Please sign in to comment.