Skip to content

Commit

Permalink
add test for pathops.operations.intersection
Browse files Browse the repository at this point in the history
  • Loading branch information
anthrotype committed Mar 28, 2020
1 parent e25ed0e commit 0738b38
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/operations_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from pathops import Path, PathVerb
from pathops.operations import union, difference, intersection, reverse_difference, xor
import pytest


@pytest.mark.parametrize(
"subject_path, clip_path, expected",
[
[
[
(PathVerb.MOVE, ((0, 0),)),
(PathVerb.LINE, ((0, 10),)),
(PathVerb.LINE, ((10, 10),)),
(PathVerb.LINE, ((10, 0),)),
(PathVerb.CLOSE, ()),
],
[
(PathVerb.MOVE, ((5, 5),)),
(PathVerb.LINE, ((5, 15),)),
(PathVerb.LINE, ((15, 15),)),
(PathVerb.LINE, ((15, 5),)),
(PathVerb.CLOSE, ()),
],
[
(PathVerb.MOVE, ((5, 5),)),
(PathVerb.LINE, ((10, 5),)),
(PathVerb.LINE, ((10, 10),)),
(PathVerb.LINE, ((5, 10),)),
(PathVerb.CLOSE, ()),
],
]
],
)
def test_intersection(subject_path, clip_path, expected):
sub = Path()
for verb, pts in subject_path:
sub.add(verb, *pts)
clip = Path()
for verb, pts in clip_path:
clip.add(verb, *pts)
result = Path()

intersection([sub], [clip], result.getPen())

assert list(result) == expected

0 comments on commit 0738b38

Please sign in to comment.