-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathchunk_test.go
More file actions
74 lines (59 loc) · 1.66 KB
/
chunk_test.go
File metadata and controls
74 lines (59 loc) · 1.66 KB
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
package caseconv
import (
"strings"
"testing"
assert "github.com/stretchr/testify/require"
)
func Test_chunk(t *testing.T) {
testCases := []testCase{
{"", ""},
// single words
{"test", "test"},
{"TEST", "test"},
{"PIPPI LÅNGSTRUMP", "pippi långstrump"},
// camel case
{"testString", "test string"},
{"testString123", "test string123"},
{"testString_1_2_3", "test string 1 2 3"},
{"x_256", "x 256"},
{"anHTMLTag", "an html tag"},
{"ID123String", "id123 string"},
{"Id123String", "id123 string"},
{"foo bar123", "foo bar123"},
{"a1bStar", "a1b star"},
// constant case
{"CONSTANT_CASE ", "constant case"},
{"CONST123_FOO", "const123 foo"},
// random cases
{"FOO_bar", "foo bar"},
{"XMLHttpRequest", "xml http request"},
{"IQueryAArgs", "i query a args"},
// non-alphanumeric separators
{"dot.case", "dot case"},
{"path/case", "path case"},
{"snake_case", "snake case"},
{"snake_case123", "snake case123"},
{"snake_case_123", "snake case 123"},
// Punctuation.
{`"quotes"`, "quotes"},
// space between number parts
{"version 0.45.0", "version 0 45 0"},
{"version 0..78..9", "version 0 78 9"},
{"version 4_99/4", "version 4 99 4"},
// whitespace.
{" test ", "test"},
// Number string input.
{"something_2014_other", "something 2014 other"},
// https://github.com/blakeembrey/change-case/issues/21
{"amazon s3 data", "amazon s3 data"},
{"foo_13_bar", "foo 13 bar"},
{"Pippil ÅNGSTRUMP", "pippil ångstrump"},
}
for _, tc := range testCases {
assert.Equal(t, tc.expectedOutput, strings.Join(chunk(tc.input), " "))
}
}
type testCase struct {
input string
expectedOutput string
}