diff options
| author | Armin Rigo <arigo@tunes.org> | 2017-02-19 14:37:36 +0100 |
|---|---|---|
| committer | Armin Rigo <arigo@tunes.org> | 2017-02-19 14:37:36 +0100 |
| commit | d5ab65efdf707e608266590a2b8dacb35f1dbba4 (patch) | |
| tree | 89b8a4377360ce4aed0f5f2dd4f6fa5ebb4e6dd5 /testing/cffi0/backend_tests.py | |
| parent | 233e3656217468ee17da96f617243392e33d4710 (diff) | |
| download | cffi-d5ab65efdf707e608266590a2b8dacb35f1dbba4.tar.gz | |
issue #255: comparing primitive cdatas
Diffstat (limited to 'testing/cffi0/backend_tests.py')
| -rw-r--r-- | testing/cffi0/backend_tests.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/testing/cffi0/backend_tests.py b/testing/cffi0/backend_tests.py index a72e5c9..65bf0ae 100644 --- a/testing/cffi0/backend_tests.py +++ b/testing/cffi0/backend_tests.py @@ -54,7 +54,8 @@ class BackendTests: min = int(min) max = int(max) p = ffi.cast(c_decl, min) - assert p != min # no __eq__(int) + assert p == min + assert hash(p) == hash(min) assert bool(p) is bool(min) assert int(p) == min p = ffi.cast(c_decl, max) @@ -65,9 +66,9 @@ class BackendTests: assert ffi.typeof(q) is ffi.typeof(p) and int(q) == max q = ffi.cast(c_decl, long(min - 1)) assert ffi.typeof(q) is ffi.typeof(p) and int(q) == max - assert q != p + assert q == p assert int(q) == int(p) - assert hash(q) != hash(p) # unlikely + assert hash(q) == hash(p) c_decl_ptr = '%s *' % c_decl py.test.raises(OverflowError, ffi.new, c_decl_ptr, min - 1) py.test.raises(OverflowError, ffi.new, c_decl_ptr, max + 1) @@ -882,9 +883,9 @@ class BackendTests: assert ffi.string(ffi.cast("enum bar", -2)) == "B1" assert ffi.string(ffi.cast("enum bar", -1)) == "CC1" assert ffi.string(ffi.cast("enum bar", 1)) == "E1" - assert ffi.cast("enum bar", -2) != ffi.cast("enum bar", -2) - assert ffi.cast("enum foo", 0) != ffi.cast("enum bar", 0) - assert ffi.cast("enum bar", 0) != ffi.cast("int", 0) + assert ffi.cast("enum bar", -2) == ffi.cast("enum bar", -2) + assert ffi.cast("enum foo", 0) == ffi.cast("enum bar", 0) + assert ffi.cast("enum bar", 0) == ffi.cast("int", 0) assert repr(ffi.cast("enum bar", -1)) == "<cdata 'enum bar' -1: CC1>" assert repr(ffi.cast("enum foo", -1)) == ( # enums are unsigned, if "<cdata 'enum foo' 4294967295>") # they contain no neg value @@ -1113,15 +1114,15 @@ class BackendTests: assert (q == None) is False assert (q != None) is True - def test_no_integer_comparison(self): + def test_integer_comparison(self): ffi = FFI(backend=self.Backend()) x = ffi.cast("int", 123) y = ffi.cast("int", 456) - py.test.raises(TypeError, "x < y") + assert x < y # z = ffi.cast("double", 78.9) - py.test.raises(TypeError, "x < z") - py.test.raises(TypeError, "z < y") + assert x > z + assert y > z def test_ffi_buffer_ptr(self): ffi = FFI(backend=self.Backend()) |
