1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 22:40:55 +00:00

Update utils_test.go

This commit is contained in:
Dennis 2018-11-15 14:50:38 +08:00 committed by GitHub
parent 1a66ad56c6
commit 81346fe641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,3 +34,20 @@ func TestCamelString(t *testing.T) {
} }
} }
} }
func TestSnakeString(t *testing.T) {
camel := []string{"PicUrl", "HelloWorld", "HelloWorld", "HelLOWord", "PicUrl1", "XyXX"}
snake := []string{"pic_url", "hello_world", "hello_world", "hel_l_o_word", "pic_url1", "xy_x_x"}
answer := make(map[string]string)
for i, v := range camel {
answer[v] = snake[i]
}
for _, v := range camel {
res := snakeString(v)
if res != answer[v] {
t.Error("Unit Test Fail:", v, res, answer[v])
}
}
}