From ff2201cc740a53c48d6ea96a263f53642735fa0e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 11 Sep 2008 13:51:41 +0000 Subject: [PATCH] added swap() for the other arrays too git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55550 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 2 +- tests/arrays/arrays.cpp | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 38529b36d6..cb0268bff5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -291,7 +291,7 @@ All: - Corrected bug in wxTimeSpan::IsShorterThan() for equal time spans. - Use std::unordered_{map,set} for wxHashMap/Set if available (Jan van Dijk). - Added wxString::Capitalize() and MakeCapitalized(). -- Added wxArrayString::swap(). +- Added wxArray::swap(). - Added wxSHUTDOWN_LOGOFF and wxSHUTDOWN_FORCE wxShutdown() flags (troelsk). All (Unix): diff --git a/tests/arrays/arrays.cpp b/tests/arrays/arrays.cpp index f97572dc99..972abe40f0 100644 --- a/tests/arrays/arrays.cpp +++ b/tests/arrays/arrays.cpp @@ -557,28 +557,44 @@ void ArraysTestCase::Alloc() CPPUNIT_ASSERT_EQUAL( 9, a[1] ); } -void ArraysTestCase::Swap() +namespace +{ + +template +void DoTestSwap(T v1, T v2, T v3, + A * WXUNUSED(dummyUglyVC6Workaround)) { - wxArrayString a1, a2; + A a1, a2; a1.swap(a2); CPPUNIT_ASSERT( a1.empty() && a2.empty() ); - a1.push_back("Foo"); + a1.push_back(v1); a1.swap(a2); CPPUNIT_ASSERT( a1.empty() ); CPPUNIT_ASSERT_EQUAL( 1, a2.size() ); - a1.push_back("Bar"); - a1.push_back("Baz"); + a1.push_back(v2); + a1.push_back(v3); a2.swap(a1); CPPUNIT_ASSERT_EQUAL( 1, a1.size() ); CPPUNIT_ASSERT_EQUAL( 2, a2.size() ); + CPPUNIT_ASSERT_EQUAL( v1, a1[0] ); + CPPUNIT_ASSERT_EQUAL( v3, a2[1] ); a1.swap(a2); CPPUNIT_ASSERT_EQUAL( 2, a1.size() ); CPPUNIT_ASSERT_EQUAL( 1, a2.size() ); } +} // anonymous namespace + +void ArraysTestCase::Swap() +{ + DoTestSwap("Foo", "Bar", "Baz", (wxArrayString *)NULL); + DoTestSwap(1, 10, 100, (wxArrayInt *)NULL); + DoTestSwap(6, 28, 496, (wxArrayLong *)NULL); +} + void ArraysTestCase::TestSTL() { wxArrayInt list1; -- 2.45.2