From 1c75cb5febdfdea9f9b6999e222859fcf2c2e801 Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Wed, 16 Oct 2019 12:32:42 -0400 Subject: [PATCH] t/iee754: add return value To facilitate automated testing, return 0 when all tests succeed and a non-zero value otherwise. Also add one more test value. --- t/ieee754.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/t/ieee754.c b/t/ieee754.c index 3898ab74..b6526394 100644 --- a/t/ieee754.c +++ b/t/ieee754.c @@ -1,21 +1,26 @@ #include #include "../lib/ieee754.h" -static double values[] = { -17.23, 17.23, 123.4567, 98765.4321, 0.0 }; +static double values[] = { -17.23, 17.23, 123.4567, 98765.4321, + 3.14159265358979323, 0.0 }; int main(int argc, char *argv[]) { uint64_t i; - double f; - int j; + double f, delta; + int j, differences = 0; j = 0; do { i = fio_double_to_uint64(values[j]); f = fio_uint64_to_double(i); - printf("%f -> %f\n", values[j], f); + delta = values[j] - f; + printf("%26.20lf -> %26.20lf, delta = %26.20lf\n", values[j], + f, delta); + if (f != values[j]) + differences++; j++; } while (values[j] != 0.0); - return 0; + return differences; } -- 2.25.1