# Path: debugger/enums.py
# class TypeCategory(Enum):
#     """
#     Represents type of C/C++ type.
#     """
#     Any = -1
#     Array = 1
#     BlockPointer = 2
#     Builtin = 4
#     Class = 8
#     ComplexFloat = 16
#     ComplexInteger = 32
#     Enumeration = 64
#     Function = 128
#     Invalid = 0
#     MemberPointer = 256
#     ObjCInterface = 1024
#     ObjCObject = 512
#     ObjCObjectPointer = 2048
#     Other = -2147483648
#     Pointer = 4096
#     CString = 4097
#     Reference = 8192
#     Struct = 16384
#     Typedef = 32768
#     Union = 65536
#     Vector = 131072
#     String = 42
# 
#     def nice_name(self):
#         name_mappings = {
#             TypeCategory.Class: "class",
#             TypeCategory.Struct: "struct"
#         }
#         return name_mappings.get(self, str(self))
# 
# Path: tests/conftest.py
# def setup_debugger(debugger, binary, lines, on_state_change=None,
#                    startup_info=None, cont=True, wait=True):
#     assert debugger.load_binary("src/{}".format(binary))
# 
#     test_exception = []
# 
#     if not isinstance(lines, Iterable):
#         lines = [lines]
# 
#     for line in lines:
#         assert debugger.breakpoint_manager.add_breakpoint(
#             "src/{}.cpp".format(binary), line)
# 
#     if on_state_change:
#         def on_stop(state, data):
#             if state == ProcessState.Stopped:
#                 try:
#                     on_state_change()
#                     if cont:
#                         debugger.exec_continue()
#                 except Exception as exc:
#                     test_exception.append(traceback.format_exc(exc))
#                     debugger.quit_program()
# 
#         debugger.on_process_state_changed.subscribe(on_stop)
# 
#     assert debugger.launch(startup_info)
# 
#     if wait:
#         debugger.wait_for_exit()
# 
#     if len(test_exception) > 0:
#         pytest.fail(test_exception[0], pytrace=False)


import re
from collections import Iterable
from debugger.enums import TypeCategory
from tests.conftest import setup_debugger
        var = check_variable(debugger, "e")
        assert var.data_address == var.address
        assert var.max_size == 10
        arr_item = debugger.variable_manager.get_variable("e[2]")
        assert arr_item.value == "3"
        assert var.get_index_by_address(arr_item.address) == 2

        check_variable(debugger, "strA.x", "5", int_size)

        vec = debugger.variable_manager.get_variable("vec")
        vec.count = vec.max_size
        debugger.variable_manager.get_vector_items(vec)
        assert map(lambda child: int(child.value), vec.children) == [1, 2, 3]

        vec_item = debugger.variable_manager.get_variable(
            "*((({}){}) + 2)".format(
                vec.type.child_type.name,
                vec.data_address))

        assert vec_item.value == "3"
        assert vec.get_index_by_address(vec_item.address) == 2

        assert vec.data_address != vec.address

    setup_debugger(debugger, TEST_FILE, TEST_LINE, test_values_cb)


def test_composite(debugger):
    def test_composite_cb():
        strA = debugger.variable_manager.get_variable("strA")

# Path: debugger/enums.py
# class TypeCategory(Enum):
#     """
#     Represents type of C/C++ type.
#     """
#     Any = -1
#     Array = 1
#     BlockPointer = 2
#     Builtin = 4
#     Class = 8
#     ComplexFloat = 16
#     ComplexInteger = 32
#     Enumeration = 64
#     Function = 128
#     Invalid = 0
#     MemberPointer = 256
#     ObjCInterface = 1024
#     ObjCObject = 512
#     ObjCObjectPointer = 2048
#     Other = -2147483648
#     Pointer = 4096
#     CString = 4097
#     Reference = 8192
#     Struct = 16384
#     Typedef = 32768
#     Union = 65536
#     Vector = 131072
#     String = 42
# 
#     def nice_name(self):
#         name_mappings = {
#             TypeCategory.Class: "class",
#             TypeCategory.Struct: "struct"
#         }
#         return name_mappings.get(self, str(self))
# 
# Path: tests/conftest.py
# def setup_debugger(debugger, binary, lines, on_state_change=None,
#                    startup_info=None, cont=True, wait=True):
#     assert debugger.load_binary("src/{}".format(binary))
# 
#     test_exception = []
# 
#     if not isinstance(lines, Iterable):
#         lines = [lines]
# 
#     for line in lines:
#         assert debugger.breakpoint_manager.add_breakpoint(
#             "src/{}.cpp".format(binary), line)
# 
#     if on_state_change:
#         def on_stop(state, data):
#             if state == ProcessState.Stopped:
#                 try:
#                     on_state_change()
#                     if cont:
#                         debugger.exec_continue()
#                 except Exception as exc:
#                     test_exception.append(traceback.format_exc(exc))
#                     debugger.quit_program()
# 
#         debugger.on_process_state_changed.subscribe(on_stop)
# 
#     assert debugger.launch(startup_info)
# 
#     if wait:
#         debugger.wait_for_exit()
# 
#     if len(test_exception) > 0:
#         pytest.fail(test_exception[0], pytrace=False)


# Path: tests/test_mi_variable.py
import re
from collections import Iterable
from debugger.enums import TypeCategory
from tests.conftest import setup_debugger

        var = check_variable(debugger, "e")
        assert var.data_address == var.address
        assert var.max_size == 10
        arr_item = debugger.variable_manager.get_variable("e[2]")
        assert arr_item.value == "3"
        assert var.get_index_by_address(arr_item.address) == 2

        check_variable(debugger, "strA.x", "5", int_size)

        vec = debugger.variable_manager.get_variable("vec")
        vec.count = vec.max_size
        debugger.variable_manager.get_vector_items(vec)
        assert map(lambda child: int(child.value), vec.children) == [1, 2, 3]

        vec_item = debugger.variable_manager.get_variable(
            "*((({}){}) + 2)".format(
                vec.type.child_type.name,
                vec.data_address))

        assert vec_item.value == "3"
        assert vec.get_index_by_address(vec_item.address) == 2

        assert vec.data_address != vec.address

    setup_debugger(debugger, TEST_FILE, TEST_LINE, test_values_cb)


def test_composite(debugger):
    def test_composite_cb():
        strA = debugger.variable_manager.get_variable("strA")

        assert strA.type.type_category == TypeCategory.Struct