2
0
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:
Bruno da Silva de Oliveira
2003-03-22 19:35:55 +00:00
parent f27e8f8ddc
commit fa27bddfab
4 changed files with 24 additions and 0 deletions

View File

@@ -34,6 +34,13 @@ struct C
}
};
struct A
{
virtual int f() { return 1; };
};
int call_foo(A* a){ return a->f(); }
}
#endif

View File

@@ -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')

View File

@@ -23,4 +23,6 @@ list RangeWrapper(int count){
return VectorToList(wrappertest::Range(count));
}
int f_wrapper(wrappertest::A*) { return 10; }
#endif

View File

@@ -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()