Debian Codegraph @

shiny/iconvg/upgrade_test.go

raw symbols SCIP
1 // Copyright 2021 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package iconvg
6
7 import (
8 "os"
9 "path/filepath"
10 "testing"
11 )
12
13 func TestUpgradeToFileFormatVersion1(t *testing.T) {
14 for _, tc := range testdataTestCases {
15 original, err := os.ReadFile(filepath.FromSlash(tc.filename) + ".ivg")
16 if err != nil {
17 t.Errorf("%s: ReadFile: %v", tc.filename, err)
18 continue
19 }
20
21 upgraded, err := UpgradeToFileFormatVersion1(original, nil)
22 if err != nil {
23 t.Errorf("%s: Upgrade: %v", tc.filename, err)
24 continue
25 }
26
27 // For most of the testdataTestCases, we just check (above) that
28 // calling UpgradeToFileFormatVersion1 returns a nil error. As a
29 // further basic consistency check, we hard-code the expected results
30 // for upgrading the "action-info.lores" icon.
31 //
32 // These 36 bytes (and its disassembly via the cmd/iconvg-disassemble
33 // tool) is also a file in the test/data directory of the
34 // github.com/google/iconvg repository (the repository that is
35 // generally responsible for "File Format Version 1").
36 if tc.filename == "testdata/action-info.lores" {
37 const want = "" +
38 "\x8A\x49\x56\x47\x03\x0B\x11\x51\x51\xB1\xB1\x35\x81\x59\x33\x59" +
39 "\x81\x81\xA9\x35\x85\x95\x34\x7D\x95\x7D\x7D\x35\x85\x75\x34\x7D" +
40 "\x75\x7D\x6D\x88"
41 if got := string(upgraded); got != want {
42 t.Errorf("%s: Upgrade: got:\n% 02x\nwant:\n% 02x", tc.filename, got, want)
43 continue
44 }
45 }
46 }
47 }