File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ func TestExecTyped(t *testing.T) {
144144 c .Assert (err , qt .IsNil )
145145 c .Assert (len (logMessages ), qt .Equals , 2 )
146146 c .Assert (string (logMessages [0 ].Body ), qt .Equals , "first log message" )
147- c .Assert (logMessages [0 ].Header .Status , qt .Equals , uint16 (0 ))
147+ c .Assert (logMessages [0 ].Header .Status , qt .Equals , uint16 (150 ))
148148 c .Assert (logMessages [0 ].Header .Version , qt .Equals , uint16 (32 ))
149149 c .Assert (client .Close (), qt .IsNil )
150150 })
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ func (h *Header) Read(r io.Reader) error {
5050 h .ID = binary .BigEndian .Uint32 (buf [0 :4 ])
5151 h .Version = binary .BigEndian .Uint16 (buf [4 :6 ])
5252 h .Status = binary .BigEndian .Uint16 (buf [6 :8 ])
53- h .Size = binary .BigEndian .Uint32 (buf [6 :])
53+ h .Size = binary .BigEndian .Uint32 (buf [8 :])
5454 return nil
5555}
5656
@@ -60,7 +60,7 @@ func (h Header) Write(w io.Writer) error {
6060 binary .BigEndian .PutUint32 (buff [0 :4 ], h .ID )
6161 binary .BigEndian .PutUint16 (buff [4 :6 ], h .Version )
6262 binary .BigEndian .PutUint16 (buff [6 :8 ], h .Status )
63- binary .BigEndian .PutUint32 (buff [6 :], h .Size )
63+ binary .BigEndian .PutUint32 (buff [8 :], h .Size )
6464 _ , err := w .Write (buff )
6565 return err
6666}
Original file line number Diff line number Diff line change 1+ package execrpc
2+
3+ import (
4+ "bytes"
5+ "testing"
6+
7+ qt "github.com/frankban/quicktest"
8+ )
9+
10+ func TestMessage (t * testing.T ) {
11+ c := qt .New (t )
12+
13+ m1 := Message {
14+ Body : []byte ("hello" ),
15+ Header : Header {
16+ ID : 2 ,
17+ Version : 3 ,
18+ Status : 4 ,
19+ Size : 5 ,
20+ },
21+ }
22+
23+ var b bytes.Buffer
24+
25+ c .Assert (m1 .Header .Write (& b ), qt .IsNil )
26+ c .Assert (m1 .Write (& b ), qt .IsNil )
27+
28+ var m2 Message
29+ c .Assert (m2 .Header .Read (& b ), qt .IsNil )
30+ c .Assert (m2 .Read (& b ), qt .IsNil )
31+
32+ c .Assert (m2 , qt .DeepEquals , m1 )
33+
34+ }
You can’t perform that action at this time.
0 commit comments