aboutsummaryrefslogtreecommitdiff
path: root/hotline/file_name_with_info_test.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2021-07-31 21:05:43 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2021-07-31 21:05:43 -0700
commit43ecc0f42eaeface5f640479df7372bfb8021f23 (patch)
tree58d9d09998070551a5c93867a9342c2ac4d64243 /hotline/file_name_with_info_test.go
parent625b0580010c7fbf183c53e388ceba8356df76f4 (diff)
First pass at file browsing
Diffstat (limited to 'hotline/file_name_with_info_test.go')
-rw-r--r--hotline/file_name_with_info_test.go79
1 files changed, 79 insertions, 0 deletions
diff --git a/hotline/file_name_with_info_test.go b/hotline/file_name_with_info_test.go
new file mode 100644
index 0000000..15ec0d3
--- /dev/null
+++ b/hotline/file_name_with_info_test.go
@@ -0,0 +1,79 @@
+package hotline
+
+import (
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestFileNameWithInfo_Read(t *testing.T) {
+ type fields struct {
+ Type []byte
+ Creator []byte
+ FileSize []byte
+ NameScript []byte
+ NameSize []byte
+ Name []byte
+ }
+ type args struct {
+ p []byte
+ }
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want *FileNameWithInfo
+ wantN int
+ wantErr bool
+ }{
+ {
+ name: "reads bytes into struct",
+ fields: fields{},
+ args: args{
+ p: []byte{
+ 0x54, 0x45, 0x58, 0x54, // TEXT
+ 0x54, 0x54, 0x58, 0x54, // TTXT
+ 0x00, 0x43, 0x16, 0xd3, // File Size
+ 0x00, 0x00, 0x00, 0x00, // RSVD
+ 0x00, 0x00, // NameScript
+ 0x00, 0x0e, // Name Size
+ 0x41, 0x75, 0x64, 0x69, 0x6f, 0x6e, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x7a, 0x69, 0x70,
+ },
+ },
+ want: &FileNameWithInfo{
+ Type: []byte("TEXT"),
+ Creator: []byte("TTXT"),
+ FileSize: []byte{0x00, 0x43, 0x16, 0xd3},
+ RSVD: []byte{0, 0, 0, 0},
+ NameScript: []byte{0, 0},
+ NameSize: []byte{0x00, 0x0e},
+ Name: []byte("Audion.app.zip"),
+ },
+ wantN: 34,
+ wantErr: false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ f := &FileNameWithInfo{
+ Type: tt.fields.Type,
+ Creator: tt.fields.Creator,
+ FileSize: tt.fields.FileSize,
+ NameScript: tt.fields.NameScript,
+ NameSize: tt.fields.NameSize,
+ Name: tt.fields.Name,
+ }
+ gotN, err := f.Read(tt.args.p)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Read() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if gotN != tt.wantN {
+ t.Errorf("Read() gotN = %v, want %v", gotN, tt.wantN)
+ }
+ if !assert.Equal(t, tt.want, f) {
+ t.Errorf("Read() got = %v, want %v", f, tt.want)
+
+ }
+ })
+ }
+}