2006-05-26 Marek Sieradzki <marek.sieradzki@gmail.com>
authorMarek Sieradzki <msierad@mono-cvs.ximian.com>
Fri, 26 May 2006 07:13:34 +0000 (07:13 -0000)
committerMarek Sieradzki <msierad@mono-cvs.ximian.com>
Fri, 26 May 2006 07:13:34 +0000 (07:13 -0000)
        * CommandLineBuilderTest.cs: Added tests for
        VerifyThrowNoEmbeddedQuotes () and IsQuotingRequired ().

svn path=/trunk/mcs/; revision=61151

mcs/class/Microsoft.Build.Utilities/Test/Microsoft.Build.Utilities/ChangeLog
mcs/class/Microsoft.Build.Utilities/Test/Microsoft.Build.Utilities/CommandLineBuilderTest.cs

index 73fecf4832d84b40955e68167abdd1e316d7270d..a8e017be9598de6d29c7110ace9ca70bab5adacd 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-26  Marek Sieradzki  <marek.sieradzki@gmail.com>
+
+       * CommandLineBuilderTest.cs: Added tests for
+       VerifyThrowNoEmbeddedQuotes () and IsQuotingRequired ().
+
 2006-04-24  Marek Sieradzki  <marek.sieradzki@gmail.com>
 
        * TaskLoggingHelperTest.cs: Added new tests.
index 8fce687f56a070bea28b1548602d22dbc2f955cc..8ed0f822ca6208d967eadd7b0433514f66dc4e99 100644 (file)
@@ -32,6 +32,21 @@ using NUnit.Framework;
 
 namespace MonoTests.Microsoft.Build.Utilities {
 
+       internal class CLBTester : CommandLineBuilder {
+
+               public new bool IsQuotingRequired (string parameter)
+               {
+                       return base.IsQuotingRequired (parameter);
+               }
+
+               public new void VerifyThrowNoEmbeddedDoubleQuotes (string switchName,
+                                               string parameter)
+               {
+                       base.VerifyThrowNoEmbeddedDoubleQuotes (switchName, parameter);
+               }
+       }
+
+
        [TestFixture]
        public class CommandLineBuilderTest {
 
@@ -384,5 +399,48 @@ namespace MonoTests.Microsoft.Build.Utilities {
                        
                        Assert.AreEqual ("/switch:a;b", clb.ToString (), "A2");
                }
+
+               [Test]
+               public void TestIsQuotingRequired ()
+               {
+                       CLBTester clbt = new CLBTester ();
+
+                       Assert.AreEqual (false, clbt.IsQuotingRequired(""), "A1");
+                       Assert.AreEqual (true, clbt.IsQuotingRequired(" "), "A2");
+                       Assert.AreEqual (false, clbt.IsQuotingRequired("a"), "A3");
+                       Assert.AreEqual (true, clbt.IsQuotingRequired("a a"), "A4");
+                       Assert.AreEqual (true, clbt.IsQuotingRequired("\'\'"), "A5");
+                       Assert.AreEqual (true, clbt.IsQuotingRequired("\' \'"), "A6");
+                       Assert.AreEqual (true, clbt.IsQuotingRequired("\"\""), "A7");
+                       Assert.AreEqual (true, clbt.IsQuotingRequired("\" \""), "A8");
+                       Assert.AreEqual (true, clbt.IsQuotingRequired("\n\n"), "A9");
+                       Assert.AreEqual (true, clbt.IsQuotingRequired("\n \n"), "A10");
+                       Assert.AreEqual (true, clbt.IsQuotingRequired("\t\t"), "A11");
+                       Assert.AreEqual (true, clbt.IsQuotingRequired("\t \t"), "A12");
+               }
+
+               [Test]
+               public void TestVerifyThrowNoEmbeddedDoubleQuotes1 ()
+               {
+                       CLBTester clbt = new CLBTester ();
+
+                       clbt.VerifyThrowNoEmbeddedDoubleQuotes (null, null);
+                       clbt.VerifyThrowNoEmbeddedDoubleQuotes ("", null);
+                       clbt.VerifyThrowNoEmbeddedDoubleQuotes (null, "");
+                       clbt.VerifyThrowNoEmbeddedDoubleQuotes (" ", "");
+                       clbt.VerifyThrowNoEmbeddedDoubleQuotes ("", " ");
+                       clbt.VerifyThrowNoEmbeddedDoubleQuotes ("\"\"", "");
+                       clbt.VerifyThrowNoEmbeddedDoubleQuotes ("\'\'", "\'\'");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException),
+                       "Illegal quote passed to the command line switch named \"a\". The value was [\"\"].")]
+               public void TestVerifyThrowNoEmbeddedDoubleQuotes2 ()
+               {
+                       CLBTester clbt = new CLBTester ();
+
+                       clbt.VerifyThrowNoEmbeddedDoubleQuotes ("a", "\"\"");
+               }
        }
 }
\ No newline at end of file