Sprinkle in readonly on array inputs (#1568)

This commit is contained in:
Jaco
2022-06-28 10:52:57 +03:00
committed by GitHub
parent 691a8e9b18
commit 3bc62adf6f
11 changed files with 35 additions and 19 deletions
+18 -3
View File
@@ -4,8 +4,6 @@
import { perf } from '../test/performance';
import { u8aEmpty } from '.';
const ztest = new Uint8Array(32);
describe('u8aEmpty', (): void => {
it('returns true on zero length', (): void => {
expect(
@@ -25,5 +23,22 @@ describe('u8aEmpty', (): void => {
).toEqual(false);
});
perf('u8aEmpty (32 cmp)', 1000000, [[ztest]], u8aEmpty);
it('returns false when value is found (256)', (): void => {
const test = new Uint8Array(256);
expect(
u8aEmpty(test)
).toEqual(true);
test[128] = 1;
expect(
u8aEmpty(test)
).toEqual(false);
});
perf('u8aEmpty (32 cmp)', 1_000_000, [[new Uint8Array(32)]], u8aEmpty);
perf('u8aEmpty (64 cmp)', 500_000, [[new Uint8Array(64)]], u8aEmpty);
perf('u8aEmpty (128 cmp)', 250_000, [[new Uint8Array(128)]], u8aEmpty);
perf('u8aEmpty (256 cmp)', 125_000, [[new Uint8Array(256)]], u8aEmpty);
});