def test_rotate_right_RedBlackNode(): leftRef = RedBlackNodeRef(referent=RedBlackNode( ValueRef(), '1', ValueRef(), ValueRef(), ValueRef(Color.RED))) rightRef = RedBlackNodeRef(referent=RedBlackNode( ValueRef(), '3', ValueRef(), ValueRef(), ValueRef(Color.RED))) node = RedBlackNode(leftRef, '2', ValueRef(), rightRef, ValueRef(Color.RED)) node = node.rotate_right() assert node.key == '1'
def test_referent_to_bytes_RedBlackNodeRef(): ref = RedBlackNodeRef() db = connect('test.dbdb') storage = db._storage referent = RedBlackNode(ValueRef(), '1', ValueRef(), ValueRef(), ValueRef()) bytes = ref.referent_to_bytes(referent) node = ref.bytes_to_referent(bytes) assert node.key == '1' os.remove('test.dbdb')
def test_prepare_to_store_RedBlackNodeRef(): ref = RedBlackNodeRef() db = connect('test.dbdb') storage = db._storage ref._referent = RedBlackNode(ValueRef(), '1', ValueRef(), ValueRef(), ValueRef()) ref.prepare_to_store(storage) node = ref.get(storage) assert type(node) == RedBlackNode assert node.key == '1' os.remove('test.dbdb')
def test_recolored_RedBlackNode(): leftRef = RedBlackNodeRef(referent=RedBlackNode( ValueRef(), '1', ValueRef(), ValueRef(), ValueRef(Color.BLACK))) rightRef = RedBlackNodeRef(referent=RedBlackNode( ValueRef(), '3', ValueRef(), ValueRef(), ValueRef(Color.BLACK))) node = RedBlackNode(leftRef, '2', ValueRef(), rightRef, ValueRef(Color.RED)) node = node.recolored() leftNode = node._follow(node.left_ref) rightNode = node._follow(node.right_ref) assert leftNode._follow(leftNode.color_ref) == "red" assert rightNode._follow(rightNode.color_ref) == "red"
def test_insert_RedBlackTree(): db = connect('test.dbdb') storage = db._storage rbtree = RedBlackTree(storage) root = rbtree._follow(rbtree._tree_ref) value_ref = ValueRef('2') rbtree._tree_ref = rbtree._insert(root, '1', value_ref) assert rbtree._tree_ref._referent.key == '1' os.remove('test.dbdb')
def test_store_ValueRef(): ref = ValueRef() db = connect('test.dbdb') storage = db._storage ref._referent = '007' ref.store(storage) assert ref.get(storage) == '007' os.remove('test.dbdb')
def test_store_refs_RedBlackNode(): ref = ValueRef() db = connect('test.dbdb') storage = db._storage ref._referent = '000' node = RedBlackNode(ValueRef(), '1', ref, ValueRef(), ValueRef()) node.store_refs(storage) assert node.value_ref.get(storage) == '000' os.remove('test.dbdb')
def test_bytes_to_referent_ValueRef(): ref = ValueRef() referent = '5' bytes = ref.referent_to_bytes(referent) assert ref.bytes_to_referent(bytes) == '5'
def test_referent_to_bytes_ValueRef(): ref = ValueRef() referent = '5' assert ref.referent_to_bytes(referent) == b'5'
def test_init_ValueRef(): ref = ValueRef() assert type(ref) is ValueRef
def test_reden_RedBlackNode(): node = RedBlackNode(ValueRef(), '1', ValueRef(), ValueRef(), ValueRef(Color.BLACK)) node = node.reden() assert node._follow(node.color_ref) == "red"
def test_blacken_RedBlackNode(): node = RedBlackNode(ValueRef(), '1', ValueRef(), ValueRef(), ValueRef(Color.RED)) node = node.blacken() assert node.is_black() == True
def test_is_red_RedBlackNode(): node = RedBlackNode(ValueRef(), '1', ValueRef(), ValueRef(), ValueRef(Color.RED)) assert node.is_red() == True
def test_is_black_RedBlackNode(): node = RedBlackNode(ValueRef(), '1', ValueRef(), ValueRef(), ValueRef(Color.RED)) assert node.is_black() == False
def test_is_empty_RedBlackNode(): node = RedBlackNode(ValueRef(), '1', ValueRef(), ValueRef(), ValueRef()) assert node.is_empty() == False
def test_init_RedBlackNode(): node = RedBlackNode(ValueRef(), '1', ValueRef(), ValueRef(), ValueRef()) assert type(node) == RedBlackNode assert node.key == '1'