def format_int(self, v: int, spec: str) -> str: if not spec: spec = DEFAULT_SPEC if "l" in spec: spec = spec.replace("l", "") loc = True else: loc = False if loc: try: label = self.debugger.instruction_number_to_location( v, append_label=False ) except IndexError: return format_int(v, spec=spec) else: return format_int(v, spec=spec) + " [" + label + "]" else: return format_int(v, spec=spec)
def test_format_int_with_non_default_format(): assert format_int(2, spec="bds") == "0b0000000000000010 = 2"
def test_format_int_with_negative(): assert format_int(65535) == "0xffff = 65535 = -1"
def test_format_int_with_large_positive(): assert format_int(4000) == "0x0fa0 = 4000"
def test_format_int_with_ASCII_value(): assert format_int(65) == "0x0041 = 65 = 'A'"
def test_format_int_with_small_positive(): assert format_int(5) == "0x0005 = 5"