to_string_test.cpp 938 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
  2. //Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #include <boost/exception/to_string.hpp>
  5. #include <boost/detail/lightweight_test.hpp>
  6. namespace
  7. n1
  8. {
  9. struct
  10. c1
  11. {
  12. };
  13. }
  14. namespace
  15. n2
  16. {
  17. struct
  18. c2
  19. {
  20. };
  21. std::string
  22. to_string( c2 const & )
  23. {
  24. return "c2";
  25. }
  26. }
  27. namespace
  28. n3
  29. {
  30. struct
  31. c3
  32. {
  33. };
  34. std::ostream &
  35. operator<<( std::ostream & s, c3 const & )
  36. {
  37. return s << "c3";
  38. }
  39. }
  40. int
  41. main()
  42. {
  43. using namespace boost;
  44. BOOST_TEST( "c2"==to_string(n2::c2()) );
  45. BOOST_TEST( "c3"==to_string(n3::c3()) );
  46. BOOST_TEST( "42"==to_string(42) );
  47. return boost::report_errors();
  48. }