From 29d8d407e8967e90ba34a6081e799b32aae42864 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 1 Aug 2017 20:29:23 +0200 Subject: [PATCH] org-macs: Add tests for `org-split-string. * testing/lisp/test-org-macs.el (test-org/split-string): New test. --- testing/lisp/test-org-macs.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/testing/lisp/test-org-macs.el b/testing/lisp/test-org-macs.el index b5ece070f..7c54761d6 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")))