test: add test case

This commit is contained in:
fatedier
2017-03-27 23:46:38 +08:00
parent 30aeaf968e
commit a0c83bdb78
7 changed files with 86 additions and 9 deletions

View File

@@ -17,9 +17,6 @@ package msg
import (
"bytes"
"encoding/binary"
"encoding/json"
"fmt"
"net"
"reflect"
"testing"

View File

@@ -0,0 +1,18 @@
package udp
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestUdpPacket(t *testing.T) {
assert := assert.New(t)
buf := []byte("hello world")
udpMsg := NewUdpPacket(buf, nil, nil)
newBuf, err := GetContent(udpMsg)
assert.NoError(err)
assert.EqualValues(buf, newBuf)
}