MCPcopy
hub / github.com/pterm/pterm / TestColorPrinterPrintMethods

Function TestColorPrinterPrintMethods

color_test.go:74–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestColorPrinterPrintMethods(t *testing.T) {
75 p := pterm.Color(16)
76
77 t.Run("Print", func(t *testing.T) {
78 testPrintContains(t, func(w io.Writer, a any) {
79 p.Print(a)
80 })
81 })
82
83 t.Run("Printf", func(t *testing.T) {
84 testPrintfContains(t, func(w io.Writer, format string, a any) {
85 p.Printf(format, a)
86 })
87 })
88
89 t.Run("Printfln", func(t *testing.T) {
90 testPrintflnContains(t, func(w io.Writer, format string, a any) {
91 p.Printfln(format, a)
92 })
93 })
94
95 t.Run("Println", func(t *testing.T) {
96 testPrintlnContains(t, func(w io.Writer, a any) {
97 p.Println(a)
98 })
99 })
100
101 t.Run("Sprint", func(t *testing.T) {
102 testSprintContains(t, func(a any) string {
103 return p.Sprint(a)
104 })
105 })
106
107 t.Run("Sprintf", func(t *testing.T) {
108 testSprintfContains(t, func(format string, a any) string {
109 return p.Sprintf(format, a)
110 })
111 })
112
113 t.Run("Sprintfln", func(t *testing.T) {
114 testSprintflnContains(t, func(format string, a any) string {
115 return p.Sprintfln(format, a)
116 })
117 })
118
119 t.Run("Sprintln", func(t *testing.T) {
120 testSprintlnContains(t, func(a any) string {
121 return p.Sprintln(a)
122 })
123 })
124
125 t.Run("PrintOnError", func(t *testing.T) {
126 result := captureStdout(func(w io.Writer) {
127 p.PrintOnError(errors.New("hello world"))
128 })
129 testza.AssertContains(t, result, "hello world")
130 })
131

Callers

nothing calls this directly

Calls 15

ColorTypeAlias · 0.92
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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…