From f7785cd446cdccd1be922bb5d54c486b88cef285 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 5 May 2010 21:53:25 +0200 Subject: [PATCH] new test for pointer operations --- tests/run/pointers.pyx | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/run/pointers.pyx diff --git a/tests/run/pointers.pyx b/tests/run/pointers.pyx new file mode 100644 index 00000000..384e5d1e --- /dev/null +++ b/tests/run/pointers.pyx @@ -0,0 +1,49 @@ + +cdef char* c_string = b'abcdefg' +cdef void* void_ptr = c_string + +def compare(): + """ + >>> compare() + True + True + True + False + False + """ + print c_string == c_string + print c_string == void_ptr + print c_string is void_ptr + print c_string != void_ptr + print c_string is not void_ptr + +def if_tests(): + """ + >>> if_tests() + True + """ + if c_string == void_ptr: + print True + if c_string != void_ptr: + print False + +def bool_binop(): + """ + >>> bool_binop() + True + """ + if c_string == void_ptr and c_string == c_string: + print True + +def bool_binop_truth(int x): + """ + >>> bool_binop_truth(1) + True + True + >>> bool_binop_truth(0) + True + """ + if c_string and void_ptr and c_string == c_string: + print True + if c_string and x or not void_ptr or x: + print True -- 2.26.2