1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-31 05:04:23 +03:00

Improves performance

This commit is contained in:
Eelco Cramer
2020-10-09 15:06:47 +02:00
parent 97bbed8a92
commit 39571ccc56
2 changed files with 30 additions and 16 deletions

View File

@ -2,6 +2,7 @@ package proto_test
import (
"bytes"
"io"
"testing"
"github.com/go-redis/redis/v8/internal/proto"
@ -29,14 +30,16 @@ func BenchmarkReader_ParseReply_Slice(b *testing.B) {
func TestReader_ReadLine(t *testing.T) {
original := bytes.Repeat([]byte("a"), 8192)
original[len(original)-2] = '\r'
original[len(original)-1] = '\n'
r := proto.NewReader(bytes.NewReader(original))
read, err := r.ReadLine()
if err != nil {
if err != nil && err != io.EOF {
t.Errorf("Should be able to read the full buffer: %v", err)
}
if bytes.Compare(read, original) != 0 {
t.Errorf("Values must be equal: %q", read)
if bytes.Compare(read, original[:len(original)-2]) != 0 {
t.Errorf("Values must be equal: %d expected %d", len(read), len(original[:len(original)-2]))
}
}