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.
This commit is contained in:
Vadim Zeitlin 2019-07-24 20:47:59 +02:00
commit 690bf8e020
5 changed files with 31 additions and 26 deletions

View file

@ -1,4 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cast_operator/cast_operator_wrap.h"
@ -7,6 +9,6 @@ int main() {
if (strcmp(A_tochar(a), "hi"))
fprintf(stderr, "cast failed\n");
A_delete(a);
SWIG_exit(0);
exit(0);
}

View file

@ -15,7 +15,7 @@ int main() {
char *str = GetCharHeapString();
if (strcmp(str, CPLUSPLUS_MSG) != 0) {
fprintf(stderr, "Test char get 1 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
DeleteCharHeapString();
}
@ -24,7 +24,7 @@ int main() {
const char *str = GetConstCharProgramCodeString();
if (strcmp(str, CPLUSPLUS_MSG) != 0) {
fprintf(stderr, "Test char get 2 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
DeleteCharHeapString();
}
@ -33,7 +33,7 @@ int main() {
char *str = GetCharStaticString();
if (strcmp(str, CPLUSPLUS_MSG) != 0) {
fprintf(stderr, "Test char get 3 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -41,7 +41,7 @@ int main() {
char *str = GetCharStaticStringFixed();
if (strcmp(str, CPLUSPLUS_MSG) != 0) {
fprintf(stderr, "Test char get 4 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -49,7 +49,7 @@ int main() {
const char *str = GetConstCharStaticStringFixed();
if (strcmp(str, CPLUSPLUS_MSG) != 0) {
fprintf(stderr, "Test char get 5 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -59,7 +59,7 @@ int main() {
sprintf(str, "%s%d", OTHERLAND_MSG, i);
if (!SetCharHeapString(str, i)) {
fprintf(stderr, "Test char set 1 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -69,7 +69,7 @@ int main() {
sprintf(str, "%s%d", OTHERLAND_MSG, i);
if (!SetCharStaticString(str, i)) {
fprintf(stderr, "Test char set 2 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -78,7 +78,7 @@ int main() {
sprintf(str, "%s%d", OTHERLAND_MSG, i);
if (!SetCharArrayStaticString(str, i)) {
fprintf(stderr, "Test char set 3 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -87,7 +87,7 @@ int main() {
sprintf(str, "%s%d", OTHERLAND_MSG, i);
if (!SetConstCharHeapString(str, i)) {
fprintf(stderr, "Test char set 4 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -96,7 +96,7 @@ int main() {
sprintf(str, "%s%d", OTHERLAND_MSG, i);
if (!SetConstCharStaticString(str, i)) {
fprintf(stderr, "Test char set 5 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -105,7 +105,7 @@ int main() {
sprintf(str, "%s%d", OTHERLAND_MSG, i);
if (!SetConstCharArrayStaticString(str, i)) {
fprintf(stderr, "Test char set 6 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -116,7 +116,7 @@ int main() {
char *pong = CharPingPong(ping);
if (strcmp(ping, pong) != 0) {
fprintf(stderr, "Test PingPong 1 failed.\nExpected:%d\nReceived:%d\n", ping, pong);
SWIG_exit(1);
exit(1);
}
}
@ -128,7 +128,7 @@ int main() {
global_char = str;
if (strcmp(global_char, str) != 0) {
fprintf(stderr, "Test variables 1 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -138,7 +138,7 @@ int main() {
sprintf(global_char_array1, "%s%d", OTHERLAND_MSG, i);
if (strcmp(global_char_array1, str) != 0) {
fprintf(stderr, "Test variables 2 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -148,14 +148,14 @@ int main() {
sprintf(global_char_array2, "%s%d", OTHERLAND_MSG, i);
if (strcmp(global_char_array2, str) != 0) {
fprintf(stderr, "Test variables 3 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
for (i=0; i<count; i++) {
if (strcmp(global_const_char, CPLUSPLUS_MSG) != 0) {
fprintf(stderr, "Test variables 3 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
@ -163,14 +163,14 @@ int main() {
for (i=0; i<count; i++) {
if (strcmp(global_const_char_array1, CPLUSPLUS_MSG) != 0) {
fprintf(stderr, "Test variables 5 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
for (i=0; i<count; i++) {
if (strcmp(global_const_char_array2, CPLUSPLUS_MSG) != 0) {
fprintf(stderr, "Test variables 6 failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
*/
@ -181,7 +181,7 @@ int main() {
char **str = GetConstCharPointerRef();
if (strcmp(*str, CPLUSPLUS_MSG) != 0) {
fprintf(stderr, "Test char pointer ref get failed, iteration %d\n",i);
SWIG_exit(1);
exit(1);
}
}
@ -190,10 +190,10 @@ int main() {
sprintf(str, "%s%d", OTHERLAND_MSG, i);
if (!SetConstCharPointerRef((char **) &str, i)) {
fprintf(stderr, "Test char pointer ref set failed, iteration %d\n", i);
SWIG_exit(1);
exit(1);
}
}
SWIG_exit(0);
exit(0);
}

View file

@ -1,4 +1,5 @@
#include <assert.h>
#include <stdlib.h>
#include "enums/enums_wrap.h"
@ -8,6 +9,6 @@ int main() {
bar2(1);
bar3(1);
bar1(1);
SWIG_exit(0);
exit(0);
}

View file

@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include "exception_order/exception_order_wrap.h"
@ -40,6 +41,6 @@ int main() {
SWIG_PendingException_reset();
}
SWIG_exit(0);
exit(0);
}

View file

@ -1,8 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
#include "operator_overload/operator_overload_wrap.h"
#define assert(x,msg) if (!x) { printf("%d: %s\n", x, msg); SWIG_exit(0); }
#define assert(x,msg) if (!x) { printf("%d: %s\n", x, msg); exit(1); }
int main() {
Op_sanity_check();
@ -21,5 +22,5 @@ int main() {
Op_delete(op1);
Op_delete(op2);
Op_delete(op3);
SWIG_exit(0);
exit(0);
}