diff options
Diffstat (limited to 'test/lisp/misc-tests.el')
-rw-r--r-- | test/lisp/misc-tests.el | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/test/lisp/misc-tests.el b/test/lisp/misc-tests.el index 36a8726b885..f84827ab025 100644 --- a/test/lisp/misc-tests.el +++ b/test/lisp/misc-tests.el @@ -44,7 +44,14 @@ (zap-up-to-char 1 ?c)) (with-misc-test "abcde abc123" "c123" (goto-char (point-min)) - (zap-up-to-char 2 ?c))) + (zap-up-to-char 2 ?c)) + (let ((case-fold-search t)) + (with-misc-test "abcdeCXYZ" "cdeCXYZ" + (goto-char (point-min)) + (zap-up-to-char 1 ?C)) + (with-misc-test "abcdeCXYZ" "CXYZ" + (goto-char (point-min)) + (zap-up-to-char 1 ?C 'interactive)))) (ert-deftest misc-test-upcase-char () (with-misc-test "abcde" "aBCDe" @@ -73,5 +80,59 @@ (backward-to-word 3) (should (equal (point) 1)))) +(ert-deftest misc--duplicate-line () + ;; Duplicate a line (twice). + (with-temp-buffer + (insert "abc\ndefg\nh\n") + (goto-char 7) + (duplicate-line 2) + (should (equal (buffer-string) "abc\ndefg\ndefg\ndefg\nh\n")) + (should (equal (point) 7))) + ;; Duplicate a non-terminated line. + (with-temp-buffer + (insert "abc") + (goto-char 2) + (duplicate-line) + (should (equal (buffer-string) "abc\nabc\n")) + (should (equal (point) 2)))) + +(require 'rect) + +(ert-deftest misc--duplicate-dwim () + ;; Duplicate a line. + (with-temp-buffer + (insert "abc\ndefg\nh\n") + (goto-char 7) + (duplicate-dwim 2) + (should (equal (buffer-string) "abc\ndefg\ndefg\ndefg\nh\n")) + (should (equal (point) 7))) + + ;; Duplicate a region. + (with-temp-buffer + (insert "abc\ndef\n") + (set-mark 2) + (goto-char 7) + (transient-mark-mode) + (should (use-region-p)) + (duplicate-dwim) + (should (equal (buffer-string) "abc\ndebc\ndef\n")) + (should (equal (point) 7)) + (should (region-active-p)) + (should (equal (mark) 2))) + + ;; Duplicate a rectangular region. + (with-temp-buffer + (insert "x\n>a\n>bcde\n>fg\nyz\n") + (goto-char 4) + (rectangle-mark-mode) + (goto-char 15) + (rectangle-forward-char 1) + (duplicate-dwim) + (should (equal (buffer-string) "x\n>a a \n>bcdbcde\n>fg fg \nyz\n")) + (should (equal (point) 24)) + (should (region-active-p)) + (should rectangle-mark-mode) + (should (equal (mark) 4)))) + (provide 'misc-tests) ;;; misc-tests.el ends here |