package gorm import "testing" func TestSnakeCaseToCamelCase(t *testing.T) { tests := []struct{ in, want string }{ {"", ""}, {"user", "user"}, {"User_Name", "userName"}, {"user_id", "userID"}, {"http_request", "httpRequest"}, } for _, tt := range tests { if got := SnakeCaseToCamelCase(tt.in); got != tt.want { t.Errorf("%q: got %q want %q", tt.in, got, tt.want) } } } func TestPascalCaseToSnakeCase(t *testing.T) { tests := []struct{ in, want string }{ {"", ""}, {"User", "user"}, {"UserName", "user_name"}, {"UserID", "user_id"}, {"HTTPRequest", "http_request"}, } for _, tt := range tests { if got := PascalCaseToSnakeCase(tt.in); got != tt.want { t.Errorf("%q: got %q want %q", tt.in, got, tt.want) } } } func TestSingularize(t *testing.T) { tests := []struct{ in, want string }{ {"", ""}, {"people", "person"}, {"People", "person"}, {"categories", "category"}, {"wolves", "wolf"}, {"boxes", "box"}, {"churches", "church"}, {"users", "user"}, {"class", "class"}, {"user", "user"}, } for _, tt := range tests { if got := Singularize(tt.in); got != tt.want { t.Errorf("%q: got %q want %q", tt.in, got, tt.want) } } } func TestPluralize(t *testing.T) { tests := []struct{ in, want string }{ {"", ""}, {"person", "people"}, {"category", "categories"}, {"box", "boxes"}, {"church", "churches"}, {"user", "users"}, {"day", "days"}, } for _, tt := range tests { if got := Pluralize(tt.in); got != tt.want { t.Errorf("%q: got %q want %q", tt.in, got, tt.want) } } } func TestIsVowel(t *testing.T) { for _, c := range []byte("aeiouAEIOU") { if !isVowel(c) { t.Errorf("%c should be vowel", c) } } for _, c := range []byte("bcxyzBZ1_") { if isVowel(c) { t.Errorf("%c should not be vowel", c) } } }