add tests for encoding data tracker fields

This commit is contained in:
2025-10-17 12:42:17 -05:00
parent 631537b473
commit 7dd6d45a08
7 changed files with 276 additions and 0 deletions
@@ -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)
}
}
}