generated from bep/golibtemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The size indices were not adjusted when we changed to int16 recently, which made it overwrite the header status. Which shows the importance of good tests.
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package execrpc | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
qt "github.com/frankban/quicktest" | ||
) | ||
|
||
func TestMessage(t *testing.T) { | ||
c := qt.New(t) | ||
|
||
m1 := Message{ | ||
Body: []byte("hello"), | ||
Header: Header{ | ||
ID: 2, | ||
Version: 3, | ||
Status: 4, | ||
Size: 5, | ||
}, | ||
} | ||
|
||
var b bytes.Buffer | ||
|
||
c.Assert(m1.Header.Write(&b), qt.IsNil) | ||
c.Assert(m1.Write(&b), qt.IsNil) | ||
|
||
var m2 Message | ||
c.Assert(m2.Header.Read(&b), qt.IsNil) | ||
c.Assert(m2.Read(&b), qt.IsNil) | ||
|
||
c.Assert(m2, qt.DeepEquals, m1) | ||
|
||
} |