Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nirosys committed May 10, 2024
1 parent 84b9f34 commit 08c2313
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
18 changes: 2 additions & 16 deletions src/lazy/binary/raw/v1_1/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,18 +311,6 @@ mod tests {
Ok(())
}

macro_rules! assert_closely_eq {
($x:expr, $y:expr, $d:expr) => {
let (a, b) = ($x, $y);
if ((a - b).abs() >= $d) {
panic!(
"float not close enough to expected value: left: {}, right: {}",
a, b
);
}
};
}

#[test]
#[allow(clippy::approx_constant)]
fn floats() -> IonResult<()> {
Expand Down Expand Up @@ -351,16 +339,14 @@ mod tests {
// TODO: Implement Half-precision.
// assert_eq!(reader.next()?.expect_value()?.read()?.expect_float()?, 3.14);

assert_closely_eq!(
assert_eq!(
reader.next()?.expect_value()?.read()?.expect_float()? as f32,
3.1415927f32,
f32::EPSILON
);

assert_closely_eq!(
assert_eq!(
reader.next()?.expect_value()?.read()?.expect_float()?,
std::f64::consts::PI,
f64::EPSILON
);

Ok(())
Expand Down
7 changes: 1 addition & 6 deletions src/lazy/binary/raw/v1_1/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,7 @@ impl<'top> LazyRawBinaryValue_1_1<'top> {
}
2 => todo!("implement half-precision floats"),
0 => 0.0f64,
n => {
return IonResult::decoding_error(format!(
"found a float value with an illegal bytes size: {:?}",
n
));
}
_ => unreachable!("found a float value with illegal byte size"),
};
Ok(RawValueRef::Float(value))
}
Expand Down

0 comments on commit 08c2313

Please sign in to comment.