-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_test.go
50 lines (45 loc) · 1.67 KB
/
util_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
package integra
import (
"reflect"
"strings"
"testing"
)
func TestSplitWords(t *testing.T) {
tests := []struct {
input string
expected []string
}{
{"FooBar", []string{"Foo", "Bar"}},
{"fooBar", []string{"foo", "Bar"}},
{"FooXYZBar", []string{"Foo", "XYZ", "Bar"}},
{"foo-bar_baz/123", []string{"foo", "bar", "baz", "123"}},
{"HTMLParser-Example_test", []string{"HTML", "Parser", "Example", "test"}},
}
for _, test := range tests {
t.Run(test.input, func(t *testing.T) {
output := SplitWords(test.input)
if !reflect.DeepEqual(output, test.expected) {
t.Errorf("SplitWords(%q) = %v; want %v", test.input, output, test.expected)
}
})
}
}
func TestNameVariants(t *testing.T) {
tests := []struct {
input string
expected []string
}{
{"fooBar", strings.Split("FooBar FooBars foo-bar foo-bars fooBar fooBars foo_bar foo_bars", " ")},
{"FooXYZBar", strings.Split("FooXYZBar FooXYZBars FooXyzBar FooXyzBars foo-xyz-bar foo-xyz-bars fooXYZBar fooXYZBars fooXyzBar fooXyzBars foo_xyz_bar foo_xyz_bars", " ")},
{"foo-bar_baz/123", strings.Split("FooBarBaz123 foo-bar-baz-123 fooBarBaz123 foo_bar_baz_123", " ")},
{"HTMLParser-Example_test", strings.Split("HTMLParserExampleTest HTMLParserExampleTests HtmlParserExampleTest HtmlParserExampleTests html-parser-example-test html-parser-example-tests htmlParserExampleTest htmlParserExampleTests html_parser_example_test html_parser_example_tests", " ")},
}
for _, test := range tests {
t.Run(test.input, func(t *testing.T) {
output := NameVariants(test.input)
if !reflect.DeepEqual(output, test.expected) {
t.Errorf("NameVariants(%q) = %v; want %v", test.input, output, test.expected)
}
})
}
}