File tree Expand file tree Collapse file tree 1 file changed +35
-8
lines changed
test/CodeQLToolkit.Shared.Tests/Utils Expand file tree Collapse file tree 1 file changed +35
-8
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
+ using System . Runtime . InteropServices ;
4
5
using System . Text ;
5
6
using System . Threading . Tasks ;
6
7
@@ -34,24 +35,50 @@ public void TestCreateTempDirectoryWithPath()
34
35
[ Test ]
35
36
public void TestSanitizeFilename ( )
36
37
{
37
- string [ ] paths = new string [ ] {
38
+
39
+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
40
+ {
41
+ string [ ] paths = new string [ ] {
38
42
"invalid:#!/\\ /path" ,
39
43
"codeql/cli-1.1.2"
40
- } ;
44
+ } ;
41
45
42
- string [ ] expected = new string [ ] {
46
+ string [ ] expected = new string [ ] {
43
47
"invalid_#!___path" ,
44
48
"codeql_cli-1.1.2"
45
- } ;
49
+ } ;
50
+
51
+ for ( int i = 0 ; i < paths . Length ; i ++ )
52
+ {
53
+ Console . WriteLine ( i + "Actual: " + FileUtils . SanitizeFilename ( paths [ i ] ) ) ;
54
+ Console . WriteLine ( i + "Expected: " + expected [ i ] ) ;
46
55
47
- for ( int i = 0 ; i < paths . Length ; i ++ )
56
+ Assert . IsTrue ( FileUtils . SanitizeFilename ( paths [ i ] ) == expected [ i ] ) ;
57
+ }
58
+
59
+ }
60
+ else
48
61
{
49
- Console . WriteLine ( i + "Actual: " + FileUtils . SanitizeFilename ( paths [ i ] ) ) ;
50
- Console . WriteLine ( i + "Expected: " + expected [ i ] ) ;
62
+ string [ ] paths = new string [ ] {
63
+ "invalid:#!/\\ /path" ,
64
+ "codeql/cli-1.1.2"
65
+ } ;
66
+
67
+ string [ ] expected = new string [ ] {
68
+ "invalid:#!_\\ _path" ,
69
+ "codeql_cli-1.1.2"
70
+ } ;
51
71
52
- Assert . IsTrue ( FileUtils . SanitizeFilename ( paths [ i ] ) == expected [ i ] ) ;
72
+ for ( int i = 0 ; i < paths . Length ; i ++ )
73
+ {
74
+ Console . WriteLine ( i + "Actual: " + FileUtils . SanitizeFilename ( paths [ i ] ) ) ;
75
+ Console . WriteLine ( i + "Expected: " + expected [ i ] ) ;
76
+
77
+ Assert . IsTrue ( FileUtils . SanitizeFilename ( paths [ i ] ) == expected [ i ] ) ;
78
+ }
53
79
}
54
80
81
+
55
82
}
56
83
}
57
84
}
You can’t perform that action at this time.
0 commit comments