-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for pathops.operations.intersection
- Loading branch information
1 parent
e25ed0e
commit 0738b38
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |