-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy_test.go
More file actions
38 lines (33 loc) · 874 Bytes
/
copy_test.go
File metadata and controls
38 lines (33 loc) · 874 Bytes
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
/*
* Copyright (c) 2024-2025 Mikhail Knyazhev <markus621@yandex.com>. All rights reserved.
* Use of this source code is governed by a BSD 3-Clause license that can be found in the LICENSE file.
*/
package ioutils
import (
"bytes"
"io"
"testing"
"go.osspkg.com/casecheck"
)
func TestUnit_Copy(t *testing.T) {
b := make([]byte, 521, 1024)
in := bytes.NewBuffer(b)
out := bytes.NewBuffer(nil)
n, err := Copy(out, in)
casecheck.NoError(t, err)
casecheck.Equal(t, 521, n)
bb, err := io.ReadAll(out)
casecheck.NoError(t, err)
casecheck.Equal(t, 521, len(bb))
}
func TestUnit_CopyN(t *testing.T) {
b := make([]byte, 521, 1024)
in := bytes.NewBuffer(b)
out := bytes.NewBuffer(nil)
n, err := CopyN(out, in, 1)
casecheck.NoError(t, err)
casecheck.Equal(t, 521, n)
bb, err := io.ReadAll(out)
casecheck.NoError(t, err)
casecheck.Equal(t, 521, len(bb))
}