From 51c998b57e74f9c288e59326fad3fb13355396d5 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Fri, 18 Sep 2015 17:39:42 -0700 Subject: [PATCH 1/3] added unit test to verify functionality of CommandLineArgvW in linux --- src/ps_test/test_CorePsPlatform.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ps_test/test_CorePsPlatform.cs b/src/ps_test/test_CorePsPlatform.cs index e11826091e..4534f8a2d4 100644 --- a/src/ps_test/test_CorePsPlatform.cs +++ b/src/ps_test/test_CorePsPlatform.cs @@ -134,5 +134,24 @@ namespace PSTests FileSystemInfo fd = new FileInfo(path); Assert.False(Platform.NonWindowsIsHardLink(fd)); } + + [Fact] + public static void TestCommandLineArgvW() + { + string testCommand= "Today is a \\\"good day\" or is it"; + + int count = 0; + + string[] retval = Platform.NonWindowsCommandLineToArgvW(testCommand, out count); + + Assert.Equal("Today", retval[0]); + Assert.Equal("is", retval[1]); + Assert.Equal("a", retval[2]); + Assert.Equal("\\\"good", retval[3]); + Assert.Equal("day\"", retval[4]); + Assert.Equal("or", retval[5]); + Assert.Equal("is", retval[6]); + Assert.Equal("it", retval[7]); + } } } From 92114f21e7471639d8a575330fc29abda3009a59 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Tue, 22 Sep 2015 15:14:22 -0700 Subject: [PATCH 2/3] added unit tests for CommandLineToArgvW in Linux --- src/ps_test/test_CorePsPlatform.cs | 107 +++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 4 deletions(-) diff --git a/src/ps_test/test_CorePsPlatform.cs b/src/ps_test/test_CorePsPlatform.cs index 4534f8a2d4..39f2b36c3d 100644 --- a/src/ps_test/test_CorePsPlatform.cs +++ b/src/ps_test/test_CorePsPlatform.cs @@ -135,10 +135,23 @@ namespace PSTests Assert.False(Platform.NonWindowsIsHardLink(fd)); } + [Fact] - public static void TestCommandLineArgvW() + public static void TestCommandLineArgvReturnsAnElement() { - string testCommand= "Today is a \\\"good day\" or is it"; + string testCommand= "Today"; + + int count = 0; + + string[] retval = Platform.NonWindowsCommandLineToArgvW(testCommand, out count); + + Assert.Equal(1, count); + } + + [Fact] + public static void TestCommandLineArgvWWithSpaces() + { + string testCommand= "Today is a good day or is it"; int count = 0; @@ -147,11 +160,97 @@ namespace PSTests Assert.Equal("Today", retval[0]); Assert.Equal("is", retval[1]); Assert.Equal("a", retval[2]); - Assert.Equal("\\\"good", retval[3]); - Assert.Equal("day\"", retval[4]); + Assert.Equal("good", retval[3]); + Assert.Equal("day", retval[4]); Assert.Equal("or", retval[5]); Assert.Equal("is", retval[6]); Assert.Equal("it", retval[7]); } + + [Fact] + public static void TestCommandLineToArgvWTabsAreTreatedAsSpaces() + { + string testCommand = "Today \t is a good day"; + + int count = 0; + + string[] retval = Platform.NonWindowsCommandLineToArgvW(testCommand, out count); + + Assert.Equal("Today", retval[0]); + Assert.Equal("is", retval[1]); + Assert.Equal("a", retval[2]); + Assert.Equal("good", retval[3]); + Assert.Equal("day", retval[4]); + } + + [Fact] + public static void TestCommandLineToArgvWQuotesAreArgs() + { + string testCommand = "Today is \"a good\" day"; + + int count = 0; + + string[] retval = Platform.NonWindowsCommandLineToArgvW(testCommand, out count); + + Assert.Equal(4, count); + Assert.Equal("Today", retval[0]); + Assert.Equal("is", retval[1]); + Assert.Equal("\"a good\"", retval[2]); + Assert.Equal("day", retval[3]); + } + + [Fact] + public static void TestCommandLineToArgvWEvenNumberBackSlashes() + { + string test1 = "a\\b c d"; + string test2 = "a\\b\\c d"; + string test3 = "a \\b\\c\\d"; + string test4 = "a\\\\\\b"; + + int count = 0; + + string[] a = Platform.NonWindowsCommandLineToArgvW(test1, out count); + + Assert.Equal(3, count); + Assert.Equal("a\\b", a[0]); + Assert.Equal("c", a[1]); + Assert.Equal("d", a[2]); + + string[] b = Platform.NonWindowsCommandLineToArgvW(test2, out count); + + Assert.Equal(2, count); + Assert.Equal("a\\b\\c", b[0]); + Assert.Equal("d", b[1]); + + string[] c = Platform.NonWindowsCommandLineToArgvW(test3, out count); + + Assert.Equal(2, count); + Assert.Equal("a", c[0]); + Assert.Equal("\\b\\c\\d", c[1]); + + string[] d = Platform.NonWindowsCommandLineToArgvW(test4, out count); + + Assert.Equal(1, count); + Assert.Equal("a\\\\\\b", d[0]); + } + + [Fact] + public static void TestCommandLineToArgvwOddNumberWithBackSlashes() + { + string test1 = "a\\\"b"; + string test2 = "a\\\\\\\"b"; + + int count = 0; + + string[] a = Platform.NonWindowsCommandLineToArgvW(test1, out count); + + Assert.Equal(1, count); + Assert.Equal("a\\\"b", a[0]); + + string[] b = Platform.NonWindowsCommandLineToArgvW(test2, out count); + + Assert.Equal(1, count); + Assert.Equal("a\\\\\\\"b", b[0]); + } } } From c3cec1d4330fb3dbf41d0bc6a74849206dfea8e1 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Fri, 9 Oct 2015 12:44:49 -0700 Subject: [PATCH 3/3] bringing in committed monad changes --- src/monad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monad b/src/monad index 9330fdf4ce..a62341e50a 160000 --- a/src/monad +++ b/src/monad @@ -1 +1 @@ -Subproject commit 9330fdf4ce15b1bfd12be3cdd5ee8a8969f92f25 +Subproject commit a62341e50a7ba958e88e3e8e9ad746af7c2b5d6c