Provide implementation for wxArrayString::resize().

This method was declared but not implemented in wxUSE_STL==0 build.

Also add unit test for this function.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61947 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-09-16 23:18:48 +00:00
parent d33ccbe15c
commit 3d156e937a
2 changed files with 19 additions and 0 deletions

View File

@@ -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 // expand the array
void wxArrayString::SetCount(size_t count) void wxArrayString::SetCount(size_t count)
{ {

View File

@@ -327,6 +327,17 @@ void ArraysTestCase::wxStringArrayTest()
CPPUNIT_ASSERT_EQUAL( WXSIZEOF(months), a5.size() ); CPPUNIT_ASSERT_EQUAL( WXSIZEOF(months), a5.size() );
CPPUNIT_ASSERT( COMPARE_3_VALUES(a5, "Jan", "Feb", "Mar") ); CPPUNIT_ASSERT( COMPARE_3_VALUES(a5, "Jan", "Feb", "Mar") );
#endif // wxHAS_VECTOR_TEMPLATE_ASSIGN #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() void ArraysTestCase::wxStringArraySplitTest()