]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/controls/itemcontainertest.cpp
Add CombineURIs implementation for wxWebFileProtocolHandler. Update the IE backend...
[wxWidgets.git] / tests / controls / itemcontainertest.cpp
index ad0d8982cc67306280590933b1d4947f61139efe..ab54a497021593b62f7ad751b68a60bb2a3495d4 100644 (file)
@@ -105,22 +105,27 @@ void ItemContainerTestCase::ItemSelection()
     testitems.Add("item 0");
     testitems.Add("item 1");
     testitems.Add("item 2");
     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);
 
     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(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());
 
     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());
 }
     CPPUNIT_ASSERT_EQUAL(2, container->GetSelection());
     CPPUNIT_ASSERT_EQUAL("item 2", container->GetStringSelection());
 }
@@ -165,6 +170,9 @@ void ItemContainerTestCase::ClientData()
 
     CPPUNIT_ASSERT_EQUAL(static_cast<wxClientData*>(item2data),
                          container->GetClientObject(2));
 
     CPPUNIT_ASSERT_EQUAL(static_cast<wxClientData*>(item2data),
                          container->GetClientObject(2));
+
+    WX_ASSERT_FAILS_WITH_ASSERT( container->SetClientObject((unsigned)-1, item0data) );
+    WX_ASSERT_FAILS_WITH_ASSERT( container->SetClientObject(12345, item0data) );
 }
 
 void ItemContainerTestCase::VoidData()
 }
 
 void ItemContainerTestCase::VoidData()
@@ -190,6 +198,9 @@ void ItemContainerTestCase::VoidData()
     container->Insert("item 2", 2, item2);
 
     CPPUNIT_ASSERT_EQUAL(item2, container->GetClientData(2));
     container->Insert("item 2", 2, item2);
 
     CPPUNIT_ASSERT_EQUAL(item2, container->GetClientData(2));
+
+    WX_ASSERT_FAILS_WITH_ASSERT( container->SetClientData((unsigned)-1, NULL) );
+    WX_ASSERT_FAILS_WITH_ASSERT( container->SetClientData(12345, NULL) );
 }
 
 void ItemContainerTestCase::Set()
 }
 
 void ItemContainerTestCase::Set()