示例#1
0
文件: shell.py 项目: iafisher/hera-py
    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)
示例#2
0
def test_format_int_with_non_default_format():
    assert format_int(2, spec="bds") == "0b0000000000000010 = 2"
示例#3
0
def test_format_int_with_negative():
    assert format_int(65535) == "0xffff = 65535 = -1"
示例#4
0
def test_format_int_with_large_positive():
    assert format_int(4000) == "0x0fa0 = 4000"
示例#5
0
def test_format_int_with_ASCII_value():
    assert format_int(65) == "0x0041 = 65 = 'A'"
示例#6
0
def test_format_int_with_small_positive():
    assert format_int(5) == "0x0005 = 5"