Skip to content

Commit

Permalink
Fix Unit Tests
Browse files Browse the repository at this point in the history
(cherry picked from commit 376ca1e)
  • Loading branch information
Simon Ensslen committed Feb 17, 2021
1 parent 216ab62 commit 159dbd4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/ICSharpCode.SharpZipLib/Tar/TarStringExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ internal static class TarStringExtension
{
public static string ClearTarPath(this string s)
{
if (Path.GetPathRoot(s) != null)
var pathRoot = Path.GetPathRoot(s);
if (!string.IsNullOrEmpty(pathRoot))
{
s = s.Substring(Path.GetPathRoot(s).Length);
s = s.Substring(pathRoot.Length);
}
return s.Replace(Path.DirectorySeparatorChar, '/');
}
Expand Down
4 changes: 2 additions & 2 deletions test/ICSharpCode.SharpZipLib.Tests/Tar/TarTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ public void rootPathIsRespected()
var expectationDirectory = new DirectoryInfo(tempDirectory);
foreach (var checkFile in expectationDirectory.GetFiles("", SearchOption.AllDirectories))
{
var relativePath = expectationDirectory.FullName.Substring(expectationDirectory.FullName.Length);
var relativePath = checkFile.FullName.Substring(expectationDirectory.FullName.Length + 1);
FileAssert.Exists(Path.Combine(extractDirectory, relativePath));
FileAssert.AreEqual(checkFile.FullName, Path.Combine(extractDirectory, relativePath));
}
Expand All @@ -954,7 +954,7 @@ private void CreateAndClearDirectory(string path)
{
if (Directory.Exists(path))
{
Directory.Delete(path);
Directory.Delete(path, true);
}
Directory.CreateDirectory(path);
}
Expand Down

0 comments on commit 159dbd4

Please sign in to comment.