forked from alecthomas/kingpin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
usage_test.go
39 lines (35 loc) · 851 Bytes
/
usage_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package kingpin
import (
"bytes"
"fmt"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestFormatTwoColumns(t *testing.T) {
buf := bytes.NewBuffer(nil)
formatTwoColumns(buf, 2, 2, 20, [][2]string{
{"--hello", "Hello world help with something that is cool."},
})
expected := ` --hello Hello
world
help with
something
that is
cool.
`
assert.Equal(t, expected, buf.String())
}
func TestFormatTwoColumnsWide(t *testing.T) {
samples := [][2]string{
{strings.Repeat("x", 19), "19 chars"},
{strings.Repeat("x", 20), "20 chars"}}
buf := bytes.NewBuffer(nil)
formatTwoColumns(buf, 0, 0, 200, samples)
fmt.Println(buf.String())
expected := `xxxxxxxxxxxxxxxxxxx19 chars
xxxxxxxxxxxxxxxxxxxx
20 chars
`
assert.Equal(t, expected, buf.String())
}