photoprism/internal/frame/angle_test.go

32 lines
634 B
Go
Raw Normal View History

package frame
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRandomAngle(t *testing.T) {
t.Run("Valid", func(t *testing.T) {
for i := 0; i < 50; i++ {
e := float64(i)
a := RandomAngle(e)
t.Logf("%f => %f", e, a)
assert.LessOrEqual(t, a, e)
assert.GreaterOrEqual(t, a, -1*e)
}
})
2023-09-12 14:04:52 +02:00
t.Run("MaxTooLow", func(t *testing.T) {
2023-09-11 17:09:54 +02:00
e := float64(-35)
a := RandomAngle(e)
assert.GreaterOrEqual(t, a, e)
assert.LessOrEqual(t, a, -1*e)
})
2023-09-12 14:04:52 +02:00
t.Run("MaxTooHigh", func(t *testing.T) {
2023-09-11 17:09:54 +02:00
e := float64(200)
a := RandomAngle(e)
assert.LessOrEqual(t, a, e)
assert.GreaterOrEqual(t, a, -1*e)
})
}