@@ -514,6 +514,32 @@ let diff_tests_their_unavailable_mine_no_nl, diff_tests_hunk_their_unavailable_m
514514let diff_tests_their_unavailable_none_no_nl, diff_tests_hunk_their_unavailable_none_no_nl =
515515 diff_tests_their_unavailable_gen ~mine_no_nl: false
516516
517+ let diff_tests_empty_gen ~mine_no_nl ~their_no_nl =
518+ let a = if mine_no_nl then " " else " \n "
519+ and b = if their_no_nl then " " else " \n " in
520+ let diff = Patch. diff (Edit (" a" , " b" )) (Some a) (Some b) in
521+ let hunk =
522+ if (mine_no_nl && their_no_nl) || (not mine_no_nl && not their_no_nl) then
523+ None
524+ else
525+ let mine_len, mine = if mine_no_nl then 0 , [] else 1 , [" " ] in
526+ let their_len, their = if their_no_nl then 0 , [] else 1 , [" " ] in
527+ Some { Patch. operation = Edit (" a" , " b" );
528+ hunks = [ { mine_start = 0 ; mine_len; mine;
529+ their_start = 0 ; their_len; their} ];
530+ mine_no_nl = false ; their_no_nl = false }
531+ in
532+ diff, hunk
533+
534+ let diff_tests_empty_both_no_nl, diff_tests_hunk_empty_both_no_nl =
535+ diff_tests_empty_gen ~mine_no_nl: true ~their_no_nl: true
536+ let diff_tests_empty_mine_no_nl, diff_tests_hunk_empty_mine_no_nl =
537+ diff_tests_empty_gen ~mine_no_nl: true ~their_no_nl: false
538+ let diff_tests_empty_their_no_nl, diff_tests_hunk_empty_their_no_nl =
539+ diff_tests_empty_gen ~mine_no_nl: false ~their_no_nl: true
540+ let diff_tests_empty_none_no_nl, diff_tests_hunk_empty_none_no_nl =
541+ diff_tests_empty_gen ~mine_no_nl: false ~their_no_nl: false
542+
517543let diff_tests_no_diff_gen ~mine_no_nl ~their_no_nl =
518544 let a =
519545{| aaa
@@ -746,6 +772,10 @@ let unified_diff_creation = [
746772 " diff (mine unavailable, none no_nl)" , `Quick , check_diff diff_tests_mine_unavailable_none_no_nl diff_tests_hunk_mine_unavailable_none_no_nl;
747773 " diff (their unavailable, mine no_nl)" , `Quick , check_diff diff_tests_their_unavailable_mine_no_nl diff_tests_hunk_their_unavailable_mine_no_nl ;
748774 " diff (their unavailable, none no_nl)" , `Quick , check_diff diff_tests_their_unavailable_none_no_nl diff_tests_hunk_their_unavailable_none_no_nl ;
775+ " diff (empty, both no_nl)" , `Quick , check_diff diff_tests_empty_both_no_nl diff_tests_hunk_empty_both_no_nl;
776+ " diff (empty, mine no_nl)" , `Quick , check_diff diff_tests_empty_mine_no_nl diff_tests_hunk_empty_mine_no_nl;
777+ " diff (empty, their no_nl)" , `Quick , check_diff diff_tests_empty_their_no_nl diff_tests_hunk_empty_their_no_nl;
778+ " diff (empty, none no_nl)" , `Quick , check_diff diff_tests_empty_none_no_nl diff_tests_hunk_empty_none_no_nl;
749779 " diff (no diff, both no_nl)" , `Quick , check_diff diff_tests_no_diff_both_no_nl diff_tests_hunk_no_diff_both_no_nl ;
750780 " diff (no diff, mine no_nl)" , `Quick , check_diff diff_tests_no_diff_mine_no_nl diff_tests_hunk_no_diff_mine_no_nl ;
751781 " diff (no diff, their no_nl)" , `Quick , check_diff diff_tests_no_diff_their_no_nl diff_tests_hunk_no_diff_their_no_nl ;
0 commit comments