mirror of
https://github.com/boostorg/python.git
synced 2026-01-22 17:32:55 +00:00
- added a case: wrapper for a virtual method
[SVN r18062]
This commit is contained in:
@@ -34,6 +34,13 @@ struct C
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct A
|
||||
{
|
||||
virtual int f() { return 1; };
|
||||
};
|
||||
|
||||
int call_foo(A* a){ return a->f(); }
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -13,3 +13,9 @@ list MulWrapper(wrappertest::C& c, int value){
|
||||
|
||||
C = Class('wrappertest::C', 'wrappertest.h')
|
||||
set_wrapper(C.Mul, mul)
|
||||
|
||||
|
||||
A = Class('wrappertest::A', 'wrappertest.h')
|
||||
set_wrapper(A.f, 'f_wrapper')
|
||||
|
||||
Function('wrappertest::call_foo', 'wrappertest.h')
|
||||
|
||||
@@ -23,4 +23,6 @@ list RangeWrapper(int count){
|
||||
return VectorToList(wrappertest::Range(count));
|
||||
}
|
||||
|
||||
int f_wrapper(wrappertest::A*) { return 10; }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,5 +7,14 @@ class WrapperTest(unittest.TestCase):
|
||||
self.assertEqual(Range(10), range(10))
|
||||
self.assertEqual(C().Mul(10), [x*10 for x in range(10)])
|
||||
|
||||
a = A()
|
||||
self.assertEqual(a.f(), 10)
|
||||
self.assertEqual(call_foo(a), 10)
|
||||
class D(A):
|
||||
def f(self): return 2
|
||||
d = D()
|
||||
self.assertEqual(d.f(), 2)
|
||||
self.assertEqual(call_foo(d), 2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user