names_test.go 848 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2018 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package protogen
  5. import "testing"
  6. func TestCamelCase(t *testing.T) {
  7. tests := []struct {
  8. in string
  9. want GoIdent
  10. }{
  11. {"one", "One"},
  12. {"one_two", "OneTwo"},
  13. {"_my_field_name_2", "XMyFieldName_2"},
  14. {"Something_Capped", "Something_Capped"},
  15. {"my_Name", "My_Name"},
  16. {"OneTwo", "OneTwo"},
  17. {"_", "X"},
  18. {"_a_", "XA_"},
  19. {"one.two", "One_Two"},
  20. {"one_two.three_four", "OneTwo_ThreeFour"},
  21. {"_one._two", "XOne_XTwo"},
  22. {"SCREAMING_SNAKE_CASE", "SCREAMING_SNAKE_CASE"},
  23. {"double__underscore", "Double_Underscore"},
  24. }
  25. for _, tc := range tests {
  26. if got := camelCase(tc.in); got != tc.want {
  27. t.Errorf("CamelCase(%q) = %q, want %q", tc.in, got, tc.want)
  28. }
  29. }
  30. }