std_string.cpp 834 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (c) 2008 Joseph Gauterin, Niels Dekker
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. // Tests swapping std::string objects by means of boost::swap.
  7. // std::string has its own std::swap overload.
  8. #include <boost/utility/swap.hpp>
  9. #include <boost/core/lightweight_test.hpp>
  10. #define BOOST_CHECK BOOST_TEST
  11. #define BOOST_CHECK_EQUAL BOOST_TEST_EQ
  12. #include <string>
  13. int main()
  14. {
  15. const std::string initial_value1 = "one";
  16. const std::string initial_value2 = "two";
  17. std::string object1 = initial_value1;
  18. std::string object2 = initial_value2;
  19. boost::swap(object1,object2);
  20. BOOST_CHECK_EQUAL(object1,initial_value2);
  21. BOOST_CHECK_EQUAL(object2,initial_value1);
  22. return boost::report_errors();
  23. }