LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package bytes_test | 5 package bytes_test |
6 | 6 |
7 import ( | 7 import ( |
8 . "bytes" | 8 . "bytes" |
9 "os" | 9 "os" |
10 "rand" | 10 "rand" |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 }{ | 357 }{ |
358 {err: os.EOF}, | 358 {err: os.EOF}, |
359 {[]byte{}, 0, []byte{}, os.EOF}, | 359 {[]byte{}, 0, []byte{}, os.EOF}, |
360 {[]byte("a\x00"), 0, []byte("a\x00"), nil}, | 360 {[]byte("a\x00"), 0, []byte("a\x00"), nil}, |
361 {[]byte("hello\x01world"), 1, []byte("hello\x01"), nil}, | 361 {[]byte("hello\x01world"), 1, []byte("hello\x01"), nil}, |
362 {[]byte("foo\nbar"), 0, []byte("foo\nbar"), os.EOF}, | 362 {[]byte("foo\nbar"), 0, []byte("foo\nbar"), os.EOF}, |
363 {[]byte("alpha beta gamma"), ' ', []byte("alpha "), nil}, | 363 {[]byte("alpha beta gamma"), ' ', []byte("alpha "), nil}, |
364 } | 364 } |
365 | 365 |
366 func TestReadBytes(t *testing.T) { | 366 func TestReadBytes(t *testing.T) { |
367 » for i, test := range readBytesTests { | 367 » for _, test := range readBytesTests { |
368 buf := NewBuffer(test.buffer) | 368 buf := NewBuffer(test.buffer) |
369 bytes, err := buf.ReadBytes(test.delim) | 369 bytes, err := buf.ReadBytes(test.delim) |
370 if !Equal(bytes, test.expected) || err != test.err { | 370 if !Equal(bytes, test.expected) || err != test.err { |
371 » » » t.Errorf("%d expected %q, %v got %q, %v", i, test.expect
ed, test.err, bytes, err) | 371 » » » t.Errorf("expected %q, %v got %q, %v", test.expected, te
st.err, bytes, err) |
372 » » } | 372 » » } |
373 » } | 373 » } |
374 } | 374 } |
LEFT | RIGHT |