Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit 77694bb

Browse files
committed
Handle both EOL cases (\n and \r\n).
1 parent 8b651a2 commit 77694bb

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

biojava-core/src/test/java/org/biojava/nbio/core/alignment/matrices/SubstitutionMatrixTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void matrixToString(){
5555
String asString = sm.toString();
5656
// description + 5*2 for ATCGNatcgn + 1 header + 1 for '-'
5757
assertEquals(13, asString.split("\n").length);
58-
String header = asString.split("\n")[1];
58+
String header = asString.split("\r?\n")[1];
5959
assertTrue(header.replaceAll(" ","").matches("[ATCGatcgNn-]+"));
6060
}
6161

@@ -65,7 +65,7 @@ void matrixAsString(){
6565

6666
// 5*2 for ATCGNatcgn + 1 header + 1 for '-'
6767
assertEquals(12, asString.split("\n").length);
68-
String header = asString.split("\n")[0];
68+
String header = asString.split("\r?\n")[0];
6969
assertTrue(header.replaceAll(" ","").matches("[ATCGatcgNn-]+"));
7070
}
7171
}

biojava-core/src/test/java/org/biojava/nbio/core/util/PrettyXMLWriterTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.biojava.nbio.core.util;
22

3-
import static org.junit.jupiter.api.Assertions.assertEquals;
3+
import static org.junit.Assert.fail;
44

55
import java.io.IOException;
66
import java.io.PrintWriter;
@@ -57,8 +57,8 @@ void simpleOutput() throws IOException {
5757

5858
xw.closeTag("to");
5959
System.out.println(sw.toString());
60-
assertEquals(EXPECTED, sw.toString());
61-
60+
if(! StringManipulationHelper.equalsToIgnoreEndline(EXPECTED, sw.toString()))
61+
fail(String.format("Strings are not equal (ignoring endline differences. expected: [%s], but it was:[%s]", EXPECTED, sw.toString()));
6262
}
6363

6464
@Test
@@ -68,7 +68,8 @@ void specialCharsAreEscaped() throws IOException {
6868
xw.print("<code>some literal xml </code>");
6969
xw.closeTag("dt");
7070

71-
assertEquals(EXPECTED, sw.toString());
71+
if(! StringManipulationHelper.equalsToIgnoreEndline(EXPECTED, sw.toString()))
72+
fail(String.format("Strings are not equal (ignoring endline differences. expected: [%s], but it was:[%s]", EXPECTED, sw.toString()));
7273
}
7374

7475
@Test
@@ -82,6 +83,7 @@ void namespacesAreAddedToElements() throws IOException {
8283
xw.print("<code>some literal xml </code>");
8384
xw.closeTag(HTTP_TEST_NAMESPACE, "dt");
8485

85-
assertEquals(EXPECTED, sw.toString());
86+
if(! StringManipulationHelper.equalsToIgnoreEndline(EXPECTED, sw.toString()))
87+
fail(String.format("Strings are not equal (ignoring endline differences. expected: [%s], but it was:[%s]", EXPECTED, sw.toString()));
8688
}
8789
}

0 commit comments

Comments
 (0)