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
Gwenaël Samain
cython
Commits
68e8ed4b
Commit
68e8ed4b
authored
Oct 22, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cpp exception tests.
parent
258a185b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
0 deletions
+86
-0
tests/run/cpp_exceptions.pyx
tests/run/cpp_exceptions.pyx
+71
-0
tests/run/cpp_exceptions_helper.cpp
tests/run/cpp_exceptions_helper.cpp
+15
-0
No files found.
tests/run/cpp_exceptions.pyx
0 → 100644
View file @
68e8ed4b
cdef
int
raise_py_error
()
except
*
:
raise
TypeError
(
"custom"
)
cdef
extern
from
"cpp_exceptions_helper.cpp"
:
cdef
int
raise_int_raw
"raise_int"
(
bint
fire
)
except
+
cdef
int
raise_int_value
"raise_int"
(
bint
fire
)
except
+
ValueError
cdef
int
raise_int_custom
"raise_int"
(
bint
fire
)
except
+
raise_py_error
cdef
int
raise_index_raw
"raise_index"
(
bint
fire
)
except
+
cdef
int
raise_index_value
"raise_index"
(
bint
fire
)
except
+
ValueError
cdef
int
raise_index_custom
"raise_index"
(
bint
fire
)
except
+
raise_py_error
def
test_int_raw
(
bint
fire
):
"""
>>> test_int_raw(False)
>>> test_int_raw(True)
Traceback (most recent call last):
...
RuntimeError: Unknown exception
"""
raise_int_raw
(
fire
)
def
test_int_value
(
bint
fire
):
"""
>>> test_int_value(False)
>>> test_int_value(True)
Traceback (most recent call last):
...
ValueError
"""
raise_int_value
(
fire
)
def
test_int_custom
(
bint
fire
):
"""
>>> test_int_custom(False)
>>> test_int_custom(True)
Traceback (most recent call last):
...
TypeError: custom
"""
raise_int_custom
(
fire
)
def
test_index_raw
(
bint
fire
):
"""
>>> test_index_raw(False)
>>> test_index_raw(True)
Traceback (most recent call last):
...
IndexError: c++ error
"""
raise_index_raw
(
fire
)
def
test_index_value
(
bint
fire
):
"""
>>> test_index_value(False)
>>> test_index_value(True)
Traceback (most recent call last):
...
ValueError: c++ error
"""
raise_index_value
(
fire
)
def
test_index_custom
(
bint
fire
):
"""
>>> test_index_custom(False)
>>> test_index_custom(True)
Traceback (most recent call last):
...
TypeError: custom
"""
raise_index_custom
(
fire
)
tests/run/cpp_exceptions_helper.cpp
0 → 100644
View file @
68e8ed4b
#include <stdexcept>
int
raise_int
(
int
fire
)
{
if
(
fire
)
{
throw
1
;
}
return
0
;
}
int
raise_index
(
int
fire
)
{
if
(
fire
)
{
throw
std
::
out_of_range
(
"c++ error"
);
}
return
0
;
}
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