コード例 #1
0
 def testExample1(self):
     """Tests Example 1 from make_dafsa.py."""
     infile = ['%%', 'aa, 1', 'a, 2', '%%']
     bytes = [0x81, 0xE1, 0x02, 0x81, 0x82, 0x61, 0x81]
     outfile = make_dafsa.to_cxx(bytes)
     self.assertEqual(
         make_dafsa.words_to_cxx(make_dafsa.parse_gperf(infile)), outfile)
コード例 #2
0
 def testExample1(self):
   """Tests Example 1 from make_dafsa.py."""
   infile = [ '%%', 'aa, 1', 'a, 2', '%%' ]
   bytes = [ 0x81, 0xE1, 0x02, 0x81, 0x82, 0x61, 0x81 ]
   outfile = make_dafsa.to_cxx(bytes)
   self.assertEqual(make_dafsa.words_to_cxx(make_dafsa.parse_gperf(infile)),
                     outfile)
コード例 #3
0
    def testValues(self):
        """Tests legal values are accepted."""
        infile1 = ['%%', 'a, 0', '%%']
        words1 = ['a0']
        self.assertEqual(make_dafsa.parse_gperf(infile1), words1)

        infile2 = ['%%', 'a, 1', '%%']
        words2 = ['a1']
        self.assertEqual(make_dafsa.parse_gperf(infile2), words2)

        infile3 = ['%%', 'a, 2', '%%']
        words3 = ['a2']
        self.assertEqual(make_dafsa.parse_gperf(infile3), words3)

        infile4 = ['%%', 'a, 4', '%%']
        words4 = ['a4']
        self.assertEqual(make_dafsa.parse_gperf(infile4), words4)
コード例 #4
0
ファイル: make_dafsa_unittest.py プロジェクト: 7kbird/chrome
  def testValues(self):
    """Tests legal values are accepted."""
    infile1 = [ '%%', 'a, 0', '%%' ]
    words1 = [ 'a0' ]
    self.assertEqual(make_dafsa.parse_gperf(infile1), words1)

    infile2 = [ '%%', 'a, 1', '%%' ]
    words2 = [ 'a1' ]
    self.assertEqual(make_dafsa.parse_gperf(infile2), words2)

    infile3 = [ '%%', 'a, 2', '%%' ]
    words3 = [ 'a2' ]
    self.assertEqual(make_dafsa.parse_gperf(infile3), words3)

    infile4 = [ '%%', 'a, 4', '%%' ]
    words4 = [ 'a4' ]
    self.assertEqual(make_dafsa.parse_gperf(infile4), words4)
コード例 #5
0
 def testExample2(self):
     """Tests Example 2 from make_dafsa.py."""
     infile = ['%%', 'aa, 1', 'bbb, 2', 'baa, 1', '%%']
     bytes = [
         0x02, 0x83, 0xE2, 0x02, 0x83, 0x61, 0x61, 0x81, 0x62, 0x62, 0x82
     ]
     outfile = make_dafsa.to_cxx(bytes)
     self.assertEqual(
         make_dafsa.words_to_cxx(make_dafsa.parse_gperf(infile, False)),
         outfile)
コード例 #6
0
    def testValues(self):
        """Tests legal values are accepted."""
        infile1 = ['%%', 'a, 0', '%%']
        words1 = ['a0']
        self.assertEqual(make_dafsa.parse_gperf(infile1, False), words1)

        infile2 = ['%%', 'a, 1', '%%']
        words2 = ['a1']
        self.assertEqual(make_dafsa.parse_gperf(infile2, False), words2)

        infile3 = ['%%', 'a, 2', '%%']
        words3 = ['a2']
        self.assertEqual(make_dafsa.parse_gperf(infile3, False), words3)

        infile4 = ['%%', 'a, 3', '%%']
        words4 = ['a3']
        self.assertEqual(make_dafsa.parse_gperf(infile4, False), words4)

        infile5 = ['%%', 'a, 4', '%%']
        words5 = ['a4']
        self.assertEqual(make_dafsa.parse_gperf(infile5, False), words5)

        infile6 = ['%%', 'a, 6', '%%']
        words6 = ['a6']
        self.assertEqual(make_dafsa.parse_gperf(infile6, False), words6)
コード例 #7
0
 def testReverse(self):
     infile = ['%%', 'foo.com, 0', 'foo.bar.com, 1', '%%']
     words = ['moc.oof0', 'moc.rab.oof1']
     self.assertEqual(make_dafsa.parse_gperf(infile, True), words)
コード例 #8
0
 def testTwoWords(self):
     """Tests a sequence of keys can be parsed."""
     infile = ['%%', 'apa, 1', 'bepa.com, 2', '%%']
     words = ['apa1', 'bepa.com2']
     self.assertEqual(make_dafsa.parse_gperf(infile, False), words)
コード例 #9
0
 def testOneWord(self):
     """Tests a single key can be parsed."""
     infile = ['%%', 'apa, 1', '%%']
     words = ['apa1']
     self.assertEqual(make_dafsa.parse_gperf(infile, False), words)
コード例 #10
0
 def testTwoWords(self):
   """Tests a sequence of keys can be parsed."""
   infile = [ '%%', 'apa, 1', 'bepa.com, 2', '%%' ]
   words = [ 'apa1', 'bepa.com2' ]
   self.assertEqual(make_dafsa.parse_gperf(infile), words)
コード例 #11
0
 def testOneWord(self):
   """Tests a single key can be parsed."""
   infile = [ '%%', 'apa, 1', '%%' ]
   words = [ 'apa1' ]
   self.assertEqual(make_dafsa.parse_gperf(infile), words)