List of usage examples for org.eclipse.jdt.core.tests.util Util convertToIndependantLineDelimiter
public static String convertToIndependantLineDelimiter(String source)
From source file:org.eclipse.objectteams.otdt.core.tests.formatter.FormatterTests.java
License:Open Source License
private String runFormatter(CodeFormatter codeFormatter, String source, int kind, int indentationLevel, int offset, int length, String lineSeparator) { // long time = System.currentTimeMillis(); TextEdit edit = codeFormatter.format(kind, source, offset, length, indentationLevel, lineSeparator);//$NON-NLS-1$ // System.out.println((System.currentTimeMillis() - time) + " ms"); if (edit == null) return null; // System.out.println(edit.getChildrenSize() + " edits"); String result = org.eclipse.jdt.internal.core.util.Util.editedString(source, edit); if (length == source.length()) { // time = System.currentTimeMillis(); edit = codeFormatter.format(kind, result, 0, result.length(), indentationLevel, lineSeparator);//$NON-NLS-1$ // System.out.println((System.currentTimeMillis() - time) + " ms"); if (edit == null) return null; // assertEquals("Should not have edits", 0, edit.getChildren().length); final String result2 = org.eclipse.jdt.internal.core.util.Util.editedString(result, edit); if (!result.equals(result2)) { assertSourceEquals("Different reformatting", Util.convertToIndependantLineDelimiter(result), Util.convertToIndependantLineDelimiter(result2)); }/*from w w w . j a v a 2 s . c o m*/ } return result; }
From source file:org.eclipse.objectteams.otdt.core.tests.formatter.FormatterTests.java
License:Open Source License
private void assertLineEquals(String actualContents, String originalSource, String expectedContents, boolean checkNull) { if (actualContents == null) { assertTrue("actualContents is null", checkNull); assertEquals(expectedContents, originalSource); return;/* w w w .ja v a2 s . c o m*/ } assertSourceEquals("Different source", Util.convertToIndependantLineDelimiter(expectedContents), actualContents); }
From source file:org.eclipse.objectteams.otdt.tests.otjld.AbstractOTJLDTest.java
License:Open Source License
/** Relaxed comparison using contains rather than equals. TODO(SH): pattern matching. */ protected void checkCompilerLog(String[] testFiles, Requestor requestor, String[] alternatePlatformIndependantExpectedLogs, Throwable exception) { String computedProblemLog = Util.convertToIndependantLineDelimiter(requestor.problemLog.toString()); for (String platformIndependantExpectedLog : alternatePlatformIndependantExpectedLogs) { if (computedProblemLog.contains(platformIndependantExpectedLog)) return; // OK }/*w w w. ja v a2 s . c o m*/ logTestTitle(); System.out.println(Util.displayString(computedProblemLog, INDENT, SHIFT)); logTestFiles(false, testFiles); if (errorMatching && exception == null) fail("Invalid problem log\n" + computedProblemLog); if (!errorMatching && exception == null) { assertEquals("Invalid problem log ", alternatePlatformIndependantExpectedLogs[0], computedProblemLog); } }