...
1 package casing
2
3 import "testing"
4
5 func TestCamelIdentifier(t *testing.T) {
6 casingTests := []struct {
7 name string
8 input string
9 want string
10 }{
11 {
12 "regular snake case identifier",
13 "snake_case",
14 "SnakeCase",
15 },
16 {
17 "snake case identifier with digit",
18 "snake_case_0_enum",
19 "SnakeCase_0Enum",
20 },
21 {
22 "regular snake case identifier with package",
23 "pathenum.snake_case",
24 "pathenum.SnakeCase",
25 },
26 {
27 "snake case identifier with digit and package",
28 "pathenum.snake_case_0_enum",
29 "pathenum.SnakeCase_0Enum",
30 },
31 {
32 "snake case identifier with digit and multiple dots",
33 "path.pathenum.snake_case_0_enum",
34 "path.pathenum.SnakeCase_0Enum",
35 },
36 }
37
38 for _, ct := range casingTests {
39 t.Run(ct.name, func(t *testing.T) {
40 got := CamelIdentifier(ct.input)
41 if ct.want != got {
42 t.Errorf("want: %s, got: %s", ct.want, got)
43 }
44 })
45 }
46 }
47
View as plain text