@@ -338,6 +338,7 @@ impl Expect {
338338 }
339339 line_start += line. len ( ) ;
340340 }
341+ // `literal_start` points to the first character after `expect![`
341342 let ( literal_start, line_indent) = target_line. unwrap ( ) ;
342343
343344 let lit_to_eof = & file[ literal_start..] ;
@@ -352,6 +353,9 @@ impl Expect {
352353 }
353354}
354355
356+ /// Returns the byte index of the closing delimiter.
357+ ///
358+ /// `arg_start_to_eof` is the part after `expect![`, with leading whitespaces trimmed.
355359fn locate_end ( arg_start_to_eof : & str ) -> Option < usize > {
356360 match arg_start_to_eof. chars ( ) . next ( ) ? {
357361 c if c. is_whitespace ( ) => panic ! ( "skip whitespace before calling `locate_end`" ) ,
@@ -837,8 +841,9 @@ line1
837841 macro_rules! check_locate {
838842 ( $( [ [ $s: literal] ] ) ,* $( , ) ?) => { $( {
839843 let lit = stringify!( $s) ;
840- let with_trailer = format!( "{} \t ]]\n " , lit) ;
841- assert_eq!( locate_end( & with_trailer) , Some ( lit. len( ) ) ) ;
844+ let with_trailer = format!( "[{} \t ]]\n " , lit) ;
845+ // ^ ^^ ^^ 5 additional chars
846+ assert_eq!( locate_end( & with_trailer) , Some ( 4 +lit. len( ) ) ) ;
842847 } ) * } ;
843848 }
844849
@@ -851,7 +856,7 @@ line1
851856 ) ;
852857
853858 // Check `expect![[ ]]` as well.
854- assert_eq ! ( locate_end( "]]" ) , Some ( 0 ) ) ;
859+ assert_eq ! ( locate_end( "[ ]]" ) , Some ( 2 ) ) ;
855860 }
856861
857862 #[ test]
0 commit comments