Commit 39f1f7c4 authored by Aaron Jacobs's avatar Aaron Jacobs

TestOutMessageAppendString

parent c1af0dbd
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment