Skip to content

Commit

Permalink
Add e2e tests to check utf16 validity
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz committed Feb 12, 2018
1 parent 30f4d6a commit dac81ae
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/e2e/arbitraries/StringArbitrary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,21 @@ describe(`StringArbitrary (seed: ${seed})`, () => {
assert.deepEqual(out.counterexample, ["AA=="], 'Should shrink to counterexample "AA=="');
});
});
describe('unicodeString', () => {
it('Should produce valid UTF-16 strings', () => {
fc.assert(fc.property(fc.unicodeString(), (s:string) => encodeURIComponent(s) !== null), {seed: seed});
});
});
describe('fullUnicodeString', () => {
it('Should produce valid UTF-16 strings', () => {
fc.assert(fc.property(fc.fullUnicodeString(), (s:string) => encodeURIComponent(s) !== null), {seed: seed});
});
});
describe('string16bits', () => {
it('Should be able to produce invalid UTF-16 strings', () => {
const out = fc.check(fc.property(fc.string16bits(), (s:string) => encodeURIComponent(s) !== null), {seed: seed});
assert.ok(out.failed, 'Should have failed');
assert.deepEqual(out.counterexample, ['\ud800'], 'Should shrink to counterexample "\\ud800"');
});
});
});

0 comments on commit dac81ae

Please sign in to comment.