Skip to content

Commit ee0d8b8

Browse files
committed
linux specific test case
1 parent 574cee0 commit ee0d8b8

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

test/CodeQLToolkit.Shared.Tests/Utils/FileUtilsTest.cs

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Runtime.InteropServices;
45
using System.Text;
56
using System.Threading.Tasks;
67

@@ -34,24 +35,50 @@ public void TestCreateTempDirectoryWithPath()
3435
[Test]
3536
public void TestSanitizeFilename()
3637
{
37-
string[] paths = new string[]{
38+
39+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
40+
{
41+
string[] paths = new string[]{
3842
"invalid:#!/\\/path",
3943
"codeql/cli-1.1.2"
40-
};
44+
};
4145

42-
string[] expected = new string[]{
46+
string[] expected = new string[]{
4347
"invalid_#!___path",
4448
"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]);
4655

47-
for (int i= 0; i < paths.Length; i++)
56+
Assert.IsTrue(FileUtils.SanitizeFilename(paths[i]) == expected[i]);
57+
}
58+
59+
}
60+
else
4861
{
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+
};
5171

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+
}
5379
}
5480

81+
5582
}
5683
}
5784
}

0 commit comments

Comments
 (0)