mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 04:21:24 +00:00
Added more buffer/marker/editing test coverage.
This commit is contained in:
parent
7a93a7b334
commit
3dda4b85e8
4 changed files with 114 additions and 0 deletions
|
|
@ -269,6 +269,43 @@ with parameters from the *Messages* buffer modification."
|
|||
(with-temp-buffer
|
||||
(should (eq (buffer-base-buffer (current-buffer)) nil))))
|
||||
|
||||
(ert-deftest buffer-tests--basic-buffer-primitives ()
|
||||
(let ((buf (generate-new-buffer " *buffer-tests-basic*")))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(should (bufferp buf))
|
||||
(should (buffer-live-p buf))
|
||||
(should (equal (buffer-name buf) " *buffer-tests-basic*"))
|
||||
(should (eq (get-buffer " *buffer-tests-basic*") buf))
|
||||
(should (eq (get-buffer buf) buf))
|
||||
(should (eq (get-buffer-create " *buffer-tests-basic*") buf))
|
||||
(with-current-buffer buf
|
||||
(insert "abc")
|
||||
(should (= (buffer-size) 3))
|
||||
(should (eq (set-buffer buf) buf)))
|
||||
(with-current-buffer buf
|
||||
(let ((new-name (rename-buffer " *buffer-tests-renamed*" t)))
|
||||
(should (equal new-name " *buffer-tests-renamed*"))
|
||||
(should (eq (get-buffer new-name) buf))))
|
||||
(should (memq buf (buffer-list))))
|
||||
(when (buffer-live-p buf)
|
||||
(kill-buffer buf)))
|
||||
(should-not (buffer-live-p buf))))
|
||||
|
||||
(ert-deftest buffer-tests--other-buffer ()
|
||||
(let ((b1 (generate-new-buffer " *buffer-tests-ob1*"))
|
||||
(b2 (generate-new-buffer " *buffer-tests-ob2*")))
|
||||
(unwind-protect
|
||||
(with-current-buffer b1
|
||||
(let ((other (other-buffer (current-buffer) t)))
|
||||
(should (bufferp other))
|
||||
(should (buffer-live-p other))
|
||||
(should-not (eq other (current-buffer)))))
|
||||
(when (buffer-live-p b1)
|
||||
(kill-buffer b1))
|
||||
(when (buffer-live-p b2)
|
||||
(kill-buffer b2)))))
|
||||
|
||||
(ert-deftest buffer-tests--overlays-indirect-bug58928 ()
|
||||
(with-temp-buffer
|
||||
(insert "hello world")
|
||||
|
|
|
|||
|
|
@ -860,6 +860,21 @@ comparing the subr with a much slower Lisp implementation."
|
|||
(data-tests-check-sign (% -1 -3) (% nb1 nb3))
|
||||
(data-tests-check-sign (mod -1 -3) (mod nb1 nb3))))
|
||||
|
||||
(ert-deftest data-tests-bignum-remainder-invariants ()
|
||||
(let* ((b (1+ most-positive-fixnum))
|
||||
(d 7)
|
||||
(r (mod b d)))
|
||||
(should (= b (+ (* d (floor (/ b d))) r)))
|
||||
(should (<= 0 r))
|
||||
(should (< r (abs d))))
|
||||
(let* ((b (- (1+ most-positive-fixnum)))
|
||||
(d 7)
|
||||
(q (/ b d))
|
||||
(r (% b d)))
|
||||
(should (= b (+ (* q d) r)))
|
||||
(should (<= r 0))
|
||||
(should (> r (- (abs d))))))
|
||||
|
||||
(ert-deftest data-tests-mod-0 ()
|
||||
(dolist (num (list (1- most-negative-fixnum) -1 0 1
|
||||
(1+ most-positive-fixnum)))
|
||||
|
|
|
|||
|
|
@ -132,6 +132,47 @@
|
|||
"Number of args for `propertize' must be odd."
|
||||
(should-error (propertize "foo" 'bar) :type 'wrong-number-of-arguments))
|
||||
|
||||
(ert-deftest editfns-tests--line-boundaries ()
|
||||
(with-temp-buffer
|
||||
(insert "ab\ncd\n")
|
||||
(goto-char (point-min))
|
||||
(should (bobp))
|
||||
(should (bolp))
|
||||
(should-not (eobp))
|
||||
(should (= (line-beginning-position) (point-min)))
|
||||
(should (= (line-end-position) 3))
|
||||
(forward-char 1)
|
||||
(should-not (bolp))
|
||||
(should-not (eolp))
|
||||
(goto-char (line-end-position))
|
||||
(should (eolp))
|
||||
(forward-char 1)
|
||||
(should (bolp))
|
||||
(goto-char (point-max))
|
||||
(should (eobp))
|
||||
(should-not (bobp))))
|
||||
|
||||
(ert-deftest editfns-tests--current-column-move-to-column ()
|
||||
(with-temp-buffer
|
||||
(insert "ab cd\n")
|
||||
(goto-char (point-min))
|
||||
(should (= (current-column) 0))
|
||||
(move-to-column 4)
|
||||
(should (= (current-column) 4))
|
||||
(should (= (point) (+ (point-min) 4)))))
|
||||
|
||||
(ert-deftest editfns-tests--pos-bol-eol ()
|
||||
(with-temp-buffer
|
||||
(insert "ab\ncde\nf")
|
||||
(goto-char (point-min))
|
||||
(forward-char 1)
|
||||
(should (= (pos-bol) (point-min)))
|
||||
(should (= (pos-eol) 3))
|
||||
(should (= (pos-bol 2) 4))
|
||||
(should (= (pos-eol 2) 7))
|
||||
(should (= (pos-bol 3) 8))
|
||||
(should (= (pos-eol 3) 9))))
|
||||
|
||||
;; Tests for bug#5131.
|
||||
(defun transpose-test-reverse-word (start end)
|
||||
"Reverse characters in a word by transposing pairs of characters."
|
||||
|
|
|
|||
|
|
@ -69,6 +69,27 @@
|
|||
(should (= (marker-position m1) 2))
|
||||
(should (= (marker-position m2) 3)))))
|
||||
|
||||
(ert-deftest marker-tests--set-marker-insertion-type ()
|
||||
(with-temp-buffer
|
||||
(insert "ab")
|
||||
(goto-char 2)
|
||||
(let ((m (point-marker)))
|
||||
(should-not (marker-insertion-type m))
|
||||
(should (eq (set-marker-insertion-type m t) t))
|
||||
(should (marker-insertion-type m))
|
||||
(insert "X")
|
||||
(should (= (marker-position m) 3))
|
||||
(goto-char (marker-position m))
|
||||
(should (eq (set-marker-insertion-type m nil) nil))
|
||||
(should-not (marker-insertion-type m))
|
||||
(insert "Y")
|
||||
(should (= (marker-position m) 3)))))
|
||||
|
||||
(ert-deftest marker-tests--copy-marker-nil ()
|
||||
(let ((m (copy-marker nil)))
|
||||
(should-not (marker-buffer m))
|
||||
(should-not (marker-position m))))
|
||||
|
||||
(ert-deftest marker-tests--last-position-after-kill ()
|
||||
(let (marker pos)
|
||||
(with-temp-buffer
|
||||
|
|
|
|||
Loading…
Reference in a new issue