MCPcopy
hub / github.com/tdewolff/canvas / TestPathFastClip

Function TestPathFastClip

path_simplify_test.go:49–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestPathFastClip(t *testing.T) {
50 tests := []struct {
51 p string
52 rect Rect
53 r string
54 }{
55 {"M-5 5L5 5L5 15L-5 15z", Rect{0, 0, 10, 10}, "M-5 5L5 5L5 15L-5 15z"},
56 {"M1 5L9 5L9 15L1 15z", Rect{0, 0, 10, 10}, "M1 5L9 5L9 15L1 15z"},
57 {"M1 5L9 5L9 15L5 20L1 15z", Rect{0, 0, 10, 10}, "M1 5L9 5L9 15L1 15z"},
58 {"M-5 5L9 5L9 15L5 20L-5 15z", Rect{0, 0, 10, 10}, "M-5 5L9 5L9 15L-5 15z"},
59 {"M-5 15L-5 5L9 5L9 15L5 20z", Rect{0, 0, 10, 10}, "M-5 5L9 5L9 15L-5 15z"},
60 {"M20 2L30 2L30 8L20 8z", Rect{0, 0, 10, 10}, ""},
61 {"M20 5L30 5L30 15L20 15z", Rect{0, 0, 10, 10}, ""},
62 {"M20 -10L30 -10L30 20L20 20z", Rect{0, 0, 10, 10}, ""},
63 {"M14 5L14 14L5 14z", Rect{0, 0, 10, 10}, "M14 14L5 14L14 5z"},
64 {"M14 14L5 14L14 5z", Rect{0, 0, 10, 10}, "M5 14L14 5L14 14z"},
65 {"M5 14L14 5L14 14z", Rect{0, 0, 10, 10}, "M5 14L14 5L14 14z"},
66 //{"M16 5L16 16L5 16z", Rect{0, 0, 10, 10}, ""},
67 {"M-10 -10L20 -10L20 20L-10 20z", Rect{0, 0, 10, 10}, "M20 -10L20 20L-10 20L-10 -10z"},
68 {"M9 11L11 11", Rect{0, 0, 10, 10}, ""},
69 {"M15 5L15 15L5 15", Rect{0, 0, 10, 10}, ""},
70 }
71
72 for _, tt := range tests {
73 t.Run(tt.p, func(t *testing.T) {
74 p := MustParseSVGPath(tt.p)
75 r := MustParseSVGPath(tt.r)
76 test.T(t, p.FastClip(tt.rect.X0, tt.rect.Y0, tt.rect.X1, tt.rect.Y1), r)
77 })
78 }
79}
80
81func TestPathClip(t *testing.T) {
82 tests := []struct {

Callers

nothing calls this directly

Calls 4

MustParseSVGPathFunction · 0.85
TMethod · 0.80
FastClipMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected