-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlibrary.test.js
48 lines (45 loc) · 1.3 KB
/
library.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const assert = require('assert');
const endecode = require('.');
it('should check if the endecoded text is constant', () => {
const examples = [
[ 'abc', 'zdY' ],
[ 'ok', ';u' ],
[
'abcdefg',
'_KQ}Gm!'
],
[
'a b c d e f g',
'_ K Q } G m !'
],
[
'the quick brown fox jumps over the lazy dog',
'%us 4RyI. *:AZS ,>v rc"§r S€qS |FQ j|fY Gbn'
],
[
'this module is dumb',
'Z`{0 G>:7|w ~= 18&H'
],
[
'this\nis\njust\na\ntest\nto\nsee\nif\nnew\nlines\nwork',
'´([i\n5&\n~T`c\n7\ne#lN\n1T\nQsk\nk(\nZ°j\n(`HY^\nBD1u'
],
[
'aaaa\n\n\n\naaaa',
'5ubw\n\n\n\nK>Ho'
],
];
for(const [normal, encoded] of examples){
assert.strictEqual(normal, endecode(encoded));
assert.strictEqual(encoded, endecode(normal));
}
})
it('should test the stability of the endecoder', () => {
const chars =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
for(
let str = '';
str.length <= 50;
str += chars[Math.floor(Math.random()*chars.length)]
) assert.strictEqual(str, endecode(endecode(str)))
})