Path: blob/master/bench/other/boatbomber-HashLib/HashLib.spec.lua
2727 views
local function describe(phrase, callback) end1local function it(phrase, callback) end2local function expect(value) end34return function()5local HashLib = require(script.Parent)6local sha256 = HashLib.sha25678describe("HashLib.sha256", function()9it("should properly encode strings", function()10expect(sha256("abc").to.equal("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"))11expect(12sha256("The quick brown fox jumps over the lazy dog").to.equal(13"d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"14)15)16expect(sha256("123456").to.equal("8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92"))17end)1819it("should create a private closure that works", function()20local AppendNextChunk = sha256()21AppendNextChunk("The quick brown fox")22AppendNextChunk(" jumps ")23AppendNextChunk("") -- chunk may be an empty string24AppendNextChunk("over the lazy dog")25expect(AppendNextChunk()).to.equal("d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592")26end)2728it("should allow the private closure to work if called twice", function()29local AppendNextChunk = sha256()30AppendNextChunk("The quick brown fox")31AppendNextChunk(" jumps ")32AppendNextChunk("") -- chunk may be an empty string33AppendNextChunk("over the lazy dog")34AppendNextChunk()35expect(AppendNextChunk()).to.equal("d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592")36end)37end)38end394041