Add wx/meta/removeref.h header defining wxRemoveRef<> helper.
[wxWidgets.git] / tests / cmdline / cmdlinetest.cpp
index 87d02b2d16b6793ceb9340f55448f0f8d84c6aa3..82f6548e65e61e36a5b2044fc6b0dddacba89c38 100644 (file)
@@ -50,7 +50,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( CmdLineTestCase );
 
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CmdLineTestCase, "CmdLineTestCase" );
 
 // ============================================================================
@@ -139,6 +139,8 @@ void CmdLineTestCase::ParseSwitches()
     p.AddSwitch("b");
     p.AddSwitch("c");
     p.AddSwitch("d");
+    p.AddSwitch("n", "neg", "Switch that can be negated",
+                wxCMD_LINE_SWITCH_NEGATABLE);
 
     p.SetCmdLine("");
     CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
@@ -182,6 +184,23 @@ void CmdLineTestCase::ParseSwitches()
     CPPUNIT_ASSERT( !p.Found("b") );
     CPPUNIT_ASSERT( !p.Found("c") );
     CPPUNIT_ASSERT( p.Found("d") );
+
+    p.SetCmdLine("-n");
+    CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
+    CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_NOT_FOUND, p.FoundSwitch("a") );
+    CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_ON, p.FoundSwitch("n") );
+
+    p.SetCmdLine("-n-");
+    CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
+    CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_OFF, p.FoundSwitch("neg") );
+
+    p.SetCmdLine("--neg");
+    CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
+    CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_ON, p.FoundSwitch("neg") );
+
+    p.SetCmdLine("--neg-");
+    CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
+    CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_OFF, p.FoundSwitch("n") );
 }
 
 void CmdLineTestCase::Usage()