use super::Values;
#[derive(Debug, PartialEq, Clone)]
pub struct Sample {
pub timestamp: Option<f64>,
pub values: Values,
}
impl PartialOrd for Sample {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.timestamp.partial_cmp(&other.timestamp)
}
}
#[test]
fn test_sample_partialord() {
let sample1 = Sample {
timestamp: Some(1.0),
values: Values::Int8(vec![1, 2, 3]),
};
let sample2 = Sample {
timestamp: Some(2.0),
values: Values::Int8(vec![4, 5, 6]),
};
let sample3 = Sample {
timestamp: Some(3.0),
values: Values::Int8(vec![7, 8, 9]),
};
assert!(sample1 < sample2);
assert!(sample2 < sample3);
assert!(sample1 < sample3);
}