mirror of
https://github.com/GyulyVGC/sniffnet.git
synced 2025-12-23 22:29:01 -05:00
remove duplicated test
This commit is contained in:
@@ -135,72 +135,3 @@ fn build_chart<DB: DrawingBackend>(
|
||||
let _ = chart.draw_series(area_series).log_err(location!());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use splines::{Interpolation, Key, Spline};
|
||||
|
||||
use crate::chart::types::chart_series::sample_spline;
|
||||
|
||||
#[test]
|
||||
fn test_spline_samples() {
|
||||
let vec = vec![
|
||||
(0, -500),
|
||||
(1, -1000),
|
||||
(2, -1000),
|
||||
(3, -1000),
|
||||
(4, -1000),
|
||||
(5, -1000),
|
||||
(6, -1000),
|
||||
(7, -1000),
|
||||
(8, -1000),
|
||||
(9, -1000),
|
||||
(10, -1000),
|
||||
(11, -1000),
|
||||
(12, -1000),
|
||||
(13, -1000),
|
||||
(14, -1000),
|
||||
(15, -1000),
|
||||
(16, -1000),
|
||||
(17, -1000),
|
||||
(18, -1000),
|
||||
(19, -1000),
|
||||
(20, -1000),
|
||||
(21, -1000),
|
||||
(22, -1000),
|
||||
(23, -1000),
|
||||
(24, -1000),
|
||||
(25, -1000),
|
||||
(26, -1000),
|
||||
(27, -1000),
|
||||
(28, -1000),
|
||||
];
|
||||
let spline = Spline::from_vec(
|
||||
vec.iter()
|
||||
.map(|&(x, y)| Key::new(x as f32, y as f32, Interpolation::Cosine))
|
||||
.collect::<Vec<Key<f32, f32>>>(),
|
||||
);
|
||||
|
||||
let eps = 0.001;
|
||||
|
||||
let pts = spline.len() * 10;
|
||||
let samples = sample_spline(&spline, 1.0);
|
||||
assert_eq!(samples.len(), pts);
|
||||
|
||||
let delta = samples[1].0 - samples[0].0;
|
||||
|
||||
assert_eq!(samples[0].0, 0.0);
|
||||
assert_eq!(samples[0].1, -500.0);
|
||||
for i in 0..pts - 1 {
|
||||
assert_eq!(
|
||||
(samples[i + 1].0 * 10_000.0 - samples[i].0 * 10_000.0).round() / 10_000.0,
|
||||
(delta * 10_000.0).round() / 10_000.0
|
||||
);
|
||||
assert!(samples[i].1 <= -500.0);
|
||||
assert!(samples[i].1 >= -1000.0 - eps);
|
||||
assert!(samples[i + 1].1 < samples[i].1 + eps);
|
||||
}
|
||||
assert_eq!(samples[pts - 1].0, 28.0);
|
||||
assert_eq!(samples[pts - 1].1, -1000.0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user