MCPcopy Create free account
hub / github.com/github/gh-aw / TestSpec_PublicAPI_StripANSI

Function TestSpec_PublicAPI_StripANSI

pkg/stringutil/spec_test.go:214–244  ·  view source on GitHub ↗

TestSpec_PublicAPI_StripANSI validates the documented behavior of StripANSI as described in the package README.md. Specification: "Removes all ANSI/VT100 escape sequences from s. Handles CSI sequences (e.g. \x1b[31m for colors) and other ESC-prefixed sequences." Specification example: colored :=

(t *testing.T)

Source from the content-addressed store, hash-verified

212// colored := "\x1b[32mSuccess\x1b[0m"
213// plain := stringutil.StripANSI(colored) // "Success"
214func TestSpec_PublicAPI_StripANSI(t *testing.T) {
215 tests := []struct {
216 name string
217 input string
218 expected string
219 }{
220 {
221 name: "removes CSI color escape sequence (documented example)",
222 input: "\x1b[32mSuccess\x1b[0m",
223 expected: "Success",
224 },
225 {
226 name: "plain string returned unchanged",
227 input: "plain text",
228 expected: "plain text",
229 },
230 {
231 name: "removes red color code (documented \\x1b[31m form)",
232 input: "\x1b[31mError\x1b[0m",
233 expected: "Error",
234 },
235 }
236
237 for _, tt := range tests {
238 t.Run(tt.name, func(t *testing.T) {
239 result := StripANSI(tt.input)
240 assert.Equal(t, tt.expected, result,
241 "StripANSI(%q) should remove ANSI escape sequences", tt.input)
242 })
243 }
244}
245
246// TestSpec_PublicAPI_NormalizeWorkflowName validates the documented behavior of
247// NormalizeWorkflowName as described in the package README.md.

Callers

nothing calls this directly

Calls 2

StripANSIFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected