From 9b835a7ebea7607a465fd8c91c557045d9e62357 Mon Sep 17 00:00:00 2001 From: FliegendeWurst <2012gdwu@web.de> Date: Tue, 19 May 2020 08:59:51 +0200 Subject: [PATCH] Exhaustive testing --- src/main.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main.rs b/src/main.rs index 365d152..65a17ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,3 +81,25 @@ fn interpret_single_test() { assert_eq!(interpret_single(test.0), test.1); } } + +#[test] +#[ignore] +fn interpret_exhaustive_test() { + let mut any_fail = false; + for value in 0..=u32::MAX { + let expected = f32::from_bits(value); + let actual = interpret_single(value); + if expected.is_nan() { + if !actual.is_nan() { + eprintln!("value {:032b} expected {:?} actual {:?}", value, expected, actual); + any_fail = true; + } + } else { + if actual != expected { + eprintln!("value {:032b} expected {:?} actual {:?}", value, expected, actual); + any_fail = true; + } + } + } + assert!(!any_fail); +}