refactor(crypto): format test names (#3989)

* initial commit

* tweaks

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
Tim Reichen 2023-12-19 01:50:15 +01:00 committed by GitHub
parent b0803619af
commit 852ef9c77a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 38 deletions

View File

@ -2,7 +2,7 @@
import { assertEquals } from "../../assert/mod.ts";
import { mul32, mul64 } from "./util.ts";
Deno.test("[hash/fnv/util] mul32", () => {
Deno.test("mul32()", () => {
assertEquals(mul32(0xffffffff, 0xffffffff), 1);
assertEquals(mul32(0x12345678, 0xdeadbeef), 0x5621ca08);
assertEquals(mul32(0xf626f430, 0xff7469f1), 0x2a939130);
@ -17,7 +17,7 @@ Deno.test("[hash/fnv/util] mul32", () => {
assertEquals(mul32(0xc60898cc, 0xbfe7dcc4), 0x15f84c30);
});
Deno.test("[hash/fnv/util] mul64", () => {
Deno.test("mul64()", () => {
assertEquals(mul64([0xffffffff, 0xffffffff], [0xffffffff, 0xffffffff]), [
0,
1,

View File

@ -11,7 +11,7 @@ const moduleDir = dirname(fromFileUrl(import.meta.url));
const webCrypto = globalThis.crypto;
Deno.test(
"[crypto/digest] Different ways to perform the same operation should produce the same result",
"digest() handles different ways to perform the same operation should produce the same result",
async () => {
const inputString = "taking the hobbits to isengard";
const inputBytes = new TextEncoder().encode(inputString);
@ -110,7 +110,7 @@ Deno.test(
},
);
Deno.test("[crypto/digest] Should return an ArrayBuffer", async () => {
Deno.test("digest() returns an ArrayBuffer", async () => {
const inputString = "taking the hobbits to isengard";
const inputBytes = new TextEncoder().encode(inputString);
@ -147,7 +147,7 @@ Deno.test("[crypto/digest] Should return an ArrayBuffer", async () => {
);
});
Deno.test("[crypto/digest] Should not ignore length option", async () => {
Deno.test("digest() handles length option", async () => {
const inputString = "taking the hobbits to isengard";
const inputBytes = new TextEncoder().encode(inputString);
@ -166,7 +166,7 @@ Deno.test("[crypto/digest] Should not ignore length option", async () => {
);
});
Deno.test("[crypto/digest] Memory use should remain reasonable even with large inputs", async () => {
Deno.test("digest() keeps memory usage reasonable with large inputs", async () => {
const code = `
import { crypto as stdCrypto } from "./mod.ts";
import { instantiateWithInstance } from "./_wasm/lib/deno_std_wasm_crypto.generated.mjs";
@ -248,7 +248,7 @@ Deno.test("[crypto/digest] Memory use should remain reasonable even with large i
);
});
Deno.test("[crypto/digest] Memory use should remain reasonable even with many calls", async () => {
Deno.test("digest() keeps memory usage reasonable with many calls", async () => {
const code = `
import { crypto as stdCrypto } from "./mod.ts";
import { instantiateWithInstance } from "./_wasm/lib/deno_std_wasm_crypto.generated.mjs";
@ -1305,7 +1305,7 @@ const digestCases: [
],
];
Deno.test("[crypto/digest/fnv] fnv algorithm implementation", () => {
Deno.test("digest() checks fnv algorithm implementation", () => {
const inputString = "deno";
const inputBytes = new TextEncoder().encode(inputString);
@ -1335,7 +1335,7 @@ Deno.test("[crypto/digest/fnv] fnv algorithm implementation", () => {
});
for (const algorithm of digestAlgorithms) {
Deno.test(`[crypto/digest/${algorithm}] test vectors`, async () => {
Deno.test(`digest() checks ${algorithm} vectors`, async () => {
for (
const [caption, piecesVariations, options, algorithms] of digestCases
) {
@ -1402,6 +1402,6 @@ for (const algorithm of digestAlgorithms) {
* that (at least this one of) the native methods are indeed re-exported, and
* that they're appropriately bound to use the required receiver.
*/
Deno.test("[crypto/getRandomValues] passes through to native implementation", () => {
Deno.test("getRandomValues() passes through to native implementation", () => {
assertInstanceOf(stdCrypto.getRandomValues(new Uint8Array(1)), Uint8Array);
});

View File

@ -4,7 +4,7 @@ import { assert } from "../assert/mod.ts";
import { timingSafeEqual } from "./timing_safe_equal.ts";
Deno.test({
name: "[timingSafeEqual] - ArrayBuffer comparison - equal",
name: "timingSafeEqual() compares equal ArrayBuffer",
fn() {
const a = new ArrayBuffer(2);
const va = new DataView(a);
@ -19,7 +19,7 @@ Deno.test({
});
Deno.test({
name: "[timingSafeEqual] - ArrayBuffer comparison - not equal",
name: "timingSafeEqual() compares unequal ArrayBuffer",
fn() {
const a = new ArrayBuffer(2);
const va = new DataView(a);
@ -34,7 +34,7 @@ Deno.test({
});
Deno.test({
name: "[timingSafeEqual] - Uint8Array comparison - equal",
name: "timingSafeEqual() compares equal Uint8Array",
fn() {
const a = new Uint8Array([212, 213]);
const b = new Uint8Array([212, 213]);
@ -43,7 +43,7 @@ Deno.test({
});
Deno.test({
name: "[timingSafeEqual] - Uint8Array comparison - not equal",
name: "timingSafeEqual() compares unequal Uint8Array",
fn() {
const a = new Uint8Array([212, 213]);
const b = new Uint8Array([212, 212]);
@ -52,7 +52,7 @@ Deno.test({
});
Deno.test({
name: "[timingSafeEqual] - Uint8Array comparison #2 - equal",
name: "timingSafeEqual() compares equal encoded Uint8Array",
fn() {
const encoder = new TextEncoder();
const a = encoder.encode("hello deno");
@ -62,7 +62,7 @@ Deno.test({
});
Deno.test({
name: "[timingSafeEqual] - Uint8Array comparison #2 - not equal",
name: "timingSafeEqual() compares unequal encoded Uint8Array",
fn() {
const encoder = new TextEncoder();
const a = encoder.encode("hello deno");
@ -72,7 +72,8 @@ Deno.test({
});
Deno.test({
name: "[timingSafeEqual] - Uint8Array w. different buffer sizes (a > b)",
name:
"timingSafeEqual() handles Uint8Array with different buffer sizes (a > b)",
fn() {
const a = new SharedArrayBuffer(4);
const va = new DataView(a);
@ -96,7 +97,8 @@ Deno.test({
});
Deno.test({
name: "[timingSafeEqual] - Uint8Array w. different buffer sizes (b > a)",
name:
"timingSafeEqual() handles Uint8Array with different buffer sizes (b > a)",
fn() {
const a = new SharedArrayBuffer(2);
const va = new DataView(a);
@ -120,7 +122,7 @@ Deno.test({
});
Deno.test({
name: "[timingSafeEqual] - Uint8Array w. non-0 byteOffset",
name: "timingSafeEqual() handles Uint8Array with non-0 byteOffset",
fn() {
const a = new SharedArrayBuffer(4);
const va = new DataView(a);

View File

@ -5,7 +5,7 @@ import { assert, assertEquals } from "../assert/mod.ts";
import { KeyStack } from "./unstable_keystack.ts";
Deno.test({
name: "keyStack.sign() - single key",
name: "keyStack.sign() handles single key",
async fn() {
const keys = ["hello"];
const keyStack = new KeyStack(keys);
@ -16,7 +16,7 @@ Deno.test({
});
Deno.test({
name: "keyStack.sign() - two keys, first key used",
name: "keyStack.sign() handles two keys, first key used",
async fn() {
const keys = ["hello", "world"];
const keyStack = new KeyStack(keys);
@ -27,7 +27,7 @@ Deno.test({
});
Deno.test({
name: "keyStack.verify() - single key",
name: "keyStack.verify() handles single key",
async fn() {
const keys = ["hello"];
const keyStack = new KeyStack(keys);
@ -37,7 +37,7 @@ Deno.test({
});
Deno.test({
name: "keyStack.verify() - single key verify invalid",
name: "keyStack.verify() handles single key verify invalid",
async fn() {
const keys = ["hello"];
const keyStack = new KeyStack(keys);
@ -47,7 +47,7 @@ Deno.test({
});
Deno.test({
name: "keyStack.verify() - two keys",
name: "keyStack.verify() handles two keys",
async fn() {
const keys = ["hello", "world"];
const keyStack = new KeyStack(keys);
@ -57,7 +57,7 @@ Deno.test({
});
Deno.test({
name: "keyStack.verify() - unshift key",
name: "keyStack.verify() handles unshift key",
async fn() {
const keys = ["hello"];
const keyStack = new KeyStack(keys);
@ -69,7 +69,7 @@ Deno.test({
});
Deno.test({
name: "keyStack.verify() - shift key",
name: "keyStack.verify() handles shift key",
async fn() {
const keys = ["hello", "world"];
const keyStack = new KeyStack(keys);
@ -81,7 +81,7 @@ Deno.test({
});
Deno.test({
name: "keyStack.indexOf() - single key",
name: "keyStack.indexOf() handles single key",
async fn() {
const keys = ["hello"];
const keyStack = new KeyStack(keys);
@ -96,7 +96,7 @@ Deno.test({
});
Deno.test({
name: "keyStack.indexOf() - two keys index 0",
name: "keyStack.indexOf() handles two keys index 0",
async fn() {
const keys = ["hello", "world"];
const keyStack = new KeyStack(keys);
@ -111,7 +111,7 @@ Deno.test({
});
Deno.test({
name: "keyStack.indexOf() - two keys index 1",
name: "keyStack.indexOf() handles two keys index 1",
async fn() {
const keys = ["world", "hello"];
const keyStack = new KeyStack(keys);
@ -126,7 +126,7 @@ Deno.test({
});
Deno.test({
name: "keyStack.indexOf() - two keys not found",
name: "keyStack.indexOf() handles two keys not found",
async fn() {
const keys = ["world", "hello"];
const keyStack = new KeyStack(keys);
@ -141,7 +141,7 @@ Deno.test({
});
Deno.test({
name: "keyStack - number array key",
name: "keyStack.verify() handles number array key",
async fn() {
const keys = [[212, 213]];
const keyStack = new KeyStack(keys);
@ -150,7 +150,7 @@ Deno.test({
});
Deno.test({
name: "keyStack - Uint8Array key",
name: "keyStack.verify() handles Uint8Array key",
async fn() {
const keys = [new Uint8Array([212, 213])];
const keyStack = new KeyStack(keys);
@ -159,7 +159,7 @@ Deno.test({
});
Deno.test({
name: "keyStack - ArrayBuffer key",
name: "verify() handles ArrayBuffer key",
async fn() {
const key = new ArrayBuffer(2);
const dataView = new DataView(key);
@ -172,7 +172,7 @@ Deno.test({
});
Deno.test({
name: "keyStack - number array data",
name: "verify() handles number array data",
async fn() {
const keys = [[212, 213]];
const keyStack = new KeyStack(keys);
@ -181,7 +181,7 @@ Deno.test({
});
Deno.test({
name: "keyStack - Uint8Array data",
name: "verify() handles Uint8Array data",
async fn() {
const keys = [[212, 213]];
const keyStack = new KeyStack(keys);
@ -195,7 +195,7 @@ Deno.test({
});
Deno.test({
name: "keyStack - ArrayBuffer data",
name: "verify() handles ArrayBuffer data",
async fn() {
const keys = [[212, 213]];
const keyStack = new KeyStack(keys);
@ -212,7 +212,7 @@ Deno.test({
});
Deno.test({
name: "keyStack - user iterable keys",
name: "verify() handles user iterable keys",
async fn() {
const keys = new Set(["hello", "world"]);
const keyStack = new KeyStack(keys);
@ -223,7 +223,7 @@ Deno.test({
});
Deno.test({
name: "KeyStack - inspecting",
name: "KeyStack() handles inspection",
fn() {
assertEquals(
Deno.inspect(new KeyStack(["abcdef"])),