示例#1
0
class TrieTest(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        from greekutils.trie import Trie
        super(TrieTest, self).__init__(*args, **kwargs)
        self.t = Trie()

    def test_1(self):
        self.t.add("foo", "bar")
        self.assertEqual(self.t.find_prefix("fo"), ("", None, "fo"))
        self.assertEqual(self.t.find_prefix("foo"), ("foo", "bar", ""))
        self.assertEqual(self.t.find_prefix("food"), ("foo", "bar", "d"))

    def test_2(self):
        self.t.add("a", "yes")
        self.t.add("abc", "yes")
        self.assertEqual(self.t.find_prefix("abdc"), ("a", "yes", "bdc"))
示例#2
0
class TrieTest(unittest.TestCase):

    def __init__(self, *args, **kwargs):
        from greekutils.trie import Trie
        super(TrieTest, self).__init__(*args, **kwargs)
        self.t = Trie()

    def test_1(self):
        self.t.add("foo", "bar")
        self.assertEqual(self.t.find_prefix("fo"), ("", None, "fo"))
        self.assertEqual(self.t.find_prefix("foo"), ("foo", "bar", ""))
        self.assertEqual(self.t.find_prefix("food"), ("foo", "bar", "d"))

    def test_2(self):
        self.t.add("a", "yes")
        self.t.add("abc", "yes")
        self.assertEqual(self.t.find_prefix("abdc"), ("a", "yes", "bdc"))
示例#3
0
 def __init__(self, *args, **kwargs):
     from greekutils.trie import Trie
     super(TrieTest, self).__init__(*args, **kwargs)
     self.t = Trie()
示例#4
0
 def __init__(self, *args, **kwargs):
     from greekutils.trie import Trie
     super(TrieTest, self).__init__(*args, **kwargs)
     self.t = Trie()