diff options
author | Armin Rigo <arigo@tunes.org> | 2016-08-22 16:01:39 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2016-08-22 16:01:39 +0200 |
commit | 4a14e501899044786bbe9c906f8bb3147d529c33 (patch) | |
tree | 0df1857abefa951ab3c4ab2351679169d77f6e0c | |
parent | 53801207e5dcd9008dfd28e58bc40106b2919fb8 (diff) | |
download | cffi-4a14e501899044786bbe9c906f8bb3147d529c33.tar.gz |
Add two tests for 34b29a139894
-rw-r--r-- | testing/cffi1/test_recompiler.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py index 59e1e3e..248c619 100644 --- a/testing/cffi1/test_recompiler.py +++ b/testing/cffi1/test_recompiler.py @@ -1962,3 +1962,21 @@ def test_function_returns_opaque(): ffi, "test_function_returns_opaque", "?") assert str(e.value) == ("function foo: 'struct a' is used as result type," " but is opaque") + +def test_function_returns_union(): + ffi = FFI() + ffi.cdef("union u1 { int a, b; }; union u1 f1(int);") + lib = verify(ffi, "test_function_returns_union", """ + union u1 { int a, b; }; + static union u1 f1(int x) { union u1 u; u.b = x; return u; } + """) + assert lib.f1(51).a == 51 + +def test_function_returns_partial_struct(): + ffi = FFI() + ffi.cdef("struct a { int a; ...; }; struct a f1(int);") + lib = verify(ffi, "test_function_returns_partial_struct", """ + struct a { int b, a, c; }; + static struct a f1(int x) { struct a s = {0}; s.a = x; return s; } + """) + assert lib.f1(52).a == 52 |