X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/8fc43f8e53a60144f49b92a0c28b0c939a69d1c9..9360423f0aae6d7ce63cc9a4b20c031a58e06820:/hotline/file_name_with_info_test.go diff --git a/hotline/file_name_with_info_test.go b/hotline/file_name_with_info_test.go index 1637a64..5095acf 100644 --- a/hotline/file_name_with_info_test.go +++ b/hotline/file_name_with_info_test.go @@ -2,13 +2,13 @@ package hotline import ( "github.com/stretchr/testify/assert" - "reflect" + "io" "testing" ) func TestFileNameWithInfo_MarshalBinary(t *testing.T) { type fields struct { - fileNameWithInfoHeader fileNameWithInfoHeader + fileNameWithInfoHeader FileNameWithInfoHeader name []byte } tests := []struct { @@ -20,7 +20,7 @@ func TestFileNameWithInfo_MarshalBinary(t *testing.T) { { name: "returns expected bytes", fields: fields{ - fileNameWithInfoHeader: fileNameWithInfoHeader{ + fileNameWithInfoHeader: FileNameWithInfoHeader{ Type: [4]byte{0x54, 0x45, 0x58, 0x54}, // TEXT Creator: [4]byte{0x54, 0x54, 0x58, 0x54}, // TTXT FileSize: [4]byte{0x00, 0x43, 0x16, 0xd3}, // File Size @@ -45,15 +45,15 @@ func TestFileNameWithInfo_MarshalBinary(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { f := &FileNameWithInfo{ - fileNameWithInfoHeader: tt.fields.fileNameWithInfoHeader, - name: tt.fields.name, + FileNameWithInfoHeader: tt.fields.fileNameWithInfoHeader, + Name: tt.fields.name, } - gotData, err := f.MarshalBinary() + gotData, err := io.ReadAll(f) if (err != nil) != tt.wantErr { t.Errorf("MarshalBinary() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(gotData, tt.wantData) { + if !assert.Equal(t, tt.wantData, gotData) { t.Errorf("MarshalBinary() gotData = %v, want %v", gotData, tt.wantData) } }) @@ -62,7 +62,7 @@ func TestFileNameWithInfo_MarshalBinary(t *testing.T) { func TestFileNameWithInfo_UnmarshalBinary(t *testing.T) { type fields struct { - fileNameWithInfoHeader fileNameWithInfoHeader + fileNameWithInfoHeader FileNameWithInfoHeader name []byte } type args struct { @@ -89,7 +89,7 @@ func TestFileNameWithInfo_UnmarshalBinary(t *testing.T) { }, }, want: &FileNameWithInfo{ - fileNameWithInfoHeader: fileNameWithInfoHeader{ + FileNameWithInfoHeader: FileNameWithInfoHeader{ Type: [4]byte{0x54, 0x45, 0x58, 0x54}, // TEXT Creator: [4]byte{0x54, 0x54, 0x58, 0x54}, // TTXT FileSize: [4]byte{0x00, 0x43, 0x16, 0xd3}, // File Size @@ -97,7 +97,7 @@ func TestFileNameWithInfo_UnmarshalBinary(t *testing.T) { NameScript: [2]byte{0, 0}, NameSize: [2]byte{0x00, 0x0e}, }, - name: []byte("Audion.app.zip"), + Name: []byte("Audion.app.zip"), }, wantErr: false, }, @@ -105,10 +105,10 @@ func TestFileNameWithInfo_UnmarshalBinary(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { f := &FileNameWithInfo{ - fileNameWithInfoHeader: tt.fields.fileNameWithInfoHeader, - name: tt.fields.name, + FileNameWithInfoHeader: tt.fields.fileNameWithInfoHeader, + Name: tt.fields.name, } - if err := f.UnmarshalBinary(tt.args.data); (err != nil) != tt.wantErr { + if _, err := f.Write(tt.args.data); (err != nil) != tt.wantErr { t.Errorf("Write() error = %v, wantErr %v", err, tt.wantErr) } if !assert.Equal(t, tt.want, f) {