Add test for strings functions
This commit is contained in:
parent
429f226c5c
commit
f7063e7643
1 changed files with 48 additions and 0 deletions
48
internal/util/strings_test.go
Normal file
48
internal/util/strings_test.go
Normal 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"))
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue