forked from PennState/mapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapper_test.go
51 lines (44 loc) · 1.12 KB
/
mapper_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
package mapper_test
import (
"testing"
"github.com/PennState/mapper"
"github.com/stretchr/testify/assert"
)
type test struct {
name string
inp string
exp string
}
func tests() []test {
return []test{
{"Pascal", "PascalCase", "pascal_case"},
{"Camel", "camelCase", "camel_case"},
{"Snake", "snake_case", "snake_case"},
{"Kebab", "kebab_case", "kebab_case"},
{"Multiple underscores", "__Why__This__", "why_this"},
{"Dashes", "--Why--This--", "why_this"},
{"Dashes", "--why--this--", "why_this"},
// {"Prefix acronym", "IRSWantsYou", "irs_wants_you"},
// {"Infix acronym", "ExternalURLResolver", "external_url_resolver"},
{"Postfix acronym", "NoSQL", "no_sql"},
{"Mixed up mess", "Not_Pascal_Case", "not_pascal_case"},
{"Illegal", "No$SQL", "no_sql"},
}
}
func TestMapper(t *testing.T) {
tests := tests()
for i := range tests {
test := tests[i]
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, test.exp, mapper.Mapper(test.inp))
})
}
}
func BenchmarkMapper(b *testing.B) {
tests := tests()
for i := 0; i < b.N; i++ {
for j := 0; j < len(tests); j++ {
mapper.Mapper(tests[j].inp)
}
}
}