return n, nil
}
+// ReadByte reads and returns the next byte from the buffer.
+// If no byte is available, it returns error ErrEOF.
+func (b *ByteBuffer) ReadByte() (c byte, err os.Error) {
+ if b.off >= len(b.buf) {
+ return 0, ErrEOF;
+ }
+ c = b.buf[b.off];
+ b.off++;
+ return c, nil;
+}
+
// NewByteBufferFromArray creates and initializes a new ByteBuffer
// with buf as its initial contents.
func NewByteBufferFromArray(buf []byte) *ByteBuffer {
empty(t, "TestBasicOperations (9)", &buf, string(data[0 : 20]), make([]byte, 5));
empty(t, "TestBasicOperations (10)", &buf, "", make([]byte, 100));
+
+ buf.WriteByte(data[1]);
+ c, err := buf.ReadByte();
+ if err != nil {
+ t.Errorf("ReadByte unexpected eof\n");
+ }
+ if c != data[1] {
+ t.Errorf("ReadByte wrong value c=%v\n", c);
+ }
+ c, err = buf.ReadByte();
+ if err == nil {
+ t.Errorf("ReadByte unexpected not eof\n");
+ }
}
}