From 81346fe641133133830db98f690add9f0e44e01c Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 15 Nov 2018 14:50:38 +0800 Subject: [PATCH] Update utils_test.go --- orm/utils_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/orm/utils_test.go b/orm/utils_test.go index 8c7c5008..11e76687 100644 --- a/orm/utils_test.go +++ b/orm/utils_test.go @@ -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]) + } + } +}