From 5a26656ea1095083def4c82918116b2d5cb2e641 Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Mon, 13 Jul 2020 10:35:43 +0200 Subject: add floating point test cases. One for fuzzing (test-floatingpoint.c) and one for testing all cases with the instrumented program (test-fp_cases.c) --- test/test-floatingpoint.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/test-floatingpoint.c (limited to 'test/test-floatingpoint.c') diff --git a/test/test-floatingpoint.c b/test/test-floatingpoint.c new file mode 100644 index 00000000..f78b5d9f --- /dev/null +++ b/test/test-floatingpoint.c @@ -0,0 +1,18 @@ +#include +#include + +int main(void) +{ + long double magic; + + ssize_t bytes_read = read(STDIN_FILENO, &magic, sizeof(magic)); + if (bytes_read < (ssize_t)sizeof(magic)) { + return 1; + } + + if( (-magic == 15.0 + 0.5 + 0.125 + 0.03125 + 0.0078125) ){ /* 15 + 1/2 + 1/8 + 1/32 + 1/128 */ + abort(); + } + + return 0; +} -- cgit 1.4.1