-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
24 bit integer support, forms strx3, addrx3 (#553)
* 24 bit integer support, forms strx3, addrx3 * More DWARFv1 constants * More DWARFv1 constants * LLVM lineprog header content type codes * No global declarations
- Loading branch information
Showing
5 changed files
with
71 additions
and
4 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
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 @@ | ||
#------------------------------------------------------------------------------ | ||
# elftools tests | ||
# | ||
# Seva Alekseyev (sevaa@sprynet.com) | ||
# This code is in the public domain | ||
#------------------------------------------------------------------------------ | ||
import unittest | ||
import random | ||
from io import BytesIO | ||
|
||
from elftools.common.construct_utils import ULInt24, UBInt24 | ||
from elftools.common.utils import struct_parse | ||
|
||
class TestInt24(unittest.TestCase): | ||
def test_main(self): | ||
# Testing parsing and building, both LE and BE | ||
b = random.randbytes(3) | ||
|
||
n = struct_parse(UBInt24(''), BytesIO(b)) | ||
self.assertEqual(n, (b[0] << 16) | (b[1] << 8) | b[2]) | ||
s = UBInt24('').build(n) | ||
self.assertEqual(s, b) | ||
|
||
n = struct_parse(ULInt24(''), BytesIO(b)) | ||
self.assertEqual(n, b[0] | (b[1] << 8) | (b[2] << 16)) | ||
s = ULInt24('').build(n) | ||
self.assertEqual(s, b) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |