mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 00:14:22 +00:00
Reccmp comparison engine refactor (#405)
* Reccmp comparison engine refactor * Remove redundant references to 'entry' symbol
This commit is contained in:
39
tools/isledecomp/tests/test_cvdump.py
Normal file
39
tools/isledecomp/tests/test_cvdump.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import pytest
|
||||
from isledecomp.cvdump.analysis import data_type_info
|
||||
|
||||
# fmt: off
|
||||
type_check_cases = [
|
||||
("T_32PINT4", 4, True),
|
||||
("T_32PLONG", 4, True),
|
||||
("T_32PRCHAR", 4, True),
|
||||
("T_32PREAL32", 4, True),
|
||||
("T_32PUCHAR", 4, True),
|
||||
("T_32PUINT4", 4, True),
|
||||
("T_32PULONG", 4, True),
|
||||
("T_32PUSHORT", 4, True),
|
||||
("T_32PVOID", 4, True),
|
||||
("T_CHAR", 1, False),
|
||||
("T_INT4", 4, False),
|
||||
("T_LONG", 4, False),
|
||||
("T_NOTYPE", 0, False), # ?
|
||||
("T_QUAD", 8, False),
|
||||
("T_RCHAR", 1, False),
|
||||
("T_REAL32", 4, False),
|
||||
("T_REAL64", 8, False),
|
||||
("T_SHORT", 2, False),
|
||||
("T_UCHAR", 1, False),
|
||||
("T_UINT4", 4, False),
|
||||
("T_ULONG", 4, False),
|
||||
("T_UQUAD", 8, False),
|
||||
("T_USHORT", 2, False),
|
||||
("T_VOID", 0, False), # ?
|
||||
("T_WCHAR", 2, False),
|
||||
]
|
||||
# fmt: on
|
||||
|
||||
|
||||
@pytest.mark.parametrize("type_name, size, is_pointer", type_check_cases)
|
||||
def test_type_check(type_name: str, size: int, is_pointer: bool):
|
||||
assert (info := data_type_info(type_name)) is not None
|
||||
assert info[0] == size
|
||||
assert info[1] == is_pointer
|
55
tools/isledecomp/tests/test_demangler.py
Normal file
55
tools/isledecomp/tests/test_demangler.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import pytest
|
||||
from isledecomp.cvdump.demangler import (
|
||||
demangle_string_const,
|
||||
demangle_vtable,
|
||||
parse_encoded_number,
|
||||
InvalidEncodedNumberError,
|
||||
)
|
||||
|
||||
string_demangle_cases = [
|
||||
("??_C@_08LIDF@December?$AA@", 8, False),
|
||||
("??_C@_0L@EGPP@english?9nz?$AA@", 11, False),
|
||||
(
|
||||
"??_C@_1O@POHA@?$AA?$CI?$AAn?$AAu?$AAl?$AAl?$AA?$CJ?$AA?$AA?$AA?$AA?$AA?$AH?$AA?$AA?$AA?$AA?$AA?$AA?$AA?$9A?$AE?$;I@",
|
||||
14,
|
||||
True,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("symbol, strlen, is_utf16", string_demangle_cases)
|
||||
def test_strings(symbol, is_utf16, strlen):
|
||||
s = demangle_string_const(symbol)
|
||||
assert s.len == strlen
|
||||
assert s.is_utf16 == is_utf16
|
||||
|
||||
|
||||
encoded_numbers = [
|
||||
("A@", 0),
|
||||
("AA@", 0), # would never happen?
|
||||
("P@", 15),
|
||||
("BA@", 16),
|
||||
("BCD@", 291),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("string, value", encoded_numbers)
|
||||
def test_encoded_numbers(string, value):
|
||||
assert parse_encoded_number(string) == value
|
||||
|
||||
|
||||
def test_invalid_encoded_number():
|
||||
with pytest.raises(InvalidEncodedNumberError):
|
||||
parse_encoded_number("Hello")
|
||||
|
||||
|
||||
vtable_cases = [
|
||||
("??_7LegoCarBuildAnimPresenter@@6B@", "LegoCarBuildAnimPresenter"),
|
||||
("??_7?$MxCollection@PAVLegoWorld@@@@6B@", "MxCollection<LegoWorld *>"),
|
||||
("??_7?$MxPtrList@VLegoPathController@@@@6B@", "MxPtrList<LegoPathController>"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("symbol, class_name", vtable_cases)
|
||||
def test_vtable(symbol, class_name):
|
||||
assert demangle_vtable(symbol) == class_name
|
Reference in New Issue
Block a user