diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-06-07 14:45:04 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-07 14:45:04 -0500 |
| commit | b747b68ba0ba777be578e73bd1328fbde940e436 (patch) | |
| tree | 160d23aeb8707dc04f81bb52e81913c1b77bb2a4 /tests/slskd.Tests.Unit/Common/FileSafety/IsPathTests.cs | |
| parent | e06999e5eec1616d93b34ffbab0eade617d1aaf6 (diff) | |
| parent | 2d069bbf1f71f38e1286e27d45c24b478feb11ac (diff) | |
| download | slskd-b747b68ba0ba777be578e73bd1328fbde940e436.tar.gz | |
Merge branch 'master' into dependabot/npm_and_yarn/src/web/launch-editor-2.14.1
Diffstat (limited to 'tests/slskd.Tests.Unit/Common/FileSafety/IsPathTests.cs')
| -rw-r--r-- | tests/slskd.Tests.Unit/Common/FileSafety/IsPathTests.cs | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/tests/slskd.Tests.Unit/Common/FileSafety/IsPathTests.cs b/tests/slskd.Tests.Unit/Common/FileSafety/IsPathTests.cs index 42eab9b8..771a1ea0 100644 --- a/tests/slskd.Tests.Unit/Common/FileSafety/IsPathTests.cs +++ b/tests/slskd.Tests.Unit/Common/FileSafety/IsPathTests.cs @@ -1,8 +1,7 @@ -using System.Runtime.InteropServices; -using Xunit; - namespace slskd.Tests.Unit.Common; +using Xunit; + public partial class FileSafetyTests { public class IsPathTests @@ -23,6 +22,9 @@ public partial class FileSafetyTests [InlineData("C:\\Users\\Ünïcödé\\Music")] [InlineData("C:\\Users\\пользователь\\Музыка")] [InlineData("C:\\Users\\用户\\音乐")] + // lowercase drive letters + [InlineData("c:\\Music")] + [InlineData("a:/path")] // UNC paths (\\ prefix) [InlineData("\\\\server\\share")] [InlineData("\\\\server\\share\\folder")] @@ -31,10 +33,11 @@ public partial class FileSafetyTests [InlineData("\\\\server\\Ünïcödé")] [InlineData("\\\\server\\share\\пользователь")] [InlineData("\\\\server\\share\\用户\\音乐")] + [InlineData("\\\\server")] public void IsAbsolute_NotRelative(string path) { - Assert.True(FileSafety.IsPathAbsolute(path, OSPlatform.Windows)); - Assert.False(FileSafety.IsPathRelative(path, OSPlatform.Windows)); + Assert.True(FileSafety.IsPathAbsolute(path, OperatingSystem.Windows)); + Assert.False(FileSafety.IsPathRelative(path, OperatingSystem.Windows)); } } @@ -59,17 +62,18 @@ public partial class FileSafetyTests [InlineData(".")] [InlineData("Ünïcödé")] [InlineData("пользователь/Музыка")] - [InlineData("/Music")] // root-relative — no drive letter, not absolute on Windows - [InlineData("\\Music")] // root-relative — no drive letter, not absolute on Windows - [InlineData("/home/user")] // Unix-style — not recognised as absolute on Windows - [InlineData("//server/share")] // Unix UNC — not recognised as absolute on Windows - [InlineData("C:")] // bare drive letter — length < 3, not absolute - [InlineData("C:Music")] // drive-relative — no separator after colon, not absolute - [InlineData("D:path")] // drive-relative — no separator after colon, not absolute + [InlineData("/Music")] + [InlineData("\\Music")] + [InlineData("/home/user")] + [InlineData("//server/share")] + [InlineData("//server")] + [InlineData("C:")] + [InlineData("C:Music")] + [InlineData("D:path")] public void IsRelative_NotAbsolute(string path) { - Assert.False(FileSafety.IsPathAbsolute(path, OSPlatform.Windows)); - Assert.True(FileSafety.IsPathRelative(path, OSPlatform.Windows)); + Assert.False(FileSafety.IsPathAbsolute(path, OperatingSystem.Windows)); + Assert.True(FileSafety.IsPathRelative(path, OperatingSystem.Windows)); } } } @@ -95,8 +99,8 @@ public partial class FileSafetyTests [InlineData("//192.168.1.1/share")] public void IsAbsolute_NotRelative(string path) { - Assert.True(FileSafety.IsPathAbsolute(path, OSPlatform.Linux)); - Assert.False(FileSafety.IsPathRelative(path, OSPlatform.Linux)); + Assert.True(FileSafety.IsPathAbsolute(path, OperatingSystem.Linux)); + Assert.False(FileSafety.IsPathRelative(path, OperatingSystem.Linux)); } } @@ -116,14 +120,14 @@ public partial class FileSafetyTests [InlineData(".")] [InlineData("Ünïcödé")] [InlineData("пользователь/Музыка")] - [InlineData("C:\\Music")] // Windows drive-letter — not absolute on Linux - [InlineData("C:/Music")] // Windows drive-letter — not absolute on Linux - [InlineData("\\\\server\\share")] // Windows UNC — not absolute on Linux - [InlineData("\\Music")] // Windows root-relative — not absolute on Linux + [InlineData("C:\\Music")] + [InlineData("C:/Music")] + [InlineData("\\\\server\\share")] + [InlineData("\\Music")] public void IsRelative_NotAbsolute(string path) { - Assert.False(FileSafety.IsPathAbsolute(path, OSPlatform.Linux)); - Assert.True(FileSafety.IsPathRelative(path, OSPlatform.Linux)); + Assert.False(FileSafety.IsPathAbsolute(path, OperatingSystem.Linux)); + Assert.True(FileSafety.IsPathRelative(path, OperatingSystem.Linux)); } } } |
