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

Side by Side Diff: net/tools/dafsa/make_dafsa_unittest.py

Issue 1756733003: Support all possible bitflags when computing the PSL DAFSA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback Created 4 years, 9 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 | « net/tools/dafsa/make_dafsa.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 6
7 import sys 7 import sys
8 import unittest 8 import unittest
9 import make_dafsa 9 import make_dafsa
10 10
(...skipping 11 matching lines...) Expand all
22 self.assertRaises(make_dafsa.InputError, make_dafsa.parse_gperf, infile3) 22 self.assertRaises(make_dafsa.InputError, make_dafsa.parse_gperf, infile3)
23 23
24 def testBadValues(self): 24 def testBadValues(self):
25 """Tests exception is thrown when value is out of range.""" 25 """Tests exception is thrown when value is out of range."""
26 infile1 = [ '%%', 'a, -1', '%%' ] 26 infile1 = [ '%%', 'a, -1', '%%' ]
27 self.assertRaises(make_dafsa.InputError, make_dafsa.parse_gperf, infile1) 27 self.assertRaises(make_dafsa.InputError, make_dafsa.parse_gperf, infile1)
28 28
29 infile2 = [ '%%', 'a, x', '%%' ] 29 infile2 = [ '%%', 'a, x', '%%' ]
30 self.assertRaises(make_dafsa.InputError, make_dafsa.parse_gperf, infile2) 30 self.assertRaises(make_dafsa.InputError, make_dafsa.parse_gperf, infile2)
31 31
32 infile3 = [ '%%', 'a, 3', '%%' ] 32 infile5 = [ '%%', 'a, 12', '%%' ]
33 self.assertRaises(make_dafsa.InputError, make_dafsa.parse_gperf, infile3)
34
35 infile4 = [ '%%', 'a, 6', '%%' ]
36 self.assertRaises(make_dafsa.InputError, make_dafsa.parse_gperf, infile4)
37
38 infile5 = [ '%%', 'a, 12', '%%' ]
39 self.assertRaises(make_dafsa.InputError, make_dafsa.parse_gperf, infile5) 33 self.assertRaises(make_dafsa.InputError, make_dafsa.parse_gperf, infile5)
40 34
41 def testValues(self): 35 def testValues(self):
42 """Tests legal values are accepted.""" 36 """Tests legal values are accepted."""
43 infile1 = [ '%%', 'a, 0', '%%' ] 37 infile1 = [ '%%', 'a, 0', '%%' ]
44 words1 = [ 'a0' ] 38 words1 = [ 'a0' ]
45 self.assertEqual(make_dafsa.parse_gperf(infile1), words1) 39 self.assertEqual(make_dafsa.parse_gperf(infile1), words1)
46 40
47 infile2 = [ '%%', 'a, 1', '%%' ] 41 infile2 = [ '%%', 'a, 1', '%%' ]
48 words2 = [ 'a1' ] 42 words2 = [ 'a1' ]
49 self.assertEqual(make_dafsa.parse_gperf(infile2), words2) 43 self.assertEqual(make_dafsa.parse_gperf(infile2), words2)
50 44
51 infile3 = [ '%%', 'a, 2', '%%' ] 45 infile3 = [ '%%', 'a, 2', '%%' ]
52 words3 = [ 'a2' ] 46 words3 = [ 'a2' ]
53 self.assertEqual(make_dafsa.parse_gperf(infile3), words3) 47 self.assertEqual(make_dafsa.parse_gperf(infile3), words3)
54 48
55 infile4 = [ '%%', 'a, 4', '%%' ] 49 infile4 = [ '%%', 'a, 3', '%%' ]
56 words4 = [ 'a4' ] 50 words4 = [ 'a3' ]
57 self.assertEqual(make_dafsa.parse_gperf(infile4), words4) 51 self.assertEqual(make_dafsa.parse_gperf(infile4), words4)
58 52
53 infile5 = [ '%%', 'a, 4', '%%' ]
54 words5 = [ 'a4' ]
55 self.assertEqual(make_dafsa.parse_gperf(infile5), words5)
56
57 infile6 = [ '%%', 'a, 6', '%%' ]
58 words6 = [ 'a6' ]
59 self.assertEqual(make_dafsa.parse_gperf(infile6), words6)
60
59 def testOneWord(self): 61 def testOneWord(self):
60 """Tests a single key can be parsed.""" 62 """Tests a single key can be parsed."""
61 infile = [ '%%', 'apa, 1', '%%' ] 63 infile = [ '%%', 'apa, 1', '%%' ]
62 words = [ 'apa1' ] 64 words = [ 'apa1' ]
63 self.assertEqual(make_dafsa.parse_gperf(infile), words) 65 self.assertEqual(make_dafsa.parse_gperf(infile), words)
64 66
65 def testTwoWords(self): 67 def testTwoWords(self):
66 """Tests a sequence of keys can be parsed.""" 68 """Tests a sequence of keys can be parsed."""
67 infile = [ '%%', 'apa, 1', 'bepa.com, 2', '%%' ] 69 infile = [ '%%', 'apa, 1', 'bepa.com, 2', '%%' ]
68 words = [ 'apa1', 'bepa.com2' ] 70 words = [ 'apa1', 'bepa.com2' ]
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 infile = [ '%%', 'aa, 1', 'bbb, 2', 'baa, 1', '%%' ] 750 infile = [ '%%', 'aa, 1', 'bbb, 2', 'baa, 1', '%%' ]
749 bytes = [ 0x02, 0x83, 0xE2, 0x02, 0x83, 0x61, 0x61, 0x81, 0x62, 0x62, 751 bytes = [ 0x02, 0x83, 0xE2, 0x02, 0x83, 0x61, 0x61, 0x81, 0x62, 0x62,
750 0x82 ] 752 0x82 ]
751 outfile = make_dafsa.to_cxx(bytes) 753 outfile = make_dafsa.to_cxx(bytes)
752 self.assertEqual(make_dafsa.words_to_cxx(make_dafsa.parse_gperf(infile)), 754 self.assertEqual(make_dafsa.words_to_cxx(make_dafsa.parse_gperf(infile)),
753 outfile) 755 outfile)
754 756
755 757
756 if __name__ == '__main__': 758 if __name__ == '__main__':
757 unittest.main() 759 unittest.main()
OLDNEW
« no previous file with comments | « net/tools/dafsa/make_dafsa.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698