예제 #1
0
 def test_add_chain(self):
     t = Tree()
     ch_0 = 'l1-1'
     ch_1 = 'l2-1'
     chain = [ch_0, ch_1]
     t.add_chain(chain)
     self.assertTrue(t.root.has_child(ch_0))
     self.assertTrue(t.root.get_child(ch_0).has_child(ch_1))
예제 #2
0
 def test_walk_depth(self):
     t = Tree(0)
     t.add_chain([1, 11])
     t.add_chain([1, 12])
     t.add_chain([1, 13])
     t.add_chain([1, 12, 121])
     t.add_chain([1, 12, 122])
     for _, _ in t.walk_depth():
         pass
예제 #3
0
 def test_next(self):
     t = Tree(0)
     t.add_chain([1, 11])
     t.add_chain([1, 12])
     t.add_chain([1, 13])
     t.add_chain([1, 12, 121])
     t.add_chain([1, 12, 122])
     it = TreeNodeWalkDepthIter(t.root)
     exp_res = [(0, 0), (1, 1), (11, 2), (12, 2), (121, 3), (122, 3), (13, 2)]
     act_res = []
     for pair in it:
         act_res.append(pair)
     self.assertEquals(exp_res, act_res)