Added test case for python richcompare operators.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12577 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Stefan Zager 2011-03-31 03:55:42 +00:00
commit 769f6648c8
3 changed files with 161 additions and 0 deletions

View file

@ -0,0 +1,60 @@
/* Test the tp_richcompare functions generated with the -builtin option */
%module python_richcompare
%inline {
class BaseClass {
public:
BaseClass (int i_) : i(i_) {}
~BaseClass () {}
int getValue () const
{ return i; }
bool operator< (const BaseClass& x) const
{ return this->i < x.i; }
bool operator> (const BaseClass& x) const
{ return this->i > x.i; }
bool operator<= (const BaseClass& x) const
{ return this->i <= x.i; }
bool operator>= (const BaseClass& x) const
{ return this->i >= x.i; }
bool operator== (const BaseClass& x) const
{ return this->i == x.i; }
bool operator!= (const BaseClass& x) const
{ return this->i != x.i; }
int i;
};
class SubClassA : public BaseClass {
public:
SubClassA (int i_) : BaseClass(i_) {}
~SubClassA () {}
bool operator== (const SubClassA& x) const
{ return true; }
bool operator== (const BaseClass& x) const
{ return false; }
};
class SubClassB : public BaseClass {
public:
SubClassB (int i_) : BaseClass(i_) {}
~SubClassB () {}
bool operator== (const SubClassB& x) const
{ return true; }
bool operator== (const SubClassA& x) const
{ return false; }
};
}