summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2019-04-26 14:15:51 +0200
committerArmin Rigo <arigo@tunes.org>2019-04-26 14:15:51 +0200
commitf611fd0f3e9c4e8397d3b22cbeece0436fd23811 (patch)
treebe926eabe0df530e68708535965b4921e602e4db /testing
parent027ca7570f39680c02745e428f92a8711bd57642 (diff)
downloadcffi-f611fd0f3e9c4e8397d3b22cbeece0436fd23811.tar.gz
Fix C integer division. Add modulo.
Diffstat (limited to 'testing')
-rw-r--r--testing/cffi0/test_verify.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py
index dd643a5..b1033c5 100644
--- a/testing/cffi0/test_verify.py
+++ b/testing/cffi0/test_verify.py
@@ -2534,3 +2534,29 @@ def test_ffi_new_with_cycles():
x.p = p
x.cyclic = x
del p, x
+
+def test_arithmetic_in_cdef():
+ for a in [0, 11, 15]:
+ ffi = FFI()
+ ffi.cdef("""
+ enum FOO {
+ DIVNN = ((-?) / (-3)),
+ DIVNP = ((-?) / (+3)),
+ DIVPN = ((+?) / (-3)),
+ MODNN = ((-?) % (-3)),
+ MODNP = ((-?) % (+3)),
+ MODPN = ((+?) % (-3)),
+ };
+ """.replace('?', str(a)))
+ lib = ffi.verify("""
+ enum FOO {
+ DIVNN = ((-?) / (-3)),
+ DIVNP = ((-?) / (+3)),
+ DIVPN = ((+?) / (-3)),
+ MODNN = ((-?) % (-3)),
+ MODNP = ((-?) % (+3)),
+ MODPN = ((+?) % (-3)),
+ };
+ """.replace('?', str(a)))
+ # the verify() crashes if the values in the enum are different from
+ # the values we computed ourselves from the cdef()