MCPcopy
hub / github.com/go-task/task / TestSnippetString

Function TestSnippetString

taskfile/snippet_test.go:87–289  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func TestSnippetString(t *testing.T) {
88 t.Parallel()
89 tests := []struct {
90 name string
91 b []byte
92 opts []SnippetOption
93 want string
94 }{
95 {
96 name: "empty",
97 b: []byte{},
98 opts: []SnippetOption{
99 WithLine(1),
100 WithColumn(1),
101 },
102 want: "",
103 },
104 {
105 name: "0th line, 0th column (no indicators)",
106 b: []byte(sample),
107 want: "",
108 },
109 {
110 name: "1st line, 0th column (line indicator only)",
111 b: []byte(sample),
112 opts: []SnippetOption{
113 WithLine(1),
114 },
115 want: "> 1 | \x1b[33mversion\x1b[0m\x1b[1m\x1b[30m:\x1b[0m\x1b[1m\x1b[30m \x1b[0m\x1b[36m3\x1b[0m\x1b[1m\x1b[30m\x1b[0m",
116 },
117 {
118 name: "0th line, 1st column (column indicator only)",
119 b: []byte(sample),
120 opts: []SnippetOption{
121 WithColumn(1),
122 },
123 want: "",
124 },
125 {
126 name: "0th line, 1st column, padding=2 (column indicator only)",
127 b: []byte(sample),
128 opts: []SnippetOption{
129 WithColumn(1),
130 WithPadding(2),
131 },
132 want: " 1 | \x1b[33mversion\x1b[0m\x1b[1m\x1b[30m:\x1b[0m\x1b[1m\x1b[30m \x1b[0m\x1b[36m3\x1b[0m\x1b[1m\x1b[30m\x1b[0m\n 2 | \x1b[1m\x1b[30m\x1b[0m\n | ^",
133 },
134 {
135 name: "1st line, 1st column",
136 b: []byte(sample),
137 opts: []SnippetOption{
138 WithLine(1),
139 WithColumn(1),
140 },
141 want: "> 1 | \x1b[33mversion\x1b[0m\x1b[1m\x1b[30m:\x1b[0m\x1b[1m\x1b[30m \x1b[0m\x1b[36m3\x1b[0m\x1b[1m\x1b[30m\x1b[0m\n | ^",
142 },
143 {
144 name: "1st line, 10th column",

Callers

nothing calls this directly

Calls 7

StringMethod · 0.95
WithLineFunction · 0.85
WithColumnFunction · 0.85
WithPaddingFunction · 0.85
WithNoIndicatorsFunction · 0.85
NewSnippetFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…