Document wxItemContainer::SetStringSelection() as case-insensitive.

Add unit tests checking that the behaviour really corresponds to the
documentation too.

And also mention that it's not a good idea to have strings differing by case
only in wxComboBox anyhow.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66442 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-12-25 13:19:00 +00:00
parent 1db02a5e5c
commit 3256418982
3 changed files with 21 additions and 8 deletions

View File

@@ -105,22 +105,27 @@ void ItemContainerTestCase::ItemSelection()
testitems.Add("item 0");
testitems.Add("item 1");
testitems.Add("item 2");
testitems.Add("item 3");
testitems.Add("ITEM 2"); // The same as the last one except for case.
container->Append(testitems);
container->SetSelection(wxNOT_FOUND);
CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND, container->GetSelection());
CPPUNIT_ASSERT_EQUAL("", container->GetStringSelection());
container->SetSelection(1);
CPPUNIT_ASSERT_EQUAL(1, container->GetSelection());
CPPUNIT_ASSERT_EQUAL("item 1", container->GetStringSelection());
container->SetStringSelection("item 2");
CPPUNIT_ASSERT( container->SetStringSelection("item 2") );
CPPUNIT_ASSERT_EQUAL(2, container->GetSelection());
CPPUNIT_ASSERT_EQUAL("item 2", container->GetStringSelection());
// Check that selecting a non-existent item fails.
CPPUNIT_ASSERT( !container->SetStringSelection("bloordyblop") );
// Check that SetStringSelection() is case-insensitive.
CPPUNIT_ASSERT( container->SetStringSelection("ITEM 2") );
CPPUNIT_ASSERT_EQUAL(2, container->GetSelection());
CPPUNIT_ASSERT_EQUAL("item 2", container->GetStringSelection());
}