コード例 #1
0
ファイル: test_TST.py プロジェクト: michiboo1/ands
 def test_keys_with_prefix_all_found(self):
     t = TST()
     t.insert("occasion", 2)
     t.insert("occasionally", 2)
     t.insert("occam", 2)
     self.assertEqual(sorted(t.keys_with_prefix("occa")),
                      ["occam", "occasion", "occasionally"])
コード例 #2
0
ファイル: test_TST.py プロジェクト: michiboo1/ands
 def test_keys_with_prefix_two_found(self):
     t = TST()
     t.insert("one", 1)
     t.insert("two", 2)
     t.delete("one")
     t.insert("three", 3)
     self.assertEqual(sorted(t.keys_with_prefix("t")), ["three", "two"])
コード例 #3
0
ファイル: test_TST.py プロジェクト: michiboo1/ands
    def test_keys_with_prefix_empty_prefix(self):
        t = TST()

        n = random.randint(1, 50)
        keys = set()

        for _ in range(n):
            key = TestTST.gen_rand_str(random.randint(1, 11))
            keys.add(key)
            t.insert(key, key)

        kwp = t.keys_with_prefix("")
        kwp_set = set(kwp)
        self.assertEqual(len(kwp), len(
            kwp_set))  # I should not need to check this here!!!
        self.assertEqual(kwp_set, keys)
コード例 #4
0
ファイル: test_TST.py プロジェクト: michiboo1/ands
 def test_keys_with_prefix_one_found(self):
     t = TST()
     t.insert("one", 1)
     t.insert("two", 2)
     t.insert("three", 3)
     self.assertEqual(t.keys_with_prefix("on"), ["one"])
コード例 #5
0
ファイル: test_TST.py プロジェクト: michiboo1/ands
 def test_keys_with_prefix_prefix_size_equal_to_key_size(self):
     t = TST()
     t.insert("valete", "dama")
     self.assertEqual(t.keys_with_prefix("valete"), ["valete"])