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

Bug 540373: Fix tests that rely on whitespace at end of line

Change-Id: I2aa5d28e5fbd9ba1f12f6ec275ea1474730efe46
This commit is contained in:
Jonah Graham 2018-11-20 21:51:42 +00:00
parent 871c91ee5e
commit 086e6e30b7
4 changed files with 13 additions and 9 deletions

View file

@ -156,6 +156,10 @@ public class TestSourceReader {
StringBuilder content = new StringBuilder(); StringBuilder content = new StringBuilder();
for (String line = br.readLine(); line != null; line = br.readLine()) { for (String line = br.readLine(); line != null; line = br.readLine()) {
line = line.replaceFirst("^\\s*", ""); // Replace leading whitespace, preserve trailing line = line.replaceFirst("^\\s*", ""); // Replace leading whitespace, preserve trailing
// Trailing whitespace can be removed by editor/clean-up actions. To enforce whitespace
// at end of line, use ${whitspace_eol}, which will be removed, but cause the
// whitespace to the left of it to be preserved.
line = line.replace("${whitespace_eol}", "");
if (line.startsWith("//")) { if (line.startsWith("//")) {
content.append(line.substring(2)).append('\n'); content.append(line.substring(2)).append('\n');
} else { } else {

View file

@ -102,7 +102,7 @@ public class TemplateFormatterTest extends BaseUITestCase {
//} //}
//for(int var=0; var<max; var++) { //for(int var=0; var<max; var++) {
// // ${whitespace_eol}
//} //}
public void testForLoopTemplateDefault() throws Exception { public void testForLoopTemplateDefault() throws Exception {
assertFormatterResult(); assertFormatterResult();
@ -113,7 +113,7 @@ public class TemplateFormatterTest extends BaseUITestCase {
//} //}
//for(int var=0; var<max; var++) { //for(int var=0; var<max; var++) {
// // ${whitespace_eol}
//} //}
public void testForLoopTemplateMixedIndent() throws Exception { public void testForLoopTemplateMixedIndent() throws Exception {
setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED); setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED);

View file

@ -103,7 +103,7 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
// /** X // /** X
// void foo() {} // void foo() {}
// /** // /** ${whitespace_eol}
// * X // * X
// */ // */
// void foo() {} // void foo() {}
@ -126,7 +126,7 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
// /** X // /** X
// int foo_bar() {} // int foo_bar() {}
// /** // /** ${whitespace_eol}
// * X // * X
// * @return // * @return
// */ // */
@ -506,7 +506,7 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
// /** X // /** X
// int foo_bar(); // int foo_bar();
// /** // /** ${whitespace_eol}
// * X // * X
// * @return // * @return
// */ // */

View file

@ -102,7 +102,7 @@ public class DoxygenCCommentSingleAutoEditStrategyTest extends AbstractAutoEditT
// /// X // /// X
// void foo() {} // void foo() {}
// /// // /// ${whitespace_eol}
// /// X // /// X
// void foo() {} // void foo() {}
public void testAutoDocCommentContent2() throws CoreException { public void testAutoDocCommentContent2() throws CoreException {
@ -192,7 +192,7 @@ public class DoxygenCCommentSingleAutoEditStrategyTest extends AbstractAutoEditT
// C* bar_baz(A a, B b, int c) {} // C* bar_baz(A a, B b, int c) {}
// class A {}; class B {}; // class A {}; class B {};
// /// // /// ${whitespace_eol}
// /// X@param a // /// X@param a
// /// @param b // /// @param b
// /// @param c // /// @param c
@ -271,7 +271,7 @@ public class DoxygenCCommentSingleAutoEditStrategyTest extends AbstractAutoEditT
// {} // {}
// void foo_bar(int x) // void foo_bar(int x)
// /// // /// ${whitespace_eol}
// /// X@param x // /// X@param x
// {} // {}
public void testAutoDocCommentContent9b() throws CoreException { public void testAutoDocCommentContent9b() throws CoreException {
@ -282,7 +282,7 @@ public class DoxygenCCommentSingleAutoEditStrategyTest extends AbstractAutoEditT
// {} // {}
// void foo_bar(int x) // void foo_bar(int x)
// /// // /// ${whitespace_eol}
// /// X@param x // /// X@param x
// {} // {}
public void testAutoDocCommentContent9c() throws CoreException { public void testAutoDocCommentContent9c() throws CoreException {