Skip to content

Commit

Permalink
Merge pull request typelevel#3466 from mpilquist/topic/digest
Browse files Browse the repository at this point in the history
Add tests for hashPureStream and hashChunk
  • Loading branch information
mpilquist authored Aug 26, 2024
2 parents 333b753 + 59a21dd commit f8e2a33
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/shared/src/test/scala/fs2/hashing/HashingSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,23 @@ class HashingSuite extends Fs2Suite with HashingSuitePlatform with TestPlatform
}
}

test("hashPureStream") {
forAllF { (strings: List[String]) =>
val source = strings.foldMap(s => Stream.chunk(Chunk.array(s.getBytes)))
val actual = Hashing.hashPureStream(HashAlgorithm.SHA256, source)
val expected = digest(HashAlgorithm.SHA256, strings.combineAll)
actual.pure[IO].assertEquals(expected)
}
}

test("hashChunk") {
forAllF { (string: String) =>
val actual = Hashing.hashChunk(HashAlgorithm.SHA256, Chunk.array(string.getBytes))
val expected = digest(HashAlgorithm.SHA256, string)
actual.pure[IO].assertEquals(expected)
}
}

test("example of writing a file and a hash") {
def writeAll(path: String): Pipe[IO, Byte, Nothing] = {
identity(path) // Ignore unused warning
Expand Down

0 comments on commit f8e2a33

Please sign in to comment.