From c4c9e56c6aba7d17854d4bb984dfe3528f9a64fd Mon Sep 17 00:00:00 2001 From: Joran Honig Date: Tue, 23 Oct 2018 10:42:15 +0200 Subject: [PATCH] add find sequence test --- tests/disassembler/asm.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/disassembler/asm.py b/tests/disassembler/asm.py index 4c9a9ee2..1bd3c286 100644 --- a/tests/disassembler/asm.py +++ b/tests/disassembler/asm.py @@ -42,3 +42,19 @@ def test_is_sequence_match(pattern, instruction_list, index, expected_result): return_value = is_sequence_match(pattern, instruction_list, index) # Assert assert return_value == expected_result + +find_sequence_match_test_data = [ + # Normal no match + ((["PUSH1"], ["EQ"]), [{"opcode": "PUSH1"}, {"opcode": "PUSH3"}, {"opcode": "EQ"}], []), + # Normal match + ((["PUSH1"], ["EQ"]), [{"opcode": "PUSH1"}, {"opcode": "PUSH1"}, {"opcode": "EQ"}, {"opcode": "PUSH1"}, {"opcode": "EQ"}], [1, 3]), +] + + +@pytest.mark.parametrize("pattern, instruction_list, expected_result", find_sequence_match_test_data) +def test_find_op_code_sequence(pattern, instruction_list, expected_result): + # Act + return_value = list(find_op_code_sequence(pattern, instruction_list)) + + # Assert + assert return_value == expected_result