1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2010-05-02 21:42:04 +00:00
parent e487384c29
commit e85fb0b135

View file

@ -59,9 +59,8 @@ public class AddBlockCommentTest extends BaseUITestCase {
} }
int getOffset() throws BadLocationException { int getOffset() throws BadLocationException {
return fDoc.getLineOffset(line-1) + position-1; return fDoc.getLineOffset(line - 1) + position - 1;
} }
} }
@Override @Override
@ -98,10 +97,8 @@ public class AddBlockCommentTest extends BaseUITestCase {
* @param endLinePosition * @param endLinePosition
* @throws Exception * @throws Exception
*/ */
protected void assertFormatterResult( protected void assertFormatterResult(LinePosition startLinePosition, LinePosition endLinePosition)
LinePosition startLinePosition, throws Exception {
LinePosition endLinePosition) throws Exception {
StringBuffer[] contents= getContentsForTest(2); StringBuffer[] contents= getContentsForTest(2);
String before = contents[0].toString(); String before = contents[0].toString();
String after = contents[1].toString(); String after = contents[1].toString();
@ -109,7 +106,7 @@ public class AddBlockCommentTest extends BaseUITestCase {
fDocument.set(before); fDocument.set(before);
SourceRange range = new SourceRange( startLinePosition.getOffset(), SourceRange range = new SourceRange( startLinePosition.getOffset(),
endLinePosition.getOffset()-startLinePosition.getOffset() ); endLinePosition.getOffset() - startLinePosition.getOffset());
fEditor.setSelection(range, true); fEditor.setSelection(range, true);
IAction commentAction= fEditor.getAction("AddBlockComment"); IAction commentAction= fEditor.getAction("AddBlockComment");
@ -121,7 +118,6 @@ public class AddBlockCommentTest extends BaseUITestCase {
assertEquals(expected, fDocument.get()); assertEquals(expected, fDocument.get());
} }
/** /**
* Run an action to comment block defined by line positions * Run an action to comment block defined by line positions
* and assert that the result matches the expected result. * and assert that the result matches the expected result.
@ -133,16 +129,12 @@ public class AddBlockCommentTest extends BaseUITestCase {
* @param after expected editor contents after the operation * @param after expected editor contents after the operation
* @throws Exception * @throws Exception
*/ */
protected void assertFormatterResult( protected void assertFormatterResult(LinePosition startLinePosition, LinePosition endLinePosition,
LinePosition startLinePosition, String before, String after) throws Exception {
LinePosition endLinePosition,
String before,
String after) throws Exception {
fDocument.set(before); fDocument.set(before);
SourceRange range = new SourceRange( startLinePosition.getOffset(), SourceRange range = new SourceRange( startLinePosition.getOffset(),
endLinePosition.getOffset()-startLinePosition.getOffset() ); endLinePosition.getOffset() - startLinePosition.getOffset());
fEditor.setSelection(range, true); fEditor.setSelection(range, true);
IAction commentAction= fEditor.getAction("AddBlockComment"); IAction commentAction= fEditor.getAction("AddBlockComment");
@ -158,9 +150,9 @@ public class AddBlockCommentTest extends BaseUITestCase {
//int i, /*j,*/ k; //int i, /*j,*/ k;
public void testCommentPlain() throws Exception { public void testCommentPlain() throws Exception {
LinePosition startSelection = new LinePosition(1,8,fDocument); LinePosition startSelection = new LinePosition(1, 8, fDocument);
LinePosition endSelection = new LinePosition(1,10,fDocument); LinePosition endSelection = new LinePosition(1, 10, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
//int i, //int i,
@ -171,9 +163,9 @@ public class AddBlockCommentTest extends BaseUITestCase {
// j,*/ // j,*/
// k; // k;
public void testCommentPartialLines1() throws Exception { public void testCommentPartialLines1() throws Exception {
LinePosition startSelection = new LinePosition(1,5,fDocument); LinePosition startSelection = new LinePosition(1, 5, fDocument);
LinePosition endSelection = new LinePosition(2,7,fDocument); LinePosition endSelection = new LinePosition(2, 7, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
//int i, //int i,
@ -184,9 +176,9 @@ public class AddBlockCommentTest extends BaseUITestCase {
///* j, ///* j,
// k*/; // k*/;
public void testCommentPartialLines2() throws Exception { public void testCommentPartialLines2() throws Exception {
LinePosition startSelection = new LinePosition(2,1,fDocument); LinePosition startSelection = new LinePosition(2, 1, fDocument);
LinePosition endSelection = new LinePosition(3,6,fDocument); LinePosition endSelection = new LinePosition(3, 6, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
//int i; //int i;
@ -197,9 +189,9 @@ public class AddBlockCommentTest extends BaseUITestCase {
///*int j;*/ ///*int j;*/
//int k; //int k;
public void testCommentExactlyOneLine() throws Exception { public void testCommentExactlyOneLine() throws Exception {
LinePosition startSelection = new LinePosition(2,1,fDocument); LinePosition startSelection = new LinePosition(2, 1, fDocument);
LinePosition endSelection = new LinePosition(3,1,fDocument); LinePosition endSelection = new LinePosition(3, 1, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
//int i; //int i;
@ -214,18 +206,18 @@ public class AddBlockCommentTest extends BaseUITestCase {
//*/ //*/
//int l; //int l;
public void testCommentTwoOrMoreLines() throws Exception { public void testCommentTwoOrMoreLines() throws Exception {
LinePosition startSelection = new LinePosition(2,1,fDocument); LinePosition startSelection = new LinePosition(2, 1, fDocument);
LinePosition endSelection = new LinePosition(4,1,fDocument); LinePosition endSelection = new LinePosition(4, 1, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
//const int i; //const int i;
///*const*/ int i; ///*const*/ int i;
public void testCommentFirstCharacterInFile() throws Exception { public void testCommentFirstCharacterInFile() throws Exception {
LinePosition startSelection = new LinePosition(1,1,fDocument); LinePosition startSelection = new LinePosition(1, 1, fDocument);
LinePosition endSelection = new LinePosition(1,6,fDocument); LinePosition endSelection = new LinePosition(1, 6, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
//#include <x> //#include <x>
@ -234,9 +226,9 @@ public class AddBlockCommentTest extends BaseUITestCase {
///*#include <x>*/ ///*#include <x>*/
//#include <y> //#include <y>
public void testCommentPreprocessorFirstLine() throws Exception { public void testCommentPreprocessorFirstLine() throws Exception {
LinePosition startSelection = new LinePosition(1,1,fDocument); LinePosition startSelection = new LinePosition(1, 1, fDocument);
LinePosition endSelection = new LinePosition(1,6,fDocument); LinePosition endSelection = new LinePosition(1, 6, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
//int i; // comment //int i; // comment
@ -245,9 +237,9 @@ public class AddBlockCommentTest extends BaseUITestCase {
//int i; /*// comment*/ //int i; /*// comment*/
//int j; //int j;
public void testCommentCppComment() throws Exception { public void testCommentCppComment() throws Exception {
LinePosition startSelection = new LinePosition(1,10,fDocument); LinePosition startSelection = new LinePosition(1, 10, fDocument);
LinePosition endSelection = new LinePosition(1,12,fDocument); LinePosition endSelection = new LinePosition(1, 12, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
//#include <x> //#include <x>
@ -258,9 +250,9 @@ public class AddBlockCommentTest extends BaseUITestCase {
///*#include <y>*/ ///*#include <y>*/
//#include <z> //#include <z>
public void testCommentSpecialPartition() throws Exception { public void testCommentSpecialPartition() throws Exception {
LinePosition startSelection = new LinePosition(2,1,fDocument); LinePosition startSelection = new LinePosition(2, 1, fDocument);
LinePosition endSelection = new LinePosition(3,1,fDocument); LinePosition endSelection = new LinePosition(3, 1, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
//#include <x> //#include <x>
@ -275,9 +267,9 @@ public class AddBlockCommentTest extends BaseUITestCase {
//*/ //*/
//#include <z> //#include <z>
public void testCommentSpecialPartitionExtra() throws Exception { public void testCommentSpecialPartitionExtra() throws Exception {
LinePosition startSelection = new LinePosition(2,8,fDocument); LinePosition startSelection = new LinePosition(2, 8, fDocument);
LinePosition endSelection = new LinePosition(2,10,fDocument); LinePosition endSelection = new LinePosition(2, 10, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
///*comment*/ ///*comment*/
@ -286,12 +278,11 @@ public class AddBlockCommentTest extends BaseUITestCase {
///*comment*/ ///*comment*/
//int i; //int i;
public void testCommentCommentNoScrewUp() throws Exception { public void testCommentCommentNoScrewUp() throws Exception {
LinePosition startSelection = new LinePosition(1,1,fDocument); LinePosition startSelection = new LinePosition(1, 1, fDocument);
LinePosition endSelection = new LinePosition(2,1,fDocument); LinePosition endSelection = new LinePosition(2, 1, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
//int i; //int i;
///*comment*/ ///*comment*/
//int j; //int j;
@ -300,9 +291,9 @@ public class AddBlockCommentTest extends BaseUITestCase {
//comment*/ //comment*/
//int j; //int j;
public void testCommentMergeUp() throws Exception { public void testCommentMergeUp() throws Exception {
LinePosition startSelection = new LinePosition(1,1,fDocument); LinePosition startSelection = new LinePosition(1, 1, fDocument);
LinePosition endSelection = new LinePosition(2,5,fDocument); LinePosition endSelection = new LinePosition(2, 5, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
//int i; //int i;
@ -313,9 +304,9 @@ public class AddBlockCommentTest extends BaseUITestCase {
///*comment ///*comment
//int j;*/ //int j;*/
public void testCommentMergeDown() throws Exception { public void testCommentMergeDown() throws Exception {
LinePosition startSelection = new LinePosition(2,5,fDocument); LinePosition startSelection = new LinePosition(2, 5, fDocument);
LinePosition endSelection = new LinePosition(3,7,fDocument); LinePosition endSelection = new LinePosition(3, 7, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
///*comment1*/ ///*comment1*/
@ -326,9 +317,9 @@ public class AddBlockCommentTest extends BaseUITestCase {
//comment2*/ //comment2*/
//int i; //int i;
public void testCommentMergeComments() throws Exception { public void testCommentMergeComments() throws Exception {
LinePosition startSelection = new LinePosition(1,5,fDocument); LinePosition startSelection = new LinePosition(1, 5, fDocument);
LinePosition endSelection = new LinePosition(2,5,fDocument); LinePosition endSelection = new LinePosition(2, 5, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
// //
@ -340,25 +331,25 @@ public class AddBlockCommentTest extends BaseUITestCase {
//*/ //*/
public void testCommentEndOfFileNoLoopingPlease() throws Exception { public void testCommentEndOfFileNoLoopingPlease() throws Exception {
// Don't care much about formatting but no looping please // Don't care much about formatting but no looping please
LinePosition startSelection = new LinePosition(2,1,fDocument); LinePosition startSelection = new LinePosition(2, 1, fDocument);
LinePosition endSelection = new LinePosition(3,1,fDocument); LinePosition endSelection = new LinePosition(3, 1, fDocument);
assertFormatterResult(startSelection,endSelection); assertFormatterResult(startSelection, endSelection);
} }
public void testCommentLastCharacterNoEOL() throws Exception { public void testCommentLastCharacterNoEOL() throws Exception {
String before = "int i;"; String before = "int i;";
String after = "/*int i;*/"; String after = "/*int i;*/";
LinePosition startSelection = new LinePosition(1,1,fDocument); LinePosition startSelection = new LinePosition(1, 1, fDocument);
LinePosition endSelection = new LinePosition(1,7,fDocument); LinePosition endSelection = new LinePosition(1, 7, fDocument);
assertFormatterResult(startSelection,endSelection,before,after); assertFormatterResult(startSelection, endSelection, before, after);
} }
public void testCommentLastCppCommentNoEOL() throws Exception { public void testCommentLastCppCommentNoEOL() throws Exception {
String before = "//int i;"; String before = "//int i;";
String after = "/*//int i;*/"; String after = "/*//int i;*/";
LinePosition startSelection = new LinePosition(1,3,fDocument); LinePosition startSelection = new LinePosition(1, 3, fDocument);
LinePosition endSelection = new LinePosition(1,7,fDocument); LinePosition endSelection = new LinePosition(1, 7, fDocument);
assertFormatterResult(startSelection,endSelection,before,after); assertFormatterResult(startSelection, endSelection, before, after);
} }
public void testMixedEOLs() throws Exception { public void testMixedEOLs() throws Exception {
@ -372,8 +363,8 @@ public class AddBlockCommentTest extends BaseUITestCase {
+ "int j;\n" + "int j;\n"
+ "*/\n" + "*/\n"
+ "int k;"; + "int k;";
LinePosition startSelection = new LinePosition(1,1,fDocument); LinePosition startSelection = new LinePosition(1, 1, fDocument);
LinePosition endSelection = new LinePosition(3,1,fDocument); LinePosition endSelection = new LinePosition(3, 1, fDocument);
assertFormatterResult(startSelection,endSelection,before,after); assertFormatterResult(startSelection, endSelection, before, after);
} }
} }