MCPcopy
hub / github.com/pterm/pterm / testPrintContains

Function testPrintContains

utils_test.go:27–50  ·  view source on GitHub ↗

testPrintContains can be used to test Print methods.

(t *testing.T, logic func(w io.Writer, a any))

Source from the content-addressed store, hash-verified

25
26// testPrintContains can be used to test Print methods.
27func testPrintContains(t *testing.T, logic func(w io.Writer, a any)) {
28 t.Helper()
29
30 for _, printable := range printables {
31 t.Run(fmt.Sprint(printable), func(t *testing.T) {
32 t.Helper()
33
34 s := captureStdout(func(w io.Writer) {
35 logic(w, printable)
36 })
37 testza.AssertContains(t, s, fmt.Sprint(printable))
38 })
39 pterm.DisableStyling()
40 t.Run(fmt.Sprint(printable), func(t *testing.T) {
41 t.Helper()
42
43 s := captureStdout(func(w io.Writer) {
44 logic(w, printable)
45 })
46 testza.AssertContains(t, s, fmt.Sprint(printable))
47 })
48 pterm.EnableStyling()
49 }
50}
51
52// testPrintfContains can be used to test Printf methods.
53func testPrintfContains(t *testing.T, logic func(w io.Writer, format string, a any)) {

Calls 4

DisableStylingFunction · 0.92
EnableStylingFunction · 0.92
captureStdoutFunction · 0.85
SprintMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…