diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2014-04-12 10:56:58 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2014-04-12 10:56:58 +0200 |
commit | fd455597cffde598d427ee3bea9078bb41ad3f58 (patch) | |
tree | a0fb5ae6b06dfb62b0cb3a4a13b088d9c8a50ced | |
parent | 7004806a1fe4b9511a42d33389f6b9f6283918fa (diff) | |
download | cython-fd455597cffde598d427ee3bea9078bb41ad3f58.tar.gz |
add test for utility code inclusion in conversion of external structs
-rw-r--r-- | tests/run/struct_conversion_extern.pyx | 22 | ||||
-rw-r--r-- | tests/run/struct_conversion_extern_header.h | 5 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/run/struct_conversion_extern.pyx b/tests/run/struct_conversion_extern.pyx new file mode 100644 index 000000000..3c67ec116 --- /dev/null +++ b/tests/run/struct_conversion_extern.pyx @@ -0,0 +1,22 @@ +""" +Note: this tests if the necessary utility code is included in the module env, +despite potentially being already created before. +""" + +cdef extern from "struct_conversion_extern_header.h": + cdef struct my_date_t: + int year + int month + int day + + +def test_extern_struct(): + """ + >>> test_extern_struct() + [('day', 24), ('month', 6), ('year', 2000)] + """ + cdef my_date_t day = my_date_t(year=2000, month=6, day=24) + cdef object d = day + assert type(d) is dict + assert d == day + return sorted(day.items()) diff --git a/tests/run/struct_conversion_extern_header.h b/tests/run/struct_conversion_extern_header.h new file mode 100644 index 000000000..33e7753f8 --- /dev/null +++ b/tests/run/struct_conversion_extern_header.h @@ -0,0 +1,5 @@ +struct my_date_t { + int year; + int month; + int day; +}; |