diff --git a/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/internal/checkers/AssignmentToItselfCheckerTest.java b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/internal/checkers/AssignmentToItselfCheckerTest.java index 869969c319c..ef5f46bb18d 100644 --- a/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/internal/checkers/AssignmentToItselfCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/internal/checkers/AssignmentToItselfCheckerTest.java @@ -76,6 +76,6 @@ public class AssignmentToItselfCheckerTest extends CheckerTestCase { int start = marker.getAttribute(IMarker.CHAR_START, -1); int end = marker.getAttribute(IMarker.CHAR_END, -1); // The offset should start at the beginning of the expression "x = x" - assertEquals("x\n = x", code.substring(start, end)); + assertEquals("x" + NL + " = x", code.substring(start, end)); } } diff --git a/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/CodanTestCase.java b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/CodanTestCase.java index 718a998799a..41321abc344 100644 --- a/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/CodanTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/CodanTestCase.java @@ -174,7 +174,7 @@ public class CodanTestCase extends BaseTestCase { } protected String getAboveComment() { - return getContents(1)[0].toString(); + return getContents(1)[0].toString().replaceAll("\\r\\n|\\n", NL); } protected StringBuilder[] getContents(int sections) { diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java index d48b25666c1..911a9026579 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java @@ -73,6 +73,12 @@ public class BaseTestCase extends TestCase { protected static final int GCC_MAJOR_VERSION_FOR_TESTS = 5; protected static final int GCC_MINOR_VERSION_FOR_TESTS = 1; + /** + * This provides the systems new line separator. Use this if you do String comparisons in tests + * instead of hard coding '\n' or '\r\n' respectively. + */ + protected static final String NL = System.getProperty("line.separator"); + private boolean fExpectFailure; private int fBugNumber; private int fExpectedLoggedNonOK;