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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
2bd0a604
Commit
2bd0a604
authored
Oct 17, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simple test for testing truth of C values
parent
d4a1b872
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
0 deletions
+88
-0
tests/run/ctruthtests.pyx
tests/run/ctruthtests.pyx
+88
-0
No files found.
tests/run/ctruthtests.pyx
0 → 100644
View file @
2bd0a604
__doc__
=
u"""
>>> test_int(0)
False
>>> test_int(1)
True
>>> test_short(0)
False
>>> test_short(1)
True
>>> test_Py_ssize_t(0)
False
>>> test_Py_ssize_t(1)
True
>>> test_ptr()
False
>>> test_ptr2()
2
>>> test_attr_int(TestExtInt(0))
False
>>> test_attr_int(TestExtInt(1))
True
>>> test_attr_ptr(TestExtPtr(0))
False
>>> test_attr_ptr(TestExtPtr(1))
True
"""
def
test_ptr
():
cdef
void
*
p
=
NULL
if
p
:
return
True
else
:
return
False
def
test_ptr2
():
cdef
void
*
p1
=
NULL
cdef
void
*
p2
=
NULL
p1
+=
1
if
p1
and
p2
:
return
1
elif
p1
or
p2
:
return
2
else
:
return
3
def
test_int
(
int
i
):
if
i
:
return
True
else
:
return
False
def
test_short
(
short
i
):
if
i
:
return
True
else
:
return
False
def
test_Py_ssize_t
(
Py_ssize_t
i
):
if
i
:
return
True
else
:
return
False
cdef
class
TestExtInt
:
cdef
int
i
def
__init__
(
self
,
i
):
self
.
i
=
i
def
test_attr_int
(
TestExtInt
e
):
if
e
.
i
:
return
True
else
:
return
False
cdef
class
TestExtPtr
:
cdef
void
*
p
def
__init__
(
self
,
int
i
):
self
.
p
=
<
void
*>
i
def
test_attr_ptr
(
TestExtPtr
e
):
if
e
.
p
:
return
True
else
:
return
False
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