Imported Upstream version 1.51.0
[platform/upstream/boost.git] / libs / utility / swap / test / specialized_in_std.cpp
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 #define BOOST_INCLUDE_MAIN
9 #include <boost/test/test_tools.hpp>
10
11 //Put test class in the global namespace
12 #include "./swap_test_class.hpp"
13
14
15 //Provide swap function in namespace std
16 namespace std
17 {
18   template <>
19   void swap(swap_test_class& left, swap_test_class& right)
20   {
21     left.swap(right);
22   }
23 }
24
25 int test_main(int, char*[])
26 {
27   const swap_test_class initial_value1(1);
28   const swap_test_class initial_value2(2);
29
30   swap_test_class object1 = initial_value1;
31   swap_test_class object2 = initial_value2;
32   
33   swap_test_class::reset();
34   boost::swap(object1,object2);
35
36   BOOST_CHECK(object1 == initial_value2);
37   BOOST_CHECK(object2 == initial_value1);
38   
39   BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1);
40   BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0);
41
42   return 0;
43 }
44