Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

masks: adapt the long-segment test to endpoint-only hostile segments

eliets267f53390fe4d
diff --git a/crates/pipeline/src/masks/tests.rs b/crates/pipeline/src/masks/tests.rs
index 66e451a75..59f258726 100644
--- a/crates/pipeline/src/masks/tests.rs
+++ b/crates/pipeline/src/masks/tests.rs
@@ -148,7 +148,8 @@ fn a_long_segment_gets_dabs_at_most_the_spacing_apart() {
}
assert_eq!(committed.dabs, again);
assert!(committed.dabs.windows(2).all(|w| w[0].dist(w[1]) <= dab_spacing(committed.r) + 1e-9));
- // many huge segments stop at the stroke budget instead of adding up without bound
+ // a huge segment lays only its end point, so many of them add one dab each instead of
+ // filling the stroke budget with intermediate dabs
let mut big = Vec::new();
let mut at = Point::new(0.0, 0.0);
for i in 0..5 {
@@ -157,8 +158,9 @@ fn a_long_segment_gets_dabs_at_most_the_spacing_apart() {
at = q;
}
}
- assert!(big.len() <= MAX_STROKE_DABS, "{} dabs", big.len());
- assert!(!push_dabs(&mut big, Some(at), Point::new(5.0, 5.0), 1.0), "a full stroke takes no more");
+ assert_eq!(big.len(), 5, "an extreme segment lays no intermediate dabs");
+ let mut spent = MAX_STROKE_DABS;
+ assert!(!push_dabs_counted(&mut big, &mut spent, Some(at), Point::new(5.0, 5.0), 1.0), "a full stroke takes no more");
// a hostile segment places no in-between dabs
let mut v = Vec::new();
assert!(!push_dabs(&mut v, Some(Point::new(f64::NAN, 0.0)), Point::new(1.0, 1.0), r));