summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2015-10-22 09:31:13 +0200
committerArmin Rigo <arigo@tunes.org>2015-10-22 09:31:13 +0200
commit6fa865c917e0c9b34b5e8eb13ddd19f8a117e5f5 (patch)
tree1610e8ea2a5b78bf7c6eaefe5e16afda94771365
parentb9d028096549c4e340c7ad145c0ce86903ac0fe2 (diff)
downloadcffi-6fa865c917e0c9b34b5e8eb13ddd19f8a117e5f5.tar.gz
wchar_t can be signed or not, apparently, even on the same platform (arm
linux)
-rw-r--r--testing/cffi0/backend_tests.py7
-rw-r--r--testing/cffi1/test_new_ffi_1.py7
2 files changed, 8 insertions, 6 deletions
diff --git a/testing/cffi0/backend_tests.py b/testing/cffi0/backend_tests.py
index f887bf0..66bf462 100644
--- a/testing/cffi0/backend_tests.py
+++ b/testing/cffi0/backend_tests.py
@@ -756,10 +756,11 @@ class BackendTests:
p = ffi.cast("long long", ffi.cast("wchar_t", -1))
if SIZE_OF_WCHAR == 2: # 2 bytes, unsigned
assert int(p) == 0xffff
- elif platform.machine().startswith(('arm', 'aarch64')):
- assert int(p) == 0xffffffff # 4 bytes, unsigned
- else: # 4 bytes, signed
+ elif (sys.platform.startswith('linux') and
+ platform.machine().startswith('x86')): # known to be signed
assert int(p) == -1
+ else: # in general, it can be either signed or not
+ assert int(p) in [-1, 0xffffffff] # e.g. on arm, both cases occur
p = ffi.cast("int", u+'\u1234')
assert int(p) == 0x1234
diff --git a/testing/cffi1/test_new_ffi_1.py b/testing/cffi1/test_new_ffi_1.py
index 4e4f515..b1f1b33 100644
--- a/testing/cffi1/test_new_ffi_1.py
+++ b/testing/cffi1/test_new_ffi_1.py
@@ -781,10 +781,11 @@ class TestNewFFI1:
p = ffi.cast("long long", ffi.cast("wchar_t", -1))
if SIZE_OF_WCHAR == 2: # 2 bytes, unsigned
assert int(p) == 0xffff
- elif platform.machine().startswith(('arm', 'aarch64')):
- assert int(p) == 0xffffffff # 4 bytes, unsigned
- else: # 4 bytes, signed
+ elif (sys.platform.startswith('linux') and
+ platform.machine().startswith('x86')): # known to be signed
assert int(p) == -1
+ else: # in general, it can be either signed or not
+ assert int(p) in [-1, 0xffffffff] # e.g. on arm, both cases occur
p = ffi.cast("int", u+'\u1234')
assert int(p) == 0x1234