1def test_ptr():
2    """
3    >>> test_ptr()
4    False
5    """
6    cdef void* p = NULL
7    if p:
8        return True
9    else:
10        return False
11
12def test_ptr2():
13    """
14    >>> test_ptr2()
15    2
16    """
17    cdef char* p1 = NULL
18    cdef char* p2 = NULL
19    p1 += 1
20
21    if p1 and p2:
22        return 1
23    elif p1 or p2:
24        return 2
25    else:
26        return 3
27
28def test_int(int i):
29    """
30    >>> test_int(0)
31    False
32    >>> test_int(1)
33    True
34    """
35    if i:
36        return True
37    else:
38        return False
39
40def test_short(short i):
41    """
42    >>> test_short(0)
43    False
44    >>> test_short(1)
45    True
46    """
47    if i:
48        return True
49    else:
50        return False
51
52def test_Py_ssize_t(Py_ssize_t i):
53    """
54    >>> test_Py_ssize_t(0)
55    False
56    >>> test_Py_ssize_t(1)
57    True
58    """
59    if i:
60        return True
61    else:
62        return False
63
64cdef class TestExtInt:
65    cdef int i
66    def __init__(self, i): self.i = i
67
68def test_attr_int(TestExtInt e):
69    """
70    >>> test_attr_int(TestExtInt(0))
71    False
72    >>> test_attr_int(TestExtInt(1))
73    True
74    """
75    if e.i:
76        return True
77    else:
78        return False
79
80ctypedef union _aux:
81    size_t i
82    void *p
83
84cdef class TestExtPtr:
85    cdef void* p
86    def __init__(self, int i):
87        cdef _aux aux
88        aux.i = i
89        self.p = aux.p
90
91def test_attr_ptr(TestExtPtr e):
92    """
93    >>> test_attr_ptr(TestExtPtr(0))
94    False
95    >>> test_attr_ptr(TestExtPtr(1))
96    True
97    """
98    if e.p:
99        return True
100    else:
101        return False
102