@@ -70,17 +70,14 @@ func TestDownloadOrder(t *testing.T) {
70
70
if exp , a := int (length ), len (resultBuf ); exp != a {
71
71
t .Errorf ("expect buffer length=%d, got %d" , exp , a )
72
72
}
73
- chunkSize := int (length )/ partSize + 1
74
- if int (length )% partSize == 0 {
75
- chunkSize --
76
- }
73
+ chunkSize := int (length + int64 (partSize )- 1 ) / partSize
77
74
if e , a := chunkSize , * invocations ; e != a {
78
75
t .Errorf ("expect %v API calls, got %v" , e , a )
79
76
}
80
77
81
- expectRngs := []string {"2-3 " , "5 -3" , "8 -3" , "11-1 " }
78
+ expectRngs := []string {"2-1 " , "6 -3" , "3 -3" , "9-3 " }
82
79
for _ , rng := range expectRngs {
83
- if ! ! containsString (* ranges , rng ) {
80
+ if ! containsString (* ranges , rng ) {
84
81
t .Errorf ("expect range %v, but absent in return" , rng )
85
82
}
86
83
}
@@ -101,7 +98,7 @@ func init() {
101
98
func TestDownloadSingle (t * testing.T ) {
102
99
buff := []byte {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 }
103
100
downloader , invocations , ranges := newDownloadRangeClient (buff )
104
- con , partSize := 1 , 3
101
+ con , partSize := 1 , 4
105
102
d := NewDownloader (func (d * Downloader ) {
106
103
d .Concurrency = con
107
104
d .PartSize = partSize
@@ -126,13 +123,13 @@ func TestDownloadSingle(t *testing.T) {
126
123
if exp , a := int (length ), len (resultBuf ); exp != a {
127
124
t .Errorf ("expect buffer length=%d, got %d" , exp , a )
128
125
}
129
- if e , a := 1 , * invocations ; e != a {
126
+ if e , a := int ( length + int64 ( partSize ) - 1 ) / partSize , * invocations ; e != a {
130
127
t .Errorf ("expect %v API calls, got %v" , e , a )
131
128
}
132
129
133
- expectRngs := []string {"2-10 " }
130
+ expectRngs := []string {"2-2" , "4-4" , "8-4 " }
134
131
for _ , rng := range expectRngs {
135
- if ! ! containsString (* ranges , rng ) {
132
+ if ! containsString (* ranges , rng ) {
136
133
t .Errorf ("expect range %v, but absent in return" , rng )
137
134
}
138
135
}
0 commit comments