-
Notifications
You must be signed in to change notification settings - Fork 0
/
org-utf-to-xetex-test.el
137 lines (112 loc) Β· 6.49 KB
/
org-utf-to-xetex-test.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
;;; org-utf-to-xetex-test.el --- Tests for org-utf-to-xetex. -*- lexical-binding: t; -*-
;; Copyright (C) 2018 Grant Rettke
;; Author: Grant Rettke <[email protected]>
;; 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/>.
;;; Commentary:
;; Tests for org-utf-to-xetex.
;;; Code:
(require 'ert)
(require 'org-utf-to-xetex)
(ert-deftest org-utf-to-xetex--block-to-friendly-name ()
(should (equal "" (org-utf-to-xetex--block-to-friendly-name nil)))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name "")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name " ")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name " ")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name " ")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name "-")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name "--")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name "---")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name "_")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name "__")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name "___")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name " -_")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name "- _")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name "_ -")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name " _-")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name "-_ ")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name "_- ")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name " - _")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name " - _")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name " _ -")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name " _ -")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name " - _ ")))
(should (equal "" (org-utf-to-xetex--block-to-friendly-name " _ - ")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name "A B-C_")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name "A-B C_")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name "A_B C-")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name "A B_C-")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name "A-B_C ")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name "A_B-C ")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name " A-B_C")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name "-A B_C")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name "_A B-C")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name " A_B-C")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name "-A_B C")))
(should (equal "ABC" (org-utf-to-xetex--block-to-friendly-name "_A-B C"))))
(ert-deftest org-utf-to-xetex--block-to-newfontfamily ()
(should (equal "\\newfontfamily\\A{font}"
(org-utf-to-xetex--block-to-newfontfamily "A")))
(should (equal "\\newfontfamily\\A{B}"
(org-utf-to-xetex--block-to-newfontfamily "A" "B"))))
(ert-deftest org-utf-to-xetex--block-to-textfontcommand ()
(should (equal "\\textABC"
(org-utf-to-xetex--block-to-textfontcommand "ABC"))))
(ert-deftest org-utf-to-xetex--block-to-declaretextfontcommand ()
(should (equal "\\DeclareTextFontCommand{\\textEmoticons}{\\Emoticons}"
(org-utf-to-xetex--block-to-declaretextfontcommand
"Emoticons"))))
(ert-deftest org-utf-to-xetex--valid-char ()
(should (equal nil
(org-utf-to-xetex--valid-char nil)))
(should (equal nil
(org-utf-to-xetex--valid-char "")))
(should (equal nil
(org-utf-to-xetex--valid-char " ")))
(should (equal t
(org-utf-to-xetex--valid-char " ")))
(should (equal t
(org-utf-to-xetex--valid-char "A")))
(should (equal t
(org-utf-to-xetex--valid-char "π")))
(should (equal t
(org-utf-to-xetex--valid-char "β")))
(should (equal t
(org-utf-to-xetex--valid-char "ζ"))))
(ert-deftest org-utf-to-xetex--char-to-block-def ()
;; no argument
(should (equal nil (org-utf-to-xetex--char-to-block-def nil)))
;; Emoticons
(should (equal "Emoticons" (car (org-utf-to-xetex--char-to-block-def "π"))))
(should (equal "Emoticons" (car (org-utf-to-xetex--char-to-block-def "π¨"))))
(should (equal "Emoticons" (car (org-utf-to-xetex--char-to-block-def "π"))))
;; Miscellaneous Symbols
(should (equal "Miscellaneous Symbols" (car (org-utf-to-xetex--char-to-block-def "β"))))
;; Miscellaneous Symbols
(should (equal "Miscellaneous Technical" (car (org-utf-to-xetex--char-to-block-def "β"))))
;; "CJK Unified Ideographs"
(should (equal "CJK Unified Ideographs" (car (org-utf-to-xetex--char-to-block-def "ζ"))))
(should (equal "CJK Unified Ideographs" (car (org-utf-to-xetex--char-to-block-def "δΊΊ"))))
(should (equal "CJK Unified Ideographs" (car (org-utf-to-xetex--char-to-block-def "ζ₯")))))
(ert-deftest org-utf-to-xetex--char-to-xetex ()
(should (equal "\\textEmoticons{π}"
(org-utf-to-xetex--char-to-xetex "π")))
(should (equal "\\textCJKUnifiedIdeographs{ζ}"
(org-utf-to-xetex--char-to-xetex "ζ"))))
(ert-deftest org-utf-to-xetex-string-to-xetex ()
(should (equal
"A \\textCJKUnifiedIdeographs{ζ}-\\textMiscellaneousTechnical{β}+\\textMiscellaneousSymbols{β}APPLE\\textEmoticons{π}ZEBRA"
(org-utf-to-xetex-string-to-xetex "A ζ-β+βAPPLEπZEBRA"))))
(provide 'org-utf-to-xetex-test)
;;; org-utf-to-xetex-test.el ends here
;; LocalWords: textfontcommand textABC declaretextfontcommand textEmoticons
;; LocalWords: textCJKUnifiedIdeographs textMiscellaneousTechnical
;; LocalWords: textMiscellaneousSymbols