mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 13:02:50 -05:00
Tests: Connect tangents' external shape does not cross itself
The test checked only which corners the shape has, so corners joined in the wrong order passed. It now also checks the shape's area.
This commit is contained in:
1 parent
6230cf282a
commit
5d494db4d9
1 file changed
+3
@@ -385,6 +385,9 @@ fn connect_joins_the_external_tangents_and_the_chords_into_one_closed_shape_in_o
|
||||
for p in [Point::new(100.0, 80.0), Point::new(200.0, 80.0), Point::new(200.0, 120.0), Point::new(100.0, 120.0)] {
|
||||
assert!(found.iter().any(|&q| near(p, q)), "{p:?} in {found:?}");
|
||||
}
|
||||
// In order around the band, not crossing itself: the area is the 100 by 40 rectangle's.
|
||||
let area = found.iter().zip(found.iter().cycle().skip(1)).map(|(p, q)| p.x * q.y - q.x * p.y).sum::<f64>() / 2.0;
|
||||
assert!((area.abs() - 4000.0).abs() < 1e-6, "area {area} of {found:?}");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().doc.node_count(), count);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user