-
Notifications
You must be signed in to change notification settings - Fork 51
/
packet_test.go
35 lines (31 loc) · 1.01 KB
/
packet_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package flatend
import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
"testing/quick"
)
func TestServiceRequestPacket(t *testing.T) {
var dst []byte
f := func(expected ServiceRequestPacket) bool {
actual, err := UnmarshalServiceRequestPacket(expected.AppendTo(dst[:0]))
return assert.NoError(t, err) && assert.EqualValues(t, expected, actual)
}
require.NoError(t, quick.Check(f, nil))
}
func TestServiceResponsePacket(t *testing.T) {
var dst []byte
f := func(expected ServiceResponsePacket) bool {
actual, err := UnmarshalServiceResponsePacket(expected.AppendTo(dst[:0]))
return assert.NoError(t, err) && assert.EqualValues(t, expected, actual)
}
require.NoError(t, quick.Check(f, nil))
}
func TestDataPacket(t *testing.T) {
var dst []byte
f := func(expected DataPacket) bool {
actual, err := UnmarshalDataPacket(expected.AppendTo(dst[:0]))
return assert.NoError(t, err) && assert.EqualValues(t, expected, actual)
}
require.NoError(t, quick.Check(f, nil))
}