1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Fix CodeFormatter JUnit test, bug 272006

This commit is contained in:
Anton Leherbauer 2009-04-27 09:19:39 +00:00
parent 7f998b3962
commit 48bdc40eec
2 changed files with 21 additions and 19 deletions

View file

@ -1,3 +0,0 @@
#Thu Apr 23 17:28:18 CEST 2009
eclipse.preferences.version=1
encoding//ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java=UTF-8

View file

@ -16,6 +16,7 @@ import java.util.Map;
import junit.framework.TestSuite;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextUtilities;
@ -59,9 +60,13 @@ public class CodeFormatterTest extends BaseUITestCase {
protected void assertFormatterResult() throws Exception {
StringBuffer[] contents= getContentsForTest(2);
String before= contents[0].toString();
IDocument document= new Document(before);
String expected= contents[1].toString();
TextEdit edit= CodeFormatterUtil.format(CodeFormatter.K_TRANSLATION_UNIT, before, 0, TextUtilities.getDefaultLineDelimiter(document), fOptions);
assertFormatterResult(before, expected);
}
private void assertFormatterResult(String original, String expected) throws BadLocationException {
IDocument document= new Document(original);
TextEdit edit= CodeFormatterUtil.format(CodeFormatter.K_TRANSLATION_UNIT, original, 0, TextUtilities.getDefaultLineDelimiter(document), fOptions);
assertNotNull(edit);
edit.apply(document);
assertEquals(expected, document.get());
@ -1181,21 +1186,21 @@ public class CodeFormatterTest extends BaseUITestCase {
assertFormatterResult();
}
//class 大大大大
//{
//public:
// 大大大大();
// virtual ~大大大大();
//};
//class 大大大大
//{
//public:
// 大大大大();
// virtual ~大大大大();
//};
public void testFormatGeneratedClass_Bug272006() throws Exception {
assertFormatterResult();
String original =
"class \u5927\u5927\u5927\u5927\n" +
"{\n" +
"public:\n" +
" \u5927\u5927\u5927\u5927();\n" +
" virtual ~\u5927\u5927\u5927\u5927();\n" +
"};\n";
String expected =
"class \u5927\u5927\u5927\u5927 {\n" +
"public:\n" +
" \u5927\u5927\u5927\u5927();\n" +
" virtual ~\u5927\u5927\u5927\u5927();\n" +
"};\n";
assertFormatterResult(original, expected);
}
}