lexical_cast_noncopyable_test.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Unit test for boost::lexical_cast.
  2. //
  3. // See http://www.boost.org for most recent version, including documentation.
  4. //
  5. // Copyright Alexander Nasonov, 2007.
  6. //
  7. // Distributed under the Boost
  8. // Software License, Version 1.0. (See accompanying file
  9. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
  10. //
  11. // Test that Source can be non-copyable.
  12. #include <boost/config.hpp>
  13. #if defined(__INTEL_COMPILER)
  14. #pragma warning(disable: 193 383 488 981 1418 1419)
  15. #elif defined(BOOST_MSVC)
  16. #pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800)
  17. #endif
  18. #include <boost/lexical_cast.hpp>
  19. #include <boost/noncopyable.hpp>
  20. #include <boost/test/unit_test.hpp>
  21. using namespace boost;
  22. void test_noncopyable();
  23. unit_test::test_suite *init_unit_test_suite(int, char *[])
  24. {
  25. unit_test::test_suite *suite =
  26. BOOST_TEST_SUITE("lexical_cast unit test");
  27. suite->add(BOOST_TEST_CASE(&test_noncopyable));
  28. return suite;
  29. }
  30. class Noncopyable : private boost::noncopyable
  31. {
  32. public:
  33. Noncopyable() {}
  34. };
  35. inline std::ostream &operator<<(std::ostream &out, const Noncopyable&)
  36. {
  37. return out << "Noncopyable";
  38. }
  39. void test_noncopyable()
  40. {
  41. Noncopyable x;
  42. BOOST_CHECK(boost::lexical_cast<std::string>(x) == "Noncopyable");
  43. }