@@ -521,8 +521,16 @@ mod tests {
521521 for i in 0u8 ..32 {
522522 let s = String :: from_utf8 ( vec ! [ i] ) . unwrap ( ) ;
523523 let result = escape ( & s) ;
524- let expected = serde_json:: to_string ( & s) . unwrap ( ) ;
525- assert_eq ! ( result, expected, "Failed for byte 0x{:02x}" , i) ;
524+ let expected = String :: from_utf8 ( QUOTE_TAB [ i as usize ] . 1 . to_vec ( ) )
525+ . unwrap ( )
526+ . trim_end_matches ( '\0' )
527+ . to_string ( ) ;
528+ assert_eq ! (
529+ result,
530+ format!( "\" {}\" " , expected) ,
531+ "Failed for byte 0x{:02x}" ,
532+ i
533+ ) ;
526534 }
527535 }
528536
@@ -563,9 +571,9 @@ mod tests {
563571 . iter ( )
564572 . take ( if cfg ! ( miri) { 10 } else { sources. len ( ) } )
565573 {
566- assert_eq ! ( escape( source) , serde_json:: to_string( & source) . unwrap( ) ) ;
574+ assert_eq ! ( escape( & source) , serde_json:: to_string( & source) . unwrap( ) ) ;
567575 let mut output = String :: new ( ) ;
568- escape_into ( source, unsafe { output. as_mut_vec ( ) } ) ;
576+ escape_into ( & source, unsafe { output. as_mut_vec ( ) } ) ;
569577 assert_eq ! ( output, serde_json:: to_string( & source) . unwrap( ) ) ;
570578 }
571579 }
@@ -603,8 +611,10 @@ mod tests {
603611 for entry in dir {
604612 let p = entry?;
605613 let metadata = std:: fs:: metadata ( p. path ( ) ) ?;
606- if metadata. is_file ( ) && f ( p. path ( ) ) {
607- sources. push ( std:: fs:: read_to_string ( p. path ( ) ) ?) ;
614+ if metadata. is_file ( ) {
615+ if f ( p. path ( ) ) {
616+ sources. push ( std:: fs:: read_to_string ( p. path ( ) ) ?) ;
617+ }
608618 }
609619 if metadata. is_dir ( ) {
610620 read_dir_recursive ( p. path ( ) , sources, f) ?;
0 commit comments