Add tests for unicode normalization

This commit is contained in:
D. Scott Boggs 2023-10-11 06:40:47 -04:00
parent a379c994f2
commit 9219fdc530

View file

@ -230,3 +230,28 @@ describe('verifySync() error cases', function () {
checkThrows('')
})
})
describe('normalization of unicode characters', function () {
it('works, async', async () => {
const angstromChar = '\xC5ngstrom'
const composed = 'A\u030Angstrom'
const withRingAbove = '\u212Bngstrom'
let hash = await scrypt.hash(angstromChar)
const tests = []
tests.push(scrypt.verify(hash, composed).should.eventually.be.true)
tests.push(scrypt.verify(hash, withRingAbove).should.eventually.be.true)
hash = await scrypt.hash(composed)
tests.push(scrypt.verify(hash, withRingAbove).should.eventually.be.true)
await Promise.all(tests)
})
it('works, sync', () => {
const angstromChar = '\xC5ngstrom'
const composed = 'A\u030Angstrom'
const withRingAbove = '\u212Bngstrom'
let hash = scrypt.hashSync(angstromChar)
scrypt.verifySync(hash, composed).should.be.true
scrypt.verifySync(hash, withRingAbove).should.be.true
hash = scrypt.hashSync(composed)
scrypt.verifySync(hash, withRingAbove).should.be.true
})
})