diff --git a/src/common/arrstr.cpp b/src/common/arrstr.cpp index 862519fe33..be461cc639 100644 --- a/src/common/arrstr.cpp +++ b/src/common/arrstr.cpp @@ -345,6 +345,14 @@ wxArrayString::insert(iterator it, const_iterator first, const_iterator last) } } +void wxArrayString::resize(size_type n, value_type v) +{ + if ( n < m_nCount ) + m_nCount = n; + else if ( n > m_nCount ) + Add(v, n - m_nCount); +} + // expand the array void wxArrayString::SetCount(size_t count) { diff --git a/tests/arrays/arrays.cpp b/tests/arrays/arrays.cpp index ed74c94835..4d276963db 100644 --- a/tests/arrays/arrays.cpp +++ b/tests/arrays/arrays.cpp @@ -327,6 +327,17 @@ void ArraysTestCase::wxStringArrayTest() CPPUNIT_ASSERT_EQUAL( WXSIZEOF(months), a5.size() ); CPPUNIT_ASSERT( COMPARE_3_VALUES(a5, "Jan", "Feb", "Mar") ); #endif // wxHAS_VECTOR_TEMPLATE_ASSIGN + + a5.clear(); + CPPUNIT_ASSERT_EQUAL( 0, a5.size() ); + + a5.resize(7, "Foo"); + CPPUNIT_ASSERT_EQUAL( 7, a5.size() ); + CPPUNIT_ASSERT_EQUAL( "Foo", a5[3] ); + + a5.resize(3); + CPPUNIT_ASSERT_EQUAL( 3, a5.size() ); + CPPUNIT_ASSERT_EQUAL( "Foo", a5[2] ); } void ArraysTestCase::wxStringArraySplitTest()