Skip to content

Commit

Permalink
Python/test_views: make test more portable
Browse files Browse the repository at this point in the history
  • Loading branch information
aguinetqb committed Oct 17, 2020
1 parent c483a4f commit 2ae7b97
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bindings/python/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ class ViewsTest(DFFITest):
def test_views(self):
F = self.FFI
CU = F.cdef('''
#include <stdint.h>
typedef struct {
unsigned int a;
unsigned long long b;
uint32_t a;
uint64_t b;
} A;
''')

S = pydffi.view_as(pydffi.const(CU.types.A), b"A"*16)
A = CU.types.A
Len = A.size
S = pydffi.view_as(pydffi.const(A), b"A"*Len)
self.assertEqual(int(S.a), 0x41414141)
self.assertEqual(int(S.b), 0x4141414141414141)
B = bytearray(pydffi.view_as_bytes(S))
self.assertEqual(B, b"A"*16)
self.assertEqual(B, b"A"*Len)

B = pydffi.view_as_bytes(S)
One = 1 if sys.version_info >= (3, 0) else struct.pack("B", 1)
Expand Down

0 comments on commit 2ae7b97

Please sign in to comment.