summaryrefslogtreecommitdiff
path: root/test/lisp/vc/diff-mode-tests.el
diff options
context:
space:
mode:
authorGerd Möllmann <gerd@gnu.org>2022-12-31 09:04:56 +0100
committerGerd Möllmann <gerd@gnu.org>2022-12-31 09:04:56 +0100
commit716d676747119f9950861f9a64a8e7871b0082d4 (patch)
treeb71f94b50896736a007d6977c97679e1abd895a6 /test/lisp/vc/diff-mode-tests.el
parent54ec3973e298c3d2b3d81484f80053d881694f88 (diff)
parent7493b4026fc74a51c76c5b614bc83b864af9bc31 (diff)
downloademacs-scratch/pkg.tar.gz
Merge remote-tracking branch 'origin/master' into scratch/pkgscratch/pkg
Diffstat (limited to 'test/lisp/vc/diff-mode-tests.el')
-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"))))
(should (equal (diff-hunk-file-names)
'("/tmp/ange-ftp1351895K.el" "/tmp/ange-ftp13518wvE.el")))))
+(ert-deftest diff-mode-test-fixups-added-lines ()
+ "Check that `diff-fixup-modifs' works well with hunks with added lines."
+ (let ((patch "--- file
++++ file
+@@ -0,0 +1,15 @@
++1
++2
++3
++4
+"))
+ (with-temp-buffer
+ (insert patch)
+ (diff-fixup-modifs (point-min) (point-max))
+ (should (equal (buffer-string) "--- file
++++ file
+@@ -0,0 +1,4 @@
++1
++2
++3
++4
+"))))
+ (let ((patch "--- file
++++ file
+@@ -389,5 +398,6 @@
+ while (1)
+ ;
++ # not needed
+ # at all
+ # stop
+"))
+ (with-temp-buffer
+ (insert patch)
+ (diff-fixup-modifs (point-min) (point-max))
+ (should (equal (buffer-string) "--- file
++++ file
+@@ -389,4 +398,5 @@
+ while (1)
+ ;
++ # not needed
+ # at all
+ # stop
+")))))
+
+(ert-deftest diff-mode-test-fixups-empty-hunks ()
+ "Check that `diff-fixup-modifs' works well with empty hunks."
+ (let ((patch "--- file
++++ file
+@@ -1 +1 @@
+-1
+@@ -10 +10 @@
+-1
++1
+--- otherfile
++++ otherfile
+@@ -1 +1 @@
++2
+@@ -10 +10 @@
+-1
++1
+"))
+ (with-temp-buffer
+ (insert patch)
+ (diff-fixup-modifs (point-min) (point-max))
+ (should (equal (buffer-string) "--- file
++++ file
+@@ -1,1 +1,0 @@
+-1
+@@ -10,1 +10,1 @@
+-1
++1
+--- otherfile
++++ otherfile
+@@ -1,0 +1,1 @@
++2
+@@ -10,1 +10,1 @@
+-1
++1
+")))))
+
(provide 'diff-mode-tests)
;;; diff-mode-tests.el ends here