modify test-suite (barring python atm) to not rely on the -I path to find the input .i file - removes the new warning 125 and sets up the test-suite for testing with ccache. This change required the use of -outcurrentdir and moving the .i files from the language subdirectories to the directory above along with some .i file name changes.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10949 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2008-11-26 21:35:15 +00:00
commit db83e51441
61 changed files with 390 additions and 709 deletions

View file

@ -10,7 +10,9 @@ top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CPP_TEST_CASES += \
cell_deref
li_std_pair_extra \
li_std_string_extra \
octave_cell_deref
CPP_TEST_BROKEN += \
implicittest \

View file

@ -1,15 +0,0 @@
%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

@ -1,68 +0,0 @@
%module(naturalvar="1") implicittest
%implicitconv;
%inline
{
struct B { };
}
%inline
{
struct A
{
int ii;
A(int i) { ii = 1; }
A(double d) { ii = 2; }
A(const B& b) { ii = 3; }
explicit A(char *s) { ii = 4; }
int get() const { return ii; }
};
int get(const A& a) { return a.ii; }
template <class T>
struct A_T
{
int ii;
A_T(int i) { ii = 1; }
A_T(double d) { ii = 2; }
A_T(const B& b) { ii = 3; }
explicit A_T(char *s) { ii = 4; }
int get() const { return ii; }
};
}
%inline
{
struct Foo
{
int ii;
Foo(){ ii = 0;}
Foo(int){ ii = 1;}
Foo(double){ ii = 2;}
explicit Foo(char *s){ii = 3;}
Foo(const Foo& f){ ii = f.ii;}
};
struct Bar
{
int ii;
Foo f;
Bar() {ii = -1;}
Bar(const Foo& ff){ ii = ff.ii;}
};
int get_b(const Bar&b) { return b.ii; }
Foo foo;
}
%template(A_int) A_T<int>;

View file

@ -1,210 +0,0 @@
%module li_std_pair
//
// activate the automatic comparison methods generation (==,!=,...)
//
%{
#include <algorithm> // for std::swap
%}
%include std_pair.i
%include std_string.i
%include std_complex.i
%inline
%{
struct A
{
int val;
A(int v = 0): val(v)
{
}
};
struct B
{
};
%}
%std_comp_methods(std::pair<std::string, int>);
namespace std {
%template(CIntPair) pair<const int, const int>;
%template() pair<double, double>;
%template(ShortPair) pair<short, short>;
%template(IntPair) pair<int, int>;
%extend pair<int, int>
{
%template(pair) pair<short,short>;
}
%template(SIPair) pair<std::string, int>;
%template(CIPair) pair<std::complex<double>, int>;
%template(SIIPair) pair<std::pair<std::string, int>, int>;
%template(AIntPair) pair<A, int>;
%template(CCIntPair) pair<const A, const pair<int, int> >;
%template(ABPair) pair<A, B>;
%template(IntAPair) pair<int, A>;
%template(pairP1) pair<int, A*>;
%template(pairP2) pair<A*, int>;
%template(pairP3) pair<A*, A*>;
%template(pairP4) pair<int, int*>;
%template(pairP5) pair<int*, int>;
%template(pairP6) pair<int*, int*>;
}
%std_comp_methods(std::pair<std::pair<std::string, int>, int>);
%apply std::pair<int,int> *INOUT {std::pair<int,int> *INOUT2};
%inline %{
/* Test the "out" typemap for pair<T, U> */
std::pair<int, int> makeIntPair(int a, int b) {
return std::make_pair(a, b);
}
/**
* There is no "out" typemap for a pointer to a pair, so
* this should return a wrapped instance of a std::pair
* instead of the native "array" type for the target language.
*/
std::pair<int, int> * makeIntPairPtr(int a, int b) {
static std::pair<int, int> p = std::make_pair(a, b);
return &p;
}
/**
* There is no "out" typemap for a non-const reference to a pair, so
* this should return a wrapped instance of a std::pair instead of
* the native "array" type for the target language.
*/
std::pair<int, int>& makeIntPairRef(int a, int b) {
static std::pair<int, int> p = std::make_pair(a, b);
return p;
}
/**
* There is no "out" typemap for a const reference to a pair, so
* this should return a wrapped instance of a std::pair
* instead of the native "array" type for the target language.
*/
const std::pair<int, int> & makeIntPairConstRef(int a, int b) {
static std::pair<int, int> p = std::make_pair(a, b);
return p;
}
/* Test the "in" typemap for pair<T, U> */
int product1(std::pair<int, int> p) {
return p.first*p.second;
}
/* Test the "in" typemap for const pair<T, U>& */
int product2(const std::pair<int, int>& p) {
return p.first*p.second;
}
std::pair<int, int>
p_ident(std::pair<int, int> p, const std::pair<int, int>& q) {
return p;
}
std::pair<int, A*>
p_identa(const std::pair<int, A*>& p) {
return p;
}
void
d_inout(double *INOUT) {
*INOUT += *INOUT;
}
void
d_inout(int *INOUT) {
*INOUT += *INOUT;
}
int
d_inout2(double *INOUT) {
*INOUT += *INOUT;
return 1;
}
void
p_inout(std::pair<int, int> *INOUT) {
std::swap(INOUT->first, INOUT->second);
}
int
p_inout2(std::pair<int, int> *INOUT) {
std::swap(INOUT->first, INOUT->second);
return 1;
}
void
p_inout3(std::pair<int,int> *INOUT, std::pair<int,int> *INOUT2) {
std::swap(*INOUT, *INOUT2);
}
void
p_inoutd(std::pair<double, double> *INOUT) {
std::swap(INOUT->first, INOUT->second);
}
std::string
s_ident(const std::string& s) {
return s;
}
#if 0
std::pair<char, char>
p_ident(std::pair<char, char> p, const std::pair<char, char>& q) {
return p;
}
/* Test the "in" typemap for const pair<T, U>* */
std::pair<A, B>
p_ident(std::pair<A, B> p, const std::pair<A, B>& q) {
return q;
}
/* Test the "in" typemap for const pair<T, U>* */
std::pair<int, A>
p_ident(std::pair<int, A> p, const std::pair<int, A>& q) {
return p;
}
std::pair<int, int>
p_ident(std::pair<int, int> p, const std::pair<A, int>& q) {
return p;
}
std::pair<int, int>
p_ident(std::pair<int, int> p, const std::pair<A, B>& q) {
return p;
}
#endif
%}
namespace std
{
%template(paircA1) pair<const int, A*>;
%template(paircA2) pair<const int, const A*>;
%template(pairiiA) pair<int,pair<int, A*> >;
}

View file

@ -0,0 +1,69 @@
li_std_pair_extra
p = {1,2};
p1 = li_std_pair_extra.p_inout(p);
assert(all(cell2mat(p1)==[2,1]));
p2 = li_std_pair_extra.p_inoutd(p1);
assert(all(cell2mat(p2)==[1,2]));
d1 = li_std_pair_extra.d_inout(2);
assert(d1==4);
[i,d2] = li_std_pair_extra.d_inout2(2);
assert(all([i,d2]==[1,4]));
[i,p] = li_std_pair_extra.p_inout2(p);
assert(i==1&&all([cell2mat(p)]==[2,1]));
[p3,p4] = li_std_pair_extra.p_inout3(p1,p1);
assert(all(cell2mat(p3)==[2,1]));
assert(all(cell2mat(p4)==[2,1]));
psi = li_std_pair_extra.SIPair("hello",1);
assert(psi=={"hello",1});
pci = li_std_pair_extra.CIPair(complex(1,2),1);
assert(pci.first==complex(1,2)&&pci.second==1);
psi = li_std_pair_extra.SIPair("hi",1);
assert(psi.first=="hi"&&psi.second==1);
psii = li_std_pair_extra.SIIPair(psi,1);
assert(psii.first.first=="hi");
assert(psii.first.second==1);
assert(psii.second==1);
a = li_std_pair_extra.A();
b = li_std_pair_extra.B();
pab = li_std_pair_extra.ABPair(a,b);
pab.first = a;
pab.first.val = 2;
assert(pab.first.val == 2);
pci = li_std_pair_extra.CIntPair(1,0);
assert(pci.first==1&&pci.second==0);
a = li_std_pair_extra.A(5);
p1 = li_std_pair_extra.pairP1(1,a);
p2 = li_std_pair_extra.pairP2(a,1);
p3 = li_std_pair_extra.pairP3(a,a);
assert(a.val == li_std_pair_extra.p_identa(p1){2}.val);
p = li_std_pair_extra.IntPair(1,10);
assert(p.first==1&&p.second==10);
p.first = 1;
assert(p.first==1);
p = li_std_pair_extra.paircA1(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
p = li_std_pair_extra.paircA2(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
#pp = li_std_pair_extra.pairiiA(1,p); # conversion pb re const of pairA1/A2
pp = li_std_pair_extra.pairiiA(1,{1,A()});

View file

@ -1,69 +0,0 @@
li_std_pair
p = {1,2};
p1 = li_std_pair.p_inout(p);
assert(all(cell2mat(p1)==[2,1]));
p2 = li_std_pair.p_inoutd(p1);
assert(all(cell2mat(p2)==[1,2]));
d1 = li_std_pair.d_inout(2);
assert(d1==4);
[i,d2] = li_std_pair.d_inout2(2);
assert(all([i,d2]==[1,4]));
[i,p] = li_std_pair.p_inout2(p);
assert(i==1&&all([cell2mat(p)]==[2,1]));
[p3,p4] = li_std_pair.p_inout3(p1,p1);
assert(all(cell2mat(p3)==[2,1]));
assert(all(cell2mat(p4)==[2,1]));
psi = li_std_pair.SIPair("hello",1);
assert(psi=={"hello",1});
pci = li_std_pair.CIPair(complex(1,2),1);
assert(pci.first==complex(1,2)&&pci.second==1);
psi = li_std_pair.SIPair("hi",1);
assert(psi.first=="hi"&&psi.second==1);
psii = li_std_pair.SIIPair(psi,1);
assert(psii.first.first=="hi");
assert(psii.first.second==1);
assert(psii.second==1);
a = li_std_pair.A();
b = li_std_pair.B();
pab = li_std_pair.ABPair(a,b);
pab.first = a;
pab.first.val = 2;
assert(pab.first.val == 2);
pci = li_std_pair.CIntPair(1,0);
assert(pci.first==1&&pci.second==0);
a = li_std_pair.A(5);
p1 = li_std_pair.pairP1(1,a);
p2 = li_std_pair.pairP2(a,1);
p3 = li_std_pair.pairP3(a,a);
assert(a.val == li_std_pair.p_identa(p1){2}.val);
p = li_std_pair.IntPair(1,10);
assert(p.first==1&&p.second==10);
p.first = 1;
assert(p.first==1);
p = li_std_pair.paircA1(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
p = li_std_pair.paircA2(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
#pp = li_std_pair.pairiiA(1,p); # conversion pb re const of pairA1/A2
pp = li_std_pair.pairiiA(1,{1,A()});

View file

@ -1,55 +0,0 @@
%module li_std_string
%naturalvar A;
%include <std_basic_string.i>
%include <std_string.i>
%inline %{
struct A : std::string
{
A(const std::string& s) : std::string(s)
{
}
};
struct B
{
B(const std::string& s) : cname(0), name(s), a(s)
{
}
char *cname;
std::string name;
A a;
};
const char* test_ccvalue(const char* x) {
return x;
}
char* test_cvalue(char* x) {
return x;
}
std::basic_string<char> test_value_basic1(std::basic_string<char> x) {
return x;
}
std::basic_string<char,std::char_traits<char> > test_value_basic2(std::basic_string<char,std::char_traits<char> > x) {
return x;
}
std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_basic3(std::basic_string<char,std::char_traits<char>,std::allocator<char> > x) {
return x;
}
%}
%include ../li_std_string.i

View file

@ -1,27 +1,27 @@
li_std_string
li_std_string_extra
x="hello";
if (li_std_string.test_ccvalue(x) != x)
if (li_std_string_extra.test_ccvalue(x) != x)
error("bad string mapping")
endif
if (li_std_string.test_cvalue(x) != x)
if (li_std_string_extra.test_cvalue(x) != x)
error("bad string mapping")
endif
if (li_std_string.test_value(x) != x)
error("bad string mapping: %s, %s", x, li_std_string.test_value(x))
if (li_std_string_extra.test_value(x) != x)
error("bad string mapping: %s, %s", x, li_std_string_extra.test_value(x))
endif
if (li_std_string.test_const_reference(x) != x)
if (li_std_string_extra.test_const_reference(x) != x)
error("bad string mapping")
endif
s = li_std_string.string("he");
s = li_std_string_extra.string("he");
#s += "ll"
#s.append('o')
s = s + "llo";
@ -34,25 +34,25 @@ if (s[1:4] != x[1:4])
error("bad string mapping")
endif
if (li_std_string.test_value(s) != x)
if (li_std_string_extra.test_value(s) != x)
error("bad string mapping")
endif
if (li_std_string.test_const_reference(s) != x)
if (li_std_string_extra.test_const_reference(s) != x)
error("bad string mapping")
endif
a = li_std_string.A(s);
a = li_std_string_extra.A(s);
if (li_std_string.test_value(a) != x)
if (li_std_string_extra.test_value(a) != x)
error("bad string mapping")
endif
if (li_std_string.test_const_reference(a) != x)
if (li_std_string_extra.test_const_reference(a) != x)
error("bad string mapping")
endif
b = li_std_string.string(" world");
b = li_std_string_extra.string(" world");
s = a + b;
if (a + b != "hello world")
@ -74,48 +74,48 @@ endif
s = "hello world";
b = li_std_string.B("hi");
b = li_std_string_extra.B("hi");
b.name = li_std_string.string("hello");
b.name = li_std_string_extra.string("hello");
if (b.name != "hello")
error("bad string mapping")
endif
b.a = li_std_string.A("hello");
b.a = li_std_string_extra.A("hello");
if (b.a != "hello")
error("bad string mapping")
endif
if (li_std_string.test_value_basic1(x) != x)
if (li_std_string_extra.test_value_basic1(x) != x)
error("bad string mapping")
endif
if (li_std_string.test_value_basic2(x) != x)
if (li_std_string_extra.test_value_basic2(x) != x)
error("bad string mapping")
endif
if (li_std_string.test_value_basic3(x) != x)
if (li_std_string_extra.test_value_basic3(x) != x)
error("bad string mapping")
endif
# Global variables
s = "initial string";
if (li_std_string.cvar.GlobalString2 != "global string 2")
if (li_std_string_extra.cvar.GlobalString2 != "global string 2")
error("GlobalString2 test 1")
endif
li_std_string.cvar.GlobalString2 = s;
if (li_std_string.cvar.GlobalString2 != s)
li_std_string_extra.cvar.GlobalString2 = s;
if (li_std_string_extra.cvar.GlobalString2 != s)
error("GlobalString2 test 2")
endif
if (li_std_string.cvar.ConstGlobalString != "const global string")
if (li_std_string_extra.cvar.ConstGlobalString != "const global string")
error("ConstGlobalString test")
endif
# Member variables
myStructure = li_std_string.Structure();
myStructure = li_std_string_extra.Structure();
if (myStructure.MemberString2 != "member string 2")
error("MemberString2 test 1")
endif
@ -127,36 +127,36 @@ if (myStructure.ConstMemberString != "const member string")
error("ConstMemberString test")
endif
if (li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2")
if (li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2")
error("StaticMemberString2 test 1")
endif
li_std_string.cvar.Structure_StaticMemberString2 = s;
if (li_std_string.cvar.Structure_StaticMemberString2 != s)
li_std_string_extra.cvar.Structure_StaticMemberString2 = s;
if (li_std_string_extra.cvar.Structure_StaticMemberString2 != s)
error("StaticMemberString2 test 2")
endif
if (li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string")
if (li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string")
error("ConstStaticMemberString test")
endif
if (li_std_string.test_reference_input("hello") != "hello")
if (li_std_string_extra.test_reference_input("hello") != "hello")
error
endif
s = li_std_string.test_reference_inout("hello");
s = li_std_string_extra.test_reference_inout("hello");
if (s != "hellohello")
error
endif
if (li_std_string.stdstring_empty() != "")
if (li_std_string_extra.stdstring_empty() != "")
error
endif
if (li_std_string.c_empty() != "")
if (li_std_string_extra.c_empty() != "")
error
endif
if (li_std_string.c_null() != None)
if (li_std_string_extra.c_null() != None)
error
endif

View file

@ -1,4 +1,4 @@
cell_deref;
octave_cell_deref;
assert(func("hello"));
assert(func({"hello"}));