Type checking for `define-widget'
[emacs.git] / test / automated / mule-util.el
blob038881a7915e331c3afcc1f194af6097b1f16e80
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/>.
20 ;;; Commentary:
22 ;;; Code:
24 (require 'ert)
25 (require 'mule-util)
27 (defconst mule-util-test-truncate-data
28 '((("" 0) . "")
29 (("x" 1) . "x")
30 (("xy" 1) . "x")
31 (("xy" 2 1) . "y")
32 (("xy" 0) . "")
33 (("xy" 3) . "xy")
34 (("中" 0) . "")
35 (("中" 1) . "")
36 (("中" 2) . "中")
37 (("中" 1 nil ? ) . " ")
38 (("中文" 3 1 ? ) . " ")
39 (("x中x" 2) . "x")
40 (("x中x" 3) . "x中")
41 (("x中x" 3) . "x中")
42 (("x中x" 4 1) . "中x")
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'."
73 n))
74 (testdata (nth n mule-util-test-truncate-data)))
75 (eval
76 `(ert-deftest ,testname ()
77 ,testdoc
78 (should (equal (apply 'truncate-string-to-width ',(car testdata))
79 ,(cdr testdata)))))))
81 (dotimes (i (length mule-util-test-truncate-data))
82 (mule-util-test-truncate-create i))
84 ;;; mule-util.el ends here