Skip to content

Commit a92501a

Browse files
committed
Fix #3
1 parent 503d398 commit a92501a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/String_random.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function String_random (pattern, options) {
233233
if (!before) {
234234
sets.push(chr);
235235
} else {
236-
for (let i = before.charCodeAt(0) + 1, len = next.charCodeAt(0); i < len; i++) {
236+
for (let i = before.charCodeAt(0) + 1, len = next.charCodeAt(0); i <= len; i++) {
237237
sets.push(String.fromCharCode(i));
238238
}
239239
}

test/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ test('character class: [abc]', (t) => {
9595
}
9696
});
9797

98+
test('character class: [1-2]', (t) => {
99+
const random = seededRandom(42);
100+
const val = String_random(/[1-2]{5}/, { random });
101+
assert.strictEqual(val, '21222');
102+
});
103+
98104
test('character class: range [a-z]', (t) => {
99105
for (let i = 0; i < 100; i++) {
100106
const val = String_random(/[a-z]{3}/, { random });

0 commit comments

Comments
 (0)