summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormozbugbox <mozbugbox@yahoo.com.au>2014-04-02 19:08:04 +0800
committermozbugbox <mozbugbox@yahoo.com.au>2014-04-02 19:08:04 +0800
commit9600a4c193a7b8bf0a7d8dbecaf9d054bc7c8ffc (patch)
treef476f8f47d5ee1d4c60dd9ab180a9c37b72fe368
parent8e032289bf02907c13051538eec9cf7e579f4b3a (diff)
downloadcffi-9600a4c193a7b8bf0a7d8dbecaf9d054bc7c8ffc.tar.gz
Add test to '#define DOT 0x1FF' like defines
-rw-r--r--testing/backend_tests.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/backend_tests.py b/testing/backend_tests.py
index e7da1ef..35e382d 100644
--- a/testing/backend_tests.py
+++ b/testing/backend_tests.py
@@ -1581,3 +1581,21 @@ class BackendTests:
assert s[0].a == b'X'
assert s[1].b == -4892220
assert s[1].a == b'Y'
+
+ def test_define_integer_constant(self):
+ ffi = FFI(backend=self.Backend())
+ ffi.cdef("""
+ #define DOT 100
+ #define DOT_OCT 0100l
+ #define DOT_HEX 0x100u
+ #define DOT_UL 1000UL
+ enum foo {AA, BB=DOT, CC};
+ """)
+ lib = ffi.dlopen(None)
+ assert ffi.string(ffi.cast("enum foo", 100)) == "BB"
+ assert lib.DOT == 100
+ assert lib.DOT_OCT == 0o100
+ assert lib.DOT_HEX == 0x100
+ assert lib.DOT_UL == 1000
+
+