aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/encoding/binary/varint_test.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2012-01-20 12:57:53 -0800
committerRobert Griesemer <gri@golang.org>2012-01-20 12:57:53 -0800
commit0796c1c3ec8b6555ff03d617f8fcbc43aa564063 (patch)
tree39f603e61563eeef544986848a4edc0f957f9620 /src/pkg/encoding/binary/varint_test.go
parent6923f6d12aad4fb196bff109f091b042a2d17f39 (diff)
downloadgo-0796c1c3ec8b6555ff03d617f8fcbc43aa564063.tar.xz
encoding/varint: deleted WriteXvarint
Fixes #2748. R=rsc, r, r CC=golang-dev https://golang.org/cl/5557072
Diffstat (limited to 'src/pkg/encoding/binary/varint_test.go')
-rw-r--r--src/pkg/encoding/binary/varint_test.go32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/pkg/encoding/binary/varint_test.go b/src/pkg/encoding/binary/varint_test.go
index dc550f22f4..9476bd5fb7 100644
--- a/src/pkg/encoding/binary/varint_test.go
+++ b/src/pkg/encoding/binary/varint_test.go
@@ -25,9 +25,9 @@ func TestConstants(t *testing.T) {
}
func testVarint(t *testing.T, x int64) {
- buf1 := make([]byte, MaxVarintLen64)
- n := PutVarint(buf1[:], x)
- y, m := Varint(buf1[0:n])
+ buf := make([]byte, MaxVarintLen64)
+ n := PutVarint(buf, x)
+ y, m := Varint(buf[0:n])
if x != y {
t.Errorf("Varint(%d): got %d", x, y)
}
@@ -35,15 +35,7 @@ func testVarint(t *testing.T, x int64) {
t.Errorf("Varint(%d): got n = %d; want %d", x, m, n)
}
- var buf2 bytes.Buffer
- err := WriteVarint(&buf2, x)
- if err != nil {
- t.Errorf("WriteVarint(%d): %s", x, err)
- }
- if n != buf2.Len() {
- t.Errorf("WriteVarint(%d): got n = %d; want %d", x, buf2.Len(), n)
- }
- y, err = ReadVarint(&buf2)
+ y, err := ReadVarint(bytes.NewBuffer(buf))
if err != nil {
t.Errorf("ReadVarint(%d): %s", x, err)
}
@@ -53,9 +45,9 @@ func testVarint(t *testing.T, x int64) {
}
func testUvarint(t *testing.T, x uint64) {
- buf1 := make([]byte, MaxVarintLen64)
- n := PutUvarint(buf1[:], x)
- y, m := Uvarint(buf1[0:n])
+ buf := make([]byte, MaxVarintLen64)
+ n := PutUvarint(buf, x)
+ y, m := Uvarint(buf[0:n])
if x != y {
t.Errorf("Uvarint(%d): got %d", x, y)
}
@@ -63,15 +55,7 @@ func testUvarint(t *testing.T, x uint64) {
t.Errorf("Uvarint(%d): got n = %d; want %d", x, m, n)
}
- var buf2 bytes.Buffer
- err := WriteUvarint(&buf2, x)
- if err != nil {
- t.Errorf("WriteUvarint(%d): %s", x, err)
- }
- if n != buf2.Len() {
- t.Errorf("WriteUvarint(%d): got n = %d; want %d", x, buf2.Len(), n)
- }
- y, err = ReadUvarint(&buf2)
+ y, err := ReadUvarint(bytes.NewBuffer(buf))
if err != nil {
t.Errorf("ReadUvarint(%d): %s", x, err)
}