-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream_modify_test.go
58 lines (56 loc) · 1.02 KB
/
stream_modify_test.go
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
package easiest
import (
"io"
"reflect"
"strings"
"testing"
)
func Test_newReplaceReader(t *testing.T) {
type args struct {
r io.Reader
old []byte
new []byte
}
tests := []struct {
name string
args args
want []byte
}{
{
name: "3 -> 3",
args: args{
r: strings.NewReader("123456789"),
old: []byte("456"),
new: []byte("ABC"),
},
want: []byte("123ABC789"),
},
{
name: "3 -> 2",
args: args{
r: strings.NewReader("123456789"),
old: []byte("456"),
new: []byte("AB"),
},
want: []byte("123AB789"),
},
{
name: "3 -> 4",
args: args{
r: strings.NewReader("123456789"),
old: []byte("456"),
new: []byte("ABCD"),
},
want: []byte("123ABCD789"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := newReplaceReader(tt.args.r, tt.args.old, tt.args.new, nil)
gotData, _ := io.ReadAll(got)
if !reflect.DeepEqual(gotData, tt.want) {
t.Errorf("newReplaceReader() = %q, want %q", gotData, tt.want)
}
})
}
}