...
1 package flect
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/require"
7 )
8
9 func Test_Dasherize(t *testing.T) {
10 table := []tt{
11 {"", ""},
12 {"admin/WidgetID", "admin-widget-id"},
13 {"Donald E. Knuth", "donald-e-knuth"},
14 {"Random text with *(bad)* characters", "random-text-with-bad-characters"},
15 {"Trailing bad characters!@#", "trailing-bad-characters"},
16 {"!@#Leading bad characters", "leading-bad-characters"},
17 {"Squeeze separators", "squeeze-separators"},
18 {"Test with + sign", "test-with-sign"},
19 {"Test with malformed utf8 \251", "test-with-malformed-utf8"},
20 }
21
22 for _, tt := range table {
23 t.Run(tt.act, func(st *testing.T) {
24 r := require.New(st)
25 r.Equal(tt.exp, Dasherize(tt.act))
26 r.Equal(tt.exp, Dasherize(tt.exp))
27 })
28 }
29 }
30
View as plain text