MCPcopy
hub / github.com/tdewolff/minify / TestPathData

Function TestPathData

svg/pathdata_test.go:9–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestPathData(t *testing.T) {
10 var pathDataTests = []struct {
11 pathData string
12 expected string
13 }{
14 {"M10 10 10 10", "M10 10"},
15 {"M10 10 20 10", "M10 10H20"},
16 {"M10 10 10 20", "M10 10V20"},
17 {"M50 50 100 100", "M50 50l50 50"},
18 {"m50 50 40 40m50 50", "m50 50 40 40m50 50"},
19 {"M10 10zM15 15", "M10 10zm5 5"},
20 {"M50 50H55V55", "M50 50h5v5"},
21 {"M10 10L11 10 11 11", "M10 10h1v1"},
22 {"M10 10l1 0 0 1", "M10 10h1v1"},
23 {"M10 10v1", "M10 10v1"},
24 {"M10 10L11 11 0 0", "M10 10l1 1L0 0"},
25 {"M246.614 51.028L246.614-5.665 189.922-5.665", "M246.614 51.028V-5.665H189.922"},
26 {"M100,200 C100,100 250,100 250,200 S400,300 400,200", "M1e2 2e2c0-1e2 150-1e2 150 0s150 1e2 150 0"},
27 {"M200,300 Q400,50 600,300 T1000,300", "M2e2 3e2q2e2-250 4e2.0t4e2.0"},
28 {"M300,200 h-150 a150,150 0 1,0 150,-150 z", "M3e2 2e2H150A150 150 0 103e2 50z"},
29 {"M10 10 10 10", "M10 10"},
30 {"x5 5L10 10", "L10 10"},
31
32 {"M.0.1", "M0 .1"},
33 {"M200.0.1", "M2e2.1"},
34 {"M0 0a3.28 3.28 0 0 0 3.279 3.28", "M0 0a3.28 3.28.0 003.279 3.28"}, // #114
35 {"A1.1.0.0.0.0.2.3", "A1.1.0.0.0.0.2.3"}, // bad input (sweep and large-arc are not booleans) gives bad output
36 {"A.0.0.4 0 0.0.3", "A0 0 .4 000 .3"},
37 {"A1.1.0.0 00.2.3L10 0", "A1.1.0.0 00.2.3L10 0"},
38 {"A5 5 0 010 0", "A5 5 0 010 0"}, // different flag syntax
39 {
40 "q6.55 0 10.56-2.93a9.36 9.36 0 004-8 10 10 0 00-3.37-7.83q-3.37-3-9.9-4.79A25.38 25.38 0 0137.76 44",
41 "q6.55.0 10.56-2.93a9.36 9.36.0 004-8 10 10 0 00-3.37-7.83q-3.37-3-9.9-4.79A25.38 25.38.0 0137.76 44"}, // #275
42 {
43 "m-3.5498-0.0882q0-5.1924-4.5861-5.1924h-1.819v10.495h1.4662q4.9389-0+4.9389-5.3027z",
44 "m-3.5498-.0882q0-5.1924-4.5861-5.1924h-1.819v10.495h1.4662q4.9389.0 4.9389-5.3027z"}, // #284
45 {"C10 0 0 10 10 10", "C10 0 0 10 10 10"},
46
47 // change/remove commands
48 {"M10 10L10 10L20 10z", "M10 10H20z"},
49 {"M10 10t10 0", "M10 10h10"},
50 {"M10 10T20 10", "M10 10H20"},
51 {"M10 10T20 10T20 20", "M10 10t10 0 0 10"},
52 {"M10 10q0 0 10 0", "M10 10h10"},
53 {"M10 10Q10 10 20 10", "M10 10H20"},
54 {"M10 10Q20 10 20 10", "M10 10H20"},
55 {"M10 10Q15 20 20 10Q25 0 30 10", "M10 10q5 10 10 0t10 0"},
56 {"M10 10s0 0 10 0", "M10 10h10"},
57 {"M10 10S10 10 20 10", "M10 10H20"},
58 {"M10 10S20 10 20 10", "M10 10H20"},
59 {"M10 10c0 0 0 0 10 0", "M10 10h10"},
60 {"M10 10C10 10 10 10 20 10", "M10 10H20"},
61 {"M10 10C10 10 20 10 20 10", "M10 10H20"},
62 {"M10 10C20 10 10 10 20 10", "M10 10H20"},
63 {"M10 10C20 10 20 10 20 10", "M10 10H20"},
64 {"M10 10C10 20 20 20 20 10C20 0 30 0 30 10", "M10 10c0 10 10 10 10 0S30 0 30 10"},
65 // does not have C/S -> Q/T since subsequent commands could rely on the control points, and both are incompatible for that
66

Callers

nothing calls this directly

Calls 5

ShortenPathDataMethod · 0.95
NewPathDataFunction · 0.85
RunMethod · 0.80
MinifyMethod · 0.65
stringFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…