Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test for Bio.trie with_prefix bug reported by Kenvin Wu

  • Loading branch information...
commit efc289c8fe2e78ad12481973e42554fa40f2ea0a 1 parent cd7cc71
@peterjc peterjc authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 Tests/test_trie.py
View
18 Tests/test_trie.py
@@ -115,6 +115,24 @@ def test_get_approximate(self):
self.assertEqual(trieobj.get_approximate('hello me!', 4), [('hello', 1, 4)])
self.assertEqual(trieobj.get_approximate('hello me!', 5), [('hello', 1, 4)])
+ def test_with_prefix(self):
+ trieobj = trie.trie()
+ s = "BANANA"
+ for i in range(len(s)): # insert all suffixes into trie
+ trieobj[s[i:]] = i
+ self.assertEqual(trieobj[s[i:]], i)
+ self.assertEqual(set(trieobj.values()), set(range(6)))
+ self.assertEqual(set(['A', 'ANA', 'ANANA', 'BANANA', 'NA', 'NANA']),
+ set(trieobj.keys()))
+ self.assertEqual(set(['NA', 'NANA']),
+ set(trieobj.with_prefix("N")))
+ self.assertEqual(set(['NA', 'NANA']),
+ set(trieobj.with_prefix("NA")))
+ self.assertEqual(set(['A', 'ANA', 'ANANA']),
+ set(trieobj.with_prefix("A")))
+ self.assertEqual(set(['ANA', 'ANANA']),
+ set(trieobj.with_prefix("AN")))
+
class TestTrieFind(unittest.TestCase):
Please sign in to comment.
Something went wrong with that request. Please try again.