2020-05-31 15:17:01 +02:00
|
|
|
package txt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
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) {
|
|
|
|
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('\''))
|
|
|
|
})
|
|
|
|
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"))
|
|
|
|
})
|
|
|
|
t.Run("empty string", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "", UcFirst(""))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTitle(t *testing.T) {
|
2020-06-01 11:23:15 +02:00
|
|
|
t.Run("BrowseYourLife", func(t *testing.T) {
|
2020-06-01 13:22:19 +02:00
|
|
|
assert.Equal(t, "Browse Your Life in Pictures", Title("Browse your life in pictures"))
|
2020-05-31 15:17:01 +02:00
|
|
|
})
|
2020-06-01 11:23:15 +02:00
|
|
|
t.Run("PhotoLover", func(t *testing.T) {
|
2020-05-31 15:17:01 +02:00
|
|
|
assert.Equal(t, "Photo-Lover", Title("photo-lover"))
|
|
|
|
})
|
2020-06-01 11:23:15 +02:00
|
|
|
t.Run("NaomiWatts", func(t *testing.T) {
|
2020-06-01 13:22:19 +02:00
|
|
|
assert.Equal(t, "Naomi Watts / Ewan McGregor / The Impossible / TIFF", Title(" /Naomi watts / Ewan Mcgregor / the Impossible / TIFF "))
|
2020-06-01 11:23:15 +02:00
|
|
|
})
|
|
|
|
t.Run("Penguin", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "A Boulders Penguin Colony / Simon's Town / 2013", Title("A Boulders Penguin Colony /// Simon's Town / 2013 "))
|
|
|
|
})
|
|
|
|
t.Run("AirportBer", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "Around the Terminal / Airport BER", Title("Around the Terminal / Airport Ber"))
|
|
|
|
})
|
|
|
|
t.Run("KwaZulu-Natal", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "KwaZulu-Natal", Title("KwaZulu-Natal"))
|
|
|
|
})
|
|
|
|
t.Run("testAddLabel", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "TestAddLabel", Title("testAddLabel"))
|
|
|
|
})
|
2020-06-01 13:22:19 +02:00
|
|
|
t.Run("photoprism", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "PhotoPrism", Title("photoprism"))
|
|
|
|
})
|
|
|
|
t.Run("youtube", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "YouTube", Title("youtube"))
|
|
|
|
})
|
2020-06-01 13:31:49 +02:00
|
|
|
t.Run("interpunctio-1", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "This,,, Is !a ! a Very Strange Title....", Title("this,,, is !a ! a very strange title...."))
|
|
|
|
})
|
|
|
|
t.Run("interpunctio-2", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "This Is a Not So Strange Title!", Title("This is a not so strange title!"))
|
|
|
|
})
|
|
|
|
t.Run("horse", func(t *testing.T) {
|
|
|
|
assert.Equal(t, "A Horse Is Not a Cow :-)", Title("a horse is not a cow :-)"))
|
|
|
|
})
|
2020-05-31 15:17:01 +02:00
|
|
|
}
|