add LF after last written column, not before new column
This commit is contained in:
parent
7a4716dd7b
commit
e1e9a35cd7
2 changed files with 11 additions and 12 deletions
|
@ -59,19 +59,18 @@ public class Generator implements Constants, Closeable, Flushable {
|
|||
}
|
||||
|
||||
public synchronized void write(String value) throws IOException {
|
||||
if (col >= keys.size()) {
|
||||
writer.write(LF);
|
||||
row++;
|
||||
col = 0;
|
||||
} else {
|
||||
if (col > 0) {
|
||||
writer.write(separator);
|
||||
}
|
||||
if (col > 0) {
|
||||
writer.write(separator);
|
||||
}
|
||||
if (value != null) {
|
||||
writer.write(escape(value));
|
||||
}
|
||||
col++;
|
||||
if (col >= keys.size()) {
|
||||
writer.write(LF);
|
||||
row++;
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getColumn() {
|
||||
|
|
|
@ -18,7 +18,7 @@ public class GeneratorTest {
|
|||
gen.write("val" + i);
|
||||
}
|
||||
gen.close();
|
||||
assertEquals("val0\nval1", writer.toString());
|
||||
assertEquals("val0\nval1\n", writer.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -31,7 +31,7 @@ public class GeneratorTest {
|
|||
gen.write("val" + i);
|
||||
}
|
||||
gen.close();
|
||||
assertEquals("val0,val0\nval1,val1", writer.toString());
|
||||
assertEquals("val0,val0\nval1,val1\n", writer.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -45,7 +45,7 @@ public class GeneratorTest {
|
|||
gen.write("hey look a line seperator \n");
|
||||
}
|
||||
gen.close();
|
||||
assertEquals("val0,\"\"\"Hello, World\"\"\",\"hey look a line seperator \n\"", writer.toString());
|
||||
assertEquals("val0,\"\"\"Hello, World\"\"\",\"hey look a line seperator \n\"\n", writer.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -59,7 +59,7 @@ public class GeneratorTest {
|
|||
gen.write("hey look a line seperator \n");
|
||||
}
|
||||
gen.close();
|
||||
assertEquals("\"val0\";\"\"\"Hello, World\"\"\";\"hey look a line seperator \n\"", writer.toString());
|
||||
assertEquals("\"val0\";\"\"\"Hello, World\"\"\";\"hey look a line seperator \n\"\n", writer.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue