Skip to content

Commit 39e2429

Browse files
committed
Fix build - tests in ./tests don't seem to set #[cfg(test)].
1 parent 3eeb4f7 commit 39e2429

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ pub use torque_energy::TorqueEnergy;
8686

8787
pub mod prelude;
8888

89-
#[cfg(test)]
9089
pub mod test_utils;
9190

9291
/// For given types A, B and C, implement, using base units:

src/test_utils.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn almost_eq(a: f64, b: f64) -> bool {
99

1010
/// Check two floating point values are approximately equal using some given delta (a fraction of the inputs)
1111
pub fn almost_eq_delta(a: f64, b: f64, d: f64) -> bool {
12-
((a - b).abs() / a) < d
12+
(abs(a - b) / a) < d
1313
}
1414

1515
/// Assert two floating point values are approximately equal
@@ -23,3 +23,13 @@ pub fn assert_almost_eq_delta(a: f64, b: f64, d: f64) {
2323
panic!("assertion failed: {:?} != {:?} (within {:?})", a, b, d);
2424
}
2525
}
26+
27+
/// This function doesn't seem to be available no `#![no_std]` so we re-
28+
/// implement it here.
29+
fn abs(x: f64) -> f64 {
30+
if x > 0.0 {
31+
x
32+
} else {
33+
-x
34+
}
35+
}

0 commit comments

Comments
 (0)