def test_red_children_are_black(): t = RedBlackTree(StubStorage()) t.set(2,1) t.set(7,1) t.set(3,1) t.set(5,1) t.set(6,1) t.set(1,1) t.set(4,1) t.set(8,1) t.set(9,1) t.set(10,1) t.set(11,1) t.set(12,1) t.set(13,1) t.set(14,1) t.set(15,1) t.set(16,1) rootNode = t._follow(t._tree_ref) assert red_children_are_black(t, rootNode)
def test_root_black_property(): t = RedBlackTree(StubStorage()) t.set(2,1) t.set(7,1) t.set(3,1) t.set(5,1) t.set(6,1) t.set(1,1) t.set(4,1) t.set(8,1) t.set(9,1) t.set(10,1) t.set(11,1) t.set(12,1) t.set(13,1) t.set(14,1) t.set(15,1) t.set(16,1) rootNode = t._follow(t._tree_ref) assert root_black(rootNode)