add different column name parse strategy

This commit is contained in:
nlimpid
2018-11-20 22:47:56 +08:00
parent e22a5143bc
commit 6b0155c4fb
5 changed files with 63 additions and 5 deletions

View File

@@ -51,3 +51,20 @@ func TestSnakeString(t *testing.T) {
}
}
}
func TestSnakeStringWithAcronym(t *testing.T) {
camel := []string{"ID", "PicURL", "HelloWorld", "HelloWorld", "HelLOWord", "PicUrl1", "XyXX"}
snake := []string{"id", "pic_url", "hello_world", "hello_world", "hel_lo_word", "pic_url1", "xy_xx"}
answer := make(map[string]string)
for i, v := range camel {
answer[v] = snake[i]
}
for _, v := range camel {
res := snakeStringWithAcronym(v)
if res != answer[v] {
t.Error("Unit Test Fail:", v, res, answer[v])
}
}
}