mirror of
https://github.com/jwetzell/psn-go.git
synced 2026-08-19 06:04:09 +00:00
39 lines
835 B
Go
39 lines
835 B
Go
package encoders
|
|
|
|
import (
|
|
"fmt"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/jwetzell/psn-go/internal/decoders"
|
|
)
|
|
|
|
func TestInfoTrackerNameChunkEncoding(t *testing.T) {
|
|
testCases := []struct {
|
|
description string
|
|
expected []byte
|
|
chunk decoders.InfoTrackerNameChunkData
|
|
}{
|
|
{
|
|
description: "InfoTrackerNameChunk",
|
|
expected: []byte{
|
|
0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
|
|
},
|
|
chunk: decoders.InfoTrackerNameChunkData{
|
|
TrackerName: "Tracker 1",
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, testCase := range testCases {
|
|
|
|
actual := EncodeInfoTrackerNameChunk(testCase.chunk.TrackerName)
|
|
|
|
if !reflect.DeepEqual(actual, testCase.expected) {
|
|
t.Errorf("Test '%s' failed to encode chunk properly", testCase.description)
|
|
fmt.Printf("expected: %v\n", testCase.expected)
|
|
fmt.Printf("actual: %v\n", actual)
|
|
}
|
|
}
|
|
}
|