diff options
| author | Eli Zaretskii | 2016-06-28 19:59:46 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2016-06-28 19:59:46 +0300 |
| commit | 2adc4ccd03d24660bcf7f8ff056c7f32b92b584d (patch) | |
| tree | 80a3ad4cfedeae4a0c2ca59880ef520bf008ae6c | |
| parent | 0644e6f56d2be82dd716478eb65e7b3c761d813d (diff) | |
| download | emacs-2adc4ccd03d24660bcf7f8ff056c7f32b92b584d.tar.gz emacs-2adc4ccd03d24660bcf7f8ff056c7f32b92b584d.zip | |
Add tests for copying properties by 'format'
* test/src/editfns-tests.el (format-properties): New test.
| -rw-r--r-- | test/src/editfns-tests.el | 57 |
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 00000000000..c515927cff1 --- /dev/null +++ b/test/src/editfns-tests.el | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | ;;; editfns-tests.el -- tests for editfns.c | ||
| 2 | |||
| 3 | ;; Copyright (C) 2016 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; This program is free software; you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; This program is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert) | ||
| 23 | |||
| 24 | (ert-deftest format-properties () | ||
| 25 | ;; Bug #23730 | ||
| 26 | (should (ert-equal-including-properties | ||
| 27 | (format (propertize "%d" 'face '(:background "red")) 1) | ||
| 28 | #("1" 0 1 (face (:background "red"))))) | ||
| 29 | (should (ert-equal-including-properties | ||
| 30 | (format (propertize "%2d" 'face '(:background "red")) 1) | ||
| 31 | #(" 1" 0 2 (face (:background "red"))))) | ||
| 32 | (should (ert-equal-including-properties | ||
| 33 | (format (propertize "%02d" 'face '(:background "red")) 1) | ||
| 34 | #("01" 0 2 (face (:background "red"))))) | ||
| 35 | (should (ert-equal-including-properties | ||
| 36 | (format (concat (propertize "%2d" 'x 'X) | ||
| 37 | (propertize "a" 'a 'A) | ||
| 38 | (propertize "b" 'b 'B)) | ||
| 39 | 1) | ||
| 40 | #(" 1ab" 0 2 (x X) 2 3 (a A) 3 4 (b B)))) | ||
| 41 | |||
| 42 | ;; Bug #5306 | ||
| 43 | (should (ert-equal-including-properties | ||
| 44 | (format "%.10s" | ||
| 45 | (concat "1234567890aaaa" | ||
| 46 | (propertize "12345678901234567890" 'xxx 25))) | ||
| 47 | "1234567890")) | ||
| 48 | (should (ert-equal-including-properties | ||
| 49 | (format "%.10s" | ||
| 50 | (concat "123456789" | ||
| 51 | (propertize "12345678901234567890" 'xxx 25))) | ||
| 52 | #("1234567891" 9 10 (xxx 25)))) | ||
| 53 | |||
| 54 | ;; Bug #23859 | ||
| 55 | (should (ert-equal-including-properties | ||
| 56 | (format "%4s" (propertize "hi" 'face 'bold)) | ||
| 57 | #(" hi" 0 4 (face bold))))) | ||