Something went wrong. Try again.
Synapse is a study workspace. Organize courses read and annotate the material, train with generated exercises and watch your progress forked from denishovart.com/synapse
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930import { describe, expect, it } from 'vitest';import fc from 'fast-check';import { fromBase64, toBase64 } from './base64';
describe('base64', () => { it('round-trips the empty array', () => { expect(fromBase64(toBase64(new Uint8Array()))).toEqual(new Uint8Array()); });
it('round-trips arbitrary bytes (property)', () => { fc.assert( fc.property(fc.uint8Array(), (bytes) => { expect(fromBase64(toBase64(bytes))).toEqual(bytes); }), ); });
// toBase64 slices the input at 0x8000 and spreads each slice through // String.fromCharCode; a payload larger than one slice is where a // chunk-boundary bug would show, so fuzz well past it. it('round-trips payloads spanning several chunks (property)', () => { fc.assert( fc.property(fc.uint8Array({ minLength: 0x8000, maxLength: 0x8000 * 3 + 7 }), (bytes) => { expect(fromBase64(toBase64(bytes))).toEqual(bytes); }), { numRuns: 20 }, ); });});