upcast.cpp 565 B

12345678910111213141516171819
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <boost/python/cast.hpp>
  6. #include <boost/detail/lightweight_test.hpp>
  7. struct X { long x; };
  8. struct Y : X, PyObject {};
  9. int main()
  10. {
  11. PyTypeObject o;
  12. Y y;
  13. BOOST_TEST(&Py_REFCNT(boost::python::upcast<PyObject>(&o)) == &Py_REFCNT(&o));
  14. BOOST_TEST(&Py_REFCNT(boost::python::upcast<PyObject>(&y)) == &Py_REFCNT(&y));
  15. return boost::report_errors();
  16. }