[pypy-commit] cffi reusable-enum-values: add test for enum which refer to previously defined enum value

mozbugbox noreply at buildbot.pypy.org
Wed Apr 2 09:26:19 CEST 2014


Author: mozbugbox <mozbugbox at yahoo.com.au>
Branch: reusable-enum-values
Changeset: r1487:e3663a5e6a16
Date: 2014-04-01 19:31 +0800
http://bitbucket.org/cffi/cffi/changeset/e3663a5e6a16/

Log:	add test for enum which refer to previously defined enum value

diff --git a/testing/backend_tests.py b/testing/backend_tests.py
--- a/testing/backend_tests.py
+++ b/testing/backend_tests.py
@@ -1322,6 +1322,15 @@
         e = ffi.cast("enum e", 0)
         assert ffi.string(e) == "AA"     # pick the first one arbitrarily
 
+    def test_enum_refer_previous_enum_value(self):
+        ffi = FFI(backend=self.Backend())
+        ffi.cdef("enum e { AA, BB=2, CC=4, DD=BB, EE, FF=CC };")
+        assert ffi.string(ffi.cast("enum e", 2)) == "BB"
+        assert ffi.string(ffi.cast("enum e", 3)) == "EE"
+        assert ffi.sizeof("char[DD]") == 2
+        assert ffi.sizeof("char[EE]") == 3
+        assert ffi.sizeof("char[FF]") == 4
+
     def test_nested_anonymous_struct(self):
         ffi = FFI(backend=self.Backend())
         ffi.cdef("""


More information about the pypy-commit mailing list