def test_keys_that_match_pattern_using_dots_to_retrieve_all_keys_of_certain_length( self): t = TST() t.insert("zero", 0) t.insert("one", 1) t.insert("two", 2) t.insert("three", 3) t.insert("four", 4) t.insert("five", 5) t.insert("six", 6) self.assertEqual(sorted(t.keys_that_match("...")), ["one", "six", "two"]) self.assertEqual(sorted(t.keys_that_match("....")), ["five", "four", "zero"]) self.assertEqual(sorted(t.keys_that_match(".....")), ["three"])
def test_keys_that_match_pattern_using_dots(self): t = TST() t.insert("nop", 0) t.insert("one", 1) t.insert("on", "fire") t.insert("fno", "ok") self.assertEqual(sorted(t.keys_that_match(".n.")), ["fno", "one"])
def test_keys_that_match_pattern_no_dots(self): t = TST() t.insert("one", 1) t.insert("on", "fire") self.assertEqual(t.keys_that_match("on"), ["on"])
def test_keys_that_match_example_docs(self): t = TST() t.insert("food", 3) t.insert("good", 3) t.insert("foodie", 3) self.assertEqual(sorted(t.keys_that_match(".ood")), ["food", "good"])
def test_keys_that_match_tst_empty_pattern_many_dots(self): t = TST() self.assertEqual(t.keys_that_match("......."), [])