Commits

Armin Rigo  committed 33c9c67

Tests, and fix for enums.

  • Participants
  • Parent commits 08b8c2d

Comments (0)

Files changed (2)

File cffi/verifier.py

             extraarg = ', _cffi_type(%d)' % self.gettypenum(tp)
             errvalue = 'NULL'
         #
+        elif isinstance(tp, model.EnumType):
+            converter = '_cffi_to_c_int'
+            errvalue = '-1'
+        #
         else:
             raise NotImplementedError(tp)
         #

File testing/test_verify.py

             int compar(const void *, const void *));
     """)
     ffi.verify("#include <stdlib.h>")
+
+def test_array_as_argument():
+    ffi = FFI()
+    ffi.cdef("""
+        int strlen(char string[]);
+    """)
+    ffi.verify("#include <string.h>")
+
+def test_enum_as_argument():
+    ffi = FFI()
+    ffi.cdef("""
+        enum foo_e { AA, BB, ... };
+        int foo_func(enum foo_e);
+    """)
+    lib = ffi.verify("""
+        enum foo_e { AA, CC, BB };
+        int foo_func(enum foo_e e) { return e; }
+    """)
+    assert lib.foo_func(lib.BB) == 2