table_test.go 598 字节
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)
	}
}