(t *testing.T)
| 108 | } |
| 109 | |
| 110 | func Test_ttyTablePrinter_WithPadding(t *testing.T) { |
| 111 | buf := bytes.Buffer{} |
| 112 | tp := New(&buf, true, 80) |
| 113 | |
| 114 | // Center the headers. |
| 115 | tp.AddHeader([]string{"A", "B", "C"}, WithPadding(func(width int, s string) string { |
| 116 | left := (width - len(s)) / 2 |
| 117 | return strings.Repeat(" ", left) + s + strings.Repeat(" ", width-left-len(s)) |
| 118 | })) |
| 119 | |
| 120 | tp.AddField("hello") |
| 121 | tp.AddField("beautiful") |
| 122 | tp.AddField("people") |
| 123 | tp.EndRow() |
| 124 | |
| 125 | err := tp.Render() |
| 126 | if err != nil { |
| 127 | t.Fatalf("unexpected error: %v", err) |
| 128 | } |
| 129 | |
| 130 | expected := heredoc.Doc(` |
| 131 | A B C |
| 132 | hello beautiful people |
| 133 | `) |
| 134 | if buf.String() != expected { |
| 135 | t.Errorf("expected: %q, got: %q", expected, buf.String()) |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | func Test_tsvTablePrinter(t *testing.T) { |
| 140 | buf := bytes.Buffer{} |
nothing calls this directly
no test coverage detected
searching dependent graphs…