icns

Easily create .icns files (Mac Icons) with this Go library or the included CLI.
Log | Files | Refs | LICENSE

commit 4dc1c00d2b63e8fccaa4248b9706d0b79aae0b06
parent 608fd07fc64d417ba36ba11b8f8ca2bc085d14bd
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date:   Sun, 18 Feb 2018 00:19:21 +0100

[+] Added test case for icon image with weird size.

Diffstat:
Micns_test.go | 29++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/icns_test.go b/icns_test.go @@ -14,34 +14,37 @@ import ( ) // TestDecode relies on Encode being correct. +// We are testing that an ICNS with a series of icons will only yield the +// largest icon in the series. func TestDecode(t *testing.T) { t.Parallel() tests := []struct { - desc string - img image.Image - - wantErr bool + desc string + input image.Image + want image.Image }{ { - "valid rectangle icon", - rect(0, 0, 1024, 1024), - false, + "valid square icon, exact size", + rect(0, 0, 256, 256), + rect(0, 0, 256, 256), + }, + { + "non exact size", + rect(0, 0, 50, 50), + rect(0, 0, 32, 32), }, } for _, tt := range tests { t.Run(tt.desc, func(st *testing.T) { buf := bytes.NewBuffer(nil) - if err := Encode(buf, tt.img); err != nil { + if err := Encode(buf, tt.input); err != nil { st.Fatalf("unexpected error while encoding: %v", err) } img, err := Decode(buf) - if !tt.wantErr && err != nil { + if err != nil { st.Fatalf("unexpected error: %v", err) } - if tt.wantErr && err == nil { - st.Fatalf("wanted error, got nil") - } - if !imageCompare(img, tt.img) { + if tt.want != nil && !imageCompare(img, tt.want) { st.Fatalf("decoded image is incorrect") } })