Less parsing, allocation & LINQ when splitting strings (#18048)
* Less parsing, allocation & LINQ when splitting strings * Added unit test verifying refactoring of GetIdsFromPathReversed. --------- Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
@@ -387,4 +387,12 @@ public class StringExtensionsTests
|
||||
Assert.AreNotEqual(path, Path.GetFullPath(path));
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase("1,2,3,4,5", "5,4,3,2,1")]
|
||||
[TestCase("1,2,x,4,5", "5,4,2,1")]
|
||||
public void GetIdsFromPathReversed(string input, string expected)
|
||||
{
|
||||
var ids = input.GetIdsFromPathReversed();
|
||||
Assert.AreEqual(expected, string.Join(",", ids));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user