1 # This file is part of lyx2lyx
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2006 José Matos <jamatos@lyx.org>
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 " This modules tests the functions used to help parse lines."
21 from parser_tools import *
26 \begin_layout Standard
28 \begin_inset Quotes eld
36 \begin_inset Quotes erd
39 describes several things in addition to LyX's philosophy: most importantly,
40 the format of all of the manuals.
41 If you don't read it, you'll have a bear of a time navigating this manual.
42 You might also be better served looking in one of the other manuals instead
45 \begin_inset Quotes eld
53 \begin_inset Quotes erd
61 lines = ug.splitlines()
63 class TestParserTools(unittest.TestCase):
65 def test_check_token(self):
66 line = "\\begin_layout Standard"
68 self.assertEquals(check_token(line, '\\begin_layout'), True)
69 self.assertEquals(check_token(line, 'Standard'), False)
72 def test_is_nonempty_line(self):
73 self.assertEquals(is_nonempty_line(lines[0]), False)
74 self.assertEquals(is_nonempty_line(lines[1]), True)
75 self.assertEquals(is_nonempty_line(" "*5), False)
78 def test_find_token(self):
79 self.assertEquals(find_token(lines, '\\emph', 0), 7)
80 self.assertEquals(find_token(lines, '\\emph', 0, 5), -1)
81 self.assertEquals(find_token(lines, '\\emp', 0, exact = True), -1)
82 self.assertEquals(find_token(lines, '\\emp', 0, exact = False), 7)
83 self.assertEquals(find_token(lines, 'emph', 0), -1)
86 def test_find_tokens(self):
87 tokens = ['\\emph', '\\end_inset']
88 self.assertEquals(find_tokens(lines, tokens, 0), 4)
89 self.assertEquals(find_tokens(lines, tokens, 0, 4), -1)
92 if __name__ == '__main__':