mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Minor respath improvements (#5876)
* Minor respath improvements * Add helpers * tweak helper * Throw on more than 1 char * comments * No emoji separators
This commit is contained in:
@@ -36,13 +36,17 @@ public sealed class ResPathTest
|
||||
[TestCase("x/y/z", ExpectedResult = "z")]
|
||||
[TestCase("/bar", ExpectedResult = "bar")]
|
||||
[TestCase("bar/", ExpectedResult = "bar")] // Trailing / gets trimmed.
|
||||
[TestCase("/foo/bar/", ExpectedResult = "bar")]
|
||||
// These next two tests are the current behaviour. I don't know if this is how it should behave, these tests just
|
||||
// ensure that it doesn't change unintentionally
|
||||
[TestCase("/foo/bar//", ExpectedResult = "")]
|
||||
[TestCase("/foo/bar///", ExpectedResult = "")]
|
||||
public string FilenameTest(string input)
|
||||
{
|
||||
var resPathFilename = new ResPath(input).Filename;
|
||||
return resPathFilename;
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
[TestCase(@"", ExpectedResult = @".")]
|
||||
[TestCase(@".", ExpectedResult = @".")]
|
||||
@@ -66,6 +70,11 @@ public sealed class ResPathTest
|
||||
[TestCase(@"/foo/bar/x", ExpectedResult = @"/foo/bar")]
|
||||
[TestCase(@"/foo/bar.txt", ExpectedResult = @"/foo")]
|
||||
[TestCase(@"/bar.txt", ExpectedResult = @"/")]
|
||||
// These next three tests are the current behaviour. I don't know if this is how it should behave, these tests just
|
||||
// ensure that it doesn't change unintentionally
|
||||
[TestCase(@"/foo/bar//", ExpectedResult = "/foo/bar")]
|
||||
[TestCase(@"/foo/bar///", ExpectedResult = "/foo/bar/")]
|
||||
[TestCase(@"/foo/bar////", ExpectedResult = "/foo/bar//")]
|
||||
public string DirectoryTest(string path)
|
||||
{
|
||||
var resPathDirectory = new ResPath(path).Directory.ToString();
|
||||
@@ -73,8 +82,7 @@ public sealed class ResPathTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(@"a/b/c", "👏", ExpectedResult = "a👏b👏c")]
|
||||
[TestCase(@"/a/b/c", "👏", ExpectedResult = "👏a👏b👏c")]
|
||||
[TestCase(@"a/b/c", "\\", ExpectedResult = @"a\b\c")]
|
||||
[TestCase(@"/a/b/c", "\\", ExpectedResult = @"\a\b\c")]
|
||||
public string ChangeSeparatorTest(string input, string separator)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user