def atypes_list_enqueue_node_test(): l = new_list() n1 = Node(l.mem, 0x50) n1.set_pri(0) l.enqueue(n1) assert len(l) == 1 assert [a for a in l] == [n1] # same pri n2 = Node(l.mem, 0x60) n2.set_pri(0) l.enqueue(n2) assert len(l) == 2 assert [a for a in l] == [n1, n2] # higher pri n3 = Node(l.mem, 0x70) n3.set_pri(1) l.enqueue(n3) assert len(l) == 3 assert [a for a in l] == [n3, n1, n2] # lower pri n4 = Node(l.mem, 0x80) n4.set_pri(-1) l.enqueue(n4) assert len(l) == 4 assert [a for a in l] == [n3, n1, n2, n4]
def atypes_node_base_test(): mem = MockMemory() text = 'hello, world!' mem.w_cstr(12, text) node = Node(mem, 0x42) # set node node.set_succ(1234) node.set_pred(5678) node.set_type(NodeType.NT_LIBRARY) node.set_pri(-3) node.set_name(12) # check node assert node.get_succ() == 1234 assert node.get_pred() == 5678 assert int(node.get_type()) == NodeType.NT_LIBRARY assert node.get_type() == NodeType(NodeType.NT_LIBRARY) assert node.get_pri() == -3 assert node.get_name(True) == 12 assert node.get_name() == text