blob: e6162280c8717fe7f1cb7914014fbd7bfa56f10d [file] [log] [blame]
Colin Cross36f55aa2022-03-21 18:46:41 -07001// Copyright 2022 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package main
16
17import (
18 "bytes"
19 "encoding/binary"
20 "reflect"
21 "testing"
22)
23
24func Test_readNote(t *testing.T) {
25 note := []byte{
26 0x04, 0x00, 0x00, 0x00,
27 0x10, 0x00, 0x00, 0x00,
28 0x03, 0x00, 0x00, 0x00,
29 0x47, 0x4e, 0x55, 0x00,
30 0xca, 0xaf, 0x44, 0xd2, 0x82, 0x78, 0x68, 0xfe, 0xc0, 0x90, 0xa3, 0x43, 0x85, 0x36, 0x6c, 0xc7,
31 }
32
33 descs, err := readNote(bytes.NewBuffer(note), binary.LittleEndian)
34 if err != nil {
35 t.Fatalf("unexpected error in readNote: %s", err)
36 }
37
38 expectedDescs := map[string][]byte{
39 "GNU\x00": []byte{0xca, 0xaf, 0x44, 0xd2, 0x82, 0x78, 0x68, 0xfe, 0xc0, 0x90, 0xa3, 0x43, 0x85, 0x36, 0x6c, 0xc7},
40 }
41
42 if !reflect.DeepEqual(descs, expectedDescs) {
43 t.Errorf("incorrect return, want %#v got %#v", expectedDescs, descs)
44 }
45}