From 1374863f71d00371c45fa6a3cef39fbbbeab7fcf Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Fri, 19 Jul 2019 10:20:34 -0400 Subject: Failing test: edit inference: non-ascii This panics with a byte index not at a char boundary. --- src/edits.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/edits.rs') diff --git a/src/edits.rs b/src/edits.rs index b183a6e1..8ad52797 100644 --- a/src/edits.rs +++ b/src/edits.rs @@ -157,6 +157,35 @@ mod tests { assert_eq!(actual_edits, expected_edits); } + #[test] + fn test_get_diff_style_sections_1_nonascii() { + let actual_edits = get_diff_style_sections( + &vec!["áaa\n".to_string()], + &vec!["ááb\n".to_string()], + MINUS, + MINUS_EMPH, + PLUS, + PLUS_EMPH, + 1.0, + ); + let expected_edits = ( + vec![as_strings(vec![ + (MINUS, "á"), + (MINUS_EMPH, "aa"), + (MINUS, "\n"), + ])], + vec![as_strings(vec![ + (PLUS, "á"), + (PLUS_EMPH, "áb"), + (PLUS, "\n"), + ])], + ); + + assert_consistent(&expected_edits); + assert_consistent(&actual_edits); + assert_eq!(actual_edits, expected_edits); + } + #[test] fn test_get_diff_style_sections_2() { let actual_edits = get_diff_style_sections( -- cgit v1.2.3