Paul Sokolovsky
8 years ago
4 changed files with 67 additions and 1 deletions
@ -0,0 +1,54 @@ |
|||
# This test checks previously known problem values for 32-bit ports. |
|||
# It's less useful for 64-bit ports. |
|||
try: |
|||
import uctypes |
|||
except ImportError: |
|||
import sys |
|||
print("SKIP") |
|||
sys.exit() |
|||
|
|||
buf = b"12345678abcd" |
|||
struct = uctypes.struct( |
|||
uctypes.addressof(buf), |
|||
{"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4}, |
|||
uctypes.LITTLE_ENDIAN |
|||
) |
|||
|
|||
struct.f32 = 0x7fffffff |
|||
print(buf) |
|||
|
|||
struct.f32 = 0x80000000 |
|||
print(buf) |
|||
|
|||
struct.f32 = 0xff010203 |
|||
print(buf) |
|||
|
|||
struct.f64 = 0x80000000 |
|||
print(buf) |
|||
|
|||
struct.f64 = 0x80000000 * 2 |
|||
print(buf) |
|||
|
|||
print("=") |
|||
|
|||
buf = b"12345678abcd" |
|||
struct = uctypes.struct( |
|||
uctypes.addressof(buf), |
|||
{"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4}, |
|||
uctypes.BIG_ENDIAN |
|||
) |
|||
|
|||
struct.f32 = 0x7fffffff |
|||
print(buf) |
|||
|
|||
struct.f32 = 0x80000000 |
|||
print(buf) |
|||
|
|||
struct.f32 = 0xff010203 |
|||
print(buf) |
|||
|
|||
struct.f64 = 0x80000000 |
|||
print(buf) |
|||
|
|||
struct.f64 = 0x80000000 * 2 |
|||
print(buf) |
@ -0,0 +1,11 @@ |
|||
b'\xff\xff\xff\x7f5678abcd' |
|||
b'\x00\x00\x00\x805678abcd' |
|||
b'\x03\x02\x01\xff5678abcd' |
|||
b'\x03\x02\x01\xff\x00\x00\x00\x80\x00\x00\x00\x00' |
|||
b'\x03\x02\x01\xff\x00\x00\x00\x00\x01\x00\x00\x00' |
|||
= |
|||
b'\x7f\xff\xff\xff5678abcd' |
|||
b'\x80\x00\x00\x005678abcd' |
|||
b'\xff\x01\x02\x035678abcd' |
|||
b'\xff\x01\x02\x03\x00\x00\x00\x00\x80\x00\x00\x00' |
|||
b'\xff\x01\x02\x03\x00\x00\x00\x01\x00\x00\x00\x00' |
Loading…
Reference in new issue