photoprism/pkg/clean/header_test.go

40 lines
1,014 B
Go
Raw Normal View History

package clean
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestHeader(t *testing.T) {
t.Run("Ok", func(t *testing.T) {
expected := "https://docs.photoprism.app/getting-started/config-options/#file-converters"
result := Header(expected)
assert.Equal(t, expected, result)
})
t.Run("Tabs", func(t *testing.T) {
result := Header("https://..docs.photoprism.app/gettin\\g-started/config-options/\tfile-converters")
assert.Equal(t, "https://..docs.photoprism.app/gettin\\g-started/config-options/file-converters", result)
})
t.Run("Emoji", func(t *testing.T) {
result := Header("Hello 👍")
assert.Equal(t, "Hello ", result)
})
2024-01-17 14:55:20 +01:00
t.Run("Empty", func(t *testing.T) {
result := Header("")
assert.Equal(t, "", result)
})
}
func BenchmarkHeader(b *testing.B) {
for n := 0; n < b.N; n++ {
Header("https://..docs.photoprism.app/gettin\\g-started/config-options/\tfile-converters")
}
}
func BenchmarkHeaderEmpty(b *testing.B) {
for n := 0; n < b.N; n++ {
Header("")
}
}