Verify the return value of wxItemContainer::Insert() in the tests.
Check that Insert() returns the index of the last inserted item. Also document this behaviour for mulit-item renames explicitly. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66278 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -511,6 +511,8 @@ public:
|
|||||||
Array of strings to insert.
|
Array of strings to insert.
|
||||||
@param pos
|
@param pos
|
||||||
Position to insert the items before, zero based.
|
Position to insert the items before, zero based.
|
||||||
|
@return The return value is the index of the last inserted item.
|
||||||
|
If the insertion failed for some reason, -1 is returned.
|
||||||
*/
|
*/
|
||||||
int Insert(const wxArrayString& items, unsigned int pos);
|
int Insert(const wxArrayString& items, unsigned int pos);
|
||||||
|
|
||||||
@@ -527,6 +529,8 @@ public:
|
|||||||
@param clientData
|
@param clientData
|
||||||
Array of client data pointers of the same size as @a items to
|
Array of client data pointers of the same size as @a items to
|
||||||
associate with the new items.
|
associate with the new items.
|
||||||
|
@return The return value is the index of the last inserted item.
|
||||||
|
If the insertion failed for some reason, -1 is returned.
|
||||||
*/
|
*/
|
||||||
int Insert(const wxArrayString& items, unsigned int pos,
|
int Insert(const wxArrayString& items, unsigned int pos,
|
||||||
void **clientData);
|
void **clientData);
|
||||||
@@ -544,6 +548,8 @@ public:
|
|||||||
@param clientData
|
@param clientData
|
||||||
Array of client data pointers of the same size as @a items to
|
Array of client data pointers of the same size as @a items to
|
||||||
associate with the new items.
|
associate with the new items.
|
||||||
|
@return The return value is the index of the last inserted item.
|
||||||
|
If the insertion failed for some reason, -1 is returned.
|
||||||
*/
|
*/
|
||||||
int Insert(const wxArrayString& items, unsigned int pos,
|
int Insert(const wxArrayString& items, unsigned int pos,
|
||||||
wxClientData **clientData);
|
wxClientData **clientData);
|
||||||
@@ -560,6 +566,8 @@ public:
|
|||||||
Array of strings of size @a n.
|
Array of strings of size @a n.
|
||||||
@param pos
|
@param pos
|
||||||
Position to insert the items before, zero based.
|
Position to insert the items before, zero based.
|
||||||
|
@return The return value is the index of the last inserted item.
|
||||||
|
If the insertion failed for some reason, -1 is returned.
|
||||||
*/
|
*/
|
||||||
int Insert(unsigned int n, const wxString* items,
|
int Insert(unsigned int n, const wxString* items,
|
||||||
unsigned int pos);
|
unsigned int pos);
|
||||||
@@ -579,6 +587,8 @@ public:
|
|||||||
@param clientData
|
@param clientData
|
||||||
Array of client data pointers of size @a n to associate with the
|
Array of client data pointers of size @a n to associate with the
|
||||||
new items.
|
new items.
|
||||||
|
@return The return value is the index of the last inserted item.
|
||||||
|
If the insertion failed for some reason, -1 is returned.
|
||||||
*/
|
*/
|
||||||
int Insert(unsigned int n, const wxString* items,
|
int Insert(unsigned int n, const wxString* items,
|
||||||
unsigned int pos,
|
unsigned int pos,
|
||||||
@@ -599,6 +609,8 @@ public:
|
|||||||
@param clientData
|
@param clientData
|
||||||
Array of client data pointers of size @a n to associate with the
|
Array of client data pointers of size @a n to associate with the
|
||||||
new items.
|
new items.
|
||||||
|
@return The return value is the index of the last inserted item.
|
||||||
|
If the insertion failed for some reason, -1 is returned.
|
||||||
*/
|
*/
|
||||||
int Insert(unsigned int n, const wxString* items,
|
int Insert(unsigned int n, const wxString* items,
|
||||||
unsigned int pos,
|
unsigned int pos,
|
||||||
|
@@ -47,23 +47,21 @@ void ItemContainerTestCase::Insert()
|
|||||||
{
|
{
|
||||||
wxItemContainer * const container = GetContainer();
|
wxItemContainer * const container = GetContainer();
|
||||||
|
|
||||||
container->Insert("item 0", 0);
|
CPPUNIT_ASSERT_EQUAL( 0, container->Insert("item 0", 0) );
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL("item 0", container->GetString(0));
|
CPPUNIT_ASSERT_EQUAL("item 0", container->GetString(0));
|
||||||
|
|
||||||
wxArrayString testitems;
|
wxArrayString testitems;
|
||||||
testitems.Add("item 1");
|
testitems.Add("item 1");
|
||||||
testitems.Add("item 2");
|
testitems.Add("item 2");
|
||||||
|
|
||||||
container->Insert(testitems, 0);
|
CPPUNIT_ASSERT_EQUAL( 1, container->Insert(testitems, 0) );
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL("item 1", container->GetString(0));
|
CPPUNIT_ASSERT_EQUAL("item 1", container->GetString(0));
|
||||||
CPPUNIT_ASSERT_EQUAL("item 2", container->GetString(1));
|
CPPUNIT_ASSERT_EQUAL("item 2", container->GetString(1));
|
||||||
|
|
||||||
wxString arritems[] = { "item 3", "item 4" };
|
wxString arritems[] = { "item 3", "item 4" };
|
||||||
|
|
||||||
container->Insert(2, arritems, 1);
|
CPPUNIT_ASSERT_EQUAL( 2, container->Insert(2, arritems, 1) );
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL("item 3", container->GetString(1));
|
CPPUNIT_ASSERT_EQUAL("item 3", container->GetString(1));
|
||||||
CPPUNIT_ASSERT_EQUAL("item 4", container->GetString(2));
|
CPPUNIT_ASSERT_EQUAL("item 4", container->GetString(2));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user