Package test_suite :: Package unit_tests :: Package _lib :: Module test_regex
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._lib.test_regex

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2008-2013 Edward d'Auvergne                                   # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program 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.                                         # 
11  #                                                                             # 
12  # This program 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.                                # 
16  #                                                                             # 
17  # You should have received a copy of the GNU General Public License           # 
18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # Python module imports. 
23  from unittest import TestCase 
24   
25  # relax module imports. 
26  from lib import regex 
27   
28   
29 -class Test_regex(TestCase):
30 """Unit tests for the functions of the 'lib.regex' module.""" 31 32 # Place the lib.regex module into the class namespace. 33 regex = regex 34 35
36 - def test_search(self):
37 """Test the proper behaviour of the lib.regex.search() function.""" 38 39 # Test a number of calls which should return True. 40 self.assertEqual(True, self.regex.search('H', 'H')) 41 self.assertEqual(True, self.regex.search('H*', 'H')) 42 self.assertEqual(True, self.regex.search('H*', 'H1')) 43 self.assertEqual(True, self.regex.search('H1', 'H1')) 44 self.assertEqual(True, self.regex.search('^H*', 'H')) 45 self.assertEqual(True, self.regex.search('^H*$', 'H')) 46 self.assertEqual(True, self.regex.search('^H*$', 'H')) 47 48 # Test a number of calls which should return False. 49 self.assertEqual(False, self.regex.search('H*', 'NH')) 50 self.assertEqual(False, self.regex.search('H', 'HN')) 51 self.assertEqual(False, self.regex.search('H', 'H1'))
52