mirror of
https://github.com/jwetzell/psn-go.git
synced 2026-08-18 05:34:12 +00:00
37 lines
812 B
Go
37 lines
812 B
Go
package encoders
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/jwetzell/psn-go/internal/chunks"
|
|
)
|
|
|
|
func TestDataTrackerTimestampChunkEncoding(t *testing.T) {
|
|
testCases := []struct {
|
|
description string
|
|
expected []byte
|
|
data chunks.DataTrackerTimestampChunkData
|
|
}{
|
|
{
|
|
description: "basic timestamp",
|
|
expected: []byte{
|
|
6, 0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
|
|
},
|
|
data: chunks.DataTrackerTimestampChunkData{
|
|
Timestamp: 1234567890,
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, testCase := range testCases {
|
|
t.Run(testCase.description, func(t *testing.T) {
|
|
actual := EncodeDataTrackerTimestampChunk(testCase.data.Timestamp)
|
|
|
|
if !reflect.DeepEqual(actual, testCase.expected) {
|
|
t.Errorf("failed to encode chunk properly, expected: %v, actual: %v\n", testCase.expected, actual)
|
|
}
|
|
})
|
|
}
|
|
}
|