From 118e473a3d2f2286f2250f8a1018b35db2dc9d4c Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 27 Nov 2008 11:08:05 +0000 Subject: [PATCH] [utility/swap] Added comment to various array swapping tests, added member typedef to swap_test_template, to make the test more realistic. [SVN r49953] --- swap/test/array_of_class.cpp | 2 ++ swap/test/array_of_int.cpp | 2 ++ swap/test/array_of_template.cpp | 23 +++++++++++++---------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/swap/test/array_of_class.cpp b/swap/test/array_of_class.cpp index df79801..356762d 100644 --- a/swap/test/array_of_class.cpp +++ b/swap/test/array_of_class.cpp @@ -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 #define BOOST_INCLUDE_MAIN #include diff --git a/swap/test/array_of_int.cpp b/swap/test/array_of_int.cpp index f919613..22a7dde 100644 --- a/swap/test/array_of_int.cpp +++ b/swap/test/array_of_int.cpp @@ -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 integers by means of boost::swap. + #include #define BOOST_INCLUDE_MAIN #include diff --git a/swap/test/array_of_template.cpp b/swap/test/array_of_template.cpp index e6e465f..8f350ad 100644 --- a/swap/test/array_of_template.cpp +++ b/swap/test/array_of_template.cpp @@ -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 swap_test_template objects by means of boost::swap. + #include #define BOOST_INCLUDE_MAIN #include @@ -18,6 +20,7 @@ template class swap_test_template { public: + typedef T template_argument; swap_test_class swap_test_object; }; @@ -45,23 +48,23 @@ void swap(swap_test_template& left, swap_test_template& right) int test_main(int, char*[]) { - const std::size_t dimension = 2; - const swap_test_template initial_array1[dimension] = { swap_test_class(1), swap_test_class(2) }; - const swap_test_template initial_array2[dimension] = { swap_test_class(3), swap_test_class(4) }; + const std::size_t array_size = 2; + const swap_test_template initial_array1[array_size] = { swap_test_class(1), swap_test_class(2) }; + const swap_test_template initial_array2[array_size] = { swap_test_class(3), swap_test_class(4) }; - swap_test_template array1[dimension]; - swap_test_template array2[dimension]; + swap_test_template array1[array_size]; + swap_test_template array2[array_size]; - std::copy(initial_array1, initial_array1 + dimension, array1); - std::copy(initial_array2, initial_array2 + dimension, array2); + std::copy(initial_array1, initial_array1 + array_size, array1); + std::copy(initial_array2, initial_array2 + array_size, array2); swap_test_class::reset(); boost::swap(array1, array2); - BOOST_CHECK(std::equal(array1, array1 + dimension, initial_array2)); - BOOST_CHECK(std::equal(array2, array2 + dimension, initial_array1)); + BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2)); + BOOST_CHECK(std::equal(array2, array2 + array_size, initial_array1)); - BOOST_CHECK_EQUAL(swap_test_class::swap_count(), dimension); + BOOST_CHECK_EQUAL(swap_test_class::swap_count(), array_size); BOOST_CHECK_EQUAL(swap_test_class::copy_count(), 0); return 0;