Damien Neil | c7d07d9 | 2018-08-22 13:46:02 -0700 | [diff] [blame^] | 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 | |
| 5 | package protogen |
| 6 | |
| 7 | import "testing" |
| 8 | |
| 9 | func TestCamelCase(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | in string |
| 12 | want GoIdent |
| 13 | }{ |
| 14 | {"one", "One"}, |
| 15 | {"one_two", "OneTwo"}, |
| 16 | {"_my_field_name_2", "XMyFieldName_2"}, |
| 17 | {"Something_Capped", "Something_Capped"}, |
| 18 | {"my_Name", "My_Name"}, |
| 19 | {"OneTwo", "OneTwo"}, |
| 20 | {"_", "X"}, |
| 21 | {"_a_", "XA_"}, |
| 22 | {"one.two", "One_Two"}, |
| 23 | {"one_two.three_four", "OneTwo_ThreeFour"}, |
| 24 | {"_one._two", "XOne_XTwo"}, |
| 25 | {"SCREAMING_SNAKE_CASE", "SCREAMING_SNAKE_CASE"}, |
| 26 | {"double__underscore", "Double_Underscore"}, |
| 27 | } |
| 28 | for _, tc := range tests { |
| 29 | if got := camelCase(tc.in); got != tc.want { |
| 30 | t.Errorf("CamelCase(%q) = %q, want %q", tc.in, got, tc.want) |
| 31 | } |
| 32 | } |
| 33 | } |