def add_node(alist, addr, name): n = Node(alist.mem, addr) addr += n.get_type_size() name_addr = addr alist.mem.w_cstr(addr, name) addr += len(name) + 1 if addr & 3 != 0: addr = (addr & ~0x3) + 4 n.set_name(name_addr) alist.add_tail(n) return n, addr
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