1
0
mirror of https://github.com/golang/go synced 2024-11-20 07:04:40 -07:00

delete io.ByteBuffer

R=r
DELTA=25  (0 added, 15 deleted, 10 changed)
OCL=30892
CL=30892
This commit is contained in:
Russ Cox 2009-06-29 20:53:05 -07:00
parent 5d5904bb4d
commit 832e72beff
2 changed files with 10 additions and 11 deletions

View File

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package io package bytes
import ( import (
"io"; "bytes";
"rand"; "rand";
"testing"; "testing";
) )
@ -24,7 +24,7 @@ func init() {
// Verify that contents of buf match the string s. // Verify that contents of buf match the string s.
func check(t *testing.T, testname string, buf *ByteBuffer, s string) { func check(t *testing.T, testname string, buf *Buffer, s string) {
if buf.Len() != len(buf.Data()) { if buf.Len() != len(buf.Data()) {
t.Errorf("%s: buf.Len() == %d, len(buf.Data()) == %d\n", testname, buf.Len(), len(buf.Data())) t.Errorf("%s: buf.Len() == %d, len(buf.Data()) == %d\n", testname, buf.Len(), len(buf.Data()))
} }
@ -42,7 +42,7 @@ func check(t *testing.T, testname string, buf *ByteBuffer, s string) {
// Fill buf through n writes of fub. // Fill buf through n writes of fub.
// The initial contents of buf corresponds to the string s; // The initial contents of buf corresponds to the string s;
// the result is the final contents of buf returned as a string. // the result is the final contents of buf returned as a string.
func fill(t *testing.T, testname string, buf *ByteBuffer, s string, n int, fub []byte) string { func fill(t *testing.T, testname string, buf *Buffer, s string, n int, fub []byte) string {
check(t, testname + " (fill 1)", buf, s); check(t, testname + " (fill 1)", buf, s);
for ; n > 0; n-- { for ; n > 0; n-- {
m, err := buf.Write(fub); m, err := buf.Write(fub);
@ -61,7 +61,7 @@ func fill(t *testing.T, testname string, buf *ByteBuffer, s string, n int, fub [
// Empty buf through repeated reads into fub. // Empty buf through repeated reads into fub.
// The initial contents of buf corresponds to the string s. // The initial contents of buf corresponds to the string s.
func empty(t *testing.T, testname string, buf *ByteBuffer, s string, fub []byte) { func empty(t *testing.T, testname string, buf *Buffer, s string, fub []byte) {
check(t, testname + " (empty 1)", buf, s); check(t, testname + " (empty 1)", buf, s);
for { for {
@ -81,7 +81,7 @@ func empty(t *testing.T, testname string, buf *ByteBuffer, s string, fub []byte)
func TestBasicOperations(t *testing.T) { func TestBasicOperations(t *testing.T) {
var buf ByteBuffer; var buf Buffer;
for i := 0; i < 5; i++ { for i := 0; i < 5; i++ {
check(t, "TestBasicOperations (1)", &buf, ""); check(t, "TestBasicOperations (1)", &buf, "");
@ -136,7 +136,7 @@ func TestBasicOperations(t *testing.T) {
func TestLargeWrites(t *testing.T) { func TestLargeWrites(t *testing.T) {
var buf ByteBuffer; var buf Buffer;
for i := 3; i < 30; i += 3 { for i := 3; i < 30; i += 3 {
s := fill(t, "TestLargeWrites (1)", &buf, "", 5, data); s := fill(t, "TestLargeWrites (1)", &buf, "", 5, data);
empty(t, "TestLargeWrites (2)", &buf, s, make([]byte, len(data)/i)); empty(t, "TestLargeWrites (2)", &buf, s, make([]byte, len(data)/i));
@ -146,7 +146,7 @@ func TestLargeWrites(t *testing.T) {
func TestLargeReads(t *testing.T) { func TestLargeReads(t *testing.T) {
var buf ByteBuffer; var buf Buffer;
for i := 3; i < 30; i += 3 { for i := 3; i < 30; i += 3 {
s := fill(t, "TestLargeReads (1)", &buf, "", 5, data[0 : len(data)/i]); s := fill(t, "TestLargeReads (1)", &buf, "", 5, data[0 : len(data)/i]);
empty(t, "TestLargeReads (2)", &buf, s, make([]byte, len(data))); empty(t, "TestLargeReads (2)", &buf, s, make([]byte, len(data)));
@ -156,7 +156,7 @@ func TestLargeReads(t *testing.T) {
func TestMixedReadsAndWrites(t *testing.T) { func TestMixedReadsAndWrites(t *testing.T) {
var buf ByteBuffer; var buf Buffer;
s := ""; s := "";
for i := 0; i < 50; i++ { for i := 0; i < 50; i++ {
wlen := rand.Intn(len(data)); wlen := rand.Intn(len(data));

View File

@ -35,7 +35,6 @@ coverage: packages
O1=\ O1=\
io.$O\ io.$O\
pipe.$O\ pipe.$O\
xxx.$O\
O2=\ O2=\
utils.$O\ utils.$O\
@ -45,7 +44,7 @@ phases: a1 a2
_obj$D/io.a: phases _obj$D/io.a: phases
a1: $(O1) a1: $(O1)
$(AR) grc _obj$D/io.a io.$O pipe.$O xxx.$O $(AR) grc _obj$D/io.a io.$O pipe.$O
rm -f $(O1) rm -f $(O1)
a2: $(O2) a2: $(O2)