diff options
author | Lisandro Dalcin <dalcinl@gmail.com> | 2014-04-30 14:18:09 +0300 |
---|---|---|
committer | Lisandro Dalcin <dalcinl@gmail.com> | 2014-04-30 14:18:09 +0300 |
commit | b8236fdb96f73612822a5d883a881521783a2625 (patch) | |
tree | 0d26f74a622d45da32ce52f99028cd5ab05f0205 | |
parent | eb5f60af1561ab64d3b3bb62f2e643a189b52d99 (diff) | |
download | cffi-b8236fdb96f73612822a5d883a881521783a2625.tar.gz |
Add test for approximate return types
-rw-r--r-- | testing/test_verify.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/testing/test_verify.py b/testing/test_verify.py index 5e037e0..11dfa92 100644 --- a/testing/test_verify.py +++ b/testing/test_verify.py @@ -109,17 +109,19 @@ def test_rounding_2(): assert res != math.sin(1.23) # not exact, because of double->float assert abs(res - math.sin(1.23)) < 1E-5 -def test_strlen_exact(): +def test_return_exact(): ffi = FFI() ffi.cdef("size_t strlen(const char *s);") lib = ffi.verify("#include <string.h>") assert lib.strlen(b"hi there!") == 9 -def test_strlen_approximate(): - ffi = FFI() - ffi.cdef("size_t strlen(char *s);") - lib = ffi.verify("#include <string.h>") - assert lib.strlen(b"hi there!") == 9 +def test_return_approximate(): + for typename in ['short', 'int', 'long', 'long long']: + ffi = FFI() + ffi.cdef("%s foo(signed char x);" % typename) + lib = ffi.verify("signed char foo(signed char x) { return x;}") + assert lib.foo(-128) == -128 + assert lib.foo(+127) == +127 def test_strlen_array_of_char(): ffi = FFI() |