]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 other | |
13 | namespace other | |
14 | { | |
15 | #include "./swap_test_class.hpp" | |
16 | } | |
17 | ||
18 | //Provide swap function in namespace other | |
19 | namespace other | |
20 | { | |
21 | void swap(swap_test_class& left, swap_test_class& right) | |
22 | { | |
23 | left.swap(right); | |
24 | } | |
25 | } | |
26 | ||
27 | int main() | |
28 | { | |
29 | const other::swap_test_class initial_value1(1); | |
30 | const other::swap_test_class initial_value2(2); | |
31 | ||
32 | other::swap_test_class object1 = initial_value1; | |
33 | other::swap_test_class object2 = initial_value2; | |
34 | ||
35 | other::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(other::swap_test_class::swap_count(),1); | |
42 | BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0); | |
43 | ||
44 | return boost::report_errors(); | |
45 | } | |
46 |