1package hdrcursor
2
3import (
4 "bytes"
5 "testing"
6)
7
8func TestCacheKeyGeometry(t *testing.T) {
9 px := []byte{10, 20, 30, 255, 40, 50, 60, 255, 70, 80, 90, 255, 100, 110, 120, 255}
10 for _, tc := range []struct {
11 name string
12 w, h, side int
13 }{{"dimensions", 1, 4, 4}, {"max-side", 2, 2, 1}} {
14 t.Run(tc.name, func(t *testing.T) {
15 var c Cache
16 c.Convert(px, 2, 2, 4, 203)
17 before := c.Key()
18 got := bytes.Clone(c.Convert(px, tc.w, tc.h, tc.side, 203))
19 if c.Key() == before {
20 t.Fatal("geometry missing from cache key")
21 }
22 var fresh Cache
23 want := fresh.Convert(px, tc.w, tc.h, tc.side, 203)
24 if !bytes.Equal(got, want) {
25 t.Fatalf("stale conversion: %v want %v", got, want)
26 }
27 })
28 }
29}