| 1 | See https://gitlab.com/procps-ng/procps/-/issues/271
|
| 2 |
|
| 3 | diff -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 | |
| 5 | |
| 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;
|