@@ -179,14 +179,14 @@ test('write/read big chunks', async function (t) {
179
179
io . absent ( err , 'no error' )
180
180
file . read ( 0 , bigBuffer . length , function ( err , buf ) {
181
181
io . absent ( err , 'no error' )
182
- io . alike ( buf , bigBuffer )
182
+ io . ok ( buf . equals ( bigBuffer ) )
183
183
} )
184
184
} )
185
185
file . write ( bigBuffer . length * 2 , bigBuffer , function ( err ) {
186
186
io . absent ( err , 'no error' )
187
187
file . read ( bigBuffer . length * 2 , bigBuffer . length , function ( err , buf ) {
188
188
io . absent ( err , 'no error' )
189
- io . alike ( buf , bigBuffer )
189
+ io . ok ( buf . equals ( bigBuffer ) )
190
190
} )
191
191
} )
192
192
@@ -195,6 +195,29 @@ test('write/read big chunks', async function (t) {
195
195
file . unlink ( ( ) => t . pass ( ) )
196
196
} )
197
197
198
+ test ( 'read tons of small chunks' , function ( t ) {
199
+ t . plan ( 1 )
200
+ const file = new RAF ( gen ( ) )
201
+ const bigBuffer = Buffer . alloc ( 10 * 1024 * 1024 )
202
+ let same = true
203
+
204
+ bigBuffer . fill ( 'hey. hey. how are you doing?. i am good thanks how about you? i am good' )
205
+
206
+ file . write ( 0 , bigBuffer , function ( ) {
207
+ let offset = 0
208
+ file . read ( offset , 128 , function loop ( _ , buf ) {
209
+ if ( same ) same = buf . equals ( bigBuffer . subarray ( offset , offset + 128 ) )
210
+ offset += 128
211
+ if ( offset >= bigBuffer . byteLength ) {
212
+ t . ok ( same , 'all sub chunks match' )
213
+ t . end ( )
214
+ } else {
215
+ file . read ( offset , 128 , loop )
216
+ }
217
+ } )
218
+ } )
219
+ } )
220
+
198
221
test ( 'rmdir option' , function ( t ) {
199
222
t . plan ( 5 )
200
223
0 commit comments