-
Notifications
You must be signed in to change notification settings - Fork 31
/
mapper_test.go
60 lines (51 loc) · 1.17 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
52
53
54
55
56
57
58
59
60
package meddler
import (
"testing"
)
func TestDefaultMapper(t *testing.T) {
// default mapper should be no-op
var tests = map[string]string{
"": "",
"foo": "foo",
"foo_bar": "foo_bar",
"FooBar": "FooBar",
"FOOBAR": "FOOBAR",
}
for i, e := range tests {
if v := Mapper(i); v != e {
t.Errorf("Mapper(\"%s\"): expected %s, got %s", i, e, v)
}
}
}
func TestSnakeCase(t *testing.T) {
var tests = map[string]string{
"": "",
"ID": "id",
"ColumnName": "column_name",
"COLUMN_NAME": "column_name",
"column_name": "column_name",
"UserID": "user_id",
"UserNameRaw": "user_name_raw",
}
for i, e := range tests {
if v := SnakeCase(i); v != e {
t.Errorf("SnakeCase(\"%s\"): expected %s, got %s", i, e, v)
}
}
}
func TestLowerCase(t *testing.T) {
var tests = map[string]string{
"": "",
"ID": "id",
"ColumnName": "columnname",
"COLUMN_NAME": "column_name",
"column_name": "column_name",
"UserID": "userid",
"UserNameRaw": "usernameraw",
}
for i, e := range tests {
if v := LowerCase(i); v != e {
t.Errorf("LowerCase(\"%s\"): expected %s, got %s", i, e, v)
}
}
}