-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
2ae2639
commit dd67fe6
Showing
4 changed files
with
41 additions
and
34 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
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
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
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,31 @@ | ||
from richchk.io.richchk.rich_str_lookup_builder import RichStrLookupBuilder | ||
from richchk.model.chk.str.decoded_str_section import DecodedStrSection | ||
from richchk.model.chk.strx.decoded_strx_section import DecodedStrxSection | ||
from richchk.transcoder.chk.transcoders.chk_str_transcoder import ChkStrTranscoder | ||
from richchk.transcoder.chk.transcoders.chk_strx_transcoder import ChkStrxTranscoder | ||
|
||
|
||
def assert_string_offsets_are_valid_for_str(str_section: DecodedStrSection): | ||
expected_strings = set(str_section.strings) | ||
found_strings = set() | ||
str_binary_data = ChkStrTranscoder().encode(str_section, include_header=False) | ||
for offset in str_section.strings_offsets: | ||
found_strings.add( | ||
RichStrLookupBuilder.get_rich_string_by_offset( | ||
offset=offset, str_binary_data=str_binary_data | ||
).value | ||
) | ||
assert expected_strings == found_strings | ||
|
||
|
||
def assert_string_offsets_are_valid_for_strx(str_section: DecodedStrxSection): | ||
expected_strings = set(str_section.strings) | ||
found_strings = set() | ||
str_binary_data = ChkStrxTranscoder().encode(str_section, include_header=False) | ||
for offset in str_section.strings_offsets: | ||
found_strings.add( | ||
RichStrLookupBuilder.get_rich_string_by_offset( | ||
offset=offset, str_binary_data=str_binary_data | ||
).value | ||
) | ||
assert expected_strings == found_strings |