Files
injoyai-tdx/protocol/frame_test.go
2024-10-13 23:23:34 +08:00

26 lines
421 B
Go

package protocol
import (
"encoding/hex"
"testing"
)
func TestFrame_Bytes(t *testing.T) {
f := Frame{
MsgID: 1,
Control: 1,
Type: Connect,
Data: []byte{0x01},
}
hex := f.Bytes().HEX()
t.Log(hex)
if hex != "0c0100000001030003000d0001" {
t.Error("编码错误")
}
}
func TestBytes(t *testing.T) {
t.Log(hex.EncodeToString(Bytes(uint32(1))))
t.Log(hex.EncodeToString(Bytes(uint16(0x0d00))))
}