Skip to content

Commit

Permalink
Extend replay testing to include serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekuruu committed Oct 11, 2024
1 parent 14a4619 commit 803c896
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions common/replays_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func TestReplayParsing(t *testing.T) {
return
}

// Deserialize replay from file
stream := NewIOStream(replayData, binary.BigEndian)
replay, err := ReadFullReplay(stream)
if err != nil {
Expand All @@ -38,4 +39,29 @@ func TestReplayParsing(t *testing.T) {
t.Cleanup(func() {
file.Close()
})

// Re-serialize replay
stream = NewIOStream([]byte{}, binary.BigEndian)
replay.Serialize(stream)

if len(stream.Get()) == 0 {
t.Error("failed to serialize replay")
}

// Deserialize replay from serialized data
stream.Seek(0)
replaySerialized, err := ReadFullReplay(stream)

if err != nil {
t.Error(err)
return
}

if replaySerialized.Header == nil {
t.Error("failed to read replay header")
}

if len(replaySerialized.Frames) == 0 {
t.Error("failed to read replay frames")
}
}

0 comments on commit 803c896

Please sign in to comment.