Add test for strings functions

This commit is contained in:
Theresa Gresch 2019-07-17 13:26:20 +02:00
parent 429f226c5c
commit f7063e7643

View file

@ -0,0 +1,48 @@
package util
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestIsSeparator(t *testing.T) {
t.Run("rune A", func(t *testing.T) {
assert.Equal(t, false, isSeparator('A'))
})
t.Run("rune 9", func(t *testing.T) {
assert.Equal(t, false, isSeparator('9'))
})
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('\''))
})
}
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"))
})
}
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"))
})
}