2019-01-03 02:16:19 +01:00
|
|
|
|
using LibHac.IO;
|
2018-12-23 22:49:28 +01:00
|
|
|
|
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"},
|
2019-01-03 02:16:19 +01:00
|
|
|
|
new object[] {"/../a/b/c/.", "/a/b/c"},
|
|
|
|
|
new object[] {"/./a/b/c/.", "/a/b/c"},
|
2018-12-23 22:49:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new object[] {"/a/b/c/", "/a/b/c/"},
|
|
|
|
|
new object[] {"/a/./b/../c/", "/a/c/"},
|
2019-01-03 02:16:19 +01:00
|
|
|
|
new object[] {"/./b/../c/", "/c/"},
|
2018-12-23 22:49:28 +01:00
|
|
|
|
new object[] {"/a/../../../", "/"},
|
|
|
|
|
new object[] {"//a/b//.//c/", "/a/b/c/"},
|
2019-01-03 02:16:19 +01:00
|
|
|
|
new object[] {"/tmp/../", "/"},
|
|
|
|
|
|
|
|
|
|
new object[] {"a", "/a"},
|
|
|
|
|
new object[] {"a/../../../a/b/c", "/a/b/c"},
|
|
|
|
|
new object[] {"./b/../c/", "/c/"},
|
|
|
|
|
new object[] {".", "/"},
|
|
|
|
|
new object[] {"..", "/"},
|
|
|
|
|
new object[] {"../a/b/c/.", "/a/b/c"},
|
|
|
|
|
new object[] {"./a/b/c/.", "/a/b/c"},
|
2018-12-23 22:49:28 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[MemberData(nameof(NormalizedPathTestItems))]
|
|
|
|
|
public static void NormalizePath(string path, string expected)
|
|
|
|
|
{
|
|
|
|
|
string actual = PathTools.Normalize(path);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|