diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2019-02-16 00:36:18 -0500 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2019-02-16 11:11:08 -0500 |
| commit | effecf8007507ee2e90e5462ff6ef7dbc8871d3f (patch) | |
| tree | 8f5a2ea446e1c3daaa05e4acbac62756786ba33a /strings/strings_test.go | |
| parent | ffb7d693baa8f95df96484e9b1a9c6267be066cf (diff) | |
New functions strings.CamelCase and strings.SnakeCase
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'strings/strings_test.go')
| -rw-r--r-- | strings/strings_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
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)) + } +} |
