Skip to content

Commit 7a68a1f

Browse files
committed
fix tests so that each contour is a regular closed contour
1 parent af031b1 commit 7a68a1f

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

iOverlay/src/vector/simplify.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,15 @@ mod tests {
264264
#[rustfmt::skip]
265265
let mut contour = vec![
266266
VectorEdge::new(1, int_pnt!(-1, 3), int_pnt!(-1, 1)),
267-
VectorEdge::new(2, int_pnt!(-1, 3), int_pnt!(-1, 1)),
267+
VectorEdge::new(2, int_pnt!(-1, 1), int_pnt!(-1, 1)),
268268
VectorEdge::new(3, int_pnt!(-1, 1), int_pnt!(-3, 1)),
269269
VectorEdge::new(4, int_pnt!(-3, 1), int_pnt!(-3, -2)),
270270
VectorEdge::new(5, int_pnt!(-3, -2), int_pnt!(3, -2)),
271271
VectorEdge::new(6, int_pnt!(3, -2), int_pnt!(3, 1)),
272-
VectorEdge::new(7, int_pnt!(3, -2), int_pnt!(1, 1)),
273-
VectorEdge::new(8, int_pnt!(1, 1), int_pnt!(1, 3)),
274-
VectorEdge::new(9, int_pnt!(1, 3), int_pnt!(-1, 3)),
275-
VectorEdge::new(10, int_pnt!(-1, 3), int_pnt!(-1, -1)),
272+
VectorEdge::new(7, int_pnt!(3, 1), int_pnt!(3, 1)),
273+
VectorEdge::new(8, int_pnt!(3, 1), int_pnt!(1, 1)),
274+
VectorEdge::new(9, int_pnt!(1, 1), int_pnt!(1, 3)),
275+
VectorEdge::new(10, int_pnt!(1, 3), int_pnt!(-1, 3)),
276276
];
277277

278278
let result = contour.simplify_contour();
@@ -285,12 +285,12 @@ mod tests {
285285
fn test_tiny_segments() {
286286
#[rustfmt::skip]
287287
let mut contour = vec![
288-
VectorEdge::new(1, int_pnt!(0, 1), int_pnt!(-1, 0)),
289-
VectorEdge::new(2, int_pnt!(-1, 0), int_pnt!(0, -1)),
290-
VectorEdge::new(3, int_pnt!(-1, 0), int_pnt!(0, -1)),
291-
VectorEdge::new(4, int_pnt!(0, -1), int_pnt!(1, 0)),
292-
VectorEdge::new(5, int_pnt!(1, 0), int_pnt!(0, 1)),
293-
VectorEdge::new(6, int_pnt!(1, 0), int_pnt!(0, 1)),
288+
VectorEdge::new(1, int_pnt!(0, 2), int_pnt!(-1, 1)),
289+
VectorEdge::new(2, int_pnt!(-1, 1), int_pnt!(-2, 0)),
290+
VectorEdge::new(3, int_pnt!(-2, 0), int_pnt!(0, -1)),
291+
VectorEdge::new(4, int_pnt!(0, -1), int_pnt!(2, 0)),
292+
VectorEdge::new(5, int_pnt!(2, 0), int_pnt!(1, 1)),
293+
VectorEdge::new(6, int_pnt!(1, 1), int_pnt!(0, 2)),
294294
];
295295

296296
let result = contour.simplify_contour();
@@ -303,26 +303,29 @@ mod tests {
303303
fn test_collinear_runs() {
304304
#[rustfmt::skip]
305305
let mut contour = vec![
306-
VectorEdge::new(1, int_pnt!(-3, 0), int_pnt!(3, 0)),
307-
VectorEdge::new(2, int_pnt!(-3, 0), int_pnt!(-1, 0)),
308-
VectorEdge::new(3, int_pnt!(-2, 0), int_pnt!(2, 0)),
309-
VectorEdge::new(4, int_pnt!(3, 0), int_pnt!(0, -3)),
310-
VectorEdge::new(5, int_pnt!(0, -3), int_pnt!(-3, 0)),
306+
VectorEdge::new(1, int_pnt!(-2, -2), int_pnt!(0, -2)),
307+
VectorEdge::new(2, int_pnt!(0, -2), int_pnt!(2, -2)),
308+
VectorEdge::new(3, int_pnt!(2, -2), int_pnt!(2, 0)),
309+
VectorEdge::new(4, int_pnt!(2, 0), int_pnt!(2, 2)),
310+
VectorEdge::new(5, int_pnt!(2, 2), int_pnt!(0, 2)),
311+
VectorEdge::new(6, int_pnt!(0, 2), int_pnt!(-2, 2)),
312+
VectorEdge::new(7, int_pnt!(-2, 2), int_pnt!(-2, 0)),
313+
VectorEdge::new(8, int_pnt!(-2, 0), int_pnt!(-2, -2)),
311314
];
312315

313316
let result = contour.simplify_contour();
314317

315318
debug_assert!(result);
316-
debug_assert!(contour.len() == 3);
319+
debug_assert!(contour.len() == 4);
317320
}
318321

319322
#[test]
320323
fn test_zero_area_path() {
321324
#[rustfmt::skip]
322325
let mut contour = vec![
323-
VectorEdge::new(1, int_pnt!(-3, 0), int_pnt!(3, 0)),
324-
VectorEdge::new(2, int_pnt!(-3, 0), int_pnt!(-1, 0)),
325-
VectorEdge::new(3, int_pnt!(-2, 0), int_pnt!(2, 0)),
326+
VectorEdge::new(1, int_pnt!(-3, 0), int_pnt!(0, 0)),
327+
VectorEdge::new(2, int_pnt!(0, 0), int_pnt!(3, 0)),
328+
VectorEdge::new(3, int_pnt!(3, 0), int_pnt!(-3, 0)),
326329
];
327330

328331
let result = contour.simplify_contour();

0 commit comments

Comments
 (0)