MCPcopy
hub / github.com/pterm/pterm / TestPrefixPrinterPrintMethods

Function TestPrefixPrinterPrintMethods

prefix_printer_test.go:23–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21}
22
23func TestPrefixPrinterPrintMethods(t *testing.T) {
24 for _, p := range prefixPrinters {
25 t.Run("Print", func(t *testing.T) {
26 testPrintContains(t, func(w io.Writer, a any) {
27 p.WithWriter(w).Print(a)
28 })
29 })
30
31 t.Run("PrintWithScope", func(t *testing.T) {
32 testPrintContains(t, func(w io.Writer, a any) {
33 p2 := p.WithScope(pterm.Scope{
34 Text: "test",
35 Style: pterm.NewStyle(pterm.FgRed, pterm.BgBlue, pterm.Bold),
36 })
37 p2.WithWriter(w).Print(a)
38 })
39 })
40
41 t.Run("PrintWithShowLineNumber", func(t *testing.T) {
42 testPrintContains(t, func(w io.Writer, a any) {
43 p2 := p.WithShowLineNumber().WithWriter(w)
44 p2.Print(a)
45 })
46 })
47
48 t.Run("PrintWithMultipleLines", func(t *testing.T) {
49 p2 := p.WithScope(pterm.Scope{
50 Text: "test",
51 Style: pterm.NewStyle(pterm.FgRed, pterm.BgBlue, pterm.Bold),
52 })
53 p2.Print("This text\nhas\nmultiple\nlines")
54 })
55
56 t.Run("Printf", func(t *testing.T) {
57 testPrintfContains(t, func(w io.Writer, format string, a any) {
58 p.WithWriter(w).Printf(format, a)
59 })
60 })
61
62 t.Run("Printfln", func(t *testing.T) {
63 testPrintflnContains(t, func(w io.Writer, format string, a any) {
64 p.WithWriter(w).Printfln(format, a)
65 })
66 })
67
68 t.Run("Println", func(t *testing.T) {
69 testPrintlnContains(t, func(w io.Writer, a any) {
70 p.WithWriter(w).Println(a)
71 })
72 })
73
74 t.Run("Sprint", func(t *testing.T) {
75 testSprintContains(t, func(a any) string {
76 return p.Sprint(a)
77 })
78 })
79
80 t.Run("Sprintf", func(t *testing.T) {

Callers

nothing calls this directly

Calls 15

NewStyleFunction · 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
WithScopeMethod · 0.80
WithShowLineNumberMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…