Permalink
Browse files

extended test case

  • Loading branch information...
1 parent ebc0723 commit e8527c58b9cd6504cd212b690d340139f85541f6 Stefan Behnel committed Sep 28, 2011
Showing with 41 additions and 0 deletions.
  1. +41 −0 tests/run/for_in_string.pyx
View
41 tests/run/for_in_string.pyx
@@ -183,3 +183,44 @@ def for_pyunicode_in_enumerate_unicode(unicode s):
return i
else:
return 'X'
+
+@cython.test_assert_path_exists("//ForFromStatNode")
+@cython.test_fail_if_path_exists("//ForInStatNode")
+def for_pyucs4_in_unicode(unicode s):
+ """
+ >>> for_pyucs4_in_unicode(unicode_abc)
+ 'X'
+ >>> for_pyucs4_in_unicode(unicode_ABC)
+ 'C'
+ >>> for_pyucs4_in_unicode(unicode_abc_null)
+ 'X'
+ >>> for_pyucs4_in_unicode(unicode_ABC_null)
+ 'C'
+ """
+ cdef Py_UCS4 c
+ for c in s:
+ if c == u'C':
+ return 'C'
+ else:
+ return 'X'
+
+@cython.test_assert_path_exists("//ForFromStatNode")
+@cython.test_fail_if_path_exists("//ForInStatNode")
+def for_pyucs4_in_enumerate_unicode(unicode s):
+ """
+ >>> for_pyucs4_in_enumerate_unicode(unicode_abc)
+ 'X'
+ >>> for_pyucs4_in_enumerate_unicode(unicode_ABC)
+ 2
+ >>> for_pyucs4_in_enumerate_unicode(unicode_abc_null)
+ 'X'
+ >>> for_pyucs4_in_enumerate_unicode(unicode_ABC_null)
+ 4
+ """
+ cdef Py_UCS4 c
+ cdef Py_ssize_t i
+ for i, c in enumerate(s):
+ if c == u'C':
+ return i
+ else:
+ return 'X'

0 comments on commit e8527c5

Please sign in to comment.