Skip to content

Commit 681bd65

Browse files
committed
Add a test.
1 parent 54cfe62 commit 681bd65

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

cmd/algocfg/getCommand_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"fmt"
6+
"testing"
7+
"time"
8+
9+
"github.com/stretchr/testify/assert"
10+
)
11+
12+
func TestPrint(t *testing.T) {
13+
testcases := []struct {
14+
input interface{}
15+
expected string
16+
}{
17+
{
18+
input: uint64(1234),
19+
expected: "1234",
20+
},
21+
{
22+
input: int64(-1234),
23+
expected: "-1234",
24+
},
25+
{
26+
input: true,
27+
expected: "true",
28+
},
29+
{
30+
input: time.Second,
31+
expected: "1s",
32+
},
33+
}
34+
for i, tc := range testcases {
35+
t.Run(fmt.Sprintf("test %d", i), func(t *testing.T) {
36+
var buf bytes.Buffer
37+
fmt.Fprintf(&buf, "%v", tc.input)
38+
assert.Equal(t, tc.expected, buf.String())
39+
})
40+
}
41+
}

0 commit comments

Comments
 (0)