-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
cgstrings_test.go
46 lines (41 loc) 路 1.09 KB
/
cgstrings_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
45
46
package cgstrings
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCamel(t *testing.T) {
t.Parallel()
assert := assert.New(t)
assert.Equal("", Camel(""))
assert.Equal("plugh", Camel("plugh"))
assert.Equal("waldoThudFred", Camel("WaldoThudFred"))
assert.Equal("graultBaz", Camel("Grault-Baz"))
assert.Equal("graultBaz", Camel("grault-baz"))
assert.Equal("graultBaz", Camel("graultBaz"))
assert.Equal("grault_Baz", Camel("Grault_Baz"))
assert.Equal("graultBaz", Camel("Grault-baz"))
}
func TestUnhyphenate(t *testing.T) {
t.Parallel()
testcases := []struct {
input, expected string
}{
{"", ""},
{"waldo", "waldo"},
{"waldo-thud-fred", "waldoThudFred"},
{"waldo-Thud-Fred", "waldoThudFred"},
{"waldo-Thud-Fred-", "waldoThudFred"},
{"-waldo-Thud-Fred", "WaldoThudFred"},
{"waldoThudFred", "waldoThudFred"},
{"WaldoThudFred", "WaldoThudFred"},
}
for _, tc := range testcases {
tc := tc
t.Run(fmt.Sprintf("Subtest:%q", tc.input), func(t *testing.T) {
t.Parallel()
assert := assert.New(t)
assert.Equal(tc.expected, Unhyphenate(tc.input))
})
}
}