aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp
diff options
context:
space:
mode:
authorDaniel Martín2022-12-22 19:10:24 +0100
committerEli Zaretskii2022-12-24 09:27:07 +0200
commit24cd2f0daf1363eef9847d5cc8ff342ca8ac342a (patch)
tree5af8f6e0c998e923bae7061772755a138f7f984d /test/lisp
parentd32091199ae5de590a83f1542a01d75fba000467 (diff)
downloademacs-24cd2f0daf1363eef9847d5cc8ff342ca8ac342a.tar.gz
emacs-24cd2f0daf1363eef9847d5cc8ff342ca8ac342a.zip
Add some diff-fixup-modifs tests
* test/lisp/vc/diff-mode-tests.el (diff-mode-test-fixups-added-lines): Test that diff-mode fixes patches with added lines correctly. * test/lisp/vc/diff-mode-tests.el (diff-mode-test-fixups-empty-hunks): Ditto for patches with empty hunks. (Bug#60259)
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/vc/diff-mode-tests.el79
1 files changed, 79 insertions, 0 deletions
diff --git a/test/lisp/vc/diff-mode-tests.el b/test/lisp/vc/diff-mode-tests.el
index 19e3dbb42a6..b67ccd4fe09 100644
--- a/test/lisp/vc/diff-mode-tests.el
+++ b/test/lisp/vc/diff-mode-tests.el
@@ -478,5 +478,84 @@ baz"))))
478 (should (equal (diff-hunk-file-names) 478 (should (equal (diff-hunk-file-names)
479 '("/tmp/ange-ftp1351895K.el" "/tmp/ange-ftp13518wvE.el"))))) 479 '("/tmp/ange-ftp1351895K.el" "/tmp/ange-ftp13518wvE.el")))))
480 480
481(ert-deftest diff-mode-test-fixups-added-lines ()
482 "Check that `diff-fixup-modifs' works well with hunks with added lines."
483 (let ((patch "--- file
484+++ file
485@@ -0,0 +1,15 @@
486+1
487+2
488+3
489+4
490"))
491 (with-temp-buffer
492 (insert patch)
493 (diff-fixup-modifs (point-min) (point-max))
494 (should (equal (buffer-string) "--- file
495+++ file
496@@ -0,0 +1,4 @@
497+1
498+2
499+3
500+4
501"))))
502 (let ((patch "--- file
503+++ file
504@@ -389,5 +398,6 @@
505 while (1)
506 ;
507+ # not needed
508 # at all
509 # stop
510"))
511 (with-temp-buffer
512 (insert patch)
513 (diff-fixup-modifs (point-min) (point-max))
514 (should (equal (buffer-string) "--- file
515+++ file
516@@ -389,4 +398,5 @@
517 while (1)
518 ;
519+ # not needed
520 # at all
521 # stop
522")))))
523
524(ert-deftest diff-mode-test-fixups-empty-hunks ()
525 "Check that `diff-fixup-modifs' works well with empty hunks."
526 (let ((patch "--- file
527+++ file
528@@ -1 +1 @@
529-1
530@@ -10 +10 @@
531-1
532+1
533--- otherfile
534+++ otherfile
535@@ -1 +1 @@
536+2
537@@ -10 +10 @@
538-1
539+1
540"))
541 (with-temp-buffer
542 (insert patch)
543 (diff-fixup-modifs (point-min) (point-max))
544 (should (equal (buffer-string) "--- file
545+++ file
546@@ -1,1 +1,0 @@
547-1
548@@ -10,1 +10,1 @@
549-1
550+1
551--- otherfile
552+++ otherfile
553@@ -1,0 +1,1 @@
554+2
555@@ -10,1 +10,1 @@
556-1
557+1
558")))))
559
481(provide 'diff-mode-tests) 560(provide 'diff-mode-tests)
482;;; diff-mode-tests.el ends here 561;;; diff-mode-tests.el ends here