1cimport cython 2 3cdef char* s = b"abcdefg" 4cdef const char* cs = b"abcdefg" 5cdef unsigned char* us = b"abcdefg" 6cdef const unsigned char* cus = b"abcdefg" 7cdef bytes pystr = b"abcdefg" 8 9 10@cython.test_assert_path_exists( 11 "//PythonCapiCallNode", 12 ) 13def lentest_char(): 14 """ 15 >>> lentest_char() 16 7 17 """ 18 return len(s) 19 20 21@cython.test_assert_path_exists( 22 "//PythonCapiCallNode", 23 ) 24def lentest_const_char(): 25 """ 26 >>> lentest_const_char() 27 7 28 """ 29 return len(cs) 30 31 32@cython.test_assert_path_exists( 33 "//PythonCapiCallNode", 34 ) 35def lentest_char_c(): 36 """ 37 >>> lentest_char_c() 38 7 39 """ 40 cdef Py_ssize_t l = len(s) 41 return l 42 43 44@cython.test_assert_path_exists( 45 "//PythonCapiCallNode", 46 ) 47def lentest_char_c_short(): 48 """ 49 >>> lentest_char_c_short() 50 7 51 """ 52 cdef short l = len(s) 53 return l 54 55 56@cython.test_assert_path_exists( 57 "//PythonCapiCallNode", 58 ) 59def lentest_char_c_float(): 60 """ 61 >>> lentest_char_c_float() 62 7.0 63 """ 64 cdef float l = len(s) 65 return l 66 67 68@cython.test_assert_path_exists( 69 "//PythonCapiCallNode", 70 ) 71def lentest_uchar(): 72 """ 73 >>> lentest_uchar() 74 7 75 """ 76 return len(us) 77 78 79@cython.test_assert_path_exists( 80 "//PythonCapiCallNode", 81 ) 82def lentest_const_uchar(): 83 """ 84 >>> lentest_const_uchar() 85 7 86 """ 87 return len(cus) 88 89 90@cython.test_assert_path_exists( 91 "//PythonCapiCallNode", 92 ) 93def lentest_uchar_c(): 94 """ 95 >>> lentest_uchar_c() 96 7 97 """ 98 cdef Py_ssize_t l = len(us) 99 return l 100 101 102def lentest_py(): 103 """ 104 >>> lentest_py() 105 7 106 """ 107 return len(pystr) 108 109 110def lentest_py_c(): 111 """ 112 >>> lentest_py_c() 113 7 114 """ 115 cdef Py_ssize_t l = len(pystr) 116 return l 117