[master] 1e997e24c [vnum] more lenient test
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Sep 22 07:42:05 UTC 2021
commit 1e997e24c1022862f9bdf1b2dba8d3d5b28921c2
Author: Guillaume Quintard <guillaume.quintard at gmail.com>
Date: Tue Sep 21 22:11:19 2021 -0700
[vnum] more lenient test
fixes #3697
diff --git a/include/vnum.h b/include/vnum.h
index fe9e78bd1..5189b541a 100644
--- a/include/vnum.h
+++ b/include/vnum.h
@@ -31,6 +31,7 @@
*/
/* from libvarnish/vnum.c */
+#define VNUM_EPSILON (1e-9d)
double VNUM(const char *p);
vtim_dur VNUM_duration_unit(vtim_dur r, const char *b, const char *e);
vtim_dur VNUM_duration(const char *p);
diff --git a/lib/libvarnish/vnum.c b/lib/libvarnish/vnum.c
index fa3a8cc97..88c688f08 100644
--- a/lib/libvarnish/vnum.c
+++ b/lib/libvarnish/vnum.c
@@ -693,9 +693,10 @@ main(int argc, char *argv[])
++ec;
}
d1 = VNUM_duration(" 365.24219d ");
- if (d1 != 31556908.8) {
+ d2 = 31556908.8;
+ if (fabs(d1 - d2) > VNUM_EPSILON) {
printf("%s: VNUM_Duration() wrong, %.3f delta = %e\n",
- *argv, d1, d1 - 31556908.8);
+ *argv, d1, d1 - d2);
++ec;
}
/* TODO: test invalid strings */
More information about the varnish-commit
mailing list