Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
com.google.protobuf.CodedInputStreamTest Class Reference
Inheritance diagram for com.google.protobuf.CodedInputStreamTest:
Inheritance graph
[legend]

Classes

enum  InputType
 
class  RepeatingInputStream
 
class  SmallBlockInputStream
 

Public Member Functions

void testCompatibleTypes () throws Exception
 
void testCurrentLimitExceeded () throws Exception
 
void testDecodeZigZag () throws Exception
 
void testInvalidTag () throws Exception
 
void testIsAtEnd () throws Exception
 
void testMaliciousInputStream () throws Exception
 
void testMaliciousRecursion () throws Exception
 
void testParseMessagesCloseTo2G () throws IOException
 
void testParseMessagesOver2G () throws IOException
 
void testReadByteArray () throws Exception
 
void testReadByteBuffer () throws Exception
 
void testReadByteBufferAliasing () throws Exception
 
void testReadFromSlice () throws Exception
 
void testReadHugeBlob () throws Exception
 
void testReadLargeByteArrayFromInputStream () throws Exception
 
void testReadLargeByteStringFromInputStream () throws Exception
 
void testReadLittleEndian () throws Exception
 
void testReadMaliciouslyLargeBlob () throws Exception
 
void testReadString () throws Exception
 
void testReadStringInvalidUtf8 () throws Exception
 
void testReadStringRequireUtf8 () throws Exception
 
void testReadStringRequireUtf8InvalidUtf8 () throws Exception
 
void testReadVarint () throws Exception
 
void testReadWholeMessage () throws Exception
 
void testRefillBufferWithCorrectSize () throws Exception
 
void testResetSizeCounter () throws Exception
 
void testSizeLimit () throws Exception
 
void testSizeLimitMultipleMessages () throws Exception
 
void testSkipHugeBlob () throws Exception
 
void testSkipInvalidVarint_FastPath () throws Exception
 
void testSkipInvalidVarint_SlowPath () throws Exception
 
void testSkipMaliciouslyHugeBlob () throws Exception
 
void testSkipPastEndOfByteArrayInput () throws Exception
 
void testSkipRawBytesActuallySkips () throws Exception
 
void testSkipRawBytesBug () throws Exception
 
void testSkipRawBytesPastEndOfBufferWithLimit () throws Exception
 
void testSkipWholeMessage () throws Exception
 

Private Member Functions

void assertDataConsumed (String msg, byte[] data, CodedInputStream input) throws IOException
 
void assertMessageDepth (String msg, TestRecursiveMessage message, int depth)
 
void assertReadLittleEndian32 (byte[] data, int value) throws Exception
 
void assertReadLittleEndian64 (byte[] data, long value) throws Exception
 
void assertReadVarint (byte[] data, long value) throws Exception
 
void assertReadVarintFailure (InvalidProtocolBufferException expected, byte[] data) throws Exception
 
byte[] bytes (int... bytesAsInts)
 
void checkSizeLimitExceeded (InvalidProtocolBufferException e)
 
TestRecursiveMessage makeRecursiveMessage (int depth)
 

Static Private Member Functions

static byte[] getBigSerializedMessage ()
 

Static Private Attributes

static final int DEFAULT_BLOCK_SIZE = 4096
 

Detailed Description

Unit test for CodedInputStream.

Author
kento.nosp@m.n@go.nosp@m.ogle..nosp@m.com Kenton Varda

Definition at line 55 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

Member Function Documentation

◆ assertDataConsumed()

void com.google.protobuf.CodedInputStreamTest.assertDataConsumed ( String  msg,
byte[]  data,
CodedInputStream  input 
) throws IOException
inlineprivate

◆ assertMessageDepth()

void com.google.protobuf.CodedInputStreamTest.assertMessageDepth ( String  msg,
TestRecursiveMessage  message,
int  depth 
)
inlineprivate

◆ assertReadLittleEndian32()

void com.google.protobuf.CodedInputStreamTest.assertReadLittleEndian32 ( byte[]  data,
int  value 
) throws Exception
inlineprivate

Parses the given bytes using readRawLittleEndian32() and checks that the result matches the given value.

Definition at line 307 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ assertReadLittleEndian64()

void com.google.protobuf.CodedInputStreamTest.assertReadLittleEndian64 ( byte[]  data,
long  value 
) throws Exception
inlineprivate

Parses the given bytes using readRawLittleEndian64() and checks that the result matches the given value.

Definition at line 322 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ assertReadVarint()

void com.google.protobuf.CodedInputStreamTest.assertReadVarint ( byte[]  data,
long  value 
) throws Exception
inlineprivate

Parses the given bytes using readRawVarint32() and readRawVarint64() and checks that the result matches the given value.

Definition at line 190 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ assertReadVarintFailure()

void com.google.protobuf.CodedInputStreamTest.assertReadVarintFailure ( InvalidProtocolBufferException  expected,
byte[]  data 
) throws Exception
inlineprivate

Parses the given bytes using readRawVarint32() and readRawVarint64() and expects them to fail with an InvalidProtocolBufferException whose description matches the given one.

Definition at line 226 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ bytes()

byte [] com.google.protobuf.CodedInputStreamTest.bytes ( int...  bytesAsInts)
inlineprivate

Helper to construct a byte array from a bunch of bytes. The inputs are actually ints so that I can use hex notation and not get stupid errors about precision.

Definition at line 133 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ checkSizeLimitExceeded()

void com.google.protobuf.CodedInputStreamTest.checkSizeLimitExceeded ( InvalidProtocolBufferException  e)
inlineprivate

◆ getBigSerializedMessage()

static byte [] com.google.protobuf.CodedInputStreamTest.getBigSerializedMessage ( )
inlinestaticprivate

◆ makeRecursiveMessage()

TestRecursiveMessage com.google.protobuf.CodedInputStreamTest.makeRecursiveMessage ( int  depth)
inlineprivate

◆ testCompatibleTypes()

void com.google.protobuf.CodedInputStreamTest.testCompatibleTypes ( ) throws Exception
inline

◆ testCurrentLimitExceeded()

void com.google.protobuf.CodedInputStreamTest.testCurrentLimitExceeded ( ) throws Exception
inline

◆ testDecodeZigZag()

void com.google.protobuf.CodedInputStreamTest.testDecodeZigZag ( ) throws Exception
inline

Test decodeZigZag32() and decodeZigZag64().

Definition at line 345 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testInvalidTag()

void com.google.protobuf.CodedInputStreamTest.testInvalidTag ( ) throws Exception
inline

◆ testIsAtEnd()

void com.google.protobuf.CodedInputStreamTest.testIsAtEnd ( ) throws Exception
inline

◆ testMaliciousInputStream()

void com.google.protobuf.CodedInputStreamTest.testMaliciousInputStream ( ) throws Exception
inline

◆ testMaliciousRecursion()

void com.google.protobuf.CodedInputStreamTest.testMaliciousRecursion ( ) throws Exception
inline

◆ testParseMessagesCloseTo2G()

void com.google.protobuf.CodedInputStreamTest.testParseMessagesCloseTo2G ( ) throws IOException
inline

Test we can do messages that are up to CodedInputStream::DEFAULT_SIZE_LIMIT in size (2G or Integer::MAX_SIZE).

Exceptions
IOException

Definition at line 544 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testParseMessagesOver2G()

void com.google.protobuf.CodedInputStreamTest.testParseMessagesOver2G ( ) throws IOException
inline

Test there is an exception if a message exceeds CodedInputStream::DEFAULT_SIZE_LIMIT in size (2G or Integer::MAX_SIZE).

Exceptions
IOException

Definition at line 561 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testReadByteArray()

void com.google.protobuf.CodedInputStreamTest.testReadByteArray ( ) throws Exception
inline

◆ testReadByteBuffer()

void com.google.protobuf.CodedInputStreamTest.testReadByteBuffer ( ) throws Exception
inline

◆ testReadByteBufferAliasing()

void com.google.protobuf.CodedInputStreamTest.testReadByteBufferAliasing ( ) throws Exception
inline

◆ testReadFromSlice()

void com.google.protobuf.CodedInputStreamTest.testReadFromSlice ( ) throws Exception
inline

◆ testReadHugeBlob()

void com.google.protobuf.CodedInputStreamTest.testReadHugeBlob ( ) throws Exception
inline

◆ testReadLargeByteArrayFromInputStream()

void com.google.protobuf.CodedInputStreamTest.testReadLargeByteArrayFromInputStream ( ) throws Exception
inline

◆ testReadLargeByteStringFromInputStream()

void com.google.protobuf.CodedInputStreamTest.testReadLargeByteStringFromInputStream ( ) throws Exception
inline

◆ testReadLittleEndian()

void com.google.protobuf.CodedInputStreamTest.testReadLittleEndian ( ) throws Exception
inline

Tests readRawLittleEndian32() and readRawLittleEndian64().

Definition at line 334 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testReadMaliciouslyLargeBlob()

void com.google.protobuf.CodedInputStreamTest.testReadMaliciouslyLargeBlob ( ) throws Exception
inline

◆ testReadString()

void com.google.protobuf.CodedInputStreamTest.testReadString ( ) throws Exception
inline

◆ testReadStringInvalidUtf8()

void com.google.protobuf.CodedInputStreamTest.testReadStringInvalidUtf8 ( ) throws Exception
inline

Tests that if we readString invalid UTF-8 bytes, no exception is thrown. Instead, the invalid bytes are replaced with the Unicode "replacement character" U+FFFD.

Definition at line 861 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testReadStringRequireUtf8()

void com.google.protobuf.CodedInputStreamTest.testReadStringRequireUtf8 ( ) throws Exception
inline

◆ testReadStringRequireUtf8InvalidUtf8()

void com.google.protobuf.CodedInputStreamTest.testReadStringRequireUtf8InvalidUtf8 ( ) throws Exception
inline

Tests that if we readStringRequireUtf8 invalid UTF-8 bytes, an InvalidProtocolBufferException is thrown.

Definition at line 884 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testReadVarint()

void com.google.protobuf.CodedInputStreamTest.testReadVarint ( ) throws Exception
inline

Tests readRawVarint32() and readRawVarint64().

Definition at line 255 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testReadWholeMessage()

void com.google.protobuf.CodedInputStreamTest.testReadWholeMessage ( ) throws Exception
inline

Tests reading and parsing a whole message with every field type.

Definition at line 368 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testRefillBufferWithCorrectSize()

void com.google.protobuf.CodedInputStreamTest.testRefillBufferWithCorrectSize ( ) throws Exception
inline

◆ testResetSizeCounter()

void com.google.protobuf.CodedInputStreamTest.testResetSizeCounter ( ) throws Exception
inline

◆ testSizeLimit()

void com.google.protobuf.CodedInputStreamTest.testSizeLimit ( ) throws Exception
inline

◆ testSizeLimitMultipleMessages()

void com.google.protobuf.CodedInputStreamTest.testSizeLimitMultipleMessages ( ) throws Exception
inline

◆ testSkipHugeBlob()

void com.google.protobuf.CodedInputStreamTest.testSkipHugeBlob ( ) throws Exception
inline

◆ testSkipInvalidVarint_FastPath()

void com.google.protobuf.CodedInputStreamTest.testSkipInvalidVarint_FastPath ( ) throws Exception
inline

◆ testSkipInvalidVarint_SlowPath()

void com.google.protobuf.CodedInputStreamTest.testSkipInvalidVarint_SlowPath ( ) throws Exception
inline

◆ testSkipMaliciouslyHugeBlob()

void com.google.protobuf.CodedInputStreamTest.testSkipMaliciouslyHugeBlob ( ) throws Exception
inline

Skipping a huge blob should not allocate excessive memory, so there should be no limit

Definition at line 479 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testSkipPastEndOfByteArrayInput()

void com.google.protobuf.CodedInputStreamTest.testSkipPastEndOfByteArrayInput ( ) throws Exception
inline

◆ testSkipRawBytesActuallySkips()

void com.google.protobuf.CodedInputStreamTest.testSkipRawBytesActuallySkips ( ) throws Exception
inline

Test that calling skipRawBytes (when not merging a message) actually skips from the underlying inputstream, regardless of the buffer size used.

Definition at line 453 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testSkipRawBytesBug()

void com.google.protobuf.CodedInputStreamTest.testSkipRawBytesBug ( ) throws Exception
inline

Test that a bug in skipRawBytes() has been fixed: if the skip skips exactly up to a limit, this should not break things.

Definition at line 418 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testSkipRawBytesPastEndOfBufferWithLimit()

void com.google.protobuf.CodedInputStreamTest.testSkipRawBytesPastEndOfBufferWithLimit ( ) throws Exception
inline

Test that a bug in skipRawBytes() has been fixed: if the skip skips past the end of a buffer with a limit that has been set past the end of that buffer, this should not break things.

Definition at line 433 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

◆ testSkipWholeMessage()

void com.google.protobuf.CodedInputStreamTest.testSkipWholeMessage ( ) throws Exception
inline

Tests skipField().

Definition at line 384 of file core/src/test/java/com/google/protobuf/CodedInputStreamTest.java.

Member Data Documentation

◆ DEFAULT_BLOCK_SIZE

final int com.google.protobuf.CodedInputStreamTest.DEFAULT_BLOCK_SIZE = 4096
staticprivate

The documentation for this class was generated from the following file:


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:06