MCPcopy
hub / github.com/pterm/pterm / TestSectionPrinterPrintMethods

Function TestSectionPrinterPrintMethods

section_printer_test.go:19–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17}
18
19func TestSectionPrinterPrintMethods(t *testing.T) {
20 p := pterm.DefaultSection
21
22 t.Run("Print", func(t *testing.T) {
23 testPrintContains(t, func(w io.Writer, a any) {
24 p.Print(a)
25 })
26 })
27
28 t.Run("Printf", func(t *testing.T) {
29 testPrintfContains(t, func(w io.Writer, format string, a any) {
30 p.Printf(format, a)
31 })
32 })
33
34 t.Run("Printfln", func(t *testing.T) {
35 testPrintflnContains(t, func(w io.Writer, format string, a any) {
36 p.Printfln(format, a)
37 })
38 })
39
40 t.Run("Println", func(t *testing.T) {
41 testPrintlnContains(t, func(w io.Writer, a any) {
42 p.Println(a)
43 })
44 })
45
46 t.Run("Sprint", func(t *testing.T) {
47 testSprintContains(t, func(a any) string {
48 return p.Sprint(a)
49 })
50 })
51
52 t.Run("Sprintf", func(t *testing.T) {
53 testSprintfContains(t, func(format string, a any) string {
54 return p.Sprintf(format, a)
55 })
56 })
57
58 t.Run("Sprintfln", func(t *testing.T) {
59 testSprintflnContains(t, func(format string, a any) string {
60 return p.Sprintfln(format, a)
61 })
62 })
63
64 t.Run("Sprintln", func(t *testing.T) {
65 testSprintlnContains(t, func(a any) string {
66 return p.Sprintln(a)
67 })
68 })
69
70 t.Run("PrintOnError", func(t *testing.T) {
71 result := captureStdout(func(w io.Writer) {
72 p.PrintOnError(errors.New("hello world"))
73 })
74 testza.AssertContains(t, result, "hello world")
75 })
76

Callers

nothing calls this directly

Calls 15

testPrintContainsFunction · 0.85
testPrintfContainsFunction · 0.85
testPrintflnContainsFunction · 0.85
testPrintlnContainsFunction · 0.85
testSprintContainsFunction · 0.85
testSprintfContainsFunction · 0.85
testSprintflnContainsFunction · 0.85
testSprintlnContainsFunction · 0.85
captureStdoutFunction · 0.85
PrintMethod · 0.65
PrintfMethod · 0.65
PrintflnMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…