}
// String returns the contents of the unread portion of the buffer
-// as a string.
+// as a string. If the Buffer is a nil pointer, it returns "<nil>".
func (b *Buffer) String() string {
+ if b == nil {
+ // Special case, useful in debugging.
+ return "<nil>"
+ }
return string(b.buf[b.off : len(b.buf)]);
}
}
empty(t, "TestMixedReadsAndWrites (2)", &buf, s, make([]byte, buf.Len()));
}
+
+
+func TestNil(t *testing.T) {
+ var b *Buffer;
+ if b.String() != "<nil>" {
+ t.Error("expcted <nil>; got %q", b.String());
+ }
+}