1 ;;; descr-text-test.el --- ERT tests for descr-text.el -*- lexical-binding: t -*-
3 ;; Copyright (C) 2014 Free Software Foundation, Inc.
5 ;; Author: Michal Nazarewicz <mina86@mina86.com>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;; This package defines regression tests for the descr-text package.
32 (ert-deftest descr-text-test-truncate
()
33 "Tests describe-char-eldoc--truncate function."
35 (describe-char-eldoc--truncate " \t \n" 100)))
37 (describe-char-eldoc--truncate "foo" 1)))
38 (should (equal "foo..."
39 (describe-char-eldoc--truncate "foo wilma fred" 0)))
40 (should (equal "foo..."
41 (describe-char-eldoc--truncate
42 "foo wilma fred" (length "foo wilma"))))
43 (should (equal "foo wilma..."
44 (describe-char-eldoc--truncate
45 "foo wilma fred" (+ 3 (length "foo wilma")))))
46 (should (equal "foo wilma..."
47 (describe-char-eldoc--truncate
48 "foo wilma fred" (1- (length "foo wilma fred")))))
49 (should (equal "foo wilma fred"
50 (describe-char-eldoc--truncate
51 "foo wilma fred" (length "foo wilma fred"))))
52 (should (equal "foo wilma fred"
53 (describe-char-eldoc--truncate
54 " foo\t wilma \nfred\t " (length "foo wilma fred")))))
56 (ert-deftest descr-text-test-format-desc
()
57 "Tests describe-char-eldoc--format function."
58 (should (equal "U+2026: Horizontal ellipsis (Po: Punctuation, Other)"
59 (describe-char-eldoc--format ?…
)))
60 (should (equal "U+2026: Horizontal ellipsis (Punctuation, Other)"
61 (describe-char-eldoc--format ?…
51)))
62 (should (equal "U+2026: Horizontal ellipsis (Po)"
63 (describe-char-eldoc--format ?…
40)))
64 (should (equal "Horizontal ellipsis (Po)"
65 (describe-char-eldoc--format ?…
30)))
66 (should (equal "Horizontal ellipsis"
67 (describe-char-eldoc--format ?…
20)))
68 (should (equal "Horizontal..."
69 (describe-char-eldoc--format ?…
10))))
71 (ert-deftest descr-text-test-desc
()
72 "Tests describe-char-eldoc function."
75 (goto-char (point-min))
76 (should (eq ?a
(following-char))) ; make sure we are where we think we are
77 ;; Function should return nil for an ASCII character.
78 (should (not (describe-char-eldoc)))
80 (goto-char (1+ (point)))
81 (should (eq ?…
(following-char)))
82 (let ((eldoc-echo-area-use-multiline-p t
))
83 ;; Function should return description of an Unicode character.
84 (should (equal "U+2026: Horizontal ellipsis (Po: Punctuation, Other)"
85 (describe-char-eldoc))))
87 (goto-char (point-max))
88 ;; At the end of the buffer, function should return nil and not blow up.
89 (should (not (describe-char-eldoc)))))
92 (provide 'descr-text-test
)
94 ;;; descr-text-test.el ends here