Commit c1af0dbd authored by Aaron Jacobs's avatar Aaron Jacobs

TestOutMessageAppend

parent e7b9860f
package buffer package buffer
import ( import (
"bytes"
"crypto/rand" "crypto/rand"
"fmt" "fmt"
"io" "io"
...@@ -87,7 +88,34 @@ func TestMemclr(t *testing.T) { ...@@ -87,7 +88,34 @@ func TestMemclr(t *testing.T) {
} }
func TestOutMessageAppend(t *testing.T) { func TestOutMessageAppend(t *testing.T) {
t.Fatal("TODO") var om OutMessage
om.Reset()
// Append some payload.
const wantPayloadStr = "tacoburrito"
wantPayload := []byte(wantPayloadStr)
om.Append(wantPayload[:4])
om.Append(wantPayload[4:])
// The result should be a zeroed header followed by the desired payload.
const wantLen = int(OutMessageInitialSize) + len(wantPayloadStr)
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 TestOutMessageAppendString(t *testing.T) { func TestOutMessageAppendString(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