-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { toBase64 } from "@smithy/util-base64"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
import { CrtCrc64Nvme } from "./CrtCrc64Nvme"; | ||
|
||
describe(CrtCrc64Nvme.name, () => { | ||
it("should throw an error if digest is called before update", async () => { | ||
const crc64 = new CrtCrc64Nvme(); | ||
await expect(crc64.digest()).rejects.toThrowError("No data provided to checksum"); | ||
}); | ||
|
||
it.each([ | ||
["", "AAAAAAAAAAA="], | ||
["abc", "BeXKuz/B+us="], | ||
["Hello world", "OOJZ0D8xKts="], | ||
])(`crc64-nvme for "%s" is "%s"`, async (input, output) => { | ||
const crc64 = new CrtCrc64Nvme(); | ||
crc64.update(new TextEncoder().encode(input)); | ||
const digest = await crc64.digest(); | ||
expect(toBase64(digest)).toEqual(output); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
include: ["**/*.spec.ts"], | ||
environment: "node", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters