From b98d07fd7159dce79033717c92c8b752d9137975 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Mon, 17 May 2010 13:23:56 +0200 Subject: [PATCH] extended test case --- tests/run/py_unicode_type.pyx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/run/py_unicode_type.pyx b/tests/run/py_unicode_type.pyx index c7283144..f0f9b3e8 100644 --- a/tests/run/py_unicode_type.pyx +++ b/tests/run/py_unicode_type.pyx @@ -129,3 +129,24 @@ def len_uchar(Py_UNICODE uchar): 1 """ return len(uchar) + +mixed_ustring = u'AbcDefGhIjKlmnoP' +lower_ustring = mixed_ustring.lower() +upper_ustring = mixed_ustring.lower() + +@cython.test_assert_path_exists('//PythonCapiCallNode', + '//ForFromStatNode') +@cython.test_fail_if_path_exists('//SimpleCallNode', + '//ForInStatNode') +def count_lower_case_characters(unicode ustring): + """ + >>> count_lower_case_characters(mixed_ustring) + 10 + >>> count_lower_case_characters(lower_ustring) + 16 + """ + cdef Py_ssize_t count = 0 + for uchar in ustring: + if uchar.islower(): + count += 1 + return count -- 2.26.2