]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/core/test/swap/array_of_int.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / core / test / swap / array_of_int.cpp
1 // Copyright (c) 2008 Joseph Gauterin, Niels Dekker
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 // Tests swapping an array of integers by means of boost::swap.
8
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
13
14 #include <algorithm> //for std::copy and std::equal
15 #include <cstddef> //for std::size_t
16
17
18 int main()
19 {
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 };
23
24 int array1[array_size];
25 int array2[array_size];
26
27 std::copy(initial_array1, initial_array1 + array_size, array1);
28 std::copy(initial_array2, initial_array2 + array_size, array2);
29
30 boost::swap(array1, array2);
31
32 BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2));
33 BOOST_CHECK(std::equal(array2, array2 + array_size, initial_array1));
34
35 return boost::report_errors();
36 }