1 package flect
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/require"
7 )
8
9 func Test_Camelize(t *testing.T) {
10 table := []tt{
11 {"", ""},
12 {"bob dylan", "bobDylan"},
13 {"id", "id"},
14 {"ID", "id"},
15 {"widgetID", "widgetID"},
16 {"widget_ID", "widgetID"},
17 {"Widget_ID", "widgetID"},
18 {"Widget_Id", "widgetID"},
19 {"Widget_id", "widgetID"},
20 {"Nice to see you!", "niceToSeeYou"},
21 {"*hello*", "hello"},
22 {"i've read a book! have you?", "iveReadABookHaveYou"},
23 {"This is `code` ok", "thisIsCodeOK"},
24 {"foo_bar", "fooBar"},
25 {"admin/widget", "adminWidget"},
26 {"widget", "widget"},
27 {"widgets", "widgets"},
28 {"status", "status"},
29 {"Statuses", "statuses"},
30 {"statuses", "statuses"},
31 {"People", "people"},
32 {"people", "people"},
33 {"ip_address", "ipAddress"},
34 {"some_url", "someURL"},
35 }
36
37 for _, tt := range table {
38 t.Run(tt.act, func(st *testing.T) {
39 r := require.New(st)
40 r.Equal(tt.exp, Camelize(tt.act))
41 r.Equal(tt.exp, Camelize(tt.exp))
42 })
43 }
44 }
45
View as plain text