summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-08-01 20:29:23 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-08-01 20:29:23 +0200
commit29d8d407e8967e90ba34a6081e799b32aae42864 (patch)
treef15070927321d379fb0a91cd1357d97740e5e0a1
parent80d70257704f65394b985fdf2b9f8d1ee1dc2bc0 (diff)
downloadorg-mode-29d8d407e8967e90ba34a6081e799b32aae42864.tar.gz
org-macs: Add tests for `org-split-string.
* testing/lisp/test-org-macs.el (test-org/split-string): New test.
-rw-r--r--testing/lisp/test-org-macs.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/lisp/test-org-macs.el b/testing/lisp/test-org-macs.el
index b5ece07..7c54761 100644
--- a/testing/lisp/test-org-macs.el
+++ b/testing/lisp/test-org-macs.el
@@ -19,6 +19,24 @@
;;; Code:
+
+(ert-deftest test-org/split-string ()
+ "Test `org-split-string' specifications."
+ ;; Regular test.
+ (should (equal '("a" "b") (org-split-string "a b" " ")))
+ ;; Empty parts are not removed.
+ (should (equal '("a" "" "b") (org-split-string "a||b" "|")))
+ ;; However, empty parts at beginning or end of string are removed.
+ (should (equal '("a" "b") (org-split-string "|a|b|" "|")))
+ ;; Pathological case: call on an empty string. Since empty parts
+ ;; are not removed, it shouldn't return nil.
+ (should (equal '("") (org-split-string "")))
+ ;; SEPARATORS, when non-nil, is a regexp. In particular, do not
+ ;; match more than specified.
+ (should-not (equal '("a" "b") (org-split-string "a b" " ")))
+ ;; When nil, SEPARATORS matches any number of blank characters.
+ (should (equal '("a" "b") (org-split-string "a \t\nb"))))
+
(ert-deftest test-org/string-display ()
"Test `org-string-display' specifications."
(should (equal "a" (org-string-display "a")))