photoprism/pkg/txt/strings_test.go

65 lines
1.6 KiB
Go
Raw Normal View History

package txt
2019-07-17 13:26:20 +02:00
import (
"testing"
"github.com/stretchr/testify/assert"
2019-07-17 13:26:20 +02:00
)
2019-12-17 17:03:56 +01:00
func TestContainsNumber(t *testing.T) {
t.Run("True", func(t *testing.T) {
assert.Equal(t, true, ContainsNumber("f3abcde"))
})
t.Run("False", func(t *testing.T) {
assert.Equal(t, false, ContainsNumber("abcd"))
})
}
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'))
})
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"))
})
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"))
})
}