Skip to content

Commit

Permalink
Issue 42BV#57 Use CRLF as line separator for writing as per specifica…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
mparaz committed Dec 11, 2014
1 parent fc1cc16 commit 34fc884
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/csveed/row/RowWriterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void writeCells(Iterator<String> cells) {
}

private void writeEOL() throws IOException {
writer.write(rowInstructions.getEndOfLine());
writer.write("\r\n");
}

private void writeSeparator() throws IOException {
Expand Down
32 changes: 16 additions & 16 deletions src/test/java/org/csveed/api/CsvClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public void writeBeansBasedOnClass() throws IOException {
client.writeBeans(beans);
writer.close();
assertEquals(
"\"gamma\";\"beta\";\"alpha\"\r"+
"\"row 1, cell 1\";\"row 1, cell 2\";\"row 1, cell 3\"\r"+
"\"row 2, cell 1\";\"row 2, cell 2\";\"row 2, cell 3\"\r"+
"\"row 3, cell 1\";\"row 3, cell 2\";\"row 3, cell 3\"\r",
"\"gamma\";\"beta\";\"alpha\"\r\n"+
"\"row 1, cell 1\";\"row 1, cell 2\";\"row 1, cell 3\"\r\n"+
"\"row 2, cell 1\";\"row 2, cell 2\";\"row 2, cell 3\"\r\n"+
"\"row 3, cell 1\";\"row 3, cell 2\";\"row 3, cell 3\"\r\n",
writer.getBuffer().toString());
}

Expand All @@ -52,10 +52,10 @@ writer, new BeanInstructionsImpl(BeanWithMultipleStrings.class)
client.writeBeans(beans);
writer.close();
assertEquals(
"\"beta\";\"alpha\"\r"+
"\"row 1, cell 2\";\"row 1, cell 3\"\r"+
"\"row 2, cell 2\";\"row 2, cell 3\"\r"+
"\"row 3, cell 2\";\"row 3, cell 3\"\r",
"\"beta\";\"alpha\"\r\n"+
"\"row 1, cell 2\";\"row 1, cell 3\"\r\n"+
"\"row 2, cell 2\";\"row 2, cell 3\"\r\n"+
"\"row 3, cell 2\";\"row 3, cell 3\"\r\n",
writer.getBuffer().toString());
}

Expand Down Expand Up @@ -84,9 +84,9 @@ public void readAndWriteRows() throws IOException {
writer.close();

assertEquals(
"\"alpha\";\"beta\";\"gamma\"\r"+
"\"row 1, cell 1\";\"row 1, cell 2\";\"row 1, cell 3\"\r"+
"\"row 2, cell 1\";\"row 2, cell 2\";\"row 2, cell 3\"\r",
"\"alpha\";\"beta\";\"gamma\"\r\n"+
"\"row 1, cell 1\";\"row 1, cell 2\";\"row 1, cell 3\"\r\n"+
"\"row 2, cell 1\";\"row 2, cell 2\";\"row 2, cell 3\"\r\n",
writer.getBuffer().toString());
}

Expand All @@ -97,7 +97,7 @@ public void writeRow() throws IOException {
.setUseHeader(false);
csvClient.writeRow(new String[] { "alpha", "beta", "gamma" } );
writer.close();
assertEquals("\"alpha\";\"beta\";\"gamma\"\r", writer.getBuffer().toString());
assertEquals("\"alpha\";\"beta\";\"gamma\"\r\n", writer.getBuffer().toString());
}

@Test
Expand All @@ -115,10 +115,10 @@ public void writeRows() throws IOException {
} );
writer.close();
assertEquals(
"\"h1\";\"h2\";\"h3\"\r"+
"\"l1c1\";\"l1c2\";\"l1c3\"\r"+
"\"l2c1\";\"l2c2\";\"l2c3\"\r"+
"\"l3c1\";\"l3c2\";\"l3c3\"\r",
"\"h1\";\"h2\";\"h3\"\r\n"+
"\"l1c1\";\"l1c2\";\"l1c3\"\r\n"+
"\"l2c1\";\"l2c2\";\"l2c3\"\r\n"+
"\"l3c1\";\"l3c2\";\"l3c3\"\r\n",
writer.getBuffer().toString());
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/csveed/bean/BeanWriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public void writeBeans() throws IOException {
beanWriter.writeBeans(beans);
writer.close();
assertEquals(
"\"gamma\";\"beta\";\"alpha\"\r"+
"\"row 1, cell 1\";\"row 1, cell 2\";\"row 1, cell 3\"\r"+
"\"row 2, cell 1\";\"row 2, cell 2\";\"row 2, cell 3\"\r"+
"\"row 3, cell 1\";\"row 3, cell 2\";\"row 3, cell 3\"\r",
"\"gamma\";\"beta\";\"alpha\"\r\n"+
"\"row 1, cell 1\";\"row 1, cell 2\";\"row 1, cell 3\"\r\n"+
"\"row 2, cell 1\";\"row 2, cell 2\";\"row 2, cell 3\"\r\n"+
"\"row 3, cell 1\";\"row 3, cell 2\";\"row 3, cell 3\"\r\n",
writer.getBuffer().toString());
}

Expand Down
22 changes: 11 additions & 11 deletions src/test/java/org/csveed/row/RowWriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public void readAndWrite() throws IOException {

writer.close();
assertEquals(
"\"alpha\";\"beta\";\"gamma\"\r"+
"\"row 1, cell 1\";\"row 1, cell 2\";\"row 1, cell 3\"\r"+
"\"row 2, cell 1\";\"row 2, cell 2\";\"row 2, cell 3\"\r",
"\"alpha\";\"beta\";\"gamma\"\r\n"+
"\"row 1, cell 1\";\"row 1, cell 2\";\"row 1, cell 3\"\r\n"+
"\"row 2, cell 1\";\"row 2, cell 2\";\"row 2, cell 3\"\r\n",
writer.getBuffer().toString());
}

Expand All @@ -52,10 +52,10 @@ public void writeMultipleRows() throws IOException {
});
writer.close();
assertEquals(
"\"desc1\";\"desc2\";\"desc3\"\r"+
"\"alpha\";\"beta\";\"gamma\"\r"+
"\"delta\";\"epsilon\";\"phi\"\r"+
"\"b1\";\"b2\";\"b3\"\r",
"\"desc1\";\"desc2\";\"desc3\"\r\n"+
"\"alpha\";\"beta\";\"gamma\"\r\n"+
"\"delta\";\"epsilon\";\"phi\"\r\n"+
"\"b1\";\"b2\";\"b3\"\r\n",
writer.getBuffer().toString());
}

Expand All @@ -68,7 +68,7 @@ public void writeRowWithEscapeCharacters() throws IOException {
RowWriter rowWriter = new RowWriterImpl(writer, instructions);
rowWriter.writeRow(new String[] { "\"tekst met \"quotes\"\"" } );
writer.close();
assertEquals("\"\\\"tekst met \\\"quotes\\\"\\\"\"\r", writer.getBuffer().toString());
assertEquals("\"\\\"tekst met \\\"quotes\\\"\\\"\"\r\n", writer.getBuffer().toString());
}

@Test
Expand All @@ -79,7 +79,7 @@ public void writeRow() throws IOException {
RowWriter rowWriter = new RowWriterImpl(writer, instructions);
rowWriter.writeRow(new String[] { "alpha", "beta", "gamma" } );
writer.close();
assertEquals("\"alpha\";\"beta\";\"gamma\"\r", writer.getBuffer().toString());
assertEquals("\"alpha\";\"beta\";\"gamma\"\r\n", writer.getBuffer().toString());
}

@Test
Expand All @@ -90,8 +90,8 @@ public void writeRowAndHeader() throws IOException {
rowWriter.writeRow(new String[] { "alpha", "beta", "gamma" } );
writer.close();
assertEquals(
"\"desc1\";\"desc2\";\"desc3\"\r"+
"\"alpha\";\"beta\";\"gamma\"\r",
"\"desc1\";\"desc2\";\"desc3\"\r\n"+
"\"alpha\";\"beta\";\"gamma\"\r\n",
writer.getBuffer().toString());
}

Expand Down

0 comments on commit 34fc884

Please sign in to comment.