test_lib_typeid.cpp 656 B

1234567891011121314151617181920212223242526
  1. // Copyright 2018 Peter Dimov.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. #include <boost/core/typeinfo.hpp>
  4. #include <boost/core/lightweight_test.hpp>
  5. boost::core::typeinfo const & get_typeid_int();
  6. int main()
  7. {
  8. boost::core::typeinfo const & ti = BOOST_CORE_TYPEID( int );
  9. boost::core::typeinfo const & tf = BOOST_CORE_TYPEID( float );
  10. boost::core::typeinfo const & ti2 = get_typeid_int();
  11. BOOST_TEST( ti2 == ti );
  12. BOOST_TEST( ti2 != tf );
  13. BOOST_TEST( !ti2.before( ti ) );
  14. BOOST_TEST( !ti.before( ti2 ) );
  15. BOOST_TEST( ti2.before( tf ) != tf.before( ti2 ) );
  16. return boost::report_errors();
  17. }