add runtime test for li_cstring

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7337 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-07-18 16:46:53 +00:00
commit d54c46fed2
3 changed files with 22 additions and 1 deletions

View file

@ -11,8 +11,13 @@
%cstring_mutable(char *out4, 32);
%cstring_output_maxsize(char *out5, int max);
%cstring_output_withsize(char *out6, int *size);
#ifdef __cplusplus
%cstring_output_allocate(char **out7, delete [] $1);
%cstring_output_allocate_size(char **out8, int *size, delete [] $1);
#else
%cstring_output_allocate(char **out7, free($1));
%cstring_output_allocate_size(char **out8, int *size, free($1));
#endif
%inline %{
@ -49,9 +54,10 @@ void test4(char *out4) {
void test5(char *out5, int max) {
int i;
for (i = strlen(out5); i < max; i++) {
for (i = 0; i < max; i++) {
out5[i] = 'x';
}
out5[max]='\0';
}
void test6(char *out6, int *size) {
@ -63,13 +69,21 @@ void test6(char *out6, int *size) {
}
void test7(char **out7) {
#ifdef __cplusplus
*out7 = new char[64];
#else
*out7 = malloc(64);
#endif
strcat(*out7,"Hello world!");
}
void test8(char **out8, int *sz) {
int i;
#ifdef __cplusplus
*out8 = new char[128];
#else
*out8 = malloc(128);
#endif
for (i = 0; i < 128; i++) {
*out8[i] = (char) i;
}

View file

@ -24,6 +24,7 @@ CPP_TEST_CASES += \
input \
inplaceadd \
kwargs \
li_cstring \
li_std_except \
li_std_vectora \
li_std_map \
@ -39,6 +40,7 @@ CPP_TEST_CASES += \
C_TEST_CASES += \
file_test \
li_cstring \
nondynamic
#

View file

@ -0,0 +1,5 @@
from li_cstring import *
if test5(4) != 'xxxx':
raise RuntimeError