Mailing List Archive

[6.0] fa84da36f vnum: Add test coverage for 32bit unsigned limits
commit fa84da36f535f9a1d7c9a8328e8482ce0725da94
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Thu Apr 4 19:15:34 2024 +0200

vnum: Add test coverage for 32bit unsigned limits

diff --git a/lib/libvarnish/vnum.c b/lib/libvarnish/vnum.c
index 59e804ec8..47effe4cc 100644
--- a/lib/libvarnish/vnum.c
+++ b/lib/libvarnish/vnum.c
@@ -238,7 +238,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 },
@@ -278,6 +278,10 @@ static struct test_case {
{ "2%", (uintmax_t)1024, (uintmax_t)20 },
{ "3%", (uintmax_t)1024, (uintmax_t)31 },

+ /* 32bit limits */
+ { "4294967295b", (uintmax_t)0, (uintmax_t)4294967295ULL},
+ { "4294967294b", (uintmax_t)0, (uintmax_t)4294967294ULL},
+
/* Check the error checks */
{ "", 0, 0, err_miss_num },
{ "m", 0, 0, err_invalid_num },
@@ -347,7 +351,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;
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit