untitled notebook

node v8.17.0
version: master
endpointsharetweet
const leftPad = require('left-pad'); const fc = require('fast-check'); // Fake Mocha const describe = (name, f) => f(); const it = (name, f) => { try { f(); console.log(`[success] ${name}`); } catch (err) { console.error(`[error] ${name}`); console.error(err); } }; const lengthUnicode = s => [...s].length; describe('left-pad against properties', () => { it('should be able to pad simple strings with utf-16 characters', () => { fc.assert(fc.property( fc.unicodeString(),fc.nat(100), fc.fullUnicode(), (s, additionalPad, c) => lengthUnicode(leftPad(s, lengthUnicode(s) + additionalPad, c)) === lengthUnicode(s) + additionalPad)); }); it('should be able to pad utf-16 strings', () => { fc.assert(fc.property( fc.fullUnicodeString(),fc.nat(100), (s, additionalPad) => lengthUnicode(leftPad(s, lengthUnicode(s) + additionalPad)) === lengthUnicode(s) + additionalPad)); }); });
Loading…

no comments

    sign in to comment