Ticket #2056: swap_arrays.cpp

File swap_arrays.cpp, 1.1 KB (added by niels_dekker, 14 years ago)

swap_arrays.cpp test file, to be added to libs/utility/swap/test

Line 
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#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
15int test_main(int, char*[])
16{
17 const std::size_t dimension = 7;
18
19 swap_test_class array1[dimension];
20 swap_test_class array2[dimension];
21 boost::swap(array1, array2);
22
23 BOOST_CHECK_EQUAL(swap_test_class::swap_count(), dimension);
24 BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0);
25
26 swap_test_class::reset();
27
28 const std::size_t firstDimension = 3;
29 const std::size_t secondDimension = 4;
30
31 swap_test_class two_d_array1[firstDimension][secondDimension];
32 swap_test_class two_d_array2[firstDimension][secondDimension];
33 boost::swap(two_d_array1, two_d_array1);
34
35 BOOST_CHECK_EQUAL(swap_test_class::swap_count(), firstDimension*secondDimension);
36 BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0);
37
38 return 0;
39}