Skip to content

Commit ff20b0c

Browse files
committed
test: add pickFormat test for windows impl
1 parent 3ed6d39 commit ff20b0c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//go:build windows
2+
3+
package cmd
4+
5+
import "testing"
6+
7+
func TestPickFormat(t *testing.T) {
8+
tests := []struct {
9+
name string
10+
formats []uint32
11+
want uint32
12+
}{
13+
{
14+
name: "prefers CF_PNG over all others",
15+
formats: []uint32{cfUnicodeText, cfDIB, cfHdrop, cfPNG},
16+
want: cfPNG,
17+
},
18+
{
19+
name: "prefers CF_DIB over CF_HDROP and text",
20+
formats: []uint32{cfUnicodeText, cfHdrop, cfDIB},
21+
want: cfDIB,
22+
},
23+
{
24+
name: "prefers CF_HDROP over text",
25+
formats: []uint32{cfUnicodeText, cfHdrop},
26+
want: cfHdrop,
27+
},
28+
{
29+
name: "falls back to CF_UNICODETEXT",
30+
formats: []uint32{cfUnicodeText},
31+
want: cfUnicodeText,
32+
},
33+
{
34+
name: "returns 0 for unknown formats",
35+
formats: []uint32{42, 99},
36+
want: 0,
37+
},
38+
{
39+
name: "empty list returns 0",
40+
formats: []uint32{},
41+
want: 0,
42+
},
43+
}
44+
45+
for _, tt := range tests {
46+
t.Run(tt.name, func(t *testing.T) {
47+
got := pickFormat(tt.formats)
48+
if got != tt.want {
49+
t.Errorf("pickFormat(%v) = %d, want %d", tt.formats, got, tt.want)
50+
}
51+
})
52+
}
53+
}

0 commit comments

Comments
 (0)