mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
26 lines
421 B
Go
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))))
|
|
}
|