Skip to content
This repository has been archived by the owner on Jun 5, 2021. It is now read-only.

Commit

Permalink
message: add GobDecode test
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Nov 1, 2020
1 parent a2af8aa commit ba5d9a7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1037,3 +1037,32 @@ func TestMessage_MarshalBinary(t *testing.T) {
t.Fatal(err)
}
}

func TestMessage_GobDecode(t *testing.T) {
m := MustBuild(
NewSoftware("software"),
&XORMappedAddress{
IP: net.IPv4(213, 1, 223, 5),
},
)
data, err := m.GobEncode()
if err != nil {
t.Fatal(err)
}

// Reset m.Raw to check retention.
for i := range m.Raw {
m.Raw[i] = 0
}
if err := m.GobDecode(data); err != nil {
t.Fatal(err)
}

// Reset data to check retention.
for i := range data {
data[i] = 0
}
if err := m.Decode(); err != nil {
t.Fatal(err)
}
}

0 comments on commit ba5d9a7

Please sign in to comment.