forked from stoewer/go-strcase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kebab_test.go
56 lines (49 loc) · 1.71 KB
/
kebab_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 TestKebabCase(t *testing.T) {
data := map[string]string{
"": "",
"F": "f",
"Foo": "foo",
"FooB": "foo-b",
"FooID": "foo-id",
" FooBar\t": "foo-bar",
"HTTPStatusCode": "http-status-code",
"ParseURL.DoParse": "parse-url.do-parse",
"Convert Space": "convert-space",
"Convert-dash": "convert-dash",
"Skip___MultipleUnderscores": "skip-multiple-underscores",
"Skip MultipleSpaces": "skip-multiple-spaces",
"Skip---MultipleDashes": "skip-multiple-dashes",
}
for camel, snake := range data {
converted := KebabCase(camel)
assert.Equal(t, snake, converted)
}
}
func TestUpperKebabCase(t *testing.T) {
data := map[string]string{
"": "",
"F": "F",
"Foo": "FOO",
"FooB": "FOO-B",
"FooID": "FOO-ID",
" FooBar\t": "FOO-BAR",
"HTTPStatusCode": "HTTP-STATUS-CODE",
"ParseURL.DoParse": "PARSE-URL.DO-PARSE",
"Convert Space": "CONVERT-SPACE",
"Convert-dash": "CONVERT-DASH",
"Skip___MultipleUnderscores": "SKIP-MULTIPLE-UNDERSCORES",
"Skip MultipleSpaces": "SKIP-MULTIPLE-SPACES",
"Skip---MultipleDashes": "SKIP-MULTIPLE-DASHES",
}
for camel, snake := range data {
converted := UpperKebabCase(camel)
assert.Equal(t, snake, converted)
}
}