diff options
author | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-11-12 18:13:33 +0000 |
---|---|---|
committer | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-11-12 18:13:33 +0000 |
commit | 6493368285ce77792f6076954d4311a9a457a826 (patch) | |
tree | 9c77f15e07c2b7918f8a4bfc78d67a1017daf717 /java/src/test | |
parent | 6ba3df0d326e6478101c8cd0bb9bce6c7cc87488 (diff) | |
download | protobuf-6493368285ce77792f6076954d4311a9a457a826.tar.gz protobuf-6493368285ce77792f6076954d4311a9a457a826.tar.bz2 protobuf-6493368285ce77792f6076954d4311a9a457a826.zip |
CodedInputStream.getTotalBytesRead(); patch from Michael Kucharski.
Diffstat (limited to 'java/src/test')
-rw-r--r-- | java/src/test/java/com/google/protobuf/CodedInputStreamTest.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/java/src/test/java/com/google/protobuf/CodedInputStreamTest.java b/java/src/test/java/com/google/protobuf/CodedInputStreamTest.java index 850b8aa7..a75a400b 100644 --- a/java/src/test/java/com/google/protobuf/CodedInputStreamTest.java +++ b/java/src/test/java/com/google/protobuf/CodedInputStreamTest.java @@ -434,6 +434,7 @@ public class CodedInputStreamTest extends TestCase { new SmallBlockInputStream(new byte[256], 8)); input.setSizeLimit(16); input.readRawBytes(16); + assertEquals(16, input.getTotalBytesRead()); try { input.readRawByte(); @@ -443,7 +444,10 @@ public class CodedInputStreamTest extends TestCase { } input.resetSizeCounter(); + assertEquals(0, input.getTotalBytesRead()); input.readRawByte(); // No exception thrown. + input.resetSizeCounter(); + assertEquals(0, input.getTotalBytesRead()); try { input.readRawBytes(16); // Hits limit again. @@ -477,10 +481,13 @@ public class CodedInputStreamTest extends TestCase { public void testReadFromSlice() throws Exception { byte[] bytes = bytes(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); CodedInputStream in = CodedInputStream.newInstance(bytes, 3, 5); + assertEquals(0, in.getTotalBytesRead()); for (int i = 3; i < 8; i++) { assertEquals(i, in.readRawByte()); + assertEquals(i-2, in.getTotalBytesRead()); } // eof assertEquals(0, in.readTag()); + assertEquals(5, in.getTotalBytesRead()); } } |