ref: 精简路径比较修复

This commit is contained in:
Meloong Bot committed 2026-10-11 03:04:16 +08:00
1 parent 201948eac8
commit ae6676cd90
4 files changed
+1 -81

No files matched your search

-25
View File
@@ -37,31 +37,6 @@ public class PathUtilsTests : TestBase {
#region 路径处理
[Test]
[Arguments("en-US")]
[Arguments("zh-CN")]
[Arguments("tr-TR")]
public async Task 路径比较_不受当前语言影响(string cultureName) {
var originalCulture = System.Globalization.CultureInfo.CurrentCulture;
try {
System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(cultureName);
await Assert.That(PathUtils.Compare(@"C:\FILES\FILE.jar", @"C:\files\file.jar")).IsEqualTo(0);
await Assert.That(PathUtils.IsSame(@"C:\FILES\FILE.jar", @"C:\files\file.jar")).IsTrue();
await Assert.That(PathUtils.IsSame(@"C:\files\I.jar", @"C:\files\ı.jar")).IsFalse();
await Assert.That(PathUtils.IsSame(@"C:\files\ab.jar", "C:\\files\\a\u00adb.jar")).IsFalse();
await Assert.That(PathUtils.Compare(@"C:\files\I.jar", @"C:\files\J.jar") < 0).IsTrue();
await Assert.That(PathUtils.IsParentOf(@"C:\FILES", @"C:\files\child")).IsTrue();
await Assert.That(PathUtils.IsParentOf(@"C:\FILES", @"C:\files")).IsTrue();
await Assert.That(PathUtils.IsParentOf(@"C:\FILES", @"C:\files-other\child")).IsFalse();
await Assert.That(PathUtils.IsParentOf(@"C:\I", @"C:\ı\child")).IsFalse();
await Assert.That(PathUtils.IsSame(null, "")).IsTrue();
await Assert.That(PathUtils.Compare("", @"C:\files") < 0).IsTrue();
await Assert.That(PathUtils.Compare(@"C:\files", null) > 0).IsTrue();
} finally {
System.Globalization.CultureInfo.CurrentCulture = originalCulture;
}
}
[Test]
[Arguments(@"\\?\C:\foo\bar.txt", @"\\?\C:\foo")]
[Arguments(@"C:\foo\extra/bar.txt", @"C:\foo\extra")]