Files
atomctl/pkg/swag/utils_test.go
2024-12-25 16:18:41 +08:00

42 lines
641 B
Go

package swag
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFieldsByAnySpace(t *testing.T) {
type args struct {
s string
n int
}
tests := []struct {
name string
args args
want []string
}{
{
"test1",
args{
" aa bb cc dd ff",
2,
},
[]string{"aa", "bb\tcc dd \t\tff"},
},
{
"test2",
args{
` aa "bb cc dd ff"`,
2,
},
[]string{"aa", `"bb cc dd ff"`},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equalf(t, tt.want, FieldsByAnySpace(tt.args.s, tt.args.n), "FieldsByAnySpace(%v, %v)", tt.args.s, tt.args.n)
})
}
}