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

A hostile segment now lays only its end point, so five of them no longer
fill the stroke budget. The test asserts the endpoint-only count directly
and proves that a stroke which has spent its count takes no more through
push_dabs_counted, which tracks the budget across buffers.
This commit is contained in:
eliets2
2026-10-29 14:18:39 +02:00
parent 6a7a6fa3cf
commit 67f53390fe
+5 -3
View File
@@ -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));