Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tools/binary_size/match_util_test.py

Issue 2813963002: //tools/binary_size: Consolidate most tools into "supersize" command (Closed)
Patch Set: Fix readme formatting. Make archive's --outoput-file a positional arg Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/binary_size/match_util.py ('k') | tools/binary_size/models.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import unittest
7
8 import match_util
9 import re
10
11
12 class MatchHelperTest(unittest.TestCase):
13
14 def testExpandRegexIdentifierPlaceholder(self):
15 def matches(pattern, target):
16 regex = re.compile(match_util.ExpandRegexIdentifierPlaceholder(pattern))
17 return bool(regex.search(target) and regex.search(' %s ' % target))
18
19 self.assertTrue(matches(r'{{hello_world}}', 'helloWorld'))
20 self.assertTrue(matches(r'{{hello_world}}', 'HelloWorld'))
21 self.assertTrue(matches(r'{{hello_world}}', 'kHelloWorld'))
22 self.assertTrue(matches(r'{{hello_world}}', 'hello_world'))
23 self.assertTrue(matches(r'{{hello_world}}', '_hello_world'))
24 self.assertTrue(matches(r'{{hello_world}}', 'hello_world_}}'))
25 self.assertTrue(matches(r'{{hello_world}}', 'HELLO_WORLD'))
26 self.assertTrue(matches(r'{{hello_world}}', 'HELLO_WORLD1'))
27 self.assertTrue(matches(r'{{hello_world}}', 'kHelloWorld1'))
28 self.assertFalse(matches(r'{{hello_world}}', 'hello world'))
29 self.assertFalse(matches(r'{{hello_world}}', 'helloworld'))
30 self.assertFalse(matches(r'{{hello_world}}', 'f_hello_world'))
31 self.assertFalse(matches(r'{{hello_world}}', 'hello_world_f'))
32 self.assertFalse(matches(r'{{hello_world}}', 'hello/world'))
33 self.assertFalse(matches(r'{{hello_world}}', 'helloWORLD'))
34 self.assertFalse(matches(r'{{hello_world}}', 'HELLOworld'))
35 self.assertFalse(matches(r'{{hello_world}}', 'HELLOWORLD'))
36 self.assertFalse(matches(r'{{hello_world}}', 'FOO_HELLO_WORLD'))
37 self.assertFalse(matches(r'{{hello_world}}', 'HELLO_WORLD_BAR'))
38 self.assertFalse(matches(r'{{hello_world}}', 'FooHelloWorld'))
39 self.assertFalse(matches(r'{{hello_world}}', 'HelloWorldBar'))
40 self.assertFalse(matches(r'{{hello_world}}', 'foohello/world'))
41 self.assertFalse(matches(r'{{hello_world}}', '1HELLO_WORLD'))
42
43 self.assertTrue(matches(r'{{_hello_world_}}', 'helloWorld'))
44 self.assertTrue(matches(r'{{_hello_world_}}', 'HelloWorld'))
45 self.assertTrue(matches(r'{{_hello_world_}}', 'kHelloWorld'))
46 self.assertTrue(matches(r'{{_hello_world_}}', 'hello_world'))
47 self.assertTrue(matches(r'{{_hello_world_}}', '_hello_world'))
48 self.assertTrue(matches(r'{{_hello_world_}}', 'hello_world_'))
49 self.assertTrue(matches(r'{{_hello_world_}}', 'HELLO_WORLD'))
50 self.assertTrue(matches(r'{{_hello_world_}}', 'HELLO_WORLD1'))
51 self.assertTrue(matches(r'{{_hello_world_}}', 'kHelloWorld1'))
52 self.assertFalse(matches(r'{{_hello_world_}}', 'hello world'))
53 self.assertFalse(matches(r'{{_hello_world_}}', 'helloworld'))
54 self.assertTrue(matches(r'{{_hello_world_}}', 'f_hello_world'))
55 self.assertTrue(matches(r'{{_hello_world_}}', 'hello_world_f'))
56 self.assertFalse(matches(r'{{_hello_world_}}', 'hello/world'))
57 self.assertFalse(matches(r'{{_hello_world_}}', 'helloWORLD'))
58 self.assertFalse(matches(r'{{_hello_world_}}', 'HELLOworld'))
59 self.assertFalse(matches(r'{{_hello_world_}}', 'HELLOWORLD'))
60 self.assertTrue(matches(r'{{_hello_world_}}', 'FOO_HELLO_WORLD'))
61 self.assertTrue(matches(r'{{_hello_world_}}', 'HELLO_WORLD_BAR'))
62 self.assertTrue(matches(r'{{_hello_world_}}', 'FooHelloWorld'))
63 self.assertTrue(matches(r'{{_hello_world_}}', 'HelloWorldBar'))
64 self.assertFalse(matches(r'{{_hello_world_}}', 'foohello/world'))
65 self.assertFalse(matches(r'{{_hello_world_}}', '1HELLO_WORLD'))
66
67
68 if __name__ == '__main__':
69 unittest.main()
OLDNEW
« no previous file with comments | « tools/binary_size/match_util.py ('k') | tools/binary_size/models.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698