Ejemplo n.º 1
0
    def test_search(self):
        tree = TernarySearchTree()
        tree.add('An aapple fell off the tree')
        tree.add('An aardvark fell off the tree')

        (node, count) = tree.search('An aa')
        self.assertEqual(node.token, 'a')
        self.assertEqual(count, 2)

        (node, count) = tree.search('An aardvark')
        self.assertEqual(node.token, 'k')
        self.assertEqual(count, 1)

        (node, count) = tree.search('An aapple fell off the tree')
        self.assertEqual(node.token, 'e')
        self.assertEqual(count, 2)
    def test_search(self):
        tree = TernarySearchTree()
        tree.add("An aapple fell off the tree")
        tree.add("An aardvark fell off the tree")

        (node, count) = tree.search("An aa")
        self.assertEqual(node.token, "a")
        self.assertEqual(count, 2)

        (node, count) = tree.search("An aardvark")
        self.assertEqual(node.token, "k")
        self.assertEqual(count, 1)

        (node, count) = tree.search("An aapple fell off the tree")
        self.assertEqual(node.token, "e")
        self.assertEqual(count, 2)
Ejemplo n.º 3
0
 def test_search_not_in_tree(self):
     tree = TernarySearchTree()
     tree.add('a')
     node, count = tree.search('b')
     self.assertEqual(node, None)
     self.assertEqual(count, 0)
Ejemplo n.º 4
0
 def test_search_repeated_token(self):
     tree = TernarySearchTree()
     tree.add('aaaa')
     node, count = tree.search('aaa')
     self.assertEqual(node.token, 'a')
     self.assertEqual(count, 3)
Ejemplo n.º 5
0
 def test_search_single_token(self):
     tree = TernarySearchTree()
     tree.add('a')
     node, count = tree.search('a')
     self.assertEqual(node.token, 'a')
     self.assertEqual(count, 1)
 def test_search_not_in_tree(self):
     tree = TernarySearchTree()
     tree.add("a")
     node, count = tree.search("b")
     self.assertEqual(node, None)
     self.assertEqual(count, 0)
 def test_search_repeated_token(self):
     tree = TernarySearchTree()
     tree.add("aaaa")
     node, count = tree.search("aaa")
     self.assertEqual(node.token, "a")
     self.assertEqual(count, 3)
 def test_search_single_token(self):
     tree = TernarySearchTree()
     tree.add("a")
     node, count = tree.search("a")
     self.assertEqual(node.token, "a")
     self.assertEqual(count, 1)