mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
|
using System.IO;
|
|||
|
using LibHac.IO;
|
|||
|
using Xunit;
|
|||
|
|
|||
|
namespace LibHac.Tests
|
|||
|
{
|
|||
|
public class PathToolsTests
|
|||
|
{
|
|||
|
public static object[][] NormalizedPathTestItems =
|
|||
|
{
|
|||
|
new object[] {"", "/"},
|
|||
|
new object[] {"/", "/"},
|
|||
|
new object[] {"/.", "/"},
|
|||
|
new object[] {"/a/b/c", "/a/b/c"},
|
|||
|
new object[] {"/a/b/../c", "/a/c"},
|
|||
|
new object[] {"/a/b/c/..", "/a/b"},
|
|||
|
new object[] {"/a/b/c/.", "/a/b/c"},
|
|||
|
new object[] {"/a/../../..", "/"},
|
|||
|
new object[] {"/a/../../../a/b/c", "/a/b/c"},
|
|||
|
new object[] {"//a/b//.//c", "/a/b/c"},
|
|||
|
|
|||
|
|
|||
|
new object[] {"/a/b/c/", "/a/b/c/"},
|
|||
|
new object[] {"/a/./b/../c/", "/a/c/"},
|
|||
|
new object[] {"/a/../../../", "/"},
|
|||
|
new object[] {"//a/b//.//c/", "/a/b/c/"},
|
|||
|
new object[] {@"/tmp/../", @"/"},
|
|||
|
};
|
|||
|
|
|||
|
[Theory]
|
|||
|
[MemberData(nameof(NormalizedPathTestItems))]
|
|||
|
public static void NormalizePath(string path, string expected)
|
|||
|
{
|
|||
|
string actual = PathTools.Normalize(path);
|
|||
|
|
|||
|
Assert.Equal(expected, actual);
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public static void NormalizeThrowsOnInvalidStartChar()
|
|||
|
{
|
|||
|
Assert.Throws<InvalidDataException>(() => PathTools.Normalize(@"c:\a\b\c"));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|