mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fixes InputStreamReader one-by-one read
This commit is contained in:
parent
8cbb6477cb
commit
744033b118
|
@ -64,7 +64,7 @@ public class TInputStreamReader extends TReader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read() throws TIOException {
|
public int read() throws TIOException {
|
||||||
if (eof) {
|
if (eof && outBuffer.end()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!outBuffer.end()) {
|
if (!outBuffer.end()) {
|
||||||
|
|
|
@ -43,6 +43,21 @@ public class InputStreamReaderTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readsCharsOneByOne() throws IOException {
|
||||||
|
String str = "foo bar baz";
|
||||||
|
byte[] bytes = new byte[str.length()];
|
||||||
|
for (int i = 0; i < str.length(); ++i) {
|
||||||
|
bytes[i] = (byte)str.charAt(i);
|
||||||
|
}
|
||||||
|
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
|
||||||
|
InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
|
||||||
|
assertEquals('f', reader.read());
|
||||||
|
assertEquals('o', reader.read());
|
||||||
|
assertEquals('o', reader.read());
|
||||||
|
assertEquals(' ', reader.read());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readsManyChars() throws IOException {
|
public void readsManyChars() throws IOException {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user