-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathnode_test.py
33 lines (25 loc) · 840 Bytes
/
node_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
__author__ = 'yue'
import unittest
import node as n
class TestNode(unittest.TestCase):
def test_default_ctor(self):
node = n.Node.default()
self.assertEqual('', node.character)
self.assertEqual(0, node.frequency)
self.assertIsNone(node.left)
self.assertIsNone(node.right)
def test_ctor(self):
node = n.Node('c', 42)
self.assertEqual('c', node.character)
self.assertEqual(42, node.frequency)
self.assertIsNone(node.left)
self.assertIsNone(node.right)
def test_is_leaf(self):
node = n.Node('c', 42)
self.assertTrue(node.is_leaf())
def test_greater(self):
lhs = n.Node('c', 42)
rhs = n.Node.default()
self.assertGreater(lhs, rhs)
rhs2 = n.Node('a', 42)
self.assertGreater(lhs, rhs2)