Completed
Push — master ( f1f19a...ab9d67 )
by Xianshun
01:10
created

TernarySearchTrieUnitTest.test_map()   A

Complexity

Conditions 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
1
import unittest
2
3
from pysie.dsl.set import TernarySearchTrie
4
5
6
class TernarySearchTrieUnitTest(unittest.TestCase):
7
8
    def test_map(self):
9
        trie = TernarySearchTrie()
10
        self.assertTrue(trie.is_empty())
11
        trie.put('hello', 'world')
12
        self.assertTrue(trie.contains_key('hello'))
13
        self.assertEqual(trie.get('hello'), 'world')
14
        trie.put('hi', 'there')
15
        self.assertTrue(trie.contains_key('hi'))
16
        self.assertEqual(trie.get('hi'), 'there')
17
        self.assertEqual(trie.size(), 2)
18
        for i in range(100):
19
            trie.put(str(i), i)
20
            self.assertTrue(trie.contains_key(str(i)))
21
        self.assertEqual(trie.size(), 102)
22
        trie.delete('hi')
23
        self.assertFalse(trie.contains_key('hi'))
24
        self.assertEqual(trie.size(), 101)
25
26
if __name__ == '__main__':
27
    unittest.main()