]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/core/test/swap/array_of_int.cpp
1 // Copyright (c) 2008 Joseph Gauterin, Niels Dekker
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)
7 // Tests swapping an array of integers by means of boost::swap.
9 #include <boost/utility/swap.hpp>
10 #include <boost/core/lightweight_test.hpp>
11 #define BOOST_CHECK BOOST_TEST
12 #define BOOST_CHECK_EQUAL BOOST_TEST_EQ
14 #include <algorithm> //for std::copy and std::equal
15 #include <cstddef> //for std::size_t
20 const std::size_t array_size
= 3;
21 const int initial_array1
[array_size
] = { 1, 2, 3 };
22 const int initial_array2
[array_size
] = { 4, 5, 6 };
24 int array1
[array_size
];
25 int array2
[array_size
];
27 std::copy(initial_array1
, initial_array1
+ array_size
, array1
);
28 std::copy(initial_array2
, initial_array2
+ array_size
, array2
);
30 boost::swap(array1
, array2
);
32 BOOST_CHECK(std::equal(array1
, array1
+ array_size
, initial_array2
));
33 BOOST_CHECK(std::equal(array2
, array2
+ array_size
, initial_array1
));
35 return boost::report_errors();