mirror of
https://github.com/ricoriedel/wipe.git
synced 2024-11-16 04:56:43 +00:00
Add more unit tests
This commit is contained in:
parent
7c13c8838a
commit
d965ba413a
@ -54,6 +54,34 @@ mod test {
|
|||||||
SegmentsFactory::new(Box::new(child), 2).create(&config);
|
SegmentsFactory::new(Box::new(child), 2).create(&config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sample_above_one_untouched() {
|
||||||
|
let mut child = MockPatternFactory::new();
|
||||||
|
child.expect_create().returning(|_| {
|
||||||
|
let mut sampler = MockPattern::new();
|
||||||
|
sampler.expect_sample().return_const(1.1);
|
||||||
|
Box::new(sampler)
|
||||||
|
});
|
||||||
|
|
||||||
|
let sampler = SegmentsFactory::new(Box::new(child), 3).create(&Config::default());
|
||||||
|
|
||||||
|
assert_abs_diff_eq!(1.1, sampler.sample(Vector::default()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sample_below_zero_untouched() {
|
||||||
|
let mut child = MockPatternFactory::new();
|
||||||
|
child.expect_create().returning(|_| {
|
||||||
|
let mut sampler = MockPattern::new();
|
||||||
|
sampler.expect_sample().return_const(-0.1);
|
||||||
|
Box::new(sampler)
|
||||||
|
});
|
||||||
|
|
||||||
|
let sampler = SegmentsFactory::new(Box::new(child), 3).create(&Config::default());
|
||||||
|
|
||||||
|
assert_abs_diff_eq!(-0.1, sampler.sample(Vector::default()));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn sample_second_segment_begins_with_one() {
|
fn sample_second_segment_begins_with_one() {
|
||||||
let mut child = MockPatternFactory::new();
|
let mut child = MockPatternFactory::new();
|
||||||
|
Loading…
Reference in New Issue
Block a user