forked from json-iterator/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestIO.java
More file actions
36 lines (29 loc) · 1.25 KB
/
TestIO.java
File metadata and controls
36 lines (29 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.jsoniter;
import junit.framework.TestCase;
import org.junit.experimental.categories.Category;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@Category(AllTests.StreamingCategory.class)
public class TestIO extends TestCase {
public void test_read_byte() throws IOException {
JsonIterator iter = JsonIterator.parse(new ByteArrayInputStream("1".getBytes()), 4096);
assertEquals('1', IterImpl.readByte(iter));
assertEquals(0, IterImpl.readByte(iter));
}
public void test_read_bytes() throws IOException {
JsonIterator iter = JsonIterator.parse(new ByteArrayInputStream("12".getBytes()), 4096);
assertEquals('1', IterImpl.readByte(iter));
assertEquals('2', IterImpl.readByte(iter));
assertEquals(0, IterImpl.readByte(iter));
}
public void test_unread_byte() throws IOException {
JsonIterator iter = JsonIterator.parse(new ByteArrayInputStream("12".getBytes()), 4096);
assertEquals('1', IterImpl.readByte(iter));
assertEquals('2', IterImpl.readByte(iter));
iter.unreadByte();
assertEquals('2', IterImpl.readByte(iter));
iter.unreadByte();
iter.unreadByte();
assertEquals('1', IterImpl.readByte(iter));
}
}