-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pathlib | ||
|
||
import pytest | ||
|
||
from floss.results import StaticString, StringEncoding | ||
from floss.language.rust.extract import extract_rust_strings | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def rust_strings64(): | ||
n = 1 | ||
path = pathlib.Path(__file__).parent / "data" / "language" / "rust" / "rust-hello" / "bin" / "rust-hello64.exe" | ||
return extract_rust_strings(path, n) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"string,offset,encoding,rust_strings", | ||
[ | ||
# For 1 character strings | ||
pytest.param("Hello, world!", 0xBB030, StringEncoding.UTF8, "rust_strings64"), | ||
# For 2 character strings | ||
pytest.param("۶ж̶ƶ", 0xC73E3, StringEncoding.UTF8, "rust_strings64"), | ||
# For 3 character strings | ||
pytest.param("jd8n8n헧??", 0xD3CE2, StringEncoding.UTF8, "rust_strings64"), | ||
# For 4 character strings | ||
pytest.param("&ޓޓttt", 0xD41F8, StringEncoding.UTF8, "rust_strings64"), | ||
], | ||
) | ||
def test_utf8_decoder(request, string, offset, encoding, rust_strings): | ||
assert StaticString(string=string, offset=offset, encoding=encoding) in request.getfixturevalue(rust_strings) |