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