-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
camelize_test.go
44 lines (40 loc) · 983 Bytes
/
camelize_test.go
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
41
42
43
44
package flect
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_Camelize(t *testing.T) {
table := []tt{
{"", ""},
{"bob dylan", "bobDylan"},
{"id", "id"},
{"ID", "id"},
{"widgetID", "widgetID"},
{"widget_ID", "widgetID"},
{"Widget_ID", "widgetID"},
{"Widget_Id", "widgetID"},
{"Widget_id", "widgetID"},
{"Nice to see you!", "niceToSeeYou"},
{"*hello*", "hello"},
{"i've read a book! have you?", "iveReadABookHaveYou"},
{"This is `code` ok", "thisIsCodeOK"},
{"foo_bar", "fooBar"},
{"admin/widget", "adminWidget"},
{"widget", "widget"},
{"widgets", "widgets"},
{"status", "status"},
{"Statuses", "statuses"},
{"statuses", "statuses"},
{"People", "people"},
{"people", "people"},
{"ip_address", "ipAddress"},
{"some_url", "someURL"},
}
for _, tt := range table {
t.Run(tt.act, func(st *testing.T) {
r := require.New(st)
r.Equal(tt.exp, Camelize(tt.act))
r.Equal(tt.exp, Camelize(tt.exp))
})
}
}