Classes | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
com.google.protobuf.TestUtil Class Reference

Classes

class  MockBuilderParent
 
class  ReflectionTester
 
class  TestLogHandler
 

Static Public Member Functions

static void assertAllExtensionsSet (TestAllExtensionsLiteOrBuilder message)
 
static void assertAllExtensionsSet (TestAllExtensionsOrBuilder message)
 
static void assertAllFieldsSet (TestAllTypesOrBuilder message)
 
static void assertAtMostOneFieldSetOneof (TestOneof2 message)
 
static void assertClear (TestAllTypesOrBuilder message)
 
static void assertExtensionsClear (TestAllExtensionsLiteOrBuilder message)
 
static void assertExtensionsClear (TestAllExtensionsOrBuilder message)
 
static void assertOneofSet (TestOneof2 message)
 
static void assertPackedExtensionsSet (TestPackedExtensions message)
 
static void assertPackedExtensionsSet (TestPackedExtensionsLite message)
 
static void assertPackedFieldsSet (TestPackedTypes message)
 
static void assertRepeatedExtensionsModified (TestAllExtensionsLiteOrBuilder message)
 
static void assertRepeatedExtensionsModified (TestAllExtensionsOrBuilder message)
 
static void assertRepeatedFieldsModified (TestAllTypesOrBuilder message)
 
static void assertUnpackedFieldsSet (TestUnpackedTypes message)
 
static TestAllExtensions getAllExtensionsSet ()
 
static TestAllTypes getAllSet ()
 
static TestAllTypes.Builder getAllSetBuilder ()
 
static ExtensionRegistryLite getExtensionRegistry ()
 
static ExtensionRegistry getFullExtensionRegistry ()
 
static ByteString getGoldenMessage ()
 
static ByteString getGoldenPackedFieldsMessage ()
 
static TestPackedExtensions getPackedExtensionsSet ()
 
static TestPackedTypes getPackedSet ()
 
static TestUnpackedTypes getUnpackedSet ()
 
static void modifyRepeatedExtensions (TestAllExtensions.Builder message)
 
static void modifyRepeatedFields (TestAllTypes.Builder message)
 
static ByteString readBytesFromFile (String filename)
 
static String readTextFromFile (String filePath)
 
static void registerAllExtensions (ExtensionRegistryLite registry)
 
static void resetMemoizedSize (AbstractMessage message)
 
static void setAllExtensions (TestAllExtensions.Builder message)
 
static void setAllFields (TestAllTypes.Builder message)
 
static void setOneof (TestOneof2.Builder message)
 
static void setPackedExtensions (TestPackedExtensions.Builder message)
 
static void setPackedFields (TestPackedTypes.Builder message)
 
static void setUnpackedFields (TestUnpackedTypes.Builder message)
 

Static Public Attributes

static final TestRequired TEST_REQUIRED_INITIALIZED
 
static final TestRequired TEST_REQUIRED_UNINITIALIZED
 

Private Member Functions

 TestUtil ()
 

Static Private Member Functions

static void assertEqualsExactType (boolean a, boolean b)
 
static void assertEqualsExactType (ByteString a, ByteString b)
 
static void assertEqualsExactType (double a, double b)
 
static void assertEqualsExactType (float a, float b)
 
static void assertEqualsExactType (ForeignEnum a, ForeignEnum b)
 
static void assertEqualsExactType (ForeignEnumLite a, ForeignEnumLite b)
 
static void assertEqualsExactType (ImportEnum a, ImportEnum b)
 
static void assertEqualsExactType (ImportEnumLite a, ImportEnumLite b)
 
static void assertEqualsExactType (int a, int b)
 
static void assertEqualsExactType (long a, long b)
 
static void assertEqualsExactType (String a, String b)
 
static void assertEqualsExactType (TestAllTypes.NestedEnum a, TestAllTypes.NestedEnum b)
 
static void assertEqualsExactType (TestAllTypesLite.NestedEnum a, TestAllTypesLite.NestedEnum b)
 
static File getTestDataDir ()
 
static ByteString readBytesFromResource (String name)
 

Static Private Attributes

static ByteString goldenMessage = null
 
static ByteString goldenPackedFieldsMessage = null
 

Detailed Description

Contains methods for setting all fields of

TestAllTypes

to some values as well as checking that all the fields are set to those values. These are useful for testing various protocol message features, e.g. set all fields of a message, serialize it, parse it, and check that all fields are set.

This code is not to be used outside of

and subpackages.

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

Definition at line 254 of file core/src/test/java/com/google/protobuf/TestUtil.java.

Constructor & Destructor Documentation

◆ TestUtil()

com.google.protobuf.TestUtil.TestUtil ( )
inlineprivate

Member Function Documentation

◆ assertAllExtensionsSet() [1/2]

static void com.google.protobuf.TestUtil.assertAllExtensionsSet ( TestAllExtensionsLiteOrBuilder  message)
inlinestatic

Assert (using

junit.framework.Assert

} that all extensions of

are set to the values assigned by

.

Definition at line 1997 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ assertAllExtensionsSet() [2/2]

static void com.google.protobuf.TestUtil.assertAllExtensionsSet ( TestAllExtensionsOrBuilder  message)
inlinestatic

Assert (using

junit.framework.Assert

} that all extensions of

are set to the values assigned by

.

Definition at line 1406 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ assertAllFieldsSet()

static void com.google.protobuf.TestUtil.assertAllFieldsSet ( TestAllTypesOrBuilder  message)
inlinestatic

Assert (using

junit.framework.Assert

} that all fields of

are set to the values assigned by

.

Definition at line 489 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ assertAtMostOneFieldSetOneof()

static void com.google.protobuf.TestUtil.assertAtMostOneFieldSetOneof ( TestOneof2  message)
inlinestatic

◆ assertClear()

static void com.google.protobuf.TestUtil.assertClear ( TestAllTypesOrBuilder  message)
inlinestatic

Assert (using

junit.framework.Assert

} that all fields of

are cleared, and that getting the fields returns their default values.

Definition at line 703 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ assertEqualsExactType() [1/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( boolean  a,
boolean  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [2/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( ByteString  a,
ByteString  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [3/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( double  a,
double  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [4/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( float  a,
float  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [5/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( ForeignEnum  a,
ForeignEnum  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [6/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( ForeignEnumLite  a,
ForeignEnumLite  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [7/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( ImportEnum  a,
ImportEnum  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [8/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( ImportEnumLite  a,
ImportEnumLite  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [9/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( int  a,
int  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [10/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( long  a,
long  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [11/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( String  a,
String  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [12/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( TestAllTypes.NestedEnum  a,
TestAllTypes.NestedEnum  b 
)
inlinestaticprivate

◆ assertEqualsExactType() [13/13]

static void com.google.protobuf.TestUtil.assertEqualsExactType ( TestAllTypesLite.NestedEnum  a,
TestAllTypesLite.NestedEnum  b 
)
inlinestaticprivate

◆ assertExtensionsClear() [1/2]

static void com.google.protobuf.TestUtil.assertExtensionsClear ( TestAllExtensionsLiteOrBuilder  message)
inlinestatic

Assert (using

junit.framework.Assert

} that all extensions of

are cleared, and that getting the extensions returns their default values.

Definition at line 2223 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ assertExtensionsClear() [2/2]

static void com.google.protobuf.TestUtil.assertExtensionsClear ( TestAllExtensionsOrBuilder  message)
inlinestatic

Assert (using

junit.framework.Assert

} that all extensions of

are cleared, and that getting the extensions returns their default values.

Definition at line 1627 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ assertOneofSet()

static void com.google.protobuf.TestUtil.assertOneofSet ( TestOneof2  message)
inlinestatic

◆ assertPackedExtensionsSet() [1/2]

static void com.google.protobuf.TestUtil.assertPackedExtensionsSet ( TestPackedExtensions  message)
inlinestatic

◆ assertPackedExtensionsSet() [2/2]

static void com.google.protobuf.TestUtil.assertPackedExtensionsSet ( TestPackedExtensionsLite  message)
inlinestatic

◆ assertPackedFieldsSet()

static void com.google.protobuf.TestUtil.assertPackedFieldsSet ( TestPackedTypes  message)
inlinestatic

Assert (using

junit.framework.Assert

} that all fields of

are set to the values assigned by

.

Definition at line 1027 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ assertRepeatedExtensionsModified() [1/2]

static void com.google.protobuf.TestUtil.assertRepeatedExtensionsModified ( TestAllExtensionsLiteOrBuilder  message)
inlinestatic

Assert (using

junit.framework.Assert

} that all extensions of

are set to the values assigned by

followed by

.

Definition at line 2390 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ assertRepeatedExtensionsModified() [2/2]

static void com.google.protobuf.TestUtil.assertRepeatedExtensionsModified ( TestAllExtensionsOrBuilder  message)
inlinestatic

Assert (using

junit.framework.Assert

} that all extensions of

are set to the values assigned by

followed by

.

Definition at line 1815 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ assertRepeatedFieldsModified()

static void com.google.protobuf.TestUtil.assertRepeatedFieldsModified ( TestAllTypesOrBuilder  message)
inlinestatic

Assert (using

junit.framework.Assert

} that all fields of

are set to the values assigned by

followed by

.

Definition at line 862 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ assertUnpackedFieldsSet()

static void com.google.protobuf.TestUtil.assertUnpackedFieldsSet ( TestUnpackedTypes  message)
inlinestatic

Assert (using

junit.framework.Assert

} that all fields of

are set to the values assigned by

.

Definition at line 1076 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ getAllExtensionsSet()

static TestAllExtensions com.google.protobuf.TestUtil.getAllExtensionsSet ( )
inlinestatic

Get a

TestAllExtensions

with all fields set as they would be by {}.

Definition at line 298 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ getAllSet()

static TestAllTypes com.google.protobuf.TestUtil.getAllSet ( )
inlinestatic

Get a

TestAllTypes

with all fields set as they would be by {}.

Definition at line 278 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ getAllSetBuilder()

static TestAllTypes.Builder com.google.protobuf.TestUtil.getAllSetBuilder ( )
inlinestatic

Get a

TestAllTypes.Builder

with all fields set as they would be by {}.

Definition at line 288 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ getExtensionRegistry()

static ExtensionRegistryLite com.google.protobuf.TestUtil.getExtensionRegistry ( )
inlinestatic

Get an unmodifiable ExtensionRegistry containing all the extensions of

TestAllExtensions

.

Definition at line 1184 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ getFullExtensionRegistry()

static ExtensionRegistry com.google.protobuf.TestUtil.getFullExtensionRegistry ( )
inlinestatic

Get an unmodifiable ExtensionRegistry containing all the extensions of

TestAllExtensions

.

Definition at line 1195 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ getGoldenMessage()

static ByteString com.google.protobuf.TestUtil.getGoldenMessage ( )
inlinestatic

Get the bytes of the "golden message". This is a serialized TestAllTypes with all fields set as they would be by setAllFields(TestAllTypes.Builder), but it is loaded from a file on disk rather than generated dynamically. The file is actually generated by C++ code, so testing against it verifies compatibility with C++.

Definition at line 3818 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ getGoldenPackedFieldsMessage()

static ByteString com.google.protobuf.TestUtil.getGoldenPackedFieldsMessage ( )
inlinestatic

Get the bytes of the "golden packed fields message". This is a serialized TestPackedTypes with all fields set as they would be by setPackedFields(TestPackedTypes.Builder), but it is loaded from a file on disk rather than generated dynamically. The file is actually generated by C++ code, so testing against it verifies compatibility with C++.

Definition at line 3834 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ getPackedExtensionsSet()

static TestPackedExtensions com.google.protobuf.TestUtil.getPackedExtensionsSet ( )
inlinestatic

◆ getPackedSet()

static TestPackedTypes com.google.protobuf.TestUtil.getPackedSet ( )
inlinestatic

◆ getTestDataDir()

static File com.google.protobuf.TestUtil.getTestDataDir ( )
inlinestaticprivate

◆ getUnpackedSet()

static TestUnpackedTypes com.google.protobuf.TestUtil.getUnpackedSet ( )
inlinestatic

◆ modifyRepeatedExtensions()

static void com.google.protobuf.TestUtil.modifyRepeatedExtensions ( TestAllExtensions.Builder  message)
inlinestatic

Modify the repeated extensions of

to contain the values expected by

.

Definition at line 1360 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ modifyRepeatedFields()

static void com.google.protobuf.TestUtil.modifyRepeatedFields ( TestAllTypes.Builder  message)
inlinestatic

Modify the repeated fields of

to contain the values expected by

.

Definition at line 452 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ readBytesFromFile()

static ByteString com.google.protobuf.TestUtil.readBytesFromFile ( String  filename)
inlinestatic
Parameters
filenameThe path relative to getTestDataDir.

Definition at line 3788 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ readBytesFromResource()

static ByteString com.google.protobuf.TestUtil.readBytesFromResource ( String  name)
inlinestaticprivate

◆ readTextFromFile()

static String com.google.protobuf.TestUtil.readTextFromFile ( String  filePath)
inlinestatic
Parameters
filePathThe path relative to getTestDataDir.

Definition at line 3760 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ registerAllExtensions()

static void com.google.protobuf.TestUtil.registerAllExtensions ( ExtensionRegistryLite  registry)
inlinestatic

Register all of

TestAllExtensions

's extensions with the given {}.

Definition at line 1206 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ resetMemoizedSize()

static void com.google.protobuf.TestUtil.resetMemoizedSize ( AbstractMessage  message)
inlinestatic

Dirties the message by resetting the momoized serialized size.

Definition at line 269 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ setAllExtensions()

static void com.google.protobuf.TestUtil.setAllExtensions ( TestAllExtensions.Builder  message)
inlinestatic

Set every field of

to the values expected by

.

Definition at line 1214 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ setAllFields()

static void com.google.protobuf.TestUtil.setAllFields ( TestAllTypes.Builder  message)
inlinestatic

Set every field of

to the values expected by

.

Definition at line 323 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ setOneof()

static void com.google.protobuf.TestUtil.setOneof ( TestOneof2.Builder  message)
inlinestatic

◆ setPackedExtensions()

static void com.google.protobuf.TestUtil.setPackedExtensions ( TestPackedExtensions.Builder  message)
inlinestatic

◆ setPackedFields()

static void com.google.protobuf.TestUtil.setPackedFields ( TestPackedTypes.Builder  message)
inlinestatic

Set every field of

to a unique value.

Definition at line 955 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ setUnpackedFields()

static void com.google.protobuf.TestUtil.setUnpackedFields ( TestUnpackedTypes.Builder  message)
inlinestatic

Set every field of

to a unique value. Must correspond with the values applied by

.

Definition at line 991 of file core/src/test/java/com/google/protobuf/TestUtil.java.

Member Data Documentation

◆ goldenMessage

ByteString com.google.protobuf.TestUtil.goldenMessage = null
staticprivate

◆ goldenPackedFieldsMessage

ByteString com.google.protobuf.TestUtil.goldenPackedFieldsMessage = null
staticprivate

◆ TEST_REQUIRED_INITIALIZED

final TestRequired com.google.protobuf.TestUtil.TEST_REQUIRED_INITIALIZED
static
Initial value:
=
TestRequired.newBuilder().setA(1).setB(2).setC(3).build()

Definition at line 259 of file core/src/test/java/com/google/protobuf/TestUtil.java.

◆ TEST_REQUIRED_UNINITIALIZED

final TestRequired com.google.protobuf.TestUtil.TEST_REQUIRED_UNINITIALIZED
static
Initial value:
=
TestRequired.newBuilder().setA(1).buildPartial()

Definition at line 257 of file core/src/test/java/com/google/protobuf/TestUtil.java.


The documentation for this class was generated from the following file:
com.google.protobuf
Definition: ProtoCaliperBenchmark.java:2
com.google.protobuf.TestUtil.assertRepeatedExtensionsModified
static void assertRepeatedExtensionsModified(TestAllExtensionsOrBuilder message)
Definition: core/src/test/java/com/google/protobuf/TestUtil.java:1815
com.google.protobuf.TestUtil.setAllExtensions
static void setAllExtensions(TestAllExtensions.Builder message)
Definition: core/src/test/java/com/google/protobuf/TestUtil.java:1214
com.google.protobuf.TestUtil.assertAllExtensionsSet
static void assertAllExtensionsSet(TestAllExtensionsOrBuilder message)
Definition: core/src/test/java/com/google/protobuf/TestUtil.java:1406
com.google.protobuf.TestUtil.setPackedFields
static void setPackedFields(TestPackedTypes.Builder message)
Definition: core/src/test/java/com/google/protobuf/TestUtil.java:955
com.google.protobuf.TestUtil.modifyRepeatedFields
static void modifyRepeatedFields(TestAllTypes.Builder message)
Definition: core/src/test/java/com/google/protobuf/TestUtil.java:452
com.google.protobuf.TestUtil.setUnpackedFields
static void setUnpackedFields(TestUnpackedTypes.Builder message)
Definition: core/src/test/java/com/google/protobuf/TestUtil.java:991
com.google
com
com.google.protobuf.TestUtil.assertRepeatedFieldsModified
static void assertRepeatedFieldsModified(TestAllTypesOrBuilder message)
Definition: core/src/test/java/com/google/protobuf/TestUtil.java:862
com.google.protobuf.TestUtil.setAllFields
static void setAllFields(TestAllTypes.Builder message)
Definition: core/src/test/java/com/google/protobuf/TestUtil.java:323
com.google.protobuf.TestUtil.modifyRepeatedExtensions
static void modifyRepeatedExtensions(TestAllExtensions.Builder message)
Definition: core/src/test/java/com/google/protobuf/TestUtil.java:1360
com.google.protobuf.TestUtil.assertAllFieldsSet
static void assertAllFieldsSet(TestAllTypesOrBuilder message)
Definition: core/src/test/java/com/google/protobuf/TestUtil.java:489
message
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glcorearb.h:2695


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