Cosmetic spacing changes in test case
This commit is contained in:
parent
abf39433e3
commit
a16a818523
2 changed files with 189 additions and 172 deletions
|
|
@ -10,100 +10,112 @@ public class multiple_inheritance_abstract_runme {
|
|||
System.exit(1);
|
||||
}
|
||||
}
|
||||
//Test base class as a parameter in java
|
||||
int jfoo1(CBase1 cb1){
|
||||
return cb1.foo1();
|
||||
}
|
||||
int jbar1(ABase1 ab1){
|
||||
return ab1.bar1();
|
||||
}
|
||||
int jfoo2(CBase2 cb2){
|
||||
return cb2.foo2();
|
||||
}
|
||||
|
||||
//Test base class as a parameter in java
|
||||
int jfoo1(CBase1 cb1){
|
||||
return cb1.foo1();
|
||||
}
|
||||
int jbar1(ABase1 ab1){
|
||||
return ab1.bar1();
|
||||
}
|
||||
int jfoo2(CBase2 cb2){
|
||||
return cb2.foo2();
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
//Test Derived1
|
||||
Derived1 d1=new Derived1();
|
||||
if(d1.foo1()!=3)
|
||||
throw new RuntimeException("Derived1::foo1() failed in multiple_inheritance_abstract");
|
||||
if(d1.foo2()!=4)
|
||||
throw new RuntimeException("Derived::foo2() failed in multiple_inheritance_abstract");
|
||||
//Test Derived2
|
||||
Derived2 d2=new Derived2();
|
||||
if(d2.foo1()!=6)
|
||||
throw new RuntimeException("Derived2::foo1() failed in multiple_inheritance_abstract");
|
||||
if(d2.bar1()!=5)
|
||||
throw new RuntimeException("Derived2::bar1() failed in multiple_inheritance_abstract");
|
||||
//Test Derived3
|
||||
Derived3 d3=new Derived3();
|
||||
if( d3.foo1()!=7)
|
||||
throw new RuntimeException("Derived3::foo1() failed in multiple_inheritance_abstract");
|
||||
if(d3.foo2()!=8)
|
||||
throw new RuntimeException("Derived3::foo2() failed in multiple_inheritance_abstract");
|
||||
if(d3.bar1()!=9)
|
||||
throw new RuntimeException("Derived3::bar1() failed in multiple_inheritance_abstract");
|
||||
//Test interfaces from c++ classes
|
||||
CBase1 cb1=new SWIGTYPE_CBase1();
|
||||
CBase2 cb2=new SWIGTYPE_CBase2();
|
||||
if(cb1.foo1()!=1)
|
||||
//Test Derived1
|
||||
Derived1 d1=new Derived1();
|
||||
if(d1.foo1()!=3)
|
||||
throw new RuntimeException("Derived1::foo1() failed in multiple_inheritance_abstract");
|
||||
if(d1.foo2()!=4)
|
||||
throw new RuntimeException("Derived::foo2() failed in multiple_inheritance_abstract");
|
||||
|
||||
//Test Derived2
|
||||
Derived2 d2=new Derived2();
|
||||
if(d2.foo1()!=6)
|
||||
throw new RuntimeException("Derived2::foo1() failed in multiple_inheritance_abstract");
|
||||
if(d2.bar1()!=5)
|
||||
throw new RuntimeException("Derived2::bar1() failed in multiple_inheritance_abstract");
|
||||
|
||||
//Test Derived3
|
||||
Derived3 d3=new Derived3();
|
||||
if( d3.foo1()!=7)
|
||||
throw new RuntimeException("Derived3::foo1() failed in multiple_inheritance_abstract");
|
||||
if(d3.foo2()!=8)
|
||||
throw new RuntimeException("Derived3::foo2() failed in multiple_inheritance_abstract");
|
||||
if(d3.bar1()!=9)
|
||||
throw new RuntimeException("Derived3::bar1() failed in multiple_inheritance_abstract");
|
||||
|
||||
//Test interfaces from c++ classes
|
||||
CBase1 cb1=new SWIGTYPE_CBase1();
|
||||
CBase2 cb2=new SWIGTYPE_CBase2();
|
||||
if(cb1.foo1()!=1)
|
||||
throw new RuntimeException("CBase1::foo1() failed in multiple_inheritance_abstract");
|
||||
if(cb2.foo2()!=2)
|
||||
if(cb2.foo2()!=2)
|
||||
throw new RuntimeException("CBase2::foo2() failed in multiple_inheritance_abstract");
|
||||
//Test abstract class as return value
|
||||
ABase1 ab1=d3.clone();
|
||||
if( ab1.bar1()!=9)
|
||||
throw new RuntimeException("Derived3::bar1() through ABase1 failed in multiple_inheritance_abstract");
|
||||
//Test concrete base class as return value
|
||||
CBase1 cb6=d2.clone();
|
||||
CBase2 cb7=d1.clone();
|
||||
if(cb6.foo1()!=6)
|
||||
|
||||
//Test abstract class as return value
|
||||
ABase1 ab1=d3.clone();
|
||||
if( ab1.bar1()!=9)
|
||||
throw new RuntimeException("Derived3::bar1() through ABase1 failed in multiple_inheritance_abstract");
|
||||
|
||||
//Test concrete base class as return value
|
||||
CBase1 cb6=d2.clone();
|
||||
CBase2 cb7=d1.clone();
|
||||
if(cb6.foo1()!=6)
|
||||
throw new RuntimeException("Derived2::foo1() through CBase1 failed in multiple_inheritance_abstract");
|
||||
if(cb7.foo2()!=4)
|
||||
throw new RuntimeException("Derived1:foo2() through ABase1 failed in multiple_inheritance_abstract");
|
||||
//Test multi inheritance
|
||||
CBase1 cb3=new Derived1();
|
||||
CBase1 cb4=new Derived3();
|
||||
CBase2 cb5=new Derived3();
|
||||
ABase1 ab6=new Derived2();
|
||||
if(cb3.foo1()!=3)
|
||||
if(cb7.foo2()!=4)
|
||||
throw new RuntimeException("Derived1:foo2() through ABase1 failed in multiple_inheritance_abstract");
|
||||
|
||||
//Test multi inheritance
|
||||
CBase1 cb3=new Derived1();
|
||||
CBase1 cb4=new Derived3();
|
||||
CBase2 cb5=new Derived3();
|
||||
ABase1 ab6=new Derived2();
|
||||
if(cb3.foo1()!=3)
|
||||
throw new RuntimeException("Derived1::foo1()through CBase1 failed in multiple_inheritance_abstract");
|
||||
if(cb4.foo1()!=7)
|
||||
if(cb4.foo1()!=7)
|
||||
throw new RuntimeException("Derived3::foo1()through CBase1 failed in multiple_inheritance_abstract");
|
||||
if(cb5.foo2()!=8)
|
||||
if(cb5.foo2()!=8)
|
||||
throw new RuntimeException("Derived3::foo2()through CBase2 failed in multiple_inheritance_abstract");
|
||||
if(ab6.bar1()!=5)
|
||||
if(ab6.bar1()!=5)
|
||||
throw new RuntimeException("Derived2::bar1()through ABase1 failed in multiple_inheritance_abstract");
|
||||
//Test base classes as parameter in java
|
||||
multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme();
|
||||
if(mhar.jfoo1(d1)!=3)
|
||||
throw new RuntimeException("jfoo1()through Derived1 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jfoo1(d2)!=6)
|
||||
throw new RuntimeException("jfoo1()through Derived2 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jfoo1(d3)!=7)
|
||||
throw new RuntimeException("jfoo1()through Derived3 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jfoo2(d1)!=4)
|
||||
throw new RuntimeException("jfoo2()through Derived1 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jfoo2(d3)!=8)
|
||||
throw new RuntimeException("jfoo2()through Derived3 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jbar1(d2)!=5)
|
||||
throw new RuntimeException("jbar1()through Derived2 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jbar1(d3)!=9)
|
||||
throw new RuntimeException("jbar1()through Derived3 as parameter failed in multiple_inheritance_abstract");
|
||||
/*//Test ABase1 as a parameter
|
||||
if(multiple_inheritance_abstract.foo6(d2)!=5)
|
||||
throw new RuntimeException("foo6() through Derived2 as a parameter failed in multiple_inheritance_abstract");
|
||||
if(multiple_inheritance_abstract.foo6(d3)!=9)
|
||||
throw new RuntimeException("foo6() through Derived3 as a parameter failed in multiple_inheritance_abstract");
|
||||
//Test CBase1 CBase2 as parameters
|
||||
if(multiple_inheritance_abstract.foo7(d3)!=7)
|
||||
throw new RuntimeException("foo7() ,Derived3 as a parameter failed in multiple_inheritance_abstract");
|
||||
if(multiple_inheritance_abstract.foo7(d1)!=3)
|
||||
throw new RuntimeException("foo7() ,Derived1 as a parameter failed in multiple_inheritance_abstract");
|
||||
if(multiple_inheritance_abstract.foo7(d2)!=6)
|
||||
throw new RuntimeException("foo7() ,Derived3 as a parameter failed in multiple_inheritance_abstract");
|
||||
if(multiple_inheritance_abstract.foo8(d3)!=4)
|
||||
throw new RuntimeException("foo8() ,Derived3 as a parameter failed in multiple_inheritance_abstract");
|
||||
if(multiple_inheritance_abstract.foo8(d1)!=8)
|
||||
throw new RuntimeException("foo8() ,Derived1 as a parameter failed in multiple_inheritance_abstract");*/
|
||||
|
||||
}
|
||||
|
||||
//Test base classes as parameter in java
|
||||
multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme();
|
||||
if(mhar.jfoo1(d1)!=3)
|
||||
throw new RuntimeException("jfoo1()through Derived1 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jfoo1(d2)!=6)
|
||||
throw new RuntimeException("jfoo1()through Derived2 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jfoo1(d3)!=7)
|
||||
throw new RuntimeException("jfoo1()through Derived3 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jfoo2(d1)!=4)
|
||||
throw new RuntimeException("jfoo2()through Derived1 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jfoo2(d3)!=8)
|
||||
throw new RuntimeException("jfoo2()through Derived3 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jbar1(d2)!=5)
|
||||
throw new RuntimeException("jbar1()through Derived2 as parameter failed in multiple_inheritance_abstract");
|
||||
if(mhar.jbar1(d3)!=9)
|
||||
throw new RuntimeException("jbar1()through Derived3 as parameter failed in multiple_inheritance_abstract");
|
||||
|
||||
/*
|
||||
//Test ABase1 as a parameter
|
||||
if(multiple_inheritance_abstract.foo6(d2)!=5)
|
||||
throw new RuntimeException("foo6() through Derived2 as a parameter failed in multiple_inheritance_abstract");
|
||||
if(multiple_inheritance_abstract.foo6(d3)!=9)
|
||||
throw new RuntimeException("foo6() through Derived3 as a parameter failed in multiple_inheritance_abstract");
|
||||
|
||||
//Test CBase1 CBase2 as parameters
|
||||
if(multiple_inheritance_abstract.foo7(d3)!=7)
|
||||
throw new RuntimeException("foo7() ,Derived3 as a parameter failed in multiple_inheritance_abstract");
|
||||
if(multiple_inheritance_abstract.foo7(d1)!=3)
|
||||
throw new RuntimeException("foo7() ,Derived1 as a parameter failed in multiple_inheritance_abstract");
|
||||
if(multiple_inheritance_abstract.foo7(d2)!=6)
|
||||
throw new RuntimeException("foo7() ,Derived3 as a parameter failed in multiple_inheritance_abstract");
|
||||
if(multiple_inheritance_abstract.foo8(d3)!=4)
|
||||
throw new RuntimeException("foo8() ,Derived3 as a parameter failed in multiple_inheritance_abstract");
|
||||
if(multiple_inheritance_abstract.foo8(d1)!=8)
|
||||
throw new RuntimeException("foo8() ,Derived1 as a parameter failed in multiple_inheritance_abstract");
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,90 +8,95 @@ DECLARE_INTERFACE_RENAME(CBase2, CBase2, SWIGTYPE_CBase2)
|
|||
#endif
|
||||
|
||||
%inline %{
|
||||
struct CBase1 {
|
||||
virtual void foo9(){
|
||||
return ;
|
||||
}
|
||||
virtual int foo1(){
|
||||
return 1;
|
||||
}
|
||||
int foo3(){
|
||||
return 10;
|
||||
}
|
||||
virtual ~CBase1(){
|
||||
}
|
||||
};
|
||||
struct CBase2{
|
||||
virtual int foo2(){
|
||||
return 2;
|
||||
}
|
||||
virtual ~CBase2(){
|
||||
}
|
||||
};
|
||||
struct ABase1{
|
||||
virtual int bar1()=0;
|
||||
virtual ~ABase1(){
|
||||
}
|
||||
};
|
||||
struct CBase1 {
|
||||
virtual void foo9() {
|
||||
return ;
|
||||
}
|
||||
virtual int foo1() {
|
||||
return 1;
|
||||
}
|
||||
int foo3() {
|
||||
return 10;
|
||||
}
|
||||
virtual ~CBase1() {
|
||||
}
|
||||
};
|
||||
|
||||
struct Derived1 : CBase2,CBase1{
|
||||
virtual int foo1(){
|
||||
return 3;
|
||||
}
|
||||
virtual void foo9(){
|
||||
return;
|
||||
}
|
||||
virtual int foo2(){
|
||||
return 4;
|
||||
}
|
||||
virtual CBase2* clone(){
|
||||
return new Derived1(*this);
|
||||
}
|
||||
};
|
||||
struct Derived2:CBase1,ABase1{
|
||||
virtual int bar1(){
|
||||
return 5;
|
||||
}
|
||||
virtual int foo1(){
|
||||
return 6;
|
||||
}
|
||||
virtual void foo9(){
|
||||
return;
|
||||
}
|
||||
virtual CBase1* clone(){
|
||||
return new Derived2(*this);
|
||||
}
|
||||
};
|
||||
struct Derived3:ABase1,CBase1,CBase2{
|
||||
virtual int foo1(){
|
||||
return 7;
|
||||
}
|
||||
virtual int foo2(){
|
||||
return 8;
|
||||
}
|
||||
virtual int bar1(){
|
||||
return 9;
|
||||
}
|
||||
virtual void foo9(){
|
||||
}
|
||||
virtual ABase1* clone(){
|
||||
return new Derived3(*this);
|
||||
}
|
||||
};
|
||||
ABase1* foo4(Derived3 d){
|
||||
return d.clone();
|
||||
}
|
||||
int foo5(CBase1 cb1,CBase2 cb2){
|
||||
return cb1.foo1()+cb2.foo2();
|
||||
}
|
||||
int foo6(ABase1* pab1){
|
||||
return pab1->bar1();
|
||||
}
|
||||
int foo7(CBase1* pcb1){
|
||||
return pcb1->foo1();
|
||||
}
|
||||
int foo8(CBase2* pcb2){
|
||||
return pcb2->foo2();
|
||||
}
|
||||
struct CBase2 {
|
||||
virtual int foo2() {
|
||||
return 2;
|
||||
}
|
||||
virtual ~CBase2() {
|
||||
}
|
||||
};
|
||||
|
||||
struct ABase1 {
|
||||
virtual int bar1() = 0;
|
||||
virtual ~ABase1() {
|
||||
}
|
||||
};
|
||||
|
||||
struct Derived1 : CBase2, CBase1 {
|
||||
virtual int foo1() {
|
||||
return 3;
|
||||
}
|
||||
virtual void foo9() {
|
||||
return;
|
||||
}
|
||||
virtual int foo2() {
|
||||
return 4;
|
||||
}
|
||||
virtual CBase2 *clone() {
|
||||
return new Derived1(*this);
|
||||
}
|
||||
};
|
||||
|
||||
struct Derived2 : CBase1, ABase1 {
|
||||
virtual int bar1() {
|
||||
return 5;
|
||||
}
|
||||
virtual int foo1() {
|
||||
return 6;
|
||||
}
|
||||
virtual void foo9() {
|
||||
return;
|
||||
}
|
||||
virtual CBase1 *clone() {
|
||||
return new Derived2(*this);
|
||||
}
|
||||
};
|
||||
|
||||
struct Derived3 : ABase1, CBase1, CBase2 {
|
||||
virtual int foo1() {
|
||||
return 7;
|
||||
}
|
||||
virtual int foo2() {
|
||||
return 8;
|
||||
}
|
||||
virtual int bar1() {
|
||||
return 9;
|
||||
}
|
||||
virtual void foo9() {
|
||||
}
|
||||
virtual ABase1 *clone() {
|
||||
return new Derived3(*this);
|
||||
}
|
||||
};
|
||||
|
||||
ABase1 *foo4(Derived3 d) {
|
||||
return d.clone();
|
||||
}
|
||||
int foo5(CBase1 cb1, CBase2 cb2) {
|
||||
return cb1.foo1() + cb2.foo2();
|
||||
}
|
||||
int foo6(ABase1 *pab1) {
|
||||
return pab1->bar1();
|
||||
}
|
||||
int foo7(CBase1 *pcb1) {
|
||||
return pcb1->foo1();
|
||||
}
|
||||
int foo8(CBase2 *pcb2) {
|
||||
return pcb2->foo2();
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue