mirror of
https://github.com/jwetzell/psn-go.git
synced 2026-09-08 07:49:16 +00:00
add tests for encoding data tracker fields
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package encoders
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/psn-go/internal/decoders"
|
||||
)
|
||||
|
||||
func TestDataTrackerTimestampChunkEncoding(t *testing.T) {
|
||||
testCases := []struct {
|
||||
description string
|
||||
expected []byte
|
||||
data decoders.DataTrackerTimestampChunkData
|
||||
}{
|
||||
{
|
||||
description: "basic timestamp",
|
||||
expected: []byte{
|
||||
6, 0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
|
||||
},
|
||||
data: decoders.DataTrackerTimestampChunkData{
|
||||
Timestamp: 1234567890,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
actual := EncodeDataTrackerTimestampChunk(testCase.data.Timestamp)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user