Skip to content

Commit

Permalink
Add stream/absolute path helper functions but in a way that doesn't r…
Browse files Browse the repository at this point in the history
…equire the rate limiting library
  • Loading branch information
halgari committed Aug 15, 2023
1 parent 9bf2803 commit 9b3fd35
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/NexusMods.Hashing.xxHash64.Tests/HashTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,27 @@ public async Task CanHashLargeFile()
emptyArray[x] = (byte)(x % 256);
}
await file.WriteAllBytesAsync(emptyArray);
(await file.XxHash64Async()).Should().NotBe(Hash.FromULong(0xf4c92be058f432d0));
(await file.XxHash64Async()).Should().Be(Hash.FromULong(0x54AC7E8D1810EC9D));
file.Delete();
}

[Fact]
public async Task CanHashLargeFileWithReporting()
{
var file = _fileSystem.GetKnownPath(KnownPath.CurrentDirectory).Combine($"tempFile{Guid.NewGuid()}");
var emptyArray = new byte[1024 * 1024 * 10];
for (var x = 0; x < emptyArray.Length; x++)
{
emptyArray[x] = (byte)(x % 256);
}
await file.WriteAllBytesAsync(emptyArray);

var ms = new MemoryStream();

var expectedHash = Hash.FromULong(0x54AC7E8D1810EC9D);

(await file.XxHash64Async(reportFn: async m => await ms.WriteAsync(m))).Should().Be(expectedHash);
ms.ToArray().AsSpan().XxHash64().Should().Be(expectedHash);
file.Delete();
}
}

0 comments on commit 9b3fd35

Please sign in to comment.