diff options
Diffstat (limited to 'std/hash')
-rw-r--r-- | std/hash/_fnv/util_test.ts | 6 | ||||
-rw-r--r-- | std/hash/fnv_test.ts | 18 | ||||
-rw-r--r-- | std/hash/md5_test.ts | 6 | ||||
-rw-r--r-- | std/hash/sha1_test.ts | 7 | ||||
-rw-r--r-- | std/hash/sha256_test.ts | 14 | ||||
-rw-r--r-- | std/hash/sha3_test.ts | 57 | ||||
-rw-r--r-- | std/hash/sha512_test.ts | 16 |
7 files changed, 55 insertions, 69 deletions
diff --git a/std/hash/_fnv/util_test.ts b/std/hash/_fnv/util_test.ts index 3b16d83cb..5e31a98bd 100644 --- a/std/hash/_fnv/util_test.ts +++ b/std/hash/_fnv/util_test.ts @@ -1,10 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - -const { test } = Deno; import { assertEquals } from "../../testing/asserts.ts"; import { mul32, mul64 } from "./util.ts"; -test("[hash/fnv/util] mul32", () => { +Deno.test("[hash/fnv/util] mul32", () => { assertEquals(mul32(0xffffffff, 0xffffffff), 1); assertEquals(mul32(0x12345678, 0xdeadbeef), 0x5621ca08); assertEquals(mul32(0xf626f430, 0xff7469f1), 0x2a939130); @@ -19,7 +17,7 @@ test("[hash/fnv/util] mul32", () => { assertEquals(mul32(0xc60898cc, 0xbfe7dcc4), 0x15f84c30); }); -test("[hash/fnv/util] mul64", () => { +Deno.test("[hash/fnv/util] mul64", () => { assertEquals(mul64([0xffffffff, 0xffffffff], [0xffffffff, 0xffffffff]), [ 0, 1, diff --git a/std/hash/fnv_test.ts b/std/hash/fnv_test.ts index 6c2d66f9a..20209703a 100644 --- a/std/hash/fnv_test.ts +++ b/std/hash/fnv_test.ts @@ -3,8 +3,6 @@ // Copyright 2011 The Go Authors. All rights reserved. BSD license. // https://github.com/golang/go/blob/master/LICENSE // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import { Fnv32, Fnv32a, Fnv64, Fnv64a } from "./fnv.ts"; @@ -40,7 +38,7 @@ const golden64a = [ ["deno", [0xa5, 0xd9, 0xfb, 0x67, 0x42, 0x6e, 0x48, 0xb1]], ]; -test("[hash/fnv] testFnv32", () => { +Deno.test("[hash/fnv] testFnv32", () => { for (const [input, output] of golden32) { const fnv = new Fnv32(); fnv.write(new TextEncoder().encode(input as string)); @@ -48,7 +46,7 @@ test("[hash/fnv] testFnv32", () => { } }); -test("[hash/fnv] testFnv32a", () => { +Deno.test("[hash/fnv] testFnv32a", () => { for (const [input, output] of golden32a) { const fnv = new Fnv32a(); fnv.write(new TextEncoder().encode(input as string)); @@ -56,7 +54,7 @@ test("[hash/fnv] testFnv32a", () => { } }); -test("[hash/fnv] testFnv64", () => { +Deno.test("[hash/fnv] testFnv64", () => { for (const [input, output] of golden64) { const fnv = new Fnv64(); fnv.write(new TextEncoder().encode(input as string)); @@ -64,7 +62,7 @@ test("[hash/fnv] testFnv64", () => { } }); -test("[hash/fnv] testFnv64a", () => { +Deno.test("[hash/fnv] testFnv64a", () => { for (const [input, output] of golden64a) { const fnv = new Fnv64a(); fnv.write(new TextEncoder().encode(input as string)); @@ -72,7 +70,7 @@ test("[hash/fnv] testFnv64a", () => { } }); -test("[hash/fnv] testFnv32WriteChain", () => { +Deno.test("[hash/fnv] testFnv32WriteChain", () => { const fnv = new Fnv32(); fnv .write(new TextEncoder().encode("d")) @@ -82,7 +80,7 @@ test("[hash/fnv] testFnv32WriteChain", () => { assertEquals(fnv.sum(), [0x6e, 0xd5, 0xa7, 0xa9]); }); -test("[hash/fnv] testFnv32aWriteChain", () => { +Deno.test("[hash/fnv] testFnv32aWriteChain", () => { const fnv = new Fnv32a(); fnv .write(new TextEncoder().encode("d")) @@ -92,7 +90,7 @@ test("[hash/fnv] testFnv32aWriteChain", () => { assertEquals(fnv.sum(), [0x8e, 0xf6, 0x47, 0x11]); }); -test("[hash/fnv] testFnv64WriteChain", () => { +Deno.test("[hash/fnv] testFnv64WriteChain", () => { const fnv = new Fnv64(); fnv .write(new TextEncoder().encode("d")) @@ -102,7 +100,7 @@ test("[hash/fnv] testFnv64WriteChain", () => { assertEquals(fnv.sum(), [0x14, 0xed, 0xb2, 0x7e, 0xec, 0xda, 0xad, 0xc9]); }); -test("[hash/fnv] testFnv64aWriteChain", () => { +Deno.test("[hash/fnv] testFnv64aWriteChain", () => { const fnv = new Fnv64a(); fnv .write(new TextEncoder().encode("d")) diff --git a/std/hash/md5_test.ts b/std/hash/md5_test.ts index 050c5ae91..89bd249ab 100644 --- a/std/hash/md5_test.ts +++ b/std/hash/md5_test.ts @@ -1,6 +1,4 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import { Md5 } from "./md5.ts"; @@ -41,14 +39,14 @@ const testSetBase64 = [ [millionAs, "dwfWrk4CfHDuoqk1wilvIQ=="], ]; -test("[hash/md5] testMd5Hex", () => { +Deno.test("[hash/md5] testMd5Hex", () => { for (const [input, output] of testSetHex) { const md5 = new Md5(); assertEquals(md5.update(input).toString(), output); } }); -test("[hash/md5] testMd5Base64", () => { +Deno.test("[hash/md5] testMd5Base64", () => { for (const [input, output] of testSetBase64) { const md5 = new Md5(); assertEquals(md5.update(input).toString("base64"), output); diff --git a/std/hash/sha1_test.ts b/std/hash/sha1_test.ts index 36702d55a..2c78bb1c8 100644 --- a/std/hash/sha1_test.ts +++ b/std/hash/sha1_test.ts @@ -1,5 +1,4 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import { Sha1, Message } from "./sha1.ts"; import { join, resolve } from "../path/mod.ts"; @@ -70,7 +69,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.sha1)) { let i = 1; for (const [expected, message] of Object.entries(tests)) { - test({ + Deno.test({ name: `sha1.${method}() - ${name} - #${i++}`, fn() { const algorithm = new Sha1(); @@ -90,7 +89,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.sha1)) { let i = 1; for (const [expected, message] of Object.entries(tests)) { - test({ + Deno.test({ name: `sha1.${method}() - ${name} - #${i++}`, fn() { const algorithm = new Sha1(true); @@ -106,7 +105,7 @@ for (const method of methods) { } } -test("[hash/sha1] test Uint8Array from Reader", async () => { +Deno.test("[hash/sha1] test Uint8Array from Reader", async () => { const data = await Deno.readFile(join(testdataDir, "hashtest")); const hash = new Sha1().update(data).hex(); diff --git a/std/hash/sha256_test.ts b/std/hash/sha256_test.ts index 68c67b5ee..3cf4cbdf2 100644 --- a/std/hash/sha256_test.ts +++ b/std/hash/sha256_test.ts @@ -3,8 +3,6 @@ import { Sha256, HmacSha256, Message } from "./sha256.ts"; import { assertEquals } from "../testing/asserts.ts"; import { join, resolve } from "../path/mod.ts"; -const { test } = Deno; - const testdataDir = resolve("hash", "testdata"); /** Handy function to convert an array/array buffer to a string of hex values. */ @@ -178,7 +176,7 @@ fixtures.sha256.ArrayBuffer = { // deno-fmt-ignore fixtures.sha224.Uint8Array = { 'e17541396a3ecd1cd5a2b968b84e597e8eae3b0ea3127963bf48dd3b': new Uint8Array([211, 212]), - '730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525': new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]) + '730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525': new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]) }; // prettier-ignore // deno-fmt-ignore @@ -222,7 +220,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.sha256)) { let i = 1; for (const [expected, message] of Object.entries(tests)) { - test({ + Deno.test({ name: `sha256.${method}() - ${name} - #${i++}`, fn() { const algorithm = new Sha256(); @@ -242,7 +240,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.sha224)) { let i = 1; for (const [expected, message] of Object.entries(tests)) { - test({ + Deno.test({ name: `sha224.${method}() - ${name} - #${i++}`, fn() { const algorithm = new Sha256(true); @@ -262,7 +260,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.sha256Hmac)) { let i = 1; for (const [expected, [key, message]] of Object.entries(tests)) { - test({ + Deno.test({ name: `hmacSha256.${method}() - ${name} - #${i++}`, fn() { const algorithm = new HmacSha256(key); @@ -282,7 +280,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.sha224Hmac)) { let i = 1; for (const [expected, [key, message]] of Object.entries(tests)) { - test({ + Deno.test({ name: `hmacSha224.${method}() - ${name} - #${i++}`, fn() { const algorithm = new HmacSha256(key, true); @@ -298,7 +296,7 @@ for (const method of methods) { } } -test("[hash/sha256] test Uint8Array from Reader", async () => { +Deno.test("[hash/sha256] test Uint8Array from Reader", async () => { const data = await Deno.readFile(join(testdataDir, "hashtest")); const hash = new Sha256().update(data).hex(); diff --git a/std/hash/sha3_test.ts b/std/hash/sha3_test.ts index 6812f6209..64e426385 100644 --- a/std/hash/sha3_test.ts +++ b/std/hash/sha3_test.ts @@ -1,8 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - /* eslint-disable @typescript-eslint/camelcase */ - -const { test } = Deno; import { assertEquals, assertThrows } from "../testing/asserts.ts"; import { Keccak224, @@ -262,7 +259,7 @@ function s2b(data: string): Uint8Array { return new TextEncoder().encode(data); } -test("[hash/sha3] testSha3-224Raw", () => { +Deno.test("[hash/sha3] testSha3-224Raw", () => { const sha3sum = (data: ArrayBuffer): ArrayBuffer => { const sha3 = new Sha3_224(); return sha3.update(data).digest(); @@ -274,7 +271,7 @@ test("[hash/sha3] testSha3-224Raw", () => { } }); -test("[hash/sha3] testSha3-224String", () => { +Deno.test("[hash/sha3] testSha3-224String", () => { const sha3sum = (data: string): string => { const sha3 = new Sha3_224(); return sha3.update(data).toString(); @@ -285,7 +282,7 @@ test("[hash/sha3] testSha3-224String", () => { } }); -test("[hash/sha3] testSha3-256Raw", () => { +Deno.test("[hash/sha3] testSha3-256Raw", () => { const sha3sum = (data: ArrayBuffer): ArrayBuffer => { const sha3 = new Sha3_256(); return sha3.update(data).digest(); @@ -297,7 +294,7 @@ test("[hash/sha3] testSha3-256Raw", () => { } }); -test("[hash/sha3] testSha3-256String", () => { +Deno.test("[hash/sha3] testSha3-256String", () => { const sha3sum = (data: string): string => { const sha3 = new Sha3_256(); return sha3.update(data).toString(); @@ -308,7 +305,7 @@ test("[hash/sha3] testSha3-256String", () => { } }); -test("[hash/sha3] testSha3-384Raw", () => { +Deno.test("[hash/sha3] testSha3-384Raw", () => { const sha3sum = (data: ArrayBuffer): ArrayBuffer => { const sha3 = new Sha3_384(); return sha3.update(data).digest(); @@ -320,7 +317,7 @@ test("[hash/sha3] testSha3-384Raw", () => { } }); -test("[hash/sha3] testSha3-384String", () => { +Deno.test("[hash/sha3] testSha3-384String", () => { const sha3sum = (data: string): string => { const sha3 = new Sha3_384(); return sha3.update(data).toString(); @@ -331,7 +328,7 @@ test("[hash/sha3] testSha3-384String", () => { } }); -test("[hash/sha3] testSha3-512Raw", () => { +Deno.test("[hash/sha3] testSha3-512Raw", () => { const sha3sum = (data: ArrayBuffer): ArrayBuffer => { const sha3 = new Sha3_512(); return sha3.update(data).digest(); @@ -343,7 +340,7 @@ test("[hash/sha3] testSha3-512Raw", () => { } }); -test("[hash/sha3] testSha3-512String", () => { +Deno.test("[hash/sha3] testSha3-512String", () => { const sha3sum = (data: string): string => { const sha3 = new Sha3_512(); return sha3.update(data).toString(); @@ -354,7 +351,7 @@ test("[hash/sha3] testSha3-512String", () => { } }); -test("[hash/sha3] testKeccak-224Raw", () => { +Deno.test("[hash/sha3] testKeccak-224Raw", () => { const keccakSum = (data: ArrayBuffer): ArrayBuffer => { const keccak = new Keccak224(); return keccak.update(data).digest(); @@ -366,7 +363,7 @@ test("[hash/sha3] testKeccak-224Raw", () => { } }); -test("[hash/sha3] testKeccak-224String", () => { +Deno.test("[hash/sha3] testKeccak-224String", () => { const keccakSum = (data: string): string => { const keccak = new Keccak224(); return keccak.update(data).toString(); @@ -377,7 +374,7 @@ test("[hash/sha3] testKeccak-224String", () => { } }); -test("[hash/sha3] testKeccak-256Raw", () => { +Deno.test("[hash/sha3] testKeccak-256Raw", () => { const keccakSum = (data: ArrayBuffer): ArrayBuffer => { const keccak = new Keccak256(); return keccak.update(data).digest(); @@ -389,7 +386,7 @@ test("[hash/sha3] testKeccak-256Raw", () => { } }); -test("[hash/sha3] testKeccak-256String", () => { +Deno.test("[hash/sha3] testKeccak-256String", () => { const keccakSum = (data: string): string => { const keccak = new Keccak256(); return keccak.update(data).toString(); @@ -400,7 +397,7 @@ test("[hash/sha3] testKeccak-256String", () => { } }); -test("[hash/sha3] testKeccak-384Raw", () => { +Deno.test("[hash/sha3] testKeccak-384Raw", () => { const keccakSum = (data: ArrayBuffer): ArrayBuffer => { const keccak = new Keccak384(); return keccak.update(data).digest(); @@ -412,7 +409,7 @@ test("[hash/sha3] testKeccak-384Raw", () => { } }); -test("[hash/sha3] testKeccak-384String", () => { +Deno.test("[hash/sha3] testKeccak-384String", () => { const keccakSum = (data: string): string => { const keccak = new Keccak384(); return keccak.update(data).toString(); @@ -423,7 +420,7 @@ test("[hash/sha3] testKeccak-384String", () => { } }); -test("[hash/sha3] testKeccak-512Raw", () => { +Deno.test("[hash/sha3] testKeccak-512Raw", () => { const keccakSum = (data: ArrayBuffer): ArrayBuffer => { const keccak = new Keccak512(); return keccak.update(data).digest(); @@ -435,7 +432,7 @@ test("[hash/sha3] testKeccak-512Raw", () => { } }); -test("[hash/sha3] testKeccak-512String", () => { +Deno.test("[hash/sha3] testKeccak-512String", () => { const keccakSum = (data: string): string => { const keccak = new Keccak512(); return keccak.update(data).toString(); @@ -446,7 +443,7 @@ test("[hash/sha3] testKeccak-512String", () => { } }); -test("[hash/sha3] testSHAKE-128Raw", () => { +Deno.test("[hash/sha3] testSHAKE-128Raw", () => { const shakeSum = (data: ArrayBuffer): ArrayBuffer => { const shake = new Shake128(128); return shake.update(data).digest(); @@ -458,7 +455,7 @@ test("[hash/sha3] testSHAKE-128Raw", () => { } }); -test("[hash/sha3] testSHAKE-128String", () => { +Deno.test("[hash/sha3] testSHAKE-128String", () => { const shakeSum = (data: string): string => { const shake = new Shake128(128); return shake.update(data).toString(); @@ -469,7 +466,7 @@ test("[hash/sha3] testSHAKE-128String", () => { } }); -test("[hash/sha3] testSHAKE-128-224Raw", () => { +Deno.test("[hash/sha3] testSHAKE-128-224Raw", () => { const shakeSum = (data: ArrayBuffer): ArrayBuffer => { const shake = new Shake128(224); return shake.update(data).digest(); @@ -481,7 +478,7 @@ test("[hash/sha3] testSHAKE-128-224Raw", () => { } }); -test("[hash/sha3] testSHAKE-128-224String", () => { +Deno.test("[hash/sha3] testSHAKE-128-224String", () => { const shakeSum = (data: string): string => { const shake = new Shake128(224); return shake.update(data).toString(); @@ -492,7 +489,7 @@ test("[hash/sha3] testSHAKE-128-224String", () => { } }); -test("[hash/sha3] testSHAKE-128-2048", () => { +Deno.test("[hash/sha3] testSHAKE-128-2048", () => { const shakeSum = (data: string): string => { const shake = new Shake128(2048); return shake.update(data).toString(); @@ -503,7 +500,7 @@ test("[hash/sha3] testSHAKE-128-2048", () => { } }); -test("[hash/sha3] testSHAKE-256", () => { +Deno.test("[hash/sha3] testSHAKE-256", () => { const shakeSum = (data: string): string => { const shake = new Shake256(256); return shake.update(data).toString(); @@ -514,7 +511,7 @@ test("[hash/sha3] testSHAKE-256", () => { } }); -test("[hash/sha3] testSHAKE-256-128", () => { +Deno.test("[hash/sha3] testSHAKE-256-128", () => { const shakeSum = (data: string): string => { const shake = new Shake256(128); return shake.update(data).toString(); @@ -525,7 +522,7 @@ test("[hash/sha3] testSHAKE-256-128", () => { } }); -test("[hash/sha3] testSHAKE-256-384", () => { +Deno.test("[hash/sha3] testSHAKE-256-384", () => { const shakeSum = (data: string): string => { const shake = new Shake256(384); return shake.update(data).toString(); @@ -536,7 +533,7 @@ test("[hash/sha3] testSHAKE-256-384", () => { } }); -test("[hash/sha3] testSHAKE-256-512", () => { +Deno.test("[hash/sha3] testSHAKE-256-512", () => { const shakeSum = (data: string): string => { const shake = new Shake256(512); return shake.update(data).toString(); @@ -547,7 +544,7 @@ test("[hash/sha3] testSHAKE-256-512", () => { } }); -test("[hash/sha3] testSha3-256Chain", () => { +Deno.test("[hash/sha3] testSha3-256Chain", () => { const sha3 = new Sha3_256(); const output = sha3 .update(s2b("a")) @@ -561,7 +558,7 @@ test("[hash/sha3] testSha3-256Chain", () => { ); }); -test("[hash/sha3] testSha3UpdateFinalized", () => { +Deno.test("[hash/sha3] testSha3UpdateFinalized", () => { assertThrows( () => { const sha3 = new Sha3_256(); diff --git a/std/hash/sha512_test.ts b/std/hash/sha512_test.ts index d17df3230..c656731a3 100644 --- a/std/hash/sha512_test.ts +++ b/std/hash/sha512_test.ts @@ -3,8 +3,6 @@ import { Sha512, HmacSha512, Message } from "./sha512.ts"; import { assertEquals } from "../testing/asserts.ts"; import { join, resolve } from "../path/mod.ts"; -const { test } = Deno; - const testdataDir = resolve("hash", "testdata"); /** Handy function to convert an array/array buffer to a string of hex values. */ @@ -282,7 +280,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.sha512bits224)) { let i = 1; for (const [expected, message] of Object.entries(tests)) { - test({ + Deno.test({ name: `sha512/224.${method}() - ${name} - #${i++}`, fn() { const algorithm = new Sha512(224); @@ -302,7 +300,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.sha512bits256)) { let i = 1; for (const [expected, message] of Object.entries(tests)) { - test({ + Deno.test({ name: `sha512/256.${method}() - ${name} - #${i++}`, fn() { const algorithm = new Sha512(256); @@ -322,7 +320,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.sha512)) { let i = 1; for (const [expected, message] of Object.entries(tests)) { - test({ + Deno.test({ name: `sha512.${method}() - ${name} - #${i++}`, fn() { const algorithm = new Sha512(); @@ -342,7 +340,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.hmacSha512bits224)) { let i = 1; for (const [expected, [key, message]] of Object.entries(tests)) { - test({ + Deno.test({ name: `hmacSha512/224.${method}() - ${name} - #${i++}`, fn() { const algorithm = new HmacSha512(key, 224); @@ -362,7 +360,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.hmacSha512bits256)) { let i = 1; for (const [expected, [key, message]] of Object.entries(tests)) { - test({ + Deno.test({ name: `hmacSha512/256.${method}() - ${name} - #${i++}`, fn() { const algorithm = new HmacSha512(key, 256); @@ -382,7 +380,7 @@ for (const method of methods) { for (const [name, tests] of Object.entries(fixtures.hmacSha512)) { let i = 1; for (const [expected, [key, message]] of Object.entries(tests)) { - test({ + Deno.test({ name: `hmacSha512.${method}() - ${name} - #${i++}`, fn() { const algorithm = new HmacSha512(key); @@ -398,7 +396,7 @@ for (const method of methods) { } } -test("[hash/sha512] test Uint8Array from Reader", async () => { +Deno.test("[hash/sha512] test Uint8Array from Reader", async () => { const data = await Deno.readFile(join(testdataDir, "hashtest")); const hash = new Sha512().update(data).hex(); assertEquals( |