| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2017 The Chromium Authors. All rights reserved. | 2 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import re |
| 6 import unittest | 7 import unittest |
| 7 | 8 |
| 8 import match_util | 9 import match_util |
| 9 import re | |
| 10 | 10 |
| 11 | 11 |
| 12 class MatchHelperTest(unittest.TestCase): | 12 class MatchHelperTest(unittest.TestCase): |
| 13 | 13 |
| 14 def testExpandRegexIdentifierPlaceholder(self): | 14 def testExpandRegexIdentifierPlaceholder(self): |
| 15 def matches(pattern, target): | 15 def matches(pattern, target): |
| 16 regex = re.compile(match_util.ExpandRegexIdentifierPlaceholder(pattern)) | 16 regex = re.compile(match_util.ExpandRegexIdentifierPlaceholder(pattern)) |
| 17 return bool(regex.search(target) and regex.search(' %s ' % target)) | 17 return bool(regex.search(target) and regex.search(' %s ' % target)) |
| 18 | 18 |
| 19 self.assertTrue(matches(r'{{hello_world}}', 'helloWorld')) | 19 self.assertTrue(matches(r'{{hello_world}}', 'helloWorld')) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 self.assertTrue(matches(r'{{_hello_world_}}', 'FOO_HELLO_WORLD')) | 60 self.assertTrue(matches(r'{{_hello_world_}}', 'FOO_HELLO_WORLD')) |
| 61 self.assertTrue(matches(r'{{_hello_world_}}', 'HELLO_WORLD_BAR')) | 61 self.assertTrue(matches(r'{{_hello_world_}}', 'HELLO_WORLD_BAR')) |
| 62 self.assertTrue(matches(r'{{_hello_world_}}', 'FooHelloWorld')) | 62 self.assertTrue(matches(r'{{_hello_world_}}', 'FooHelloWorld')) |
| 63 self.assertTrue(matches(r'{{_hello_world_}}', 'HelloWorldBar')) | 63 self.assertTrue(matches(r'{{_hello_world_}}', 'HelloWorldBar')) |
| 64 self.assertFalse(matches(r'{{_hello_world_}}', 'foohello/world')) | 64 self.assertFalse(matches(r'{{_hello_world_}}', 'foohello/world')) |
| 65 self.assertFalse(matches(r'{{_hello_world_}}', '1HELLO_WORLD')) | 65 self.assertFalse(matches(r'{{_hello_world_}}', '1HELLO_WORLD')) |
| 66 | 66 |
| 67 | 67 |
| 68 if __name__ == '__main__': | 68 if __name__ == '__main__': |
| 69 unittest.main() | 69 unittest.main() |
| OLD | NEW |