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

Function TestPathMarkers

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

Source from the content-addressed store, hash-verified

490}
491
492func TestPathMarkers(t *testing.T) {
493 start := MustParseSVGPath("L1 0L0 1z")
494 mid := MustParseSVGPath("M-1 0A1 1 0 0 0 1 0z")
495 end := MustParseSVGPath("L-1 0L0 1z")
496
497 var tts = []struct {
498 p string
499 rs []string
500 }{
501 {"M10 0", []string{"M10 0L11 0L10 1z"}},
502 {"M10 0L20 10", []string{"M10 0L11 0L10 1z", "M20 10L19 10L20 11z"}},
503 {"L10 0L20 10", []string{"L1 0L0 1z", "M9 0A1 1 0 0 0 11 0z", "M20 10L19 10L20 11z"}},
504 {"L10 0L20 10z", []string{"L1 0L0 1z", "M9 0A1 1 0 0 0 11 0z", "M19 10A1 1 0 0 0 21 10z", "L-1 0L0 1z"}},
505 {"M10 0L20 10M30 0L40 10", []string{"M10 0L11 0L10 1z", "M19 10A1 1 0 0 0 21 10z", "M29 0A1 1 0 0 0 31 0z", "M40 10L39 10L40 11z"}},
506 }
507 for _, tt := range tts {
508 t.Run(tt.p, func(t *testing.T) {
509 p := MustParseSVGPath(tt.p)
510 ps := p.Markers(start, mid, end, false)
511 if len(ps) != len(tt.rs) {
512 origs := []string{}
513 for _, p := range ps {
514 origs = append(origs, p.String())
515 }
516 test.T(t, strings.Join(origs, "\n"), strings.Join(tt.rs, "\n"))
517 } else {
518 for i, p := range ps {
519 test.T(t, p, MustParseSVGPath(tt.rs[i]))
520 }
521 }
522 })
523 }
524}
525
526func TestPathMarkersAligned(t *testing.T) {
527 start := MustParseSVGPath("L1 0L0 1z")

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected