Fix header in protocol spec (fixes #360)

This commit is contained in:
Jakob Borg
2014-06-11 16:27:39 +02:00
parent 3dbaa76dcb
commit e63596681d
2 changed files with 37 additions and 11 deletions

View File

@@ -25,6 +25,31 @@ func TestHeaderFunctions(t *testing.T) {
}
}
func TestHeaderLayout(t *testing.T) {
var e, a uint32
// Version are the first four bits
e = 0xf0000000
a = encodeHeader(header{0xf, 0, 0})
if a != e {
t.Errorf("Header layout incorrect; %08x != %08x", a, e)
}
// Message ID are the following 12 bits
e = 0x0fff0000
a = encodeHeader(header{0, 0xfff, 0})
if a != e {
t.Errorf("Header layout incorrect; %08x != %08x", a, e)
}
// Type are the last 8 bits before reserved
e = 0x0000ff00
a = encodeHeader(header{0, 0, 0xff})
if a != e {
t.Errorf("Header layout incorrect; %08x != %08x", a, e)
}
}
func TestPing(t *testing.T) {
ar, aw := io.Pipe()
br, bw := io.Pipe()