Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHansruedi Patzen2017-11-24 04:44:11 -0500
committerHansruedi Patzen2017-11-24 04:44:11 -0500
commit19b4848e08c13928c1bda7235c10e77e54edf98e (patch)
tree0fefe5154ba6d4c0699602c0995ecec9a2eb730a
parent93a5fcaa2a769c12f6ff805cf3cc53b8ecfab3bc (diff)
downloadorg.eclipse.cdt-19b4848e08c13928c1bda7235c10e77e54edf98e.tar.gz
org.eclipse.cdt-19b4848e08c13928c1bda7235c10e77e54edf98e.tar.xz
org.eclipse.cdt-19b4848e08c13928c1bda7235c10e77e54edf98e.zip
Bug 527709 - [Checker] Test suite fails on Windows
Change-Id: I70cf18245dc8dba14493f212c932ea08ae85a6cf Signed-off-by: Hansruedi Patzen <hansruedi.patzen@hsr.ch>
-rw-r--r--codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/internal/checkers/AssignmentToItselfCheckerTest.java2
-rw-r--r--codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/CodanTestCase.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java6
3 files changed, 8 insertions, 2 deletions
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 869969c319..ef5f46bb18 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 718a998799..41321abc34 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 d48b25666c..911a902657 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;

Back to the top