forked from stoewer/go-strcase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
camel_test.go
56 lines (49 loc) · 1.5 KB
/
camel_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
// Copyright (c) 2017, A. Stoewer <[email protected]>
// All rights reserved.
package strcase
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestUpperCamelCase(t *testing.T) {
data := map[string]string{
"": "",
"f": "F",
"foo": "Foo",
"fooBar": "FooBar",
"FooBarBla": "FooBarBla",
"foo_barBla": "FooBarBla",
" foo_bar\n": "FooBar",
" foo-bar\t": "FooBar",
" foo bar\r": "FooBar",
"HTTP_status_code": "HttpStatusCode",
"skip many spaces": "SkipManySpaces",
"skip---many-dashes": "SkipManyDashes",
"skip___many_underline": "SkipManyUnderline",
}
for in, out := range data {
converted := UpperCamelCase(in)
assert.Equal(t, out, converted)
}
}
func TestLowerCamelCase(t *testing.T) {
data := map[string]string{
"": "",
"F": "f",
"foo": "foo",
"FooBar": "fooBar",
"fooBarBla": "fooBarBla",
"foo_barBla": "fooBarBla",
" foo_bar\n": "fooBar",
" foo-bar\t": "fooBar",
" foo bar\r": "fooBar",
"HTTP_status_code": "httpStatusCode",
"skip many spaces": "skipManySpaces",
"skip---many-dashes": "skipManyDashes",
"skip___many_underline": "skipManyUnderline",
}
for in, out := range data {
converted := LowerCamelCase(in)
assert.Equal(t, out, converted)
}
}