~verterok/ubuntu/lucid/protobuf/2.4.0a-backport

« back to all changes in this revision

Viewing changes to java/src/test/java/com/google/protobuf/CodedInputStreamTest.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2011-05-31 14:41:47 UTC
  • mfrom: (2.2.8 sid)
  • Revision ID: james.westby@ubuntu.com-20110531144147-s41g5fozgvyo462l
Tags: 2.4.0a-2ubuntu1
* Merge with Debian; remaining changes:
  - Fix linking with -lpthread.

Show diffs side-by-side

added added

removed removed

Lines of Context:
325
325
    assertEquals(2, input.readRawByte());
326
326
  }
327
327
 
 
328
  /**
 
329
   * Test that a bug in skipRawBytes() has been fixed:  if the skip skips
 
330
   * past the end of a buffer with a limit that has been set past the end of
 
331
   * that buffer, this should not break things.
 
332
   */
 
333
  public void testSkipRawBytesPastEndOfBufferWithLimit() throws Exception {
 
334
    byte[] rawBytes = new byte[] { 1, 2, 3, 4, 5 };
 
335
    CodedInputStream input = CodedInputStream.newInstance(
 
336
        new SmallBlockInputStream(rawBytes, 3));
 
337
 
 
338
    int limit = input.pushLimit(4);
 
339
    // In order to expose the bug we need to read at least one byte to prime the
 
340
    // buffer inside the CodedInputStream.
 
341
    assertEquals(1, input.readRawByte());
 
342
    // Skip to the end of the limit.
 
343
    input.skipRawBytes(3);
 
344
    assertTrue(input.isAtEnd());
 
345
    input.popLimit(limit);
 
346
    assertEquals(5, input.readRawByte());
 
347
  }
 
348
 
328
349
  public void testReadHugeBlob() throws Exception {
329
350
    // Allocate and initialize a 1MB blob.
330
351
    byte[] blob = new byte[1 << 20];