1 // Copyright (c) 2007 Joseph Gauterin 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 7 #include <boost/utility/swap.hpp> 8 #include <boost/core/lightweight_test.hpp> 9 #define BOOST_CHECK BOOST_TEST 10 #define BOOST_CHECK_EQUAL BOOST_TEST_EQ 11 12 //Put test class in namespace boost 13 namespace boost 14 { 15 #include "./swap_test_class.hpp" 16 } 17 18 //Provide swap function in namespace boost 19 namespace boost 20 { swap(swap_test_class & left,swap_test_class & right)21 void swap(swap_test_class& left, swap_test_class& right) 22 { 23 left.swap(right); 24 } 25 } 26 main()27int main() 28 { 29 const boost::swap_test_class initial_value1(1); 30 const boost::swap_test_class initial_value2(2); 31 32 boost::swap_test_class object1 = initial_value1; 33 boost::swap_test_class object2 = initial_value2; 34 35 boost::swap_test_class::reset(); 36 boost::swap(object1,object2); 37 38 BOOST_CHECK(object1 == initial_value2); 39 BOOST_CHECK(object2 == initial_value1); 40 41 BOOST_CHECK_EQUAL(boost::swap_test_class::swap_count(),1); 42 BOOST_CHECK_EQUAL(boost::swap_test_class::copy_count(),0); 43 44 return boost::report_errors(); 45 } 46 47