MCPcopy
hub / github.com/pterm/pterm / testPrintfContains

Function testPrintfContains

utils_test.go:53–70  ·  view source on GitHub ↗

testPrintfContains can be used to test Printf methods.

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

Source from the content-addressed store, hash-verified

51
52// testPrintfContains can be used to test Printf methods.
53func testPrintfContains(t *testing.T, logic func(w io.Writer, format string, a any)) {
54 for _, printable := range printables {
55 t.Run(fmt.Sprint(printable), func(t *testing.T) {
56 s := captureStdout(func(w io.Writer) {
57 logic(w, "Hello, %v!", printable)
58 })
59 testza.AssertContains(t, s, fmt.Sprintf("Hello, %v!", fmt.Sprint(printable)))
60 })
61 pterm.DisableStyling()
62 t.Run(fmt.Sprint(printable), func(t *testing.T) {
63 s := captureStdout(func(w io.Writer) {
64 logic(w, "Hello, %v!", printable)
65 })
66 testza.AssertContains(t, s, fmt.Sprintf("Hello, %v!", fmt.Sprint(printable)))
67 })
68 pterm.EnableStyling()
69 }
70}
71
72// testPrintflnContains can be used to test Printfln methods.
73func testPrintflnContains(t *testing.T, logic func(w io.Writer, format string, a any)) {

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…