summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2016-06-28 19:59:46 +0300
committerEli Zaretskii <eliz@gnu.org>2016-06-28 19:59:46 +0300
commit2adc4ccd03d24660bcf7f8ff056c7f32b92b584d (patch)
tree80a3ad4cfedeae4a0c2ca59880ef520bf008ae6c /test
parent0644e6f56d2be82dd716478eb65e7b3c761d813d (diff)
Add tests for copying properties by 'format'
* test/src/editfns-tests.el (format-properties): New test.
Diffstat (limited to 'test')
-rw-r--r--test/src/editfns-tests.el57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
new file mode 100644
index 0000000000..c515927cff
--- /dev/null
+++ b/test/src/editfns-tests.el
@@ -0,0 +1,57 @@
+;;; editfns-tests.el -- tests for editfns.c
+
+;; Copyright (C) 2016 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+
+(ert-deftest format-properties ()
+ ;; Bug #23730
+ (should (ert-equal-including-properties
+ (format (propertize "%d" 'face '(:background "red")) 1)
+ #("1" 0 1 (face (:background "red")))))
+ (should (ert-equal-including-properties
+ (format (propertize "%2d" 'face '(:background "red")) 1)
+ #(" 1" 0 2 (face (:background "red")))))
+ (should (ert-equal-including-properties
+ (format (propertize "%02d" 'face '(:background "red")) 1)
+ #("01" 0 2 (face (:background "red")))))
+ (should (ert-equal-including-properties
+ (format (concat (propertize "%2d" 'x 'X)
+ (propertize "a" 'a 'A)
+ (propertize "b" 'b 'B))
+ 1)
+ #(" 1ab" 0 2 (x X) 2 3 (a A) 3 4 (b B))))
+
+ ;; Bug #5306
+ (should (ert-equal-including-properties
+ (format "%.10s"
+ (concat "1234567890aaaa"
+ (propertize "12345678901234567890" 'xxx 25)))
+ "1234567890"))
+ (should (ert-equal-including-properties
+ (format "%.10s"
+ (concat "123456789"
+ (propertize "12345678901234567890" 'xxx 25)))
+ #("1234567891" 9 10 (xxx 25))))
+
+ ;; Bug #23859
+ (should (ert-equal-including-properties
+ (format "%4s" (propertize "hi" 'face 'bold))
+ #(" hi" 0 4 (face bold)))))