Commits

Armin Rigo committed 4d29f1e

Missing structs with bitfields support in verify()

  • Participants
  • Parent commits 384f900

Comments (0)

Files changed (1)

File testing/test_verify.py

     s = ffi.new("struct foo_s *")
     assert ffi.sizeof(s.a) == 17 * ffi.sizeof('int')
 
+def test_struct_with_bitfield_exact():
+    ffi = FFI()
+    ffi.cdef("struct foo_s { int a:2, b:3; };")
+    ffi.verify("struct foo_s { int a:2, b:3; };")
+    s = ffi.new("struct foo_s *")
+    s.b = 3
+    py.test.raises(OverflowError, "s.b = 4")
+    assert s.b == 3
+
 def test_global_constants():
     ffi = FFI()
     # use 'static const int', as generally documented, although in this