Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
a8e0f626
Commit
a8e0f626
authored
May 02, 2021
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve test output on failures and avoid C compiler warnings about signed/unsigned comparison.
parent
093b633c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
tests/run/py_unicode_strings.pyx
tests/run/py_unicode_strings.pyx
+12
-9
No files found.
tests/run/py_unicode_strings.pyx
View file @
a8e0f626
# mode: run
# tag: py_unicode_strings
import
sys
cimport
cython
from
libc.string
cimport
memcpy
,
strcpy
from
libc.string
cimport
memcpy
cdef
bint
Py_UNICODE_equal
(
const
Py_UNICODE
*
u1
,
const
Py_UNICODE
*
u2
):
while
u1
[
0
]
!=
0
and
u2
[
0
]
!=
0
and
u1
[
0
]
==
u2
[
0
]:
u1
+=
1
u2
+=
1
return
u1
[
0
]
==
u2
[
0
]
cdef
size_t
i
=
0
while
u1
[
i
]
!=
0
and
u2
[
i
]
!=
0
and
u1
[
i
]
==
u2
[
i
]:
i
+=
1
if
u1
[
i
]
!=
u2
[
i
]:
print
(
f"Mismatch at position
{
i
}
:
{
<
long
>
u1
[
i
]
}
!=
{
<
long
>
u2
[
i
]
}
"
)
return
u1
[
i
]
==
u2
[
i
]
ctypedef
Py_UNICODE
*
LPWSTR
...
...
@@ -48,9 +50,10 @@ def test_c_to_python():
assert
c_pu_str
[
1
:
7
]
==
uobj
[
1
:
7
]
assert
c_wstr
[
1
:
7
]
==
uobj
[
1
:
7
]
assert
c_pu_arr
[
1
]
==
uobj
[
1
]
assert
c_pu_str
[
1
]
==
uobj
[
1
]
assert
c_wstr
[
1
]
==
uobj
[
1
]
cdef
Py_UNICODE
ch
=
uobj
[
1
]
# Py_UCS4 is unsigned, Py_UNICODE is usually signed.
assert
c_pu_arr
[
1
]
==
ch
assert
c_pu_str
[
1
]
==
ch
assert
c_wstr
[
1
]
==
ch
assert
len
(
c_pu_str
)
==
8
assert
len
(
c_pu_arr
)
==
8
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment