photoprism/internal/thumb/sizes_test.go

67 lines
1.3 KiB
Go
Raw Normal View History

package thumb
import (
"testing"
"github.com/stretchr/testify/assert"
)
2023-07-20 20:06:27 +02:00
func TestMaxSize(t *testing.T) {
SizePrecached = 7680
SizeUncached = 1024
assert.Equal(t, MaxSize(), 7680)
SizePrecached = 2048
SizeUncached = 7680
}
func TestSize_ExceedsLimit(t *testing.T) {
SizePrecached = 1024
SizeUncached = 2048
fit4096 := Sizes[Fit4096]
assert.True(t, fit4096.ExceedsLimit())
fit2048 := Sizes[Fit2048]
assert.False(t, fit2048.ExceedsLimit())
tile500 := Sizes[Tile500]
assert.False(t, tile500.ExceedsLimit())
SizePrecached = 2048
SizeUncached = 7680
}
func TestSize_Uncached(t *testing.T) {
SizePrecached = 1024
SizeUncached = 2048
fit4096 := Sizes[Fit4096]
assert.True(t, fit4096.Uncached())
fit2048 := Sizes[Fit2048]
assert.True(t, fit2048.Uncached())
tile500 := Sizes[Tile500]
assert.False(t, tile500.Uncached())
SizePrecached = 2048
SizeUncached = 7680
}
2020-05-14 17:28:55 +02:00
func TestResampleFilter_Imaging(t *testing.T) {
t.Run("Blackman", func(t *testing.T) {
r := ResampleBlackman.Imaging()
assert.Equal(t, float64(3), r.Support)
})
t.Run("Cubic", func(t *testing.T) {
r := ResampleCubic.Imaging()
assert.Equal(t, float64(2), r.Support)
})
t.Run("Linear", func(t *testing.T) {
r := ResampleLinear.Imaging()
assert.Equal(t, float64(1), r.Support)
})
}