Skip to content

Commit

Permalink
Merge pull request #4684 from jpf91/digestCov
Browse files Browse the repository at this point in the history
Add unittest for .length and .peek (std.digest.digest.WrapperDigest)
  • Loading branch information
WalterBright authored Aug 2, 2016
2 parents 22fdbcd + 8cb66be commit 5768530
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions std/digest/digest.d
Original file line number Diff line number Diff line change
Expand Up @@ -992,3 +992,15 @@ unittest
//necessary, result will have the correct length, but buf will still have it's original
//length
}

@safe unittest
{
// Test peek & length
import std.digest.crc;
auto hash = new WrapperDigest!CRC32();
assert(hash.length == 4);
hash.put(cast(const(ubyte[]))"The quick brown fox jumps over the lazy dog");
assert(hash.peek().toHexString() == "39A34F41");
ubyte[5] buf;
assert(hash.peek(buf).toHexString() == "39A34F41");
}

0 comments on commit 5768530

Please sign in to comment.