4 "github.com/stretchr/testify/assert"
8 func TestFileNameWithInfo_Read(t *testing.T) {
24 want *FileNameWithInfo
29 name: "reads bytes into struct",
33 0x54, 0x45, 0x58, 0x54, // TEXT
34 0x54, 0x54, 0x58, 0x54, // TTXT
35 0x00, 0x43, 0x16, 0xd3, // File Size
36 0x00, 0x00, 0x00, 0x00, // RSVD
37 0x00, 0x00, // NameScript
38 0x00, 0x0e, // Name Size
39 0x41, 0x75, 0x64, 0x69, 0x6f, 0x6e, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x7a, 0x69, 0x70,
42 want: &FileNameWithInfo{
44 Creator: []byte("TTXT"),
45 FileSize: []byte{0x00, 0x43, 0x16, 0xd3},
46 RSVD: []byte{0, 0, 0, 0},
47 NameScript: []byte{0, 0},
48 NameSize: []byte{0x00, 0x0e},
49 Name: []byte("Audion.app.zip"),
55 for _, tt := range tests {
56 t.Run(tt.name, func(t *testing.T) {
57 f := &FileNameWithInfo{
59 Creator: tt.fields.Creator,
60 FileSize: tt.fields.FileSize,
61 NameScript: tt.fields.NameScript,
62 NameSize: tt.fields.NameSize,
65 gotN, err := f.Read(tt.args.p)
66 if (err != nil) != tt.wantErr {
67 t.Errorf("Read() error = %v, wantErr %v", err, tt.wantErr)
71 t.Errorf("Read() gotN = %v, want %v", gotN, tt.wantN)
73 if !assert.Equal(t, tt.want, f) {
74 t.Errorf("Read() got = %v, want %v", f, tt.want)