diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-07-30 17:46:04 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-07-31 22:16:46 +0200 |
commit | 8fb594bfb090c017d4e5cbb2905780221e202c41 (patch) | |
tree | f622b6aa90757827ea8f07cc27be692fb37b76c4 /helpers/general_test.go | |
parent | 9b4170ce768717adfbe9d97c46e38ceaec2ce994 (diff) |
Make the title case style guide configurable
This works for the `title` func and the other places where Hugo makes title case.
* AP style (new default)
* Chicago style
* Go style (what we have today)
Fixes #989
Diffstat (limited to 'helpers/general_test.go')
-rw-r--r-- | helpers/general_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/helpers/general_test.go b/helpers/general_test.go index 4d82bc0cf..561f59522 100644 --- a/helpers/general_test.go +++ b/helpers/general_test.go @@ -19,6 +19,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestGuessType(t *testing.T) { @@ -173,6 +174,20 @@ func TestReaderContains(t *testing.T) { assert.False(t, ReaderContains(nil, nil)) } +func TestGetTitleFunc(t *testing.T) { + title := "somewhere over the rainbow" + assert := require.New(t) + + assert.Equal("Somewhere Over The Rainbow", GetTitleFunc("go")(title)) + assert.Equal("Somewhere over the Rainbow", GetTitleFunc("chicago")(title), "Chicago style") + assert.Equal("Somewhere over the Rainbow", GetTitleFunc("Chicago")(title), "Chicago style") + assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("ap")(title), "AP style") + assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("ap")(title), "AP style") + assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("")(title), "AP style") + assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("unknown")(title), "AP style") + +} + func BenchmarkReaderContains(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { |