From 8f71310dea3d7c9e72f7d52aca5aa534c9ddf149 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 21 Nov 2024 22:20:51 -0600 Subject: [PATCH] conflicts: demo failed parse of diff with empty line --- lib/tests/test_conflicts.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/tests/test_conflicts.rs b/lib/tests/test_conflicts.rs index 126d879d6a..d3ff2fb438 100644 --- a/lib/tests/test_conflicts.rs +++ b/lib/tests/test_conflicts.rs @@ -766,6 +766,32 @@ fn test_parse_conflict_crlf_markers() { ); } +#[test] +fn test_parse_conflict_diff_stripped_whitespace() { + // Conflict parsing fails since diff contains empty line without leading space + assert_eq!( + parse_conflict( + indoc! {b" + line 1 + <<<<<<< + %%%%%%% + line 2 + + -line 3 + +left + \r + line 4 + +++++++ + right + >>>>>>> + line 5 + "}, + 2 + ), + None + ); +} + #[test] fn test_parse_conflict_wrong_arity() { // Valid conflict marker but it has fewer sides than the caller expected