@@ -179,14 +179,14 @@ test('write/read big chunks', async function (t) {
179179 io . absent ( err , 'no error' )
180180 file . read ( 0 , bigBuffer . length , function ( err , buf ) {
181181 io . absent ( err , 'no error' )
182- io . alike ( buf , bigBuffer )
182+ io . ok ( buf . equals ( bigBuffer ) )
183183 } )
184184 } )
185185 file . write ( bigBuffer . length * 2 , bigBuffer , function ( err ) {
186186 io . absent ( err , 'no error' )
187187 file . read ( bigBuffer . length * 2 , bigBuffer . length , function ( err , buf ) {
188188 io . absent ( err , 'no error' )
189- io . alike ( buf , bigBuffer )
189+ io . ok ( buf . equals ( bigBuffer ) )
190190 } )
191191 } )
192192
@@ -195,6 +195,29 @@ test('write/read big chunks', async function (t) {
195195 file . unlink ( ( ) => t . pass ( ) )
196196} )
197197
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+
198221test ( 'rmdir option' , function ( t ) {
199222 t . plan ( 5 )
200223
0 commit comments