2017-04-21 13:40:57 +00:00
|
|
|
# This test checks previously known problem values for 32-bit ports.
|
|
|
|
# It's less useful for 64-bit ports.
|
|
|
|
try:
|
|
|
|
import uctypes
|
|
|
|
except ImportError:
|
|
|
|
print("SKIP")
|
2017-06-10 17:14:16 +00:00
|
|
|
raise SystemExit
|
2017-04-21 13:40:57 +00:00
|
|
|
|
2022-05-17 09:45:06 +00:00
|
|
|
buf = bytearray(b"12345678abcd")
|
2017-04-21 13:40:57 +00:00
|
|
|
struct = uctypes.struct(
|
|
|
|
uctypes.addressof(buf),
|
|
|
|
{"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4},
|
2020-03-23 02:26:08 +00:00
|
|
|
uctypes.LITTLE_ENDIAN,
|
2017-04-21 13:40:57 +00:00
|
|
|
)
|
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
struct.f32 = 0x7FFFFFFF
|
2017-04-21 13:40:57 +00:00
|
|
|
print(buf)
|
|
|
|
|
|
|
|
struct.f32 = 0x80000000
|
|
|
|
print(buf)
|
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
struct.f32 = 0xFF010203
|
2017-04-21 13:40:57 +00:00
|
|
|
print(buf)
|
|
|
|
|
|
|
|
struct.f64 = 0x80000000
|
|
|
|
print(buf)
|
|
|
|
|
|
|
|
struct.f64 = 0x80000000 * 2
|
|
|
|
print(buf)
|
|
|
|
|
|
|
|
print("=")
|
|
|
|
|
2022-05-17 09:45:06 +00:00
|
|
|
buf = bytearray(b"12345678abcd")
|
2017-04-21 13:40:57 +00:00
|
|
|
struct = uctypes.struct(
|
|
|
|
uctypes.addressof(buf),
|
|
|
|
{"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4},
|
2020-03-23 02:26:08 +00:00
|
|
|
uctypes.BIG_ENDIAN,
|
2017-04-21 13:40:57 +00:00
|
|
|
)
|
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
struct.f32 = 0x7FFFFFFF
|
2017-04-21 13:40:57 +00:00
|
|
|
print(buf)
|
|
|
|
|
|
|
|
struct.f32 = 0x80000000
|
|
|
|
print(buf)
|
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
struct.f32 = 0xFF010203
|
2017-04-21 13:40:57 +00:00
|
|
|
print(buf)
|
|
|
|
|
|
|
|
struct.f64 = 0x80000000
|
|
|
|
print(buf)
|
|
|
|
|
|
|
|
struct.f64 = 0x80000000 * 2
|
|
|
|
print(buf)
|