1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

View file

@ -0,0 +1,39 @@
package binaryio
import (
"bytes"
"testing"
)
func TestMinReader(t *testing.T) {
b := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
r := bytes.NewBuffer(b)
mr := MinReader(r, 10)
toRead := make([]byte, 5)
n, err := mr.Read(toRead)
if err != nil {
t.Error(err)
}
if n != 5 {
t.Error("Expected n to be 5, but was ", n)
}
if !bytes.Equal(toRead, []byte{1, 2, 3, 4, 5}) {
t.Error("expected 5 specific bytes to be read")
}
err = mr.Close()
if err != nil {
t.Error(err)
}
n, err = r.Read(toRead) // read from the outer stream
if err != nil {
t.Error(err)
}
if n != 5 {
t.Error("Expected n to be 5, but was ", n)
}
if !bytes.Equal(toRead, []byte{11, 12, 13, 14, 15}) {
t.Error("expected the last 5 bytes to be read")
}
}