@@ -36,13 +36,13 @@ func TestV2AddNode(t *testing.T) {
3636}
3737
3838func TestFromBytes (t * testing.T ) {
39- testFromBytes (t , []byte {0x03 , 0x01 , 0x02 }, & Packet {Tag : 3 , Length : 1 , valbuf : []byte {0x02 }})
40- testFromBytes (t , []byte {0x81 , 0x03 , 0x01 , 0x06 }, & Packet {Tag : 131 , Length : 1 , valbuf : []byte {0x06 }})
39+ testFromBytes (t , []byte {0x03 , 0x01 , 0x02 }, & Packet {idTag : 3 , Length : 1 , valbuf : []byte {0x02 }})
40+ testFromBytes (t , []byte {0x81 , 0x03 , 0x01 , 0x06 }, & Packet {idTag : 131 , Length : 1 , valbuf : []byte {0x06 }})
4141
4242 foo := make ([]byte , 129 )
4343 bar := []byte {0x81 , 0x03 , 0x81 , 0x01 }
4444 buf := append (bar , foo ... )
45- testFromBytes (t , buf , & Packet {Tag : 131 , Length : 129 , valbuf : foo })
45+ testFromBytes (t , buf , & Packet {idTag : 131 , Length : 129 , valbuf : foo })
4646}
4747
4848func TestReadTag (t * testing.T ) {
@@ -62,7 +62,7 @@ func TestReadLength(t *testing.T) {
6262
6363func testReadTag (t * testing.T , buffer []byte , position int , expectValue uint64 , expectedCursor int ) {
6464 var result uint64
65- cursor , err := readTag (buffer , position , & result )
65+ cursor , err := readPVarUInt64 (buffer , position , & result )
6666 if err != nil {
6767 t .Error (err )
6868 }
@@ -76,7 +76,7 @@ func testReadTag(t *testing.T, buffer []byte, position int, expectValue uint64,
7676
7777func testReadLength (t * testing.T , buffer []byte , position int , expectValue uint64 , expectedCursor int ) {
7878 var result uint64
79- cursor , err := readLength (buffer , position , & result )
79+ cursor , err := readPVarUInt64 (buffer , position , & result )
8080 if err != nil {
8181 t .Errorf (">>> Got err=%s" , err .Error ())
8282 }
@@ -89,12 +89,14 @@ func testReadLength(t *testing.T, buffer []byte, position int, expectValue uint6
8989}
9090
9191func testFromBytes (t * testing.T , buffer []byte , expected * Packet ) {
92+ expected .Encode ()
9293 res , err := FromBytes (buffer )
94+ // t.Logf("testFromBytes: res=%v, exptected=%v", res, expected)
9395 if err != nil {
9496 t .Error (err )
9597 } else {
96- if res .Tag != expected .Tag {
97- t .Errorf ("Tag expected=[% X], actual=[% X]" , expected .Tag , res .Tag )
98+ if res .GetTag () != expected .GetTag () {
99+ t .Errorf ("Tag expected=[% X], actual=[% X]" , expected .GetTag () , res .GetTag () )
98100 }
99101 if res .Length != expected .Length {
100102 t .Errorf ("Length expected=[% X], actual=[% X]" , expected .Length , res .Length )
0 commit comments