[master] 758dad037 vnum: Add test coverage for 32bit unsigned limits

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Apr 4 18:09:06 UTC 2024


commit 758dad03772767511e99d340e8d05390c577db6e
Author: Dridi Boukelmoune <dridi.boukelmoune at 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 021aa7baf..b12e6bc01 100644
--- a/lib/libvarnish/vnum.c
+++ b/lib/libvarnish/vnum.c
@@ -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 },
@@ -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 },
@@ -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;


More information about the varnish-commit mailing list