Skip to content

Commit 3dd9a37

Browse files
committed
Simplify tests
1 parent 71c0a35 commit 3dd9a37

File tree

1 file changed

+57
-57
lines changed

1 file changed

+57
-57
lines changed

test/random.js

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,82 +5,82 @@ import test from 'ava'
55

66
test('Char Set Base 64 Strings', t => {
77
let random = new Random(charSet64)
8-
t.is(random.stringWithBytes( 6, Buffer.from([0xdd])), '3')
9-
t.is(random.stringWithBytes(12, Buffer.from([0x78, 0xfc])), 'eP')
10-
t.is(random.stringWithBytes(18, Buffer.from([0xc5, 0x6f, 0x21])), 'xW8')
11-
t.is(random.stringWithBytes(24, Buffer.from([0xc9, 0x68, 0xc7])), 'yWjH')
12-
t.is(random.stringWithBytes(30, Buffer.from([0xa5, 0x62, 0x20, 0x87])), 'pWIgh')
13-
t.is(random.stringWithBytes(36, Buffer.from([0x39, 0x51, 0xca, 0xcc, 0x8b])), 'OVHKzI')
14-
t.is(random.stringWithBytes(42, Buffer.from([0x83, 0x89, 0x00, 0xc7, 0xf4, 0x02])), 'g4kAx_Q')
15-
t.is(random.stringWithBytes(48, Buffer.from([0x51, 0xbc, 0xa8, 0xc7, 0xc9, 0x17])), 'Ubyox8kX')
16-
t.is(random.stringWithBytes(54, Buffer.from([0xd2, 0xe3, 0xe9, 0xda, 0x19, 0x97, 0x52])), '0uPp2hmXU')
8+
t.is(random.stringWithBytes( 6, [0xdd]), '3')
9+
t.is(random.stringWithBytes(12, [0x78, 0xfc]), 'eP')
10+
t.is(random.stringWithBytes(18, [0xc5, 0x6f, 0x21]), 'xW8')
11+
t.is(random.stringWithBytes(24, [0xc9, 0x68, 0xc7]), 'yWjH')
12+
t.is(random.stringWithBytes(30, [0xa5, 0x62, 0x20, 0x87]), 'pWIgh')
13+
t.is(random.stringWithBytes(36, [0x39, 0x51, 0xca, 0xcc, 0x8b]), 'OVHKzI')
14+
t.is(random.stringWithBytes(42, [0x83, 0x89, 0x00, 0xc7, 0xf4, 0x02]), 'g4kAx_Q')
15+
t.is(random.stringWithBytes(48, [0x51, 0xbc, 0xa8, 0xc7, 0xc9, 0x17]), 'Ubyox8kX')
16+
t.is(random.stringWithBytes(54, [0xd2, 0xe3, 0xe9, 0xda, 0x19, 0x97, 0x52]), '0uPp2hmXU')
1717
t.is(random.stringWithBytes(60, [0xd9, 0x39, 0xc1, 0xaf, 0x1e, 0x2e, 0x69, 0x48]), '2TnBrx4uaU')
18-
t.is(random.stringWithBytes(66, Buffer.from([0x78, 0x3f, 0xfd, 0x93, 0xd1, 0x06, 0x90, 0x4b, 0xd6])), 'eD_9k9EGkEv')
19-
t.is(random.stringWithBytes(72, Buffer.from([0x9d, 0x99, 0x4e, 0xa5, 0xd2, 0x3f, 0x8c, 0x86, 0x80])), 'nZlOpdI_jIaA')
18+
t.is(random.stringWithBytes(66, [0x78, 0x3f, 0xfd, 0x93, 0xd1, 0x06, 0x90, 0x4b, 0xd6]), 'eD_9k9EGkEv')
19+
t.is(random.stringWithBytes(72, [0x9d, 0x99, 0x4e, 0xa5, 0xd2, 0x3f, 0x8c, 0x86, 0x80]), 'nZlOpdI_jIaA')
2020
})
2121

2222
test('Char Set Base 32 Strings', t => {
2323
let random = new Random(charSet32)
24-
t.is(random.stringWithBytes( 5, Buffer.from([0xdd])), 'N')
25-
t.is(random.stringWithBytes(10, Buffer.from([0x78, 0xfc])), 'p6')
26-
t.is(random.stringWithBytes(15, Buffer.from([0x78, 0xfc])), 'p6R')
27-
t.is(random.stringWithBytes(20, Buffer.from([0xc5, 0x6f, 0x21])), 'JFHt')
28-
t.is(random.stringWithBytes(25, Buffer.from([0xa5, 0x62, 0x20, 0x87])), 'DFr43')
29-
t.is(random.stringWithBytes(30, Buffer.from([0xa5, 0x62, 0x20, 0x87])), 'DFr433')
30-
t.is(random.stringWithBytes(35, Buffer.from([0x39, 0x51, 0xca, 0xcc, 0x8b])), 'b8dPFB7')
31-
t.is(random.stringWithBytes(40, Buffer.from([0x39, 0x51, 0xca, 0xcc, 0x8b])), 'b8dPFB7h')
32-
t.is(random.stringWithBytes(45, Buffer.from([0x83, 0x89, 0x00, 0xc7, 0xf4, 0x02])), 'qn7q3rTD2')
33-
t.is(random.stringWithBytes(50, Buffer.from([0xd2, 0xe3, 0xe9, 0xda, 0x19, 0x97, 0x52])), 'MhrRBGqLtQ')
34-
t.is(random.stringWithBytes(55, Buffer.from([0xd2, 0xe3, 0xe9, 0xda, 0x19, 0x97, 0x52])), 'MhrRBGqLtQf')
24+
t.is(random.stringWithBytes( 5, [0xdd]), 'N')
25+
t.is(random.stringWithBytes(10, [0x78, 0xfc]), 'p6')
26+
t.is(random.stringWithBytes(15, [0x78, 0xfc]), 'p6R')
27+
t.is(random.stringWithBytes(20, [0xc5, 0x6f, 0x21]), 'JFHt')
28+
t.is(random.stringWithBytes(25, [0xa5, 0x62, 0x20, 0x87]), 'DFr43')
29+
t.is(random.stringWithBytes(30, [0xa5, 0x62, 0x20, 0x87]), 'DFr433')
30+
t.is(random.stringWithBytes(35, [0x39, 0x51, 0xca, 0xcc, 0x8b]), 'b8dPFB7')
31+
t.is(random.stringWithBytes(40, [0x39, 0x51, 0xca, 0xcc, 0x8b]), 'b8dPFB7h')
32+
t.is(random.stringWithBytes(45, [0x83, 0x89, 0x00, 0xc7, 0xf4, 0x02]), 'qn7q3rTD2')
33+
t.is(random.stringWithBytes(50, [0xd2, 0xe3, 0xe9, 0xda, 0x19, 0x97, 0x52]), 'MhrRBGqLtQ')
34+
t.is(random.stringWithBytes(55, [0xd2, 0xe3, 0xe9, 0xda, 0x19, 0x97, 0x52]), 'MhrRBGqLtQf')
3535
})
3636

3737
test('Char Set Base 16 Strings', t => {
3838
let random = new Random(charSet16)
39-
t.is(random.stringWithBytes( 4, Buffer.from([0x9d])), '9')
40-
t.is(random.stringWithBytes( 8, Buffer.from([0xae])), 'ae')
41-
t.is(random.stringWithBytes(12, Buffer.from([0x01, 0xf2])), '01f')
42-
t.is(random.stringWithBytes(16, Buffer.from([0xc7, 0xc9])), 'c7c9')
43-
t.is(random.stringWithBytes(20, Buffer.from([0xc7, 0xc9, 0x00])), 'c7c90')
39+
t.is(random.stringWithBytes( 4, [0x9d]), '9')
40+
t.is(random.stringWithBytes( 8, [0xae]), 'ae')
41+
t.is(random.stringWithBytes(12, [0x01, 0xf2]), '01f')
42+
t.is(random.stringWithBytes(16, [0xc7, 0xc9]), 'c7c9')
43+
t.is(random.stringWithBytes(20, [0xc7, 0xc9, 0x00]), 'c7c90')
4444
})
4545

4646
test('Char Set Base 8 Strings', t => {
4747
let random = new Random(charSet8)
48-
t.is(random.stringWithBytes( 3, Buffer.from([0x5a])), '2')
49-
t.is(random.stringWithBytes( 6, Buffer.from([0x5a])), '26')
50-
t.is(random.stringWithBytes( 9, Buffer.from([0x21, 0xa4])), '103')
51-
t.is(random.stringWithBytes(12, Buffer.from([0x21, 0xa4])), '1032')
52-
t.is(random.stringWithBytes(15, Buffer.from([0xda, 0x19])), '66414')
53-
t.is(random.stringWithBytes(18, Buffer.from([0xfd, 0x93, 0xd1])), '773117')
54-
t.is(random.stringWithBytes(21, Buffer.from([0xfd, 0x93, 0xd1])), '7731172')
55-
t.is(random.stringWithBytes(24, Buffer.from([0xfd, 0x93, 0xd1])), '77311721')
56-
t.is(random.stringWithBytes(27, Buffer.from([0xc7, 0xc9, 0x07, 0xc9])), '617444076')
57-
t.is(random.stringWithBytes(30, Buffer.from([0xc7, 0xc9, 0x07, 0xc9])), '6174440762')
48+
t.is(random.stringWithBytes( 3, [0x5a]), '2')
49+
t.is(random.stringWithBytes( 6, [0x5a]), '26')
50+
t.is(random.stringWithBytes( 9, [0x21, 0xa4]), '103')
51+
t.is(random.stringWithBytes(12, [0x21, 0xa4]), '1032')
52+
t.is(random.stringWithBytes(15, [0xda, 0x19]), '66414')
53+
t.is(random.stringWithBytes(18, [0xfd, 0x93, 0xd1]), '773117')
54+
t.is(random.stringWithBytes(21, [0xfd, 0x93, 0xd1]), '7731172')
55+
t.is(random.stringWithBytes(24, [0xfd, 0x93, 0xd1]), '77311721')
56+
t.is(random.stringWithBytes(27, [0xc7, 0xc9, 0x07, 0xc9]), '617444076')
57+
t.is(random.stringWithBytes(30, [0xc7, 0xc9, 0x07, 0xc9]), '6174440762')
5858
})
5959

6060
test('Char Set Base 4 Strings', t => {
6161
let random = new Random(charSet4)
62-
t.is(random.stringWithBytes( 2, Buffer.from([0x5a])), 'T')
63-
t.is(random.stringWithBytes( 4, Buffer.from([0x5a])), 'TT')
64-
t.is(random.stringWithBytes( 6, Buffer.from([0x93])), 'CTA')
65-
t.is(random.stringWithBytes( 8, Buffer.from([0x93])), 'CTAG')
66-
t.is(random.stringWithBytes(10, Buffer.from([0x20, 0xf1])), 'ACAAG')
67-
t.is(random.stringWithBytes(12, Buffer.from([0x20, 0xf1])), 'ACAAGG')
68-
t.is(random.stringWithBytes(14, Buffer.from([0x20, 0xf1])), 'ACAAGGA')
69-
t.is(random.stringWithBytes(16, Buffer.from([0x20, 0xf1])), 'ACAAGGAT')
62+
t.is(random.stringWithBytes( 2, [0x5a]), 'T')
63+
t.is(random.stringWithBytes( 4, [0x5a]), 'TT')
64+
t.is(random.stringWithBytes( 6, [0x93]), 'CTA')
65+
t.is(random.stringWithBytes( 8, [0x93]), 'CTAG')
66+
t.is(random.stringWithBytes(10, [0x20, 0xf1]), 'ACAAG')
67+
t.is(random.stringWithBytes(12, [0x20, 0xf1]), 'ACAAGG')
68+
t.is(random.stringWithBytes(14, [0x20, 0xf1]), 'ACAAGGA')
69+
t.is(random.stringWithBytes(16, [0x20, 0xf1]), 'ACAAGGAT')
7070
})
7171

7272
test('Char Set Base 2 Strings', t => {
7373
let random = new Random(charSet2)
74-
t.is(random.stringWithBytes( 1, Buffer.from([0x27])), '0')
75-
t.is(random.stringWithBytes( 2, Buffer.from([0x27])), '00')
76-
t.is(random.stringWithBytes( 3, Buffer.from([0x27])), '001')
77-
t.is(random.stringWithBytes( 4, Buffer.from([0x27])), '0010')
78-
t.is(random.stringWithBytes( 5, Buffer.from([0x27])), '00100')
79-
t.is(random.stringWithBytes( 6, Buffer.from([0x27])), '001001')
80-
t.is(random.stringWithBytes( 7, Buffer.from([0x27])), '0010011')
81-
t.is(random.stringWithBytes( 8, Buffer.from([0x27])), '00100111')
82-
t.is(random.stringWithBytes( 9, Buffer.from([0xe3, 0xe9])), '111000111')
83-
t.is(random.stringWithBytes(16, Buffer.from([0xe3, 0xe9])), '1110001111101001')
74+
t.is(random.stringWithBytes( 1, [0x27]), '0')
75+
t.is(random.stringWithBytes( 2, [0x27]), '00')
76+
t.is(random.stringWithBytes( 3, [0x27]), '001')
77+
t.is(random.stringWithBytes( 4, [0x27]), '0010')
78+
t.is(random.stringWithBytes( 5, [0x27]), '00100')
79+
t.is(random.stringWithBytes( 6, [0x27]), '001001')
80+
t.is(random.stringWithBytes( 7, [0x27]), '0010011')
81+
t.is(random.stringWithBytes( 8, [0x27]), '00100111')
82+
t.is(random.stringWithBytes( 9, [0xe3, 0xe9]), '111000111')
83+
t.is(random.stringWithBytes(16, [0xe3, 0xe9]), '1110001111101001')
8484
})
8585

8686
test('Char Set Strings', t => {
@@ -108,7 +108,7 @@ test('Invalid bytes', t => {
108108
let regex = /Insufficient/
109109

110110
random = new Random(charSet64)
111-
t.regex(invalidBytes(random, 7, [1]), regex)
111+
t.regex(invalidBytes(random, 7, [1]), regex)
112112
t.regex(invalidBytes(random, 13, [1,2]), regex)
113113
t.regex(invalidBytes(random, 25, [1,2,3]), regex)
114114
t.regex(invalidBytes(random, 31, [1,2,3,4]), regex)
@@ -118,9 +118,9 @@ test('Invalid bytes', t => {
118118
t.regex(invalidBytes(random, 16, [1,2]), regex)
119119
t.regex(invalidBytes(random, 21, [1,2,3]), regex)
120120
t.regex(invalidBytes(random, 31, [1,2,3,4]), regex)
121+
t.regex(invalidBytes(random, 32, [1,2,3,4]), regex)
121122
t.regex(invalidBytes(random, 41, [1,2,3,4,5]), regex)
122123
t.regex(invalidBytes(random, 46, [1,2,3,4,5,6]), regex)
123-
t.regex(invalidBytes(random, 32, [250, 200, 150, 100]), regex)
124124

125125
random = new Random(charSet16)
126126
t.regex(invalidBytes(random, 9, [1]), regex)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy