2024-01-15 13:06:27 +01:00
|
|
|
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 👍")
|
2024-01-16 12:14:06 +01:00
|
|
|
assert.Equal(t, "Hello ", result)
|
2024-01-15 13:06:27 +01:00
|
|
|
})
|
2024-01-17 14:55:20 +01:00
|
|
|
t.Run("Empty", func(t *testing.T) {
|
|
|
|
result := Header("")
|
|
|
|
assert.Equal(t, "", result)
|
|
|
|
})
|
2024-01-15 13:06:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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("")
|
|
|
|
}
|
|
|
|
}
|