TestOutMessageAppendString

geesefs-0-30-9
Aaron Jacobs 2016-12-19 12:31:08 +11:00
parent c1af0dbdee
commit 39f1f7c489
1 changed files with 27 additions and 1 deletions

View File

@ -119,7 +119,33 @@ func TestOutMessageAppend(t *testing.T) {
}
func TestOutMessageAppendString(t *testing.T) {
t.Fatal("TODO")
var om OutMessage
om.Reset()
// Append some payload.
const wantPayload = "tacoburrito"
om.AppendString(wantPayload[:4])
om.AppendString(wantPayload[4:])
// The result should be a zeroed header followed by the desired payload.
const wantLen = int(OutMessageInitialSize) + len(wantPayload)
if got, want := om.Len(), wantLen; got != want {
t.Errorf("om.Len() = %d, want %d", got, want)
}
b := om.Bytes()
if got, want := len(b), wantLen; got != want {
t.Fatalf("len(om.Bytes()) = %d, want %d", got, want)
}
want := append(
make([]byte, OutMessageInitialSize),
wantPayload...)
if !bytes.Equal(b, want) {
t.Error("messages differ")
}
}
func TestOutMessageShrinkTo(t *testing.T) {