From effecf8007507ee2e90e5462ff6ef7dbc8871d3f Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sat, 16 Feb 2019 00:36:18 -0500 Subject: New functions strings.CamelCase and strings.SnakeCase Signed-off-by: Dave Henderson --- strings/strings_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'strings/strings_test.go') diff --git a/strings/strings_test.go b/strings/strings_test.go index f2afb2f5..dfcee552 100644 --- a/strings/strings_test.go +++ b/strings/strings_test.go @@ -39,3 +39,18 @@ func TestSort(t *testing.T) { expected = []string{"18", "42", "45"} assert.EqualValues(t, expected, Sort(in)) } + +func TestCaseFuncs(t *testing.T) { + testdata := []struct{ in, s, k, c string }{ + {" Foo bar ", "Foo_bar", "Foo-bar", "FooBar"}, + {"foo bar", "foo_bar", "foo-bar", "fooBar"}, + {" baz\tqux ", "baz_qux", "baz-qux", "bazQux"}, + {"Hello, World!", "Hello_world", "Hello-world", "HelloWorld"}, + {"grüne | Straße", "grüne_straße", "grüne-straße", "grüneStraße"}, + } + for _, d := range testdata { + assert.Equal(t, d.s, SnakeCase(d.in)) + assert.Equal(t, d.k, KebabCase(d.in)) + assert.Equal(t, d.c, CamelCase(d.in)) + } +} -- cgit v1.2.3