Skip to content

Commit 08c8ae3

Browse files
author
Robert Holt
committed
Add international character escaping tests
1 parent 4dbf2f8 commit 08c8ae3

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

test/PowerShellEditorServices.Test/Session/PathEscapingTests.cs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ public class PathEscapingTests
1616
[InlineData("C:\\look\\an*\\here.ps1", "C:\\look\\an`*\\here.ps1")]
1717
[InlineData("/Users/me/Documents/?here.ps1", "/Users/me/Documents/`?here.ps1")]
1818
[InlineData("/Brackets [and s]paces/path.ps1", "/Brackets `[and s`]paces/path.ps1")]
19+
[InlineData("/CJK.chars/脚本/hello.ps1", "/CJK.chars/脚本/hello.ps1")]
20+
[InlineData("/CJK.chars/脚本/[hello].ps1", "/CJK.chars/脚本/`[hello`].ps1")]
21+
[InlineData("C:\\Animals\\утка\\quack.ps1", "C:\\Animals\\утка\\quack.ps1")]
22+
[InlineData("C:\\&nimals\\утка\\qu*ck?.ps1", "C:\\&nimals\\утка\\qu`*ck`?.ps1")]
1923
public void CorrectlyGlobEscapesPaths_NoSpaces(string unescapedPath, string escapedPath)
2024
{
2125
string extensionEscapedPath = PowerShellContext.GlobEscapePath(unescapedPath);
@@ -32,12 +36,37 @@ public void CorrectlyGlobEscapesPaths_NoSpaces(string unescapedPath, string esca
3236
[InlineData("C:\\look\\an*\\here.ps1", "C:\\look\\an`*\\here.ps1")]
3337
[InlineData("/Users/me/Documents/?here.ps1", "/Users/me/Documents/`?here.ps1")]
3438
[InlineData("/Brackets [and s]paces/path.ps1", "/Brackets` `[and` s`]paces/path.ps1")]
39+
[InlineData("/CJK chars/脚本/hello.ps1", "/CJK` chars/脚本/hello.ps1")]
40+
[InlineData("/CJK chars/脚本/[hello].ps1", "/CJK` chars/脚本/`[hello`].ps1")]
41+
[InlineData("C:\\Animal s\\утка\\quack.ps1", "C:\\Animal` s\\утка\\quack.ps1")]
42+
[InlineData("C:\\&nimals\\утка\\qu*ck?.ps1", "C:\\&nimals\\утка\\qu`*ck`?.ps1")]
3543
public void CorrectlyGlobEscapesPaths_Spaces(string unescapedPath, string escapedPath)
3644
{
3745
string extensionEscapedPath = PowerShellContext.GlobEscapePath(unescapedPath, escapeSpaces: true);
3846
Assert.Equal(escapedPath, extensionEscapedPath);
3947
}
4048

49+
[Theory]
50+
[InlineData("DebugTest.ps1", "'DebugTest.ps1'")]
51+
[InlineData("../../DebugTest.ps1", "'../../DebugTest.ps1'")]
52+
[InlineData("C:\\Users\\me\\Documents\\DebugTest.ps1", "'C:\\Users\\me\\Documents\\DebugTest.ps1'")]
53+
[InlineData("/home/me/Documents/weird&folder/script.ps1", "'/home/me/Documents/weird&folder/script.ps1'")]
54+
[InlineData("./path/with some/spaces", "'./path/with some/spaces'")]
55+
[InlineData("C:\\path\\with[some]brackets\\file.ps1", "'C:\\path\\with[some]brackets\\file.ps1'")]
56+
[InlineData("C:\\look\\an*\\here.ps1", "'C:\\look\\an*\\here.ps1'")]
57+
[InlineData("/Users/me/Documents/?here.ps1", "'/Users/me/Documents/?here.ps1'")]
58+
[InlineData("/Brackets [and s]paces/path.ps1", "'/Brackets [and s]paces/path.ps1'")]
59+
[InlineData("/file path/that isn't/normal/", "'/file path/that isn''t/normal/'")]
60+
[InlineData("/CJK.chars/脚本/hello.ps1", "'/CJK.chars/脚本/hello.ps1'")]
61+
[InlineData("/CJK chars/脚本/[hello].ps1", "'/CJK chars/脚本/[hello].ps1'")]
62+
[InlineData("C:\\Animal s\\утка\\quack.ps1", "'C:\\Animal s\\утка\\quack.ps1'")]
63+
[InlineData("C:\\&nimals\\утка\\qu*ck?.ps1", "'C:\\&nimals\\утка\\qu*ck?.ps1'")]
64+
public void CorrectlyQuoteEscapesPaths(string unquotedPath, string expectedQuotedPath)
65+
{
66+
string extensionQuotedPath = PowerShellContext.QuoteEscapeString(unquotedPath);
67+
Assert.Equal(expectedQuotedPath, extensionQuotedPath);
68+
}
69+
4170
[Theory]
4271
[InlineData("DebugTest.ps1", "'DebugTest.ps1'")]
4372
[InlineData("../../DebugTest.ps1", "'../../DebugTest.ps1'")]
@@ -49,7 +78,11 @@ public void CorrectlyGlobEscapesPaths_Spaces(string unescapedPath, string escape
4978
[InlineData("/Users/me/Documents/?here.ps1", "'/Users/me/Documents/`?here.ps1'")]
5079
[InlineData("/Brackets [and s]paces/path.ps1", "'/Brackets `[and s`]paces/path.ps1'")]
5180
[InlineData("/file path/that isn't/normal/", "'/file path/that isn''t/normal/'")]
52-
public void CorrectlyFullyEscapesPaths_Spaces(string unescapedPath, string escapedPath)
81+
[InlineData("/CJK.chars/脚本/hello.ps1", "'/CJK.chars/脚本/hello.ps1'")]
82+
[InlineData("/CJK chars/脚本/[hello].ps1", "'/CJK chars/脚本/`[hello`].ps1'")]
83+
[InlineData("C:\\Animal s\\утка\\quack.ps1", "'C:\\Animal s\\утка\\quack.ps1'")]
84+
[InlineData("C:\\&nimals\\утка\\qu*ck?.ps1", "'C:\\&nimals\\утка\\qu`*ck`?.ps1'")]
85+
public void CorrectlyFullyEscapesPaths(string unescapedPath, string escapedPath)
5386
{
5487
string extensionEscapedPath = PowerShellContext.FullyPowerShellEscapePath(unescapedPath);
5588
Assert.Equal(escapedPath, extensionEscapedPath);
@@ -65,6 +98,10 @@ public void CorrectlyFullyEscapesPaths_Spaces(string unescapedPath, string escap
6598
[InlineData("C:\\look\\an`*\\here.ps1", "C:\\look\\an*\\here.ps1")]
6699
[InlineData("/Users/me/Documents/`?here.ps1", "/Users/me/Documents/?here.ps1")]
67100
[InlineData("/Brackets` `[and` s`]paces/path.ps1", "/Brackets [and s]paces/path.ps1")]
101+
[InlineData("/CJK` chars/脚本/hello.ps1", "/CJK chars/脚本/hello.ps1")]
102+
[InlineData("/CJK` chars/脚本/`[hello`].ps1", "/CJK chars/脚本/[hello].ps1")]
103+
[InlineData("C:\\Animal` s\\утка\\quack.ps1", "C:\\Animal s\\утка\\quack.ps1")]
104+
[InlineData("C:\\&nimals\\утка\\qu`*ck`?.ps1", "C:\\&nimals\\утка\\qu*ck?.ps1")]
68105
public void CorrectlyUnescapesPaths(string escapedPath, string expectedUnescapedPath)
69106
{
70107
string extensionUnescapedPath = PowerShellContext.UnescapeGlobEscapedPath(escapedPath);

0 commit comments

Comments
 (0)