diff options
author | da_woods <n/a> | 2015-05-16 17:21:54 +0100 |
---|---|---|
committer | da_woods <n/a> | 2015-09-19 21:10:00 +0100 |
commit | d62480c26705048d12883f5f1bb6cf4d5943516b (patch) | |
tree | bfbc248a4f5d505e4bdfb8c279cb60849bf11c44 /tests/run/libcpp_all.pyx | |
parent | f1930c2d670b4ad71a0c8c8075fb659d966afc27 (diff) | |
download | cython-d62480c26705048d12883f5f1bb6cf4d5943516b.tar.gz |
Added a few more tests for the C++ standard library
These relate to non-member binary operators
Diffstat (limited to 'tests/run/libcpp_all.pyx')
-rw-r--r-- | tests/run/libcpp_all.pyx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/run/libcpp_all.pyx b/tests/run/libcpp_all.pyx index de75797de..942d352ec 100644 --- a/tests/run/libcpp_all.pyx +++ b/tests/run/libcpp_all.pyx @@ -91,3 +91,23 @@ cdef const_vector_to_list(const vector[double]& cv): lst.append(cython.operator.dereference(iter)) cython.operator.preincrement(iter) return lst + +def complex_operators(): + """ + >>> complex_operators() + [-1.0, 0.0, 0.0, 2.0, 0.0, 2.0] + """ + cdef libcpp.complex.complex[double] a = libcpp.complex.complex[double](0.0,1.0) + cdef libcpp.complex.complex[double] r1=a*a + cdef libcpp.complex.complex[double] r2=a*2.0 + cdef libcpp.complex.complex[double] r3=2.0*a + return [r1.real(), r1.imag(), r2.real(), r2.imag(), r3.real(), r3.imag()] + +def pair_comparison(): + """ + >>> pair_comparison() + [False, True, False, True, False] + """ + cdef pair[double, double] p1 = pair[double, double](1.0,2.0) + cdef pair[double, double] p2 = pair[double, double](2.0,2.0) + return [p1==p2,p1==p1,p1>p2,p1<p2,p2>p2]
\ No newline at end of file |