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

Function TestPathJoin

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

Source from the content-addressed store, hash-verified

60}
61
62func TestPathJoin(t *testing.T) {
63 var tests = []struct {
64 p, q string
65 expected string
66 }{
67 {"M5 0L5 10", "", "M5 0L5 10"},
68 {"", "M5 0L5 10", "M5 0L5 10"},
69 {"M5 0L5 10", "L10 15", "M5 0L5 10M0 0L10 15"},
70 {"M5 0L5 10z", "M5 0L10 15", "M5 0L5 10zM5 0L10 15"},
71 {"M5 0L5 10", "M5 10L10 15", "M5 0L5 10L10 15"},
72 {"M5 0L5 10", "L10 15M20 15L25 15", "M5 0L5 10M0 0L10 15M20 15L25 15"},
73 {"M5 0L5 10", "M5 10L10 15M20 15L25 15", "M5 0L5 10L10 15M20 15L25 15"},
74 {"M5 0L10 5", "M10 5L15 10", "M5 0L15 10"},
75 {"M5 0L10 5", "L5 5z", "M5 0L10 5M0 0L5 5z"},
76 }
77
78 for _, tt := range tests {
79 t.Run(fmt.Sprint(tt.p, "x", tt.q), func(t *testing.T) {
80 p := MustParseSVGPath(tt.p).Join(MustParseSVGPath(tt.q))
81 test.T(t, p, MustParseSVGPath(tt.expected))
82 })
83 }
84
85 test.T(t, MustParseSVGPath("M5 0L5 10").Join(nil), MustParseSVGPath("M5 0L5 10"))
86}
87
88func TestPathCoords(t *testing.T) {
89 coords := MustParseSVGPath("L5 10").Coords()

Callers

nothing calls this directly

Calls 4

MustParseSVGPathFunction · 0.85
TMethod · 0.80
JoinMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected