Skip to content

Commit 24dd18e

Browse files
committed
more tests
1 parent baa3be1 commit 24dd18e

1 file changed

Lines changed: 80 additions & 1 deletion

File tree

iOverlay/tests/ocg_tests.rs

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,36 @@ mod tests {
301301

302302
#[test]
303303
fn test_6() {
304+
// 0 1 2 3 4 5
305+
// 3 ┌───────┐ ┌───────┐
306+
// │ │ │ │
307+
// 2 │ ┌───●───●───┐ │
308+
// │ │ ░ │ │ ░ │ │
309+
// 1 │ └───┘ └───┘ │
310+
// │ │
311+
// 0 └───────────────────┘
312+
313+
let subj_paths = int_shape![[[0, 3], [0, 0], [5, 0], [5, 3], [3, 3], [3, 2], [2, 2], [2, 3]],];
314+
let clip_paths = int_shape![[[1, 2], [1, 1], [2, 1], [2, 2]], [[3, 2], [3, 1], [4, 1], [4, 2]],];
315+
316+
let mut overlay = Overlay::with_contours_custom(
317+
&subj_paths,
318+
&clip_paths,
319+
IntOverlayOptions::ogc(),
320+
Default::default(),
321+
);
322+
323+
let result = overlay.overlay(OverlayRule::Difference, FillRule::EvenOdd);
324+
325+
assert_eq!(result.len(), 1);
326+
assert_eq!(result[0].len(), 3);
327+
assert_eq!(result[0][0].len(), 8);
328+
assert_eq!(result[0][1].len(), 4);
329+
assert_eq!(result[0][2].len(), 4);
330+
}
331+
332+
#[test]
333+
fn test_7() {
304334
// 0 1 2 3
305335
// 3 ┌───┐
306336
// │ │
@@ -334,7 +364,56 @@ mod tests {
334364
}
335365

336366
#[test]
337-
fn test_7() {
367+
fn test_8() {
368+
// 0 1 2 3 4 5
369+
// 4 ┌───────┐ ┌───────┐
370+
// │ │ │ │
371+
// 3 │ ┌───●───●───┐ │
372+
// │ │ ░ │ │ ░ │ │
373+
// 2 │ └───●───●───┘ │
374+
// │ │ ░ │ │
375+
// 1 │ └───┘ │
376+
// │ │
377+
// 0 └───────────────────┘
378+
379+
let subj_paths = int_shape![[
380+
[0, 4],
381+
[0, 0],
382+
[5, 0],
383+
[5, 4],
384+
[3, 4],
385+
[3, 3],
386+
[4, 3],
387+
[4, 2],
388+
[3, 2],
389+
[3, 1],
390+
[2, 1],
391+
[2, 2],
392+
[1, 2],
393+
[1, 3],
394+
[2, 3],
395+
[2, 4]
396+
]];
397+
let clip_paths = int_shape![[[2, 3], [2, 2], [3, 2], [3, 3]]];
398+
399+
let mut overlay = Overlay::with_contours_custom(
400+
&subj_paths,
401+
&clip_paths,
402+
IntOverlayOptions::ogc(),
403+
Default::default(),
404+
);
405+
406+
let result = overlay.overlay(OverlayRule::Union, FillRule::EvenOdd);
407+
408+
assert_eq!(result.len(), 2);
409+
assert_eq!(result[0].len(), 1);
410+
assert_eq!(result[0][0].len(), 16);
411+
assert_eq!(result[1].len(), 1);
412+
assert_eq!(result[1][0].len(), 4);
413+
}
414+
415+
#[test]
416+
fn test_9() {
338417
let subj_paths = int_shape![
339418
[[-3, 0], [-3, -3], [0, -3], [0, 0], [3, 0], [3, 3], [0, 3], [0, 0]],
340419
[[-1, -2], [-2, -1], [0, 0], [1, 2], [2, 1], [0, 0]],

0 commit comments

Comments
 (0)