Skip to content
Permalink
Browse files

refactor: add encoding, fix expected/actual, use proper constructor

  • Loading branch information
vlsi committed Apr 17, 2017
1 parent 43e5aef commit 77cace40a4ce33fadafcb5f144b5238bff2854a3
Showing with 10 additions and 10 deletions.
  1. +10 −10 pgjdbc/src/test/java/org/postgresql/util/ReaderInputStreamTest.java
@@ -185,21 +185,21 @@ public void malformedSingleCharArrayReadTest() throws IOException {
}

@Test
public void readsSmallerThanBlockSizeTest() throws Exception {
final int BLOCK = 8 * 1024;
final int DATASIZE = BLOCK + 57;
final byte[] data = new byte[DATASIZE];
final byte[] buffer = new byte[BLOCK];
public void readsEqualToBlockSizeTest() throws Exception {
final int blockSize = 8 * 1024;
final int dataSize = blockSize + 57;
final byte[] data = new byte[dataSize];
final byte[] buffer = new byte[blockSize];

InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(data));
ReaderInputStream r = new ReaderInputStream(isr);
InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(data), "UTF-8");
ReaderInputStream r = new ReaderInputStream(isr, blockSize);

int total = 0;

total += r.read(buffer, 0, BLOCK);
total += r.read(buffer, 0, BLOCK);
total += r.read(buffer, 0, blockSize);
total += r.read(buffer, 0, blockSize);

assertEquals("Data not read completely: missing " + (DATASIZE - total) + " bytes", total, DATASIZE);
assertEquals("Data not read completely: missing " + (dataSize - total) + " bytes", dataSize, total);
}

private static class SingleCharPerReadReader extends Reader {

0 comments on commit 77cace4

Please sign in to comment.
You can’t perform that action at this time.