-
Notifications
You must be signed in to change notification settings - Fork 14
/
heck_test.go
78 lines (74 loc) · 1.97 KB
/
heck_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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package bin
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCamelCase(t *testing.T) {
type item struct {
input string
want string
}
tests := []item{
// TODO: find out if need to fix, and if yes, then fix.
// {"1hello", "1Hello"}, // actual: `1hello`
// {"1Hello", "1Hello"}, // actual: `1hello`
// {"hello1world", "Hello1World"}, // actual: `Hello1world`
// {"mGridCol6@md", "MGridCol6md"}, // actual: `MGridCol6Md`
// {"A::a", "Aa"}, // actual: `AA`
// {"foìBar-baz", "FoìBarBaz"},
//
{"hello1World", "Hello1World"},
{"Hello1World", "Hello1World"},
{"foo", "Foo"},
{"foo-bar", "FooBar"},
{"foo-bar-baz", "FooBarBaz"},
{"foo--bar", "FooBar"},
{"--foo-bar", "FooBar"},
{"--foo--bar", "FooBar"},
{"FOO-BAR", "FooBar"},
{"FOÈ-BAR", "FoèBar"},
{"-foo-bar-", "FooBar"},
{"--foo--bar--", "FooBar"},
{"foo-1", "Foo1"},
{"foo.bar", "FooBar"},
{"foo..bar", "FooBar"},
{"..foo..bar..", "FooBar"},
{"foo_bar", "FooBar"},
{"__foo__bar__", "FooBar"},
{"__foo__bar__", "FooBar"},
{"foo bar", "FooBar"},
{" foo bar ", "FooBar"},
{"-", ""},
{" - ", ""},
{"fooBar", "FooBar"},
{"fooBar-baz", "FooBarBaz"},
{"fooBarBaz-bazzy", "FooBarBazBazzy"},
{"FBBazzy", "FbBazzy"},
{"F", "F"},
{"FooBar", "FooBar"},
{"Foo", "Foo"},
{"FOO", "Foo"},
{"--", ""},
{"", ""},
{"--__--_--_", ""},
{"foo bar?", "FooBar"},
{"foo bar!", "FooBar"},
{"foo bar$", "FooBar"},
{"foo-bar#", "FooBar"},
{"XMLHttpRequest", "XmlHttpRequest"},
{"AjaxXMLHttpRequest", "AjaxXmlHttpRequest"},
{"Ajax-XMLHttpRequest", "AjaxXmlHttpRequest"},
{"Hello11World", "Hello11World"},
{"hello1", "Hello1"},
{"Hello1", "Hello1"},
{"h1W", "H1W"},
// TODO: add support to non-alphanumeric characters (non-latin, non-ascii).
}
for i := range tests {
test := tests[i]
t.Run(test.input, func(t *testing.T) {
t.Parallel()
assert.Equal(t, test.want, ToPascalCase(test.input))
})
}
}