]> git.lyx.org Git - lyx.git/blob - lib/lyx2lyx/test_lyx2lyx_tools.py
Improved LYX_BUILD_TYPE detection for cmake - case insensitive AC_INIT processing
[lyx.git] / lib / lyx2lyx / test_lyx2lyx_tools.py
1 # This file is part of lyx2lyx
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2018 The LyX team
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
19 " This modules tests the auxiliary functions for lyx2lyx."
20
21 from lyx2lyx_tools import *
22
23 import unittest
24
25 class TestParserTools(unittest.TestCase):
26
27     def test_put_cmd_in_ert(self):
28         ert =  [u'\\begin_inset ERT',
29                 u'status collapsed',
30                 u'',
31                 u'\\begin_layout Plain Layout',
32                 u'',
33                 u'',
34                 u'\\backslash',
35                 u'texttt{Gr',
36                 u'\\backslash',
37                 u'"{u}',
38                 u'\\backslash',
39                 u'ss{}e}',
40                 u'\\end_layout',
41                 u'',
42                 u'\\end_inset']
43         ert_open = ert[:]
44         ert_open[1] = u'status open'
45         ert_paragraph = ["\\begin_layout Standard",
46                          u'\\begin_inset ERT',
47                          u'status collapsed',
48                          u'',
49                          u'\\begin_layout Plain Layout',
50                          u'',
51                          u'',
52                          u'\\backslash',
53                          u'texttt{Gr',
54                          u'\\backslash',
55                          u'"{u}',
56                          u'\\backslash',
57                          u'ss{}e}',
58                          u'\\end_layout',
59                          u'',
60                          u'\\end_inset',
61                          u'',
62                          u'',
63                          u'\\end_layout',
64                          u'']
65         self.assertEqual(put_cmd_in_ert("\\texttt{Grüße}"), ert)
66         self.assertEqual(put_cmd_in_ert([u"\\texttt{Grüße}"]), ert)
67         self.assertEqual(put_cmd_in_ert(u"\\texttt{Grüße}", is_open=True), ert_open)
68         self.assertEqual(put_cmd_in_ert(u"\\texttt{Grüße}", as_paragraph=True), ert_paragraph)
69
70     def test_latex_length(self):
71         self.assertEqual(latex_length("-30.5col%"), (True, "-0.305\\columnwidth"))
72         self.assertEqual(latex_length("35baselineskip%"), (True, "0.35\\baselineskip"))
73         self.assertEqual(latex_length("11em"), (False, "11em"))
74         self.assertEqual(latex_length("-0.4pt"), (False, "-0.4pt"))
75         
76
77
78 if __name__ == '__main__':
79     unittest.main()