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
|
package flect
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_Dasherize(t *testing.T) {
table := []tt{
{"", ""},
{"admin/WidgetID", "admin-widget-id"},
{"Donald E. Knuth", "donald-e-knuth"},
{"Random text with *(bad)* characters", "random-text-with-bad-characters"},
{"Trailing bad characters!@#", "trailing-bad-characters"},
{"!@#Leading bad characters", "leading-bad-characters"},
{"Squeeze separators", "squeeze-separators"},
{"Test with + sign", "test-with-sign"},
{"Test with malformed utf8 \251", "test-with-malformed-utf8"},
}
for _, tt := range table {
t.Run(tt.act, func(st *testing.T) {
r := require.New(st)
r.Equal(tt.exp, Dasherize(tt.act))
r.Equal(tt.exp, Dasherize(tt.exp))
})
}
}
|