table_test.go
598 字节
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
40
package domain
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestLimitStringLen(t *testing.T){
inputs:=[]struct{
input string
length int
want string
}{
{
input: "123456789",
length: 6,
want: "123789",
},
{
input: "123456789",
length: 7,
want: "123789",
},
{
input: "123456789",
length: 10,
want: "123456789",
},
{
input: "pai_xu_ce_shi_zhu_biao_fu_zhi",
length: 20,
want: "pai_xu_ce_iao_fu_zhi",
},
}
for _,input:=range inputs{
got:=limitStringLen(input.input,input.length)
assert.Equal(t,input.want,got)
}
}