projects/guix·blob python-team · refs

36 lines · 1.1 KiB

1See https://gitlab.com/procps-ng/procps/-/issues/271
2
3diff -u -r procps-ng-4.0.3.alt/src/tests/test_strtod_nol.c procps-ng-4.0.3/src/tests/test_strtod_nol.c
4--- procps-ng-4.0.3.alt/src/tests/test_strtod_nol.c 2022-12-18 23:44:18.383960834 +0100
5+++ procps-ng-4.0.3/src/tests/test_strtod_nol.c 2023-03-20 16:52:26.680032658 +0100
6@@ -1,6 +1,7 @@
7
8 #include <stdio.h>
9 #include <stdlib.h>
10+#include <math.h>
11 #include "strutils.h"
12
13 struct strtod_tests {
14@@ -25,6 +26,11 @@
15 {NULL, 0.0}
16 };
17
18+#define EPSILON 1.0 // Really not trying for precision here
19+int dequal(const double d1, const double d2)
20+{
21+ return fabs(d1-d2) < EPSILON;
22+}
23
24
25 int main(int argc, char *argv[])
26@@ -33,8 +39,8 @@
27 double val;
28
29 for(i=0; tests[i].string != NULL; i++) {
30- if(strtod_nol_or_err(tests[i].string, "Cannot parse number") !=
31- tests[i].result) {
32+ if(!dequal (strtod_nol_or_err(tests[i].string, "Cannot parse number"),
33+ tests[i].result)) {
34 fprintf(stderr, "FAIL: strtod_nol_or_err(\"%s\") != %f\n",
35 tests[i].string, tests[i].result);
36 return EXIT_FAILURE;