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