[utility/swap] Distinguished between testing array-of-array-of-class and array-of-array-of-int, as the latter appears to succeed on CodeGear 6.10 while the former does not.

[SVN r49954]
This commit is contained in:
Niels Dekker 2008-11-27 11:14:52 +00:00
parent 118e473a3d
commit 97e11b024e
3 changed files with 46 additions and 1 deletions

View File

@ -29,7 +29,8 @@ test-suite utility/swap
[ run std_vector_of_global.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run std_vector_of_other.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run no_ambiguity_in_boost.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run array_of_array.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run array_of_array_of_class.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run array_of_array_of_int.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run array_of_class.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run array_of_int.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
[ run array_of_template.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]

View File

@ -4,6 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping an array of arrays of swap_test_class objects by means of boost::swap.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>

View File

@ -0,0 +1,42 @@
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping an array of arrays of integers by means of boost::swap.
#include <boost/utility/swap.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include <algorithm> //for std::copy and std::equal
#include <cstddef> //for std::size_t
int test_main(int, char*[])
{
const std::size_t first_dimension = 3;
const std::size_t second_dimension = 4;
const std::size_t number_of_elements = first_dimension * second_dimension;
int array1[first_dimension][second_dimension];
int array2[first_dimension][second_dimension];
int* const ptr1 = array1[0];
int* const ptr2 = array2[0];
for (std::size_t i = 0; i < number_of_elements; ++i)
{
ptr1[i] = static_cast<int>(i);
ptr2[i] = static_cast<int>(i + number_of_elements);
}
boost::swap(array1, array2);
for (std::size_t i = 0; i < number_of_elements; ++i)
{
BOOST_CHECK_EQUAL(ptr1[i], static_cast<int>(i + number_of_elements) );
BOOST_CHECK_EQUAL(ptr2[i], static_cast<int>(i) );
}
return 0;
}