mirror of
https://github.com/FliegendeWurst/ieee754-interpreter.git
synced 2024-11-08 16:30:35 +00:00
Exhaustive testing
This commit is contained in:
parent
321990e8d5
commit
9b835a7ebe
22
src/main.rs
22
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user