-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_camel_to_snake_test.go
53 lines (47 loc) · 1.07 KB
/
c_camel_to_snake_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
package sqac_test
import "testing"
import "github.com/1414C/sqac/common"
import "fmt"
// TestCamelToSnake
//
// Check that function CamelToSnake is correct
func TestCamelToSnake(t *testing.T) {
var errs []error
type pairs struct {
camel string
snake string
}
var p pairs
tList := make([]pairs, 0)
p.camel = "material"
p.snake = "material"
tList = append(tList, p)
p.camel = "materialNum"
p.snake = "material_num"
tList = append(tList, p)
p.camel = "testCamelCaseIBMPowerEdge"
p.snake = "test_camel_case_ibm_power_edge"
tList = append(tList, p)
p.camel = "IBMOneTwo"
p.snake = "ibm_one_two"
tList = append(tList, p)
p.camel = "IDOneTwo"
p.snake = "id_one_two"
tList = append(tList, p)
p.camel = "IOneTwo"
p.snake = "i_one_two"
tList = append(tList, p)
for _, v := range tList {
res := common.CamelToSnake(v.camel)
if res != v.snake {
errs = append(errs, fmt.Errorf("CamelToSnake('%s' expected '%s' - got '%s'", v.camel, v.snake, res))
}
}
if len(errs) > 0 {
es := ""
for _, e := range errs {
es = es + e.Error() + "\n"
}
t.Errorf(es)
}
}