testPrintContains can be used to test Print methods.
(t *testing.T, logic func(w io.Writer, a any))
| 25 | |
| 26 | // testPrintContains can be used to test Print methods. |
| 27 | func 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. |
| 53 | func testPrintfContains(t *testing.T, logic func(w io.Writer, format string, a any)) { |
no test coverage detected
searching dependent graphs…