From: Stefan Kangas Date: Sun, 7 Feb 2021 23:24:11 +0000 (+0100) Subject: Add tests for count-lines X-Git-Tag: emacs-28.0.90~3880 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=651aefa31246a786891e2e743800dbf753223928;p=emacs.git Add tests for count-lines * test/lisp/simple-tests.el (simple-test-count-lines) (simple-test-count-lines/ignore-invisible-lines): Add tests. --- diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el index 7b022811a5c..b4007a6c3f3 100644 --- a/test/lisp/simple-tests.el +++ b/test/lisp/simple-tests.el @@ -47,6 +47,26 @@ (dotimes (_i 10) (insert (propertize "test " 'field (cons nil nil)))) (should (= (count-words (point-min) (point-max)) 10)))) + +;;; `count-lines' + +(ert-deftest simple-test-count-lines () + (with-temp-buffer + (should (= (count-lines (point-min) (point-max)) 0)) + (insert "foo") + (should (= (count-lines (point-min) (point-max)) 1)) + (insert "\nbar\nbaz\n") + (should (= (count-lines (point-min) (point-max)) 3)) + (insert "r\n") + (should (= (count-lines (point-min) (point-max)) 4)))) + +(ert-deftest simple-test-count-lines/ignore-invisible-lines () + (with-temp-buffer + (insert "foo\nbar") + (should (= (count-lines (point-min) (point-max) t) 2)) + (insert (propertize "\nbar\nbaz\nzut" 'invisible t)) + (should (= (count-lines (point-min) (point-max) t) 2)))) + ;;; `transpose-sexps' (defmacro simple-test--transpositions (&rest body)