Implement basic C++ exception test for C backend.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13479 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ffb2b6b73b
commit
130ae2cb26
3 changed files with 40 additions and 1 deletions
|
|
@ -22,7 +22,8 @@ CPP_TEST_CASES += \
|
|||
cpp_basic_global_enum \
|
||||
cpp_basic_global_var_atom \
|
||||
cpp_basic_global_var_class \
|
||||
cpp_basic_namespaced_class
|
||||
cpp_basic_namespaced_class \
|
||||
c_backend_cpp_exception
|
||||
|
||||
#
|
||||
# BROKEN TEST CASES:
|
||||
|
|
|
|||
13
Examples/test-suite/c/c_backend_cpp_exception_runme.c
Normal file
13
Examples/test-suite/c/c_backend_cpp_exception_runme.c
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#include <assert.h>
|
||||
#include "c_backend_cpp_exception/c_backend_cpp_exception_proxy.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(checkVal == 0);
|
||||
throwSomeKnownException();
|
||||
assert(checkVal == 1);
|
||||
throwSomeUnknownException();
|
||||
assert(checkVal == 2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
25
Examples/test-suite/c_backend_cpp_exception.i
Normal file
25
Examples/test-suite/c_backend_cpp_exception.i
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
%module c_backend_cpp_exception
|
||||
|
||||
%exception {
|
||||
try {
|
||||
$action
|
||||
} catch(SomeKnownException) {
|
||||
checkVal = 1;
|
||||
} catch(...) {
|
||||
checkVal = 2;
|
||||
}
|
||||
}
|
||||
|
||||
%inline %{
|
||||
class SomeKnownException{};
|
||||
class SomeUnkownException{};
|
||||
int checkVal = 0;
|
||||
|
||||
void throwSomeKnownException(void) {
|
||||
throw SomeKnownException();
|
||||
}
|
||||
|
||||
void throwSomeUnknownException(void) {
|
||||
throw SomeUnkownException();
|
||||
}
|
||||
%}
|
||||
Loading…
Add table
Add a link
Reference in a new issue