@@ -440,41 +440,16 @@ mod tests {
440440 ) ;
441441 }
442442
443- /// A writer that fails once it has been given `limit` bytes.
444- struct LimitedWriter {
445- written : Vec < u8 > ,
446- limit : usize ,
447- }
448-
449- impl Write for LimitedWriter {
450- fn write ( & mut self , buf : & [ u8 ] ) -> std:: io:: Result < usize > {
451- let n = buf. len ( ) . min ( self . limit - self . written . len ( ) ) ;
452- if n == 0 {
453- return Err ( std:: io:: ErrorKind :: WriteZero . into ( ) ) ;
454- }
455- self . written . extend_from_slice ( & buf[ ..n] ) ;
456- Ok ( n)
457- }
458-
459- fn flush ( & mut self ) -> std:: io:: Result < ( ) > {
460- Ok ( ( ) )
461- }
462- }
463-
464443 #[ test]
465444 fn huge_tabsize ( ) {
466- // The spaces are streamed to the writer, so a huge tab size
467- // neither overflows nor needs a huge buffer up front.
468- for tabsize in [ usize:: MAX / 2 , usize:: MAX ] {
469- let mut output = LimitedWriter {
470- written : Vec :: new ( ) ,
471- limit : 1000 ,
472- } ;
473- assert ! ( do_expand_tabs( & mut output, b"a\t b\t c" , tabsize) . is_err( ) ) ;
474- let mut expected = b"a" . to_vec ( ) ;
475- expected. resize ( 1000 , b' ' ) ;
476- assert_eq ! ( output. written, expected) ;
477- }
445+ // The spaces are streamed to the writer, so the largest accepted
446+ // tab size neither overflows nor needs a huge buffer up front.
447+ let mut buf = [ 0u8 ; 1000 ] ;
448+ let mut output = & mut buf[ ..] ;
449+ assert ! ( do_expand_tabs( & mut output, b"a\t b\t c" , crate :: params:: MAX_TABSIZE ) . is_err( ) ) ;
450+ let mut expected = b"a" . to_vec ( ) ;
451+ expected. resize ( 1000 , b' ' ) ;
452+ assert_eq ! ( buf[ ..] , expected[ ..] ) ;
478453 }
479454 }
480455
0 commit comments