1 ;;; mule-util --- tests for international/mule-util.el -*- coding: utf-8; -*-
3 ;; Copyright (C) 2002-2015 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs 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.
12 ;; GNU Emacs 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.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 (defconst mule-util-test-truncate-data
37 (("中" 1 nil ?
) .
" ")
43 (("kor한e글an" 8 1 ?
) .
"or한e글")
44 (("kor한e글an" 7 2 ?
) .
"r한e ")
45 (("" 0 nil nil
"...") .
"")
46 (("x" 3 nil nil
"...") .
"x")
47 (("中" 3 nil nil
"...") .
"中")
48 (("foo" 3 nil nil
"...") .
"foo")
49 (("foo" 2 nil nil
"...") .
"fo") ;; XEmacs failure?
50 (("foobar" 6 0 nil
"...") .
"foobar")
51 (("foobarbaz" 6 nil nil
"...") .
"foo...")
52 (("foobarbaz" 7 2 nil
"...") .
"ob...")
53 (("foobarbaz" 9 3 nil
"...") .
"barbaz")
54 (("こhんeにlちlはo" 15 1 ? t
) .
" hんeにlちlはo")
55 (("こhんeにlちlはo" 14 1 ? t
) .
" hんeにlち...")
56 (("x" 3 nil nil
"粵語") .
"x")
57 (("中" 2 nil nil
"粵語") .
"中")
58 (("中" 1 nil ?x
"粵語") .
"x") ;; XEmacs error
59 (("中文" 3 nil ?
"粵語") .
"中 ") ;; XEmacs error
60 (("foobarbaz" 4 nil nil
"粵語") .
"粵語")
61 (("foobarbaz" 5 nil nil
"粵語") .
"f粵語")
62 (("foobarbaz" 6 nil nil
"粵語") .
"fo粵語")
63 (("foobarbaz" 8 3 nil
"粵語") .
"b粵語")
64 (("こhんeにlちlはo" 14 4 ?x
"日本語") .
"xeに日本語")
65 (("こhんeにlちlはo" 13 4 ?x
"日本語") .
"xex日本語")
67 "Test data for `truncate-string-to-width'.")
69 (defun mule-util-test-truncate-create (n)
70 "Create a test for element N of the `mule-util-test-truncate-data' constant."
71 (let ((testname (intern (format "mule-util-test-truncate-%.2d" n
)))
72 (testdoc (format "Test element %d of `mule-util-test-truncate-data'."
74 (testdata (nth n mule-util-test-truncate-data
)))
76 `(ert-deftest ,testname
()
78 (should (equal (apply 'truncate-string-to-width
',(car testdata
))
81 (dotimes (i (length mule-util-test-truncate-data
))
82 (mule-util-test-truncate-create i
))
84 ;;; mule-util.el ends here