strcase/snake_test.go

36 lines
917 B
Go
Raw Normal View History

2015-10-09 17:13:05 +08:00
package strcase
import (
"testing"
)
func TestToSnake(t *testing.T) {
cases := [][]string{
2017-11-29 09:02:53 +08:00
[]string{"testCase", "test_case"},
[]string{"TestCase", "test_case"},
[]string{"Test Case", "test_case"},
[]string{" Test Case", "test_case"},
[]string{"Test Case ", "test_case"},
[]string{" Test Case ", "test_case"},
[]string{"test", "test"},
[]string{"test_case", "test_case"},
[]string{"Test", "test"},
[]string{"", ""},
[]string{"ManyManyWords", "many_many_words"},
[]string{"manyManyWords", "many_many_words"},
[]string{"AnyKind of_string", "any_kind_of_string"},
[]string{"numbers2and55with000", "numbers_2_and_55_with_000"},
[]string{"JSONData", "json_data"},
[]string{"userID", "user_id"},
[]string{"AAAbbb", "aa_abbb"},
2015-10-09 17:13:05 +08:00
}
for _, i := range cases {
in := i[0]
out := i[1]
result := ToSnake(in)
if result != out {
t.Error("'" + result + "' != '" + out + "'")
}
}
}