forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextIterator.test.ts
More file actions
28 lines (26 loc) · 943 Bytes
/
textIterator.test.ts
File metadata and controls
28 lines (26 loc) · 943 Bytes
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import * as assert from 'assert';
import { TextIterator } from '../../client/language/textIterator';
// tslint:disable-next-line:max-func-body-length
suite('Language.TextIterator', () => {
test('Construction', async () => {
const content = 'some text';
const ti = new TextIterator(content);
assert.equal(ti.length, content.length);
assert.equal(ti.getText(), content);
});
test('Iteration', async () => {
const content = 'some text';
const ti = new TextIterator(content);
for (let i = -2; i < content.length + 2; i += 1) {
const ch = ti.charCodeAt(i);
if (i < 0 || i >= content.length) {
assert.equal(ch, 0);
} else {
assert.equal(ch, content.charCodeAt(i));
}
}
});
});