Files
psn-go/internal/decoders/info_tracker_name_chunk_test.go
T

48 lines
1.1 KiB
Go

package decoders
import (
"fmt"
"reflect"
"testing"
)
func TestGoodInfoTrackerNameChunkDecoding(t *testing.T) {
testCases := []struct {
description string
bytes []byte
expected InfoTrackerNameChunk
}{
{
description: "InfoTrackerNameChunk",
bytes: []byte{
0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
},
expected: InfoTrackerNameChunk{
Chunk: Chunk{
ChunkData: []byte{84, 114, 97, 99, 107, 101, 114, 32, 49},
Header: ChunkHeader{DataLen: 9, Id: 0, HasSubchunks: false},
},
Data: InfoTrackerNameChunkData{
TrackerName: "Tracker 1",
},
},
},
}
for _, testCase := range testCases {
actual, err := DecodeInfoTrackerNameChunk(testCase.bytes)
if err != nil {
t.Errorf("Test '%s' failed to decode chunk properly", testCase.description)
fmt.Println(err)
}
if !reflect.DeepEqual(actual, testCase.expected) {
t.Errorf("Test '%s' failed to decode chunk properly", testCase.description)
fmt.Printf("expected: %+v\n", testCase.expected)
fmt.Printf("actual: %+v\n", actual)
}
}
}