Add test for null pointer handling ([] taken as null pointer).

Support automatic single cell dereferencing. Add test for it and pass-through cell arrays.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10379 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Xavier Delacour 2008-04-20 14:29:46 +00:00
commit e7894a104b
7 changed files with 52 additions and 6 deletions

View file

@ -13,7 +13,9 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
#CPP_TEST_CASES +=
CPP_TEST_CASES += \
null_pointer \
cell_deref
CPP_TEST_BROKEN += \
implicittest \

View file

@ -0,0 +1,15 @@
%module cell_deref
%inline {
bool func(const char* s) {
return !strcmp("hello",s);
}
Cell func2() {
Cell c(1,2);
c(0) = "hello";
c(1) = 4;
return c;
}
}

View file

@ -0,0 +1,8 @@
cell_deref;
assert(func("hello"));
assert(func({"hello"}));
c = func2();
assert(strcmp(c{1}, "hello"));
assert(c{2} == 4);

View file

@ -0,0 +1,10 @@
%module null_pointer
%inline {
struct A {};
bool func(A* a) {
return !a;
}
}

View file

@ -0,0 +1,3 @@
null_pointer;
assert(func([]));