Beispiel #1
0
 def testUpdate(self):
     t = main.Trie()
     t.add("cat")
     t.add("cats")
     t.add("cattle")
     for i in range(10):
         t.update("cat")
     self.assertEquals(t.count("cat"), 10)
     for i in range(3):
         t.update("cats")
     self.assertEquals(t.count("cat"), 10)
     self.assertEquals(t.count("cats"), 3)
     for i in range(15):
         t.update("cattle")
     self.assertEquals(t.count("cat"), 10)
     self.assertEquals(t.count("cats"), 3)
     self.assertEquals(t.count("cattle"), 15)
Beispiel #2
0
 def testAddDictionary(self):
     t = main.Trie()
     infile = open(dictfile)
     [t.add(w.strip()) for w in infile]
     [self.assertTrue(w.strip() in t) for w in infile]
Beispiel #3
0
 def testAddSingle(self):
     t = main.Trie()
     t.add("test")
     self.assertTrue("test" in t)