test_null.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Boost.TypeErasure library
  2. //
  3. // Copyright 2011 Steven Watanabe
  4. //
  5. // Distributed under the Boost Software License Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // $Id$
  10. #include <boost/type_erasure/any.hpp>
  11. #include <boost/type_erasure/tuple.hpp>
  12. #include <boost/type_erasure/builtin.hpp>
  13. #include <boost/type_erasure/operators.hpp>
  14. #include <boost/type_erasure/any_cast.hpp>
  15. #include <boost/mpl/vector.hpp>
  16. #define BOOST_TEST_MAIN
  17. #include <boost/test/unit_test.hpp>
  18. using namespace boost::type_erasure;
  19. template<class T = _self>
  20. struct common : ::boost::mpl::vector<
  21. copy_constructible<T>,
  22. relaxed
  23. > {};
  24. BOOST_AUTO_TEST_CASE(test_typeid) {
  25. any<common<> > val;
  26. BOOST_CHECK(typeid_of(val) == typeid(void));
  27. }
  28. BOOST_AUTO_TEST_CASE(test_any_cast) {
  29. any<common<> > val;
  30. BOOST_CHECK_EQUAL(any_cast<void*>(&val), (void*)0);
  31. BOOST_CHECK_EQUAL(any_cast<int*>(&val), (int*)0);
  32. }
  33. BOOST_AUTO_TEST_CASE(test_copy) {
  34. any<common<> > val;
  35. any<common<> > val2(val);
  36. BOOST_CHECK(typeid_of(val2) == typeid(void));
  37. }