Path: blob/main/src/vs/editor/test/common/model/linesTextBuffer/linesTextBufferBuilder.test.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import assert from 'assert';6import * as strings from '../../../../../base/common/strings.js';7import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';8import { DefaultEndOfLine } from '../../../../common/model.js';9import { createTextBufferFactory } from '../../../../common/model/textModel.js';1011function testTextBufferFactory(text: string, eol: string, mightContainNonBasicASCII: boolean, mightContainRTL: boolean): void {12const { disposable, textBuffer } = createTextBufferFactory(text).create(DefaultEndOfLine.LF);1314assert.strictEqual(textBuffer.mightContainNonBasicASCII(), mightContainNonBasicASCII);15assert.strictEqual(textBuffer.mightContainRTL(), mightContainRTL);16assert.strictEqual(textBuffer.getEOL(), eol);17disposable.dispose();18}1920suite('ModelBuilder', () => {2122ensureNoDisposablesAreLeakedInTestSuite();2324test('t1', () => {25testTextBufferFactory('', '\n', false, false);26});2728test('t2', () => {29testTextBufferFactory('Hello world', '\n', false, false);30});3132test('t3', () => {33testTextBufferFactory('Hello world\nHow are you?', '\n', false, false);34});3536test('t4', () => {37testTextBufferFactory('Hello world\nHow are you?\nIs everything good today?\nDo you enjoy the weather?', '\n', false, false);38});3940test('carriage return detection (1 \\r\\n 2 \\n)', () => {41testTextBufferFactory('Hello world\r\nHow are you?\nIs everything good today?\nDo you enjoy the weather?', '\n', false, false);42});4344test('carriage return detection (2 \\r\\n 1 \\n)', () => {45testTextBufferFactory('Hello world\r\nHow are you?\r\nIs everything good today?\nDo you enjoy the weather?', '\r\n', false, false);46});4748test('carriage return detection (3 \\r\\n 0 \\n)', () => {49testTextBufferFactory('Hello world\r\nHow are you?\r\nIs everything good today?\r\nDo you enjoy the weather?', '\r\n', false, false);50});5152test('BOM handling', () => {53testTextBufferFactory(strings.UTF8_BOM_CHARACTER + 'Hello world!', '\n', false, false);54});5556test('RTL handling 2', () => {57testTextBufferFactory('Hello world!זוהי עובדה מבוססת שדעתו', '\n', true, true);58});5960test('RTL handling 3', () => {61testTextBufferFactory('Hello world!זוהי \nעובדה מבוססת שדעתו', '\n', true, true);62});6364test('ASCII handling 1', () => {65testTextBufferFactory('Hello world!!\nHow do you do?', '\n', false, false);66});67test('ASCII handling 2', () => {68testTextBufferFactory('Hello world!!\nHow do you do?Züricha📚📚b', '\n', true, false);69});70});717273