2019-07-17 13:26:20 +02:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-12-11 14:10:20 +01:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2019-07-17 13:26:20 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestIsSeparator(t *testing.T) {
|
|
|
|
t.Run("rune A", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, isSeparator('A'))
|
|
|
|
})
|
2019-07-17 13:46:21 +02:00
|
|
|
t.Run("rune 99", func(t *testing.T) {
|
2019-07-17 15:34:34 +02:00
|
|
|
assert.Equal(t, false, isSeparator('9'))
|
2019-07-17 13:26:20 +02:00
|
|
|
})
|
|
|
|
t.Run("rune /", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, isSeparator('/'))
|
|
|
|
})
|
|
|
|
t.Run("rune \\", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, isSeparator('\\'))
|
|
|
|
})
|
|
|
|
t.Run("rune ♥ ", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, isSeparator('♥'))
|
|
|
|
})
|
|
|
|
t.Run("rune space", func(t *testing.T) {
|
|
|
|
assert.Equal(t, true, isSeparator(' '))
|
|
|
|
})
|
|
|
|
t.Run("rune '", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, isSeparator('\''))
|
|
|
|
})
|
2019-07-17 15:34:34 +02:00
|
|
|
t.Run("rune ý", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, isSeparator('ý'))
|
|
|
|
})
|
2019-07-17 13:26:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestUcFirst(t *testing.T) {
|
|
|
|
t.Run("photo-lover", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "Photo-lover", UcFirst("photo-lover"))
|
|
|
|
})
|
|
|
|
t.Run("cat", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "Cat", UcFirst("Cat"))
|
|
|
|
})
|
2019-07-17 13:46:21 +02:00
|
|
|
t.Run("empty string", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "", UcFirst(""))
|
|
|
|
})
|
2019-07-17 13:26:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestTitle(t *testing.T) {
|
|
|
|
t.Run("photo-lover", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "Browse Your Life In Pictures", Title("Browse your life in pictures"))
|
|
|
|
})
|
|
|
|
t.Run("cat", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "Photo-Lover", Title("photo-lover"))
|
|
|
|
})
|
|
|
|
}
|