Re-define push_back() in wxSortedArrayString to behave correctly.

Adding items to wxSortedArrayString should always keep them sorted but while
Add() did this, push_back() didn't breaking the class invariant.

Redefine push_back() in _WX_DEFINE_SORTED_TYPEARRAY_2 macro to fix this and
add a unit test checking that wxSortedArrayString::push_back() does work now.

Closes #13134.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67429 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-04-10 15:36:07 +00:00
parent ceb9b8db81
commit 0287ae5c75
2 changed files with 16 additions and 0 deletions

View File

@@ -160,6 +160,7 @@ public:
private:
CPPUNIT_TEST_SUITE( ArraysTestCase );
CPPUNIT_TEST( wxStringArrayTest );
CPPUNIT_TEST( SortedArray );
CPPUNIT_TEST( wxStringArraySplitTest );
CPPUNIT_TEST( wxStringArrayJoinTest );
CPPUNIT_TEST( wxStringArraySplitJoinTest );
@@ -175,6 +176,7 @@ private:
CPPUNIT_TEST_SUITE_END();
void wxStringArrayTest();
void SortedArray();
void wxStringArraySplitTest();
void wxStringArrayJoinTest();
void wxStringArraySplitJoinTest();
@@ -340,6 +342,18 @@ void ArraysTestCase::wxStringArrayTest()
CPPUNIT_ASSERT_EQUAL( "Foo", a5[2] );
}
void ArraysTestCase::SortedArray()
{
wxSortedArrayString a;
a.Add("d");
a.Add("c");
CPPUNIT_ASSERT_EQUAL( 0, a.Index("c") );
a.push_back("b");
a.push_back("a");
CPPUNIT_ASSERT_EQUAL( 0, a.Index("a") );
}
void ArraysTestCase::wxStringArraySplitTest()
{
// test wxSplit: