MCPcopy
hub / github.com/pterm/pterm / TestPrintfln

Function TestPrintfln

print_test.go:128–157  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

126}
127
128func TestPrintfln(t *testing.T) {
129 t.Run("enabled output", func(t *testing.T) {
130 pterm.Output = true
131 for _, randomString := range internal.RandomStrings {
132 out := captureStdout(func(w io.Writer) {
133 pterm.Printfln("%s", randomString)
134 })
135 testza.AssertEqual(t, randomString+"\n", out)
136 }
137 out := captureStdout(func(w io.Writer) {
138 pterm.Printfln("Hello, %s!", "World")
139 })
140 testza.AssertEqual(t, "Hello, World!\n", out)
141 })
142
143 t.Run("disabled output", func(t *testing.T) {
144 pterm.Output = false
145 for _, randomString := range internal.RandomStrings {
146 out := captureStdout(func(w io.Writer) {
147 pterm.Printfln("%s", randomString)
148 })
149 testza.AssertEqual(t, "", out)
150 }
151 out := captureStdout(func(w io.Writer) {
152 pterm.Printfln("Hello, %s!", "World")
153 })
154 testza.AssertEqual(t, "", out)
155 pterm.Output = true
156 })
157}
158
159func TestFprint(t *testing.T) {
160 t.Run("enabled output", func(t *testing.T) {

Callers

nothing calls this directly

Calls 2

PrintflnFunction · 0.92
captureStdoutFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…