github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/codegen/cgstrings/cgstrings_test.go (about) 1 package cgstrings 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestCamel(t *testing.T) { 11 t.Parallel() 12 assert := assert.New(t) 13 14 assert.Equal("", Camel("")) 15 assert.Equal("plugh", Camel("plugh")) 16 assert.Equal("waldoThudFred", Camel("WaldoThudFred")) 17 assert.Equal("graultBaz", Camel("Grault-Baz")) 18 assert.Equal("graultBaz", Camel("grault-baz")) 19 assert.Equal("graultBaz", Camel("graultBaz")) 20 assert.Equal("grault_Baz", Camel("Grault_Baz")) 21 assert.Equal("graultBaz", Camel("Grault-baz")) 22 } 23 24 func TestUnhyphenate(t *testing.T) { 25 t.Parallel() 26 testcases := []struct { 27 input, expected string 28 }{ 29 {"", ""}, 30 {"waldo", "waldo"}, 31 {"waldo-thud-fred", "waldoThudFred"}, 32 {"waldo-Thud-Fred", "waldoThudFred"}, 33 {"waldo-Thud-Fred-", "waldoThudFred"}, 34 {"-waldo-Thud-Fred", "WaldoThudFred"}, 35 {"waldoThudFred", "waldoThudFred"}, 36 {"WaldoThudFred", "WaldoThudFred"}, 37 } 38 for _, tc := range testcases { 39 tc := tc 40 t.Run(fmt.Sprintf("Subtest:%q", tc.input), func(t *testing.T) { 41 t.Parallel() 42 assert := assert.New(t) 43 assert.Equal(tc.expected, Unhyphenate(tc.input)) 44 }) 45 } 46 }