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

Function TestPathCommands

path_test.go:101–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

99}
100
101func TestPathCommands(t *testing.T) {
102 var tts = []struct {
103 p string
104 expected string
105 }{
106 {"M3 4", "M3 4"},
107 {"M3 4M5 3", "M5 3"},
108 {"M3 4z", ""},
109 {"z", ""},
110
111 {"L3 4", "L3 4"},
112 {"L3 4L0 0z", "L3 4z"},
113 {"L3 4L4 0L2 0z", "L3 4L4 0z"},
114 {"L3 4zz", "L3 4z"},
115 {"L5 0zL6 3", "L5 0zL6 3"},
116 {"M2 1L3 4L5 0zL6 3", "M2 1L3 4L5 0zM2 1L6 3"},
117 {"M2 1L3 4L5 0zM2 1L6 3", "M2 1L3 4L5 0zM2 1L6 3"},
118
119 {"M3 4Q3 4 3 4", "M3 4"},
120 {"Q0 0 0 0", ""},
121 {"Q3 4 3 4", "L3 4"},
122 {"Q1.5 2 3 4", "L3 4"},
123 {"Q0 0 -1 -1", "L-1 -1"},
124 {"Q1 2 3 4", "Q1 2 3 4"},
125 {"Q3 4 0 0", "Q3 4 0 0"},
126 {"L5 0zQ5 3 6 3", "L5 0zQ5 3 6 3"},
127
128 {"M3 4C3 4 3 4 3 4", "M3 4"},
129 {"C0 0 0 0 0 0", ""},
130 {"C0 0 3 4 3 4", "L3 4"},
131 {"C1 1 2 2 3 3", "L3 3"},
132 {"C0 0 0 0 -1 -1", "L-1 -1"},
133 {"C-1 -1 0 0 -1 -1", "L-1 -1"},
134 {"C1 1 2 2 3 3", "L3 3"},
135 {"C1 1 2 2 3 4", "C1 1 2 2 3 4"},
136 {"C1 1 2 2 0 0", "C1 1 2 2 0 0"},
137 {"C3 3 -1 -1 2 2", "C3 3 -1 -1 2 2"},
138 {"L5 0zC5 1 5 3 6 3", "L5 0zC5 1 5 3 6 3"},
139
140 {"M3 4A2 2 0 0 0 3 4", "M3 4"},
141 {"A0 0 0 0 0 4 0", "L4 0"},
142 {"A2 1 0 0 0 4 0", "A2 1 0 0 0 4 0"},
143 {"A1 2 0 1 1 4 0", "A4 2 90 1 1 4 0"},
144 {"A1 2 90 0 0 4 0", "A2 1 0 0 0 4 0"},
145 {"L5 0zA5 5 0 0 0 10 0", "L5 0zA5 5 0 0 0 10 0"},
146 }
147 for _, tt := range tts {
148 t.Run(fmt.Sprint(tt.p), func(t *testing.T) {
149 test.T(t, MustParseSVGPath(tt.p), MustParseSVGPath(tt.expected))
150 })
151 }
152
153 p := &Path{}
154 p.Arc(2, 1, 0, 180, 0)
155 test.T(t, p, MustParseSVGPath("A2 1 0 0 0 4 0"))
156
157 p = &Path{}
158 p.Arc(2, 1, 0, 0, 180)

Callers

nothing calls this directly

Calls 4

ArcMethod · 0.95
MustParseSVGPathFunction · 0.85
TMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected