Imported Upstream version 1.51.0
[platform/upstream/boost.git] / libs / utility / swap / test / specialized_in_global.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 //Provide swap function in gloabl namespace
15 void swap(swap_test_class& left, swap_test_class& right)
16 {
17   left.swap(right);
18 }
19
20 int test_main(int, char*[])
21 {
22   const swap_test_class initial_value1(1);
23   const swap_test_class initial_value2(2);
24
25   swap_test_class object1 = initial_value1;
26   swap_test_class object2 = initial_value2;
27   
28   swap_test_class::reset();
29   boost::swap(object1,object2);
30
31   BOOST_CHECK(object1 == initial_value2);
32   BOOST_CHECK(object2 == initial_value1);
33   
34   BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1);
35   BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0);
36
37   return 0;
38 }
39