fix test bug
This commit is contained in:
parent
d4226d3b66
commit
2433c68452
|
@ -11,15 +11,15 @@ func TestDataFrameEncode(t *testing.T) {
|
||||||
d := NewDataFrame()
|
d := NewDataFrame()
|
||||||
d.SetCarriage(userDataTag, []byte("hpds"))
|
d.SetCarriage(userDataTag, []byte("hpds"))
|
||||||
|
|
||||||
tidbuf := []byte(d.TransactionId())
|
tidBuf := []byte(d.TransactionId())
|
||||||
result := []byte{
|
result := []byte{
|
||||||
0x80 | byte(TagOfDataFrame), byte(len(tidbuf) + 4 + 8 + 2),
|
0x80 | byte(TagOfDataFrame), byte(len(tidBuf) + 4 + 8 + 2),
|
||||||
0x80 | byte(TagOfMetaFrame), byte(len(tidbuf) + 2 + 2),
|
0x80 | byte(TagOfMetaFrame), byte(len(tidBuf) + 2 + 2),
|
||||||
byte(TagOfTransactionId), byte(len(tidbuf))}
|
byte(TagOfTransactionId), byte(len(tidBuf))}
|
||||||
result = append(result, tidbuf...)
|
result = append(result, tidBuf...)
|
||||||
result = append(result, byte(TagOfSourceId), 0x0)
|
result = append(result, byte(TagOfSourceId), 0x0)
|
||||||
result = append(result, 0x80|byte(TagOfPayloadFrame), 0x06,
|
result = append(result, 0x80|byte(TagOfPayloadFrame), 0x06,
|
||||||
userDataTag, 0x04, 0x79, 0x6F, 0x6D, 0x6F)
|
userDataTag, 0x04, 0x68, 0x70, 0x64, 0x73)
|
||||||
assert.Equal(t, result, d.Encode())
|
assert.Equal(t, result, d.Encode())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ func TestDataFrameDecode(t *testing.T) {
|
||||||
0x80 | byte(TagOfMetaFrame), 0x06,
|
0x80 | byte(TagOfMetaFrame), 0x06,
|
||||||
byte(TagOfTransactionId), 0x04, 0x31, 0x32, 0x33, 0x34,
|
byte(TagOfTransactionId), 0x04, 0x31, 0x32, 0x33, 0x34,
|
||||||
0x80 | byte(TagOfPayloadFrame), 0x06,
|
0x80 | byte(TagOfPayloadFrame), 0x06,
|
||||||
userDataTag, 0x04, 0x79, 0x6F, 0x6D, 0x6F}
|
userDataTag, 0x04, 0x68, 0x70, 0x64, 0x73}
|
||||||
data, err := DecodeToDataFrame(buf)
|
data, err := DecodeToDataFrame(buf)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, "1234", data.TransactionId())
|
assert.EqualValues(t, "1234", data.TransactionId())
|
||||||
|
|
|
@ -8,13 +8,13 @@ import (
|
||||||
|
|
||||||
func TestPayloadFrameEncode(t *testing.T) {
|
func TestPayloadFrameEncode(t *testing.T) {
|
||||||
f := NewPayloadFrame(0x13).SetCarriage([]byte("hpds"))
|
f := NewPayloadFrame(0x13).SetCarriage([]byte("hpds"))
|
||||||
assert.Equal(t, []byte{0x80 | byte(TagOfPayloadFrame), 0x06, 0x13, 0x04, 0x79, 0x6F, 0x6D, 0x6F}, f.Encode())
|
assert.Equal(t, []byte{0x80 | byte(TagOfPayloadFrame), 0x06, 0x13, 0x04, 0x68, 0x70, 0x64, 0x73}, f.Encode())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPayloadFrameDecode(t *testing.T) {
|
func TestPayloadFrameDecode(t *testing.T) {
|
||||||
buf := []byte{0x80 | byte(TagOfPayloadFrame), 0x06, 0x13, 0x04, 0x79, 0x6F, 0x6D, 0x6F}
|
buf := []byte{0x80 | byte(TagOfPayloadFrame), 0x06, 0x13, 0x04, 0x68, 0x70, 0x64, 0x73}
|
||||||
payload, err := DecodeToPayloadFrame(buf)
|
payload, err := DecodeToPayloadFrame(buf)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 0x13, payload.Tag)
|
assert.EqualValues(t, 0x13, payload.Tag)
|
||||||
assert.Equal(t, []byte{0x79, 0x6F, 0x6D, 0x6F}, payload.Carriage)
|
assert.Equal(t, []byte{0x68, 0x70, 0x64, 0x73}, payload.Carriage)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue