From 2433c68452d5dc0fe713a0bb5b057b0308e124fc Mon Sep 17 00:00:00 2001 From: wangjian Date: Wed, 12 Oct 2022 10:16:59 +0800 Subject: [PATCH] fix test bug --- frame/data_frame_test.go | 14 +++++++------- frame/payload_frame_test.go | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frame/data_frame_test.go b/frame/data_frame_test.go index ba9019b..3ed1cda 100644 --- a/frame/data_frame_test.go +++ b/frame/data_frame_test.go @@ -11,15 +11,15 @@ func TestDataFrameEncode(t *testing.T) { d := NewDataFrame() d.SetCarriage(userDataTag, []byte("hpds")) - tidbuf := []byte(d.TransactionId()) + tidBuf := []byte(d.TransactionId()) result := []byte{ - 0x80 | byte(TagOfDataFrame), byte(len(tidbuf) + 4 + 8 + 2), - 0x80 | byte(TagOfMetaFrame), byte(len(tidbuf) + 2 + 2), - byte(TagOfTransactionId), byte(len(tidbuf))} - result = append(result, tidbuf...) + 0x80 | byte(TagOfDataFrame), byte(len(tidBuf) + 4 + 8 + 2), + 0x80 | byte(TagOfMetaFrame), byte(len(tidBuf) + 2 + 2), + byte(TagOfTransactionId), byte(len(tidBuf))} + result = append(result, tidBuf...) result = append(result, byte(TagOfSourceId), 0x0) 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()) } @@ -30,7 +30,7 @@ func TestDataFrameDecode(t *testing.T) { 0x80 | byte(TagOfMetaFrame), 0x06, byte(TagOfTransactionId), 0x04, 0x31, 0x32, 0x33, 0x34, 0x80 | byte(TagOfPayloadFrame), 0x06, - userDataTag, 0x04, 0x79, 0x6F, 0x6D, 0x6F} + userDataTag, 0x04, 0x68, 0x70, 0x64, 0x73} data, err := DecodeToDataFrame(buf) assert.NoError(t, err) assert.EqualValues(t, "1234", data.TransactionId()) diff --git a/frame/payload_frame_test.go b/frame/payload_frame_test.go index dc520a7..34b4bb7 100644 --- a/frame/payload_frame_test.go +++ b/frame/payload_frame_test.go @@ -8,13 +8,13 @@ import ( func TestPayloadFrameEncode(t *testing.T) { 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) { - 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) assert.NoError(t, err) 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) }