mirror of
https://github.com/RustAudio/rodio
synced 2024-11-10 06:04:16 +00:00
Switched-out assert_float_eq for approx
Different macro library for testing float equality
This commit is contained in:
parent
6ba19a649d
commit
f2f93e6947
3 changed files with 14 additions and 14 deletions
|
@ -43,7 +43,7 @@ symphonia-aiff = ["symphonia/aiff", "symphonia/pcm"]
|
|||
quickcheck = "0.9.2"
|
||||
rstest = "0.18.2"
|
||||
rstest_reuse = "0.6.0"
|
||||
assert_float_eq = "1.1.3"
|
||||
approx = "0.5.1"
|
||||
|
||||
[[example]]
|
||||
name = "music_m4a"
|
||||
|
|
|
@ -139,4 +139,4 @@ pub use crate::stream::{OutputStream, OutputStreamHandle, PlayError, StreamError
|
|||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate assert_float_eq;
|
||||
extern crate approx;
|
||||
|
|
|
@ -205,30 +205,30 @@ mod tests {
|
|||
let source1 = cycle_source(20, vec![0.0f32, 0.4f32, 0.8f32]);
|
||||
let mut faded = linear_gain_ramp(source1, Duration::from_secs(10), 0.0, 1.0, true);
|
||||
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.0); // source value 0
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.04); // source value 0.4, ramp gain 0.1
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.16); // source value 0.8, ramp gain 0.2
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.0); // source value 0
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.04); // source value 0.4, ramp gain 0.1
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.16); // source value 0.8, ramp gain 0.2
|
||||
|
||||
if let Ok(_result) = faded.try_seek(Duration::from_secs(5)) {
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.40); // source value 0.8, ramp gain 0.5
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.0); // source value 0, ramp gain 0.6
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.28); // source value 0.4. ramp gain 0.7
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.40); // source value 0.8, ramp gain 0.5
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.0); // source value 0, ramp gain 0.6
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.28); // source value 0.4. ramp gain 0.7
|
||||
} else {
|
||||
panic!("try_seek() failed!");
|
||||
}
|
||||
|
||||
if let Ok(_result) = faded.try_seek(Duration::from_secs(0)) {
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.0); // source value 0, ramp gain 0.0
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.04); // source value 0.4, ramp gain 0.1
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.16); // source value 0.8. ramp gain 0.2
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.0); // source value 0, ramp gain 0.0
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.04); // source value 0.4, ramp gain 0.1
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.16); // source value 0.8. ramp gain 0.2
|
||||
} else {
|
||||
panic!("try_seek() failed!");
|
||||
}
|
||||
|
||||
if let Ok(_result) = faded.try_seek(Duration::from_secs(10)) {
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.4); // source value 0.4, ramp gain 1.0
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.8); // source value 0.8, ramp gain 1.0
|
||||
assert_float_absolute_eq!(faded.next().unwrap(), 0.0); // source value 0. ramp gain 1.0
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.4); // source value 0.4, ramp gain 1.0
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.8); // source value 0.8, ramp gain 1.0
|
||||
assert_abs_diff_eq!(faded.next().unwrap(), 0.0); // source value 0. ramp gain 1.0
|
||||
} else {
|
||||
panic!("try_seek() failed!");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue