2018-08-22 20:46:02 +00:00
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package protogen
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestCamelCase(t *testing.T) {
|
|
|
|
tests := []struct {
|
2018-08-23 21:39:30 +00:00
|
|
|
in, want string
|
2018-08-22 20:46:02 +00:00
|
|
|
}{
|
|
|
|
{"one", "One"},
|
|
|
|
{"one_two", "OneTwo"},
|
|
|
|
{"_my_field_name_2", "XMyFieldName_2"},
|
|
|
|
{"Something_Capped", "Something_Capped"},
|
|
|
|
{"my_Name", "My_Name"},
|
|
|
|
{"OneTwo", "OneTwo"},
|
|
|
|
{"_", "X"},
|
|
|
|
{"_a_", "XA_"},
|
2018-10-09 20:24:04 +00:00
|
|
|
{"one.two", "OneTwo"},
|
|
|
|
{"one.Two", "One_Two"},
|
|
|
|
{"one_two.three_four", "OneTwoThreeFour"},
|
|
|
|
{"one_two.Three_four", "OneTwo_ThreeFour"},
|
2018-08-22 20:46:02 +00:00
|
|
|
{"_one._two", "XOne_XTwo"},
|
|
|
|
{"SCREAMING_SNAKE_CASE", "SCREAMING_SNAKE_CASE"},
|
|
|
|
{"double__underscore", "Double_Underscore"},
|
|
|
|
}
|
|
|
|
for _, tc := range tests {
|
|
|
|
if got := camelCase(tc.in); got != tc.want {
|
|
|
|
t.Errorf("CamelCase(%q) = %q, want %q", tc.in, got, tc.want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|