emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 651aefa: Add tests for count-lines


From: Stefan Kangas
Subject: master 651aefa: Add tests for count-lines
Date: Sun, 7 Feb 2021 18:25:01 -0500 (EST)

branch: master
commit 651aefa31246a786891e2e743800dbf753223928
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    Add tests for count-lines
    
    * test/lisp/simple-tests.el (simple-test-count-lines)
    (simple-test-count-lines/ignore-invisible-lines): Add tests.
---
 test/lisp/simple-tests.el | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index 7b02281..b4007a6 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -48,6 +48,26 @@
     (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)
   (declare (indent 0)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]