swig/Examples/test-suite/c/exception_order_runme.c
Vadim Zeitlin 690bf8e020 Replace SWIG_exit() with just exit() in test code
SWIG_exit() is not declared anywhere, so would need to be explicitly
declared to avoid warnings, while exit() can be declared just by
including <stdlib.h>, so prefer to use the latter, especially because
they're one and the same anyhow.
2019-07-24 20:47:59 +02:00

46 lines
937 B
C

#include <stdio.h>
#include <stdlib.h>
#include "exception_order/exception_order_wrap.h"
int main() {
A* a = A_new();
A_foo(a);
if (!SWIG_PendingException_get()) {
fprintf(stderr, "foo: bad exception order\n");
} else {
SWIG_PendingException_reset();
}
A_bar(a);
if (!SWIG_PendingException_get()) {
fprintf(stderr, "bar: bad exception order\n");
} else {
SWIG_PendingException_reset();
}
A_foobar(a);
if (!SWIG_PendingException_get()) {
fprintf(stderr, "foobar: bad exception order\n");
} else {
SWIG_PendingException_reset();
}
A_barfoo(a, 1);
if (!SWIG_PendingException_get()) {
fprintf(stderr, "barfoo(1): bad exception order\n");
} else {
SWIG_PendingException_reset();
}
A_barfoo(a, 2);
if (!SWIG_PendingException_get()) {
fprintf(stderr, "barfoo(2): bad exception order\n");
} else {
SWIG_PendingException_reset();
}
exit(0);
}