/usr/share/gocode/src/github.com/mailru/easyjson/buffer/pool_test.go is in golang-github-mailru-easyjson-dev 0.0~git20161103.0.159cdb8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | package buffer
import (
"bytes"
"testing"
)
func TestAppendByte(t *testing.T) {
var b Buffer
var want []byte
for i := 0; i < 1000; i++ {
b.AppendByte(1)
b.AppendByte(2)
want = append(want, 1, 2)
}
got := b.BuildBytes()
if !bytes.Equal(got, want) {
t.Errorf("BuildBytes() = %v; want %v", got, want)
}
}
func TestAppendBytes(t *testing.T) {
var b Buffer
var want []byte
for i := 0; i < 1000; i++ {
b.AppendBytes([]byte{1, 2})
want = append(want, 1, 2)
}
got := b.BuildBytes()
if !bytes.Equal(got, want) {
t.Errorf("BuildBytes() = %v; want %v", got, want)
}
}
func TestAppendString(t *testing.T) {
var b Buffer
var want []byte
s := "test"
for i := 0; i < 1000; i++ {
b.AppendBytes([]byte(s))
want = append(want, s...)
}
got := b.BuildBytes()
if !bytes.Equal(got, want) {
t.Errorf("BuildBytes() = %v; want %v", got, want)
}
}
func TestDumpTo(t *testing.T) {
var b Buffer
var want []byte
s := "test"
for i := 0; i < 1000; i++ {
b.AppendBytes([]byte(s))
want = append(want, s...)
}
out := &bytes.Buffer{}
n, err := b.DumpTo(out)
if err != nil {
t.Errorf("DumpTo() error: %v", err)
}
got := out.Bytes()
if !bytes.Equal(got, want) {
t.Errorf("DumpTo(): got %v; want %v", got, want)
}
if n != len(want) {
t.Errorf("DumpTo() = %v; want %v", n, len(want))
}
}
|