function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAfter: number, annotatedText: string, wrappingIndent = WrappingIndent.None) {

	let rawText = '';
	let currentLineIndex = 0;
	let lineIndices: number[] = [];
	for (let i = 0, len = annotatedText.length; i < len; i++) {
		if (annotatedText.charAt(i) === '|') {
			currentLineIndex++;
		} else {
			rawText += annotatedText.charAt(i);
			lineIndices[rawText.length - 1] = currentLineIndex;
		}
	}

	let mapper = factory.createLineMapping(rawText, tabSize, breakAfter, 2, wrappingIndent);

	let actualAnnotatedText = '';
	if (mapper) {
		let previousLineIndex = 0;
		for (let i = 0, len = rawText.length; i < len; i++) {
			let r = mapper.getOutputPositionOfInputOffset(i);
			if (previousLineIndex !== r.outputLineIndex) {
				previousLineIndex = r.outputLineIndex;
				actualAnnotatedText += '|';
			}
			actualAnnotatedText += rawText.charAt(i);
		}
	} else {
		// No wrapping
		actualAnnotatedText = rawText;
	}

	assert.equal(actualAnnotatedText, annotatedText);
}
function assertLineMapping(factory:ILineMapperFactory, tabSize:number, breakAfter:number, annotatedText:string) {

	let rawText = '';
	let currentLineIndex = 0;
	let lineIndices:number[] = [];
	for (let i = 0, len = annotatedText.length; i < len; i++) {
		if (annotatedText.charAt(i) === '|') {
			currentLineIndex++;
		} else {
			rawText += annotatedText.charAt(i);
			lineIndices[rawText.length - 1] = currentLineIndex;
		}
	}

	let mapper = factory.createLineMapping(rawText, tabSize, breakAfter, 1, WrappingIndent.None);

	assert.equal(safeGetOutputLineCount(mapper), (lineIndices.length > 0 ? lineIndices[lineIndices.length - 1] + 1 : 1));
	for (let i = 0, len = rawText.length; i < len; i++) {
		assertMappingIdentity(mapper, i, lineIndices[i]);
	}
}
function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAfter: number, annotatedText: string, wrappingIndent = WrappingIndent.None): ILineMapping | null {
	// Create version of `annotatedText` with line break markers removed
	let rawText = '';
	let currentLineIndex = 0;
	let lineIndices: number[] = [];
	for (let i = 0, len = annotatedText.length; i < len; i++) {
		if (annotatedText.charAt(i) === '|') {
			currentLineIndex++;
		} else {
			rawText += annotatedText.charAt(i);
			lineIndices[rawText.length - 1] = currentLineIndex;
		}
	}

	const mapper = factory.createLineMapping(rawText, tabSize, breakAfter, 2, wrappingIndent);

	// Insert line break markers again, according to algorithm
	let actualAnnotatedText = '';
	if (mapper) {
		let previousLineIndex = 0;
		for (let i = 0, len = rawText.length; i < len; i++) {
			let r = mapper.getOutputPositionOfInputOffset(i);
			if (previousLineIndex !== r.outputLineIndex) {
				previousLineIndex = r.outputLineIndex;
				actualAnnotatedText += '|';
			}
			actualAnnotatedText += rawText.charAt(i);
		}
	} else {
		// No wrapping
		actualAnnotatedText = rawText;
	}

	assert.equal(actualAnnotatedText, annotatedText);

	return mapper;
}