forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_WildcardPattern.cs
More file actions
63 lines (55 loc) · 1.77 KB
/
test_WildcardPattern.cs
File metadata and controls
63 lines (55 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using System.Management.Automation;
using Xunit;
namespace PSTests.Parallel
{
public class WildcardPatternTests
{
[Fact]
public void TestEscape_Null()
{
Assert.Throws<System.Management.Automation.PSArgumentNullException>(delegate { WildcardPattern.Escape(null); });
}
[Fact]
public void TestEscape_Empty()
{
Assert.Equal(WildcardPattern.Escape(string.Empty), string.Empty);
}
[Theory]
[InlineData("a", "a")]
[InlineData("a*", "a`*")]
[InlineData("*?[]", "`*`?`[`]")]
public void TestEscape_String(string source, string expected)
{
Assert.Equal(WildcardPattern.Escape(source), expected);
}
[Theory]
[InlineData("a", "a")]
[InlineData("a*", "a*")]
[InlineData("*?[]", "*?[]")]
public void TestEscape_String_NotEscape(string source, string expected)
{
Assert.Equal(WildcardPattern.Escape(source, new[] { '*', '?', '[', ']' }), expected);
}
[Fact]
public void TestUnescape_Null()
{
Assert.Throws<System.Management.Automation.PSArgumentNullException>(delegate { WildcardPattern.Unescape(null); });
}
[Fact]
public void TestUnescape_Empty()
{
Assert.Equal(WildcardPattern.Unescape(string.Empty), string.Empty);
}
[Theory]
[InlineData("a", "a")]
[InlineData("a`*", "a*")]
[InlineData("`*`?`[`]", "*?[]")]
public void TestUnescape_String(string source, string expected)
{
Assert.Equal(WildcardPattern.Unescape(source), expected);
}
}
}