1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

Failing test case for bug 274973 - Problem when using backslash and ${cursor} in editor templates

This commit is contained in:
Anton Leherbauer 2009-05-13 13:38:42 +00:00
parent 6543fd0bb7
commit d791eec58b

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others. * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -57,6 +57,7 @@ public class TemplateFormatterTest extends BaseUITestCase {
private String fSelection; private String fSelection;
private HashMap fDefaultOptions; private HashMap fDefaultOptions;
@Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
fTemplateContextType= new TestTemplateContextType(); fTemplateContextType= new TestTemplateContextType();
@ -64,6 +65,7 @@ public class TemplateFormatterTest extends BaseUITestCase {
fDefaultOptions= CCorePlugin.getDefaultOptions(); fDefaultOptions= CCorePlugin.getDefaultOptions();
} }
@Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
CCorePlugin.setOptions(fDefaultOptions); CCorePlugin.setOptions(fDefaultOptions);
super.tearDown(); super.tearDown();
@ -76,6 +78,9 @@ public class TemplateFormatterTest extends BaseUITestCase {
} }
protected void assertFormatterResult() throws Exception { protected void assertFormatterResult() throws Exception {
assertFormatterResult(false);
}
protected void assertFormatterResult(boolean useFormatter) throws Exception {
StringBuffer[] contents= getContentsForTest(2); StringBuffer[] contents= getContentsForTest(2);
String before= contents[0].toString().replaceAll("\\r\\n", "\n"); String before= contents[0].toString().replaceAll("\\r\\n", "\n");
String expected= contents[1].toString(); String expected= contents[1].toString();
@ -84,12 +89,11 @@ public class TemplateFormatterTest extends BaseUITestCase {
context.setVariable(GlobalTemplateVariables.SELECTION, fSelection); context.setVariable(GlobalTemplateVariables.SELECTION, fSelection);
Template template= new Template("test", "descr", fTemplateContextType.getId(), before, false); Template template= new Template("test", "descr", fTemplateContextType.getId(), before, false);
TemplateBuffer buffer= context.evaluate(template); TemplateBuffer buffer= context.evaluate(template);
CFormatter formatter= new CFormatter("\n", 0, false, null); CFormatter formatter= new CFormatter("\n", 0, useFormatter, null);
formatter.format(buffer, context); formatter.format(buffer, context);
assertEquals(expected, buffer.getString()); assertEquals(expected, buffer.getString());
} }
//for(int var=0; var<max; var++) { //for(int var=0; var<max; var++) {
// ${cursor} // ${cursor}
//} //}
@ -142,4 +146,19 @@ public class TemplateFormatterTest extends BaseUITestCase {
fSelection= "while (true) {\n doSomething();\n}"; fSelection= "while (true) {\n doSomething();\n}";
assertFormatterResult(); assertFormatterResult();
} }
///*!
// * \brief ShortFunctionDescription${cursor}.
// *
// * \return ReturnedValueDescription.
// */
///*!
// * \brief ShortFunctionDescription.
// *
// * \return ReturnedValueDescription.
// */
public void _testIndentationProblemWithBackslashInComment_Bug274973() throws Exception {
assertFormatterResult(true);
}
} }