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
4b0a144f
Commit
4b0a144f
authored
Jan 14, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Running C++ operator tests.
parent
0078df28
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
0 deletions
+95
-0
tests/run/cpp_operators.pyx
tests/run/cpp_operators.pyx
+68
-0
tests/run/cpp_operators_helper.h
tests/run/cpp_operators_helper.h
+27
-0
No files found.
tests/run/cpp_operators.pyx
0 → 100644
View file @
4b0a144f
cimport
cython
from
cython
cimport
dereference
as
deref
cdef
extern
from
"cpp_operators_helper.h"
:
cdef
cppclass
TestOps
:
char
*
operator
+
()
char
*
operator
-
()
char
*
operator
*
()
char
*
operator
~
()
char
*
operator
++
()
char
*
operator
--
()
char
*
operator
++
(
int
)
char
*
operator
--
(
int
)
char
*
operator
+
(
int
)
char
*
operator
-
(
int
)
char
*
operator
*
(
int
)
char
*
operator
/
(
int
)
char
*
operator
%
(
int
)
def
test_unops
():
"""
>>> test_unops()
unary+
unary-
unary~
unary*
"""
cdef
TestOps
*
t
=
new
TestOps
()
print
+
t
[
0
]
print
-
t
[
0
]
print
~
t
[
0
]
print
deref
(
t
[
0
])
del
t
def
test_incdec
():
"""
>>> test_incdec()
unary++
unary--
post++
post--
"""
cdef
TestOps
*
t
=
new
TestOps
()
print
cython
.
preincrement
(
t
[
0
])
print
cython
.
predecrement
(
t
[
0
])
print
cython
.
postincrement
(
t
[
0
])
print
cython
.
postdecrement
(
t
[
0
])
del
t
def
test_binop
():
"""
>>> test_binop()
binary+
binary-
binary*
binary/
binary%
"""
cdef
TestOps
*
t
=
new
TestOps
()
print
t
[
0
]
+
1
print
t
[
0
]
-
1
print
t
[
0
]
*
1
print
t
[
0
]
/
1
print
t
[
0
]
%
1
del
t
tests/run/cpp_operators_helper.h
0 → 100644
View file @
4b0a144f
#define UN_OP(op) const char* operator op () { return "unary"#op; }
#define POST_UN_OP(op) const char* operator op (int x) { return "post"#op; }
#define BIN_OP(op) const char* operator op (int x) { return "binary"#op; }
class
TestOps
{
public:
UN_OP
(
-
);
UN_OP
(
+
);
UN_OP
(
*
);
UN_OP
(
~
);
UN_OP
(
!
);
UN_OP
(
&
);
UN_OP
(
++
);
UN_OP
(
--
);
POST_UN_OP
(
++
);
POST_UN_OP
(
--
);
BIN_OP
(
+
);
BIN_OP
(
-
);
BIN_OP
(
*
);
BIN_OP
(
/
);
BIN_OP
(
%
);
};
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