-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a basic test for convert_to_pattern
- Loading branch information
Showing
1 changed file
with
14 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
import pytest | ||
from hypothesis import given | ||
from hypothesis import strategies as st | ||
|
||
from search_offsets.patterns import hex_to_bytes | ||
from search_offsets.patterns import convert_to_pattern, hex_to_bytes | ||
|
||
|
||
@given(st.integers(0, 255)) | ||
def test_hex_to_bytes(byte: int): | ||
assert hex_to_bytes(f"{byte:02X}") == byte.to_bytes(1, "little") | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("pattern", "expected"), | ||
[ | ||
(["??"], [None]), | ||
(["FF"], [255]), | ||
(["FF", "??"], [255, None]), | ||
], | ||
) | ||
def test_convert_to_pattern(pattern: str, expected: list[int | None]): | ||
assert convert_to_pattern(pattern) == expected |