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

Public Member Functions

void testEscape () throws Exception
 
void testMapOverwrite () throws Exception
 
void testMapShortForm () throws Exception
 
void testMapShortFormEmpty () throws Exception
 
void testMapShortFormTrailingComma () throws Exception
 
void testMapTextFormat () throws Exception
 
void testMerge () throws Exception
 
void testMergeAndParseCompatibility () throws Exception
 
void testMergeAndParseExotic () throws Exception
 
void testMergeAngleBrackets () throws Exception
 
void testMergeComment () throws Exception
 
void testMergeExtensions () throws Exception
 
void testMergeInitialized () throws Exception
 
void testMergeMessageSet () throws Exception
 
void testMergeMessageSetWithOverwriteForbidden () throws Exception
 
void testMergeNumericEnum () throws Exception
 
void testMergeReader () throws Exception
 
void testMergeUninitialized () throws Exception
 
void testOneofOverwriteAllowed () throws Exception
 
void testOneofOverwriteForbidden () throws Exception
 
void testOneofTextFormat () throws Exception
 
void testParse () throws Exception
 
void testParseAdjacentStringLiterals () throws Exception
 
void testParseBoolean () throws Exception
 
void testParseErrors () throws Exception
 
void testParseExtensions () throws Exception
 
void testParseInfoTreeBuilding () throws Exception
 
void testParseInitialized () throws Exception
 
void testParseInteger () throws Exception
 
void testParseLongString () throws Exception
 
void testParseNonRepeatedFields () throws Exception
 
void testParseShortRepeatedFormOfEmptyRepeatedFields () throws Exception
 
void testParseShortRepeatedFormOfNonRepeatedFields () throws Exception
 
void testParseShortRepeatedFormOfRepeatedFields () throws Exception
 
void testParseShortRepeatedFormWithTrailingComma () throws Exception
 
void testParseString () throws Exception
 
void testParseUninitialized () throws Exception
 
void testParseUnknownExtensions () throws Exception
 
void testPrintExotic () throws Exception
 
void testPrintExtensions () throws Exception
 
void testPrintField () throws Exception
 
void testPrintFieldValue () throws Exception
 
void testPrintMessage () throws Exception
 
void testPrintMessageBuilder () throws Exception
 
void testPrintMessageSet () throws Exception
 
void testPrintToUnicodeString () throws Exception
 
void testPrintToUnicodeString_unknown ()
 
void testPrintToUnicodeStringWithNewlines () throws Exception
 
void testPrintUnknownFields () throws Exception
 
void testShortDebugString ()
 
void testShortDebugString_field ()
 
void testShortDebugString_unknown ()
 

Private Member Functions

void assertLocation (TextFormatParseInfoTree tree, final Descriptor descriptor, final String fieldName, int index, int line, int column)
 
void assertParseError (String error, String text)
 
void assertParseErrorWithOverwriteForbidden (String error, String text)
 
void assertParseErrorWithUnknownExtensions (String error, String text)
 
void assertParseErrorWithUnknownFields (String error, String text)
 
TestAllTypes assertParseSuccessWithOverwriteForbidden (String text) throws TextFormat.ParseException
 
TestAllTypes assertParseSuccessWithUnknownExtensions (String text) throws TextFormat.ParseException
 
TestAllTypes assertParseSuccessWithUnknownFields (String text) throws TextFormat.ParseException
 
void assertPrintFieldValue (String expect, Object value, String fieldName) throws Exception
 
ByteString bytes (int... bytesAsInts)
 
ByteString bytes (String str)
 
UnknownFieldSet makeUnknownFieldSet ()
 

Private Attributes

final TextFormat.Parser defaultParser = TextFormat.Parser.newBuilder().build()
 
String messageSetText
 
String messageSetTextWithRepeatedExtension
 
final TextFormat.Parser parserAllowingUnknownExtensions
 
final TextFormat.Parser parserAllowingUnknownFields
 
final TextFormat.Parser parserWithOverwriteForbidden
 

Static Private Attributes

static String allExtensionsSetText
 
static String allFieldsSetText
 
static String canonicalExoticText
 
static final String ESCAPE_TEST_STRING
 
static final String ESCAPE_TEST_STRING_ESCAPED
 
static String exoticText
 

Detailed Description

Test case for TextFormat.

TODO(wenboz): ExtensionTest and rest of text_format_unittest.cc.

Author
wenbo.nosp@m.z@go.nosp@m.ogle..nosp@m.com (Wenbo Zhu)

Definition at line 62 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

Member Function Documentation

◆ assertLocation()

void com.google.protobuf.TextFormatTest.assertLocation ( TextFormatParseInfoTree  tree,
final Descriptor  descriptor,
final String  fieldName,
int  index,
int  line,
int  column 
)
inlineprivate

◆ assertParseError()

void com.google.protobuf.TextFormatTest.assertParseError ( String  error,
String  text 
)
inlineprivate

◆ assertParseErrorWithOverwriteForbidden()

void com.google.protobuf.TextFormatTest.assertParseErrorWithOverwriteForbidden ( String  error,
String  text 
)
inlineprivate

◆ assertParseErrorWithUnknownExtensions()

void com.google.protobuf.TextFormatTest.assertParseErrorWithUnknownExtensions ( String  error,
String  text 
)
inlineprivate

◆ assertParseErrorWithUnknownFields()

void com.google.protobuf.TextFormatTest.assertParseErrorWithUnknownFields ( String  error,
String  text 
)
inlineprivate

◆ assertParseSuccessWithOverwriteForbidden()

TestAllTypes com.google.protobuf.TextFormatTest.assertParseSuccessWithOverwriteForbidden ( String  text) throws TextFormat.ParseException
inlineprivate

◆ assertParseSuccessWithUnknownExtensions()

TestAllTypes com.google.protobuf.TextFormatTest.assertParseSuccessWithUnknownExtensions ( String  text) throws TextFormat.ParseException
inlineprivate

◆ assertParseSuccessWithUnknownFields()

TestAllTypes com.google.protobuf.TextFormatTest.assertParseSuccessWithUnknownFields ( String  text) throws TextFormat.ParseException
inlineprivate

◆ assertPrintFieldValue()

void com.google.protobuf.TextFormatTest.assertPrintFieldValue ( String  expect,
Object  value,
String  fieldName 
) throws Exception
inlineprivate

◆ bytes() [1/2]

ByteString com.google.protobuf.TextFormatTest.bytes ( int...  bytesAsInts)
inlineprivate

Helper to construct a ByteString 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 269 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ bytes() [2/2]

ByteString com.google.protobuf.TextFormatTest.bytes ( String  str)
inlineprivate

Helper to construct a ByteString from a String containing only 8-bit characters. The characters are converted directly to bytes, not encoded using UTF-8.

Definition at line 261 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ makeUnknownFieldSet()

UnknownFieldSet com.google.protobuf.TextFormatTest.makeUnknownFieldSet ( )
inlineprivate

◆ testEscape()

void com.google.protobuf.TextFormatTest.testEscape ( ) throws Exception
inline

◆ testMapOverwrite()

void com.google.protobuf.TextFormatTest.testMapOverwrite ( ) throws Exception
inline

◆ testMapShortForm()

void com.google.protobuf.TextFormatTest.testMapShortForm ( ) throws Exception
inline

◆ testMapShortFormEmpty()

void com.google.protobuf.TextFormatTest.testMapShortFormEmpty ( ) throws Exception
inline

◆ testMapShortFormTrailingComma()

void com.google.protobuf.TextFormatTest.testMapShortFormTrailingComma ( ) throws Exception
inline

◆ testMapTextFormat()

void com.google.protobuf.TextFormatTest.testMapTextFormat ( ) throws Exception
inline

◆ testMerge()

void com.google.protobuf.TextFormatTest.testMerge ( ) throws Exception
inline

◆ testMergeAndParseCompatibility()

void com.google.protobuf.TextFormatTest.testMergeAndParseCompatibility ( ) throws Exception
inline

◆ testMergeAndParseExotic()

void com.google.protobuf.TextFormatTest.testMergeAndParseExotic ( ) throws Exception
inline

◆ testMergeAngleBrackets()

void com.google.protobuf.TextFormatTest.testMergeAngleBrackets ( ) throws Exception
inline

◆ testMergeComment()

void com.google.protobuf.TextFormatTest.testMergeComment ( ) throws Exception
inline

◆ testMergeExtensions()

void com.google.protobuf.TextFormatTest.testMergeExtensions ( ) throws Exception
inline

◆ testMergeInitialized()

void com.google.protobuf.TextFormatTest.testMergeInitialized ( ) throws Exception
inline

◆ testMergeMessageSet()

void com.google.protobuf.TextFormatTest.testMergeMessageSet ( ) throws Exception
inline

◆ testMergeMessageSetWithOverwriteForbidden()

void com.google.protobuf.TextFormatTest.testMergeMessageSetWithOverwriteForbidden ( ) throws Exception
inline

◆ testMergeNumericEnum()

void com.google.protobuf.TextFormatTest.testMergeNumericEnum ( ) throws Exception
inline

◆ testMergeReader()

void com.google.protobuf.TextFormatTest.testMergeReader ( ) throws Exception
inline

◆ testMergeUninitialized()

void com.google.protobuf.TextFormatTest.testMergeUninitialized ( ) throws Exception
inline

◆ testOneofOverwriteAllowed()

void com.google.protobuf.TextFormatTest.testOneofOverwriteAllowed ( ) throws Exception
inline

◆ testOneofOverwriteForbidden()

void com.google.protobuf.TextFormatTest.testOneofOverwriteForbidden ( ) throws Exception
inline

◆ testOneofTextFormat()

void com.google.protobuf.TextFormatTest.testOneofTextFormat ( ) throws Exception
inline

◆ testParse()

void com.google.protobuf.TextFormatTest.testParse ( ) throws Exception
inline

◆ testParseAdjacentStringLiterals()

void com.google.protobuf.TextFormatTest.testParseAdjacentStringLiterals ( ) throws Exception
inline

◆ testParseBoolean()

void com.google.protobuf.TextFormatTest.testParseBoolean ( ) throws Exception
inline

◆ testParseErrors()

void com.google.protobuf.TextFormatTest.testParseErrors ( ) throws Exception
inline

◆ testParseExtensions()

void com.google.protobuf.TextFormatTest.testParseExtensions ( ) throws Exception
inline

◆ testParseInfoTreeBuilding()

void com.google.protobuf.TextFormatTest.testParseInfoTreeBuilding ( ) throws Exception
inline

◆ testParseInitialized()

void com.google.protobuf.TextFormatTest.testParseInitialized ( ) throws Exception
inline

◆ testParseInteger()

void com.google.protobuf.TextFormatTest.testParseInteger ( ) throws Exception
inline

◆ testParseLongString()

void com.google.protobuf.TextFormatTest.testParseLongString ( ) throws Exception
inline

◆ testParseNonRepeatedFields()

void com.google.protobuf.TextFormatTest.testParseNonRepeatedFields ( ) throws Exception
inline

◆ testParseShortRepeatedFormOfEmptyRepeatedFields()

void com.google.protobuf.TextFormatTest.testParseShortRepeatedFormOfEmptyRepeatedFields ( ) throws Exception
inline

◆ testParseShortRepeatedFormOfNonRepeatedFields()

void com.google.protobuf.TextFormatTest.testParseShortRepeatedFormOfNonRepeatedFields ( ) throws Exception
inline

◆ testParseShortRepeatedFormOfRepeatedFields()

void com.google.protobuf.TextFormatTest.testParseShortRepeatedFormOfRepeatedFields ( ) throws Exception
inline

◆ testParseShortRepeatedFormWithTrailingComma()

void com.google.protobuf.TextFormatTest.testParseShortRepeatedFormWithTrailingComma ( ) throws Exception
inline

◆ testParseString()

void com.google.protobuf.TextFormatTest.testParseString ( ) throws Exception
inline

◆ testParseUninitialized()

void com.google.protobuf.TextFormatTest.testParseUninitialized ( ) throws Exception
inline

◆ testParseUnknownExtensions()

void com.google.protobuf.TextFormatTest.testParseUnknownExtensions ( ) throws Exception
inline

◆ testPrintExotic()

void com.google.protobuf.TextFormatTest.testPrintExotic ( ) throws Exception
inline

◆ testPrintExtensions()

void com.google.protobuf.TextFormatTest.testPrintExtensions ( ) throws Exception
inline

Print TestAllExtensions and compare with golden file.

Definition at line 173 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ testPrintField()

void com.google.protobuf.TextFormatTest.testPrintField ( ) throws Exception
inline

◆ testPrintFieldValue()

void com.google.protobuf.TextFormatTest.testPrintFieldValue ( ) throws Exception
inline

◆ testPrintMessage()

void com.google.protobuf.TextFormatTest.testPrintMessage ( ) throws Exception
inline

Print TestAllTypes and compare with golden file.

Definition at line 149 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ testPrintMessageBuilder()

void com.google.protobuf.TextFormatTest.testPrintMessageBuilder ( ) throws Exception
inline

Print TestAllTypes as Builder and compare with golden file.

Definition at line 161 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ testPrintMessageSet()

void com.google.protobuf.TextFormatTest.testPrintMessageSet ( ) throws Exception
inline

◆ testPrintToUnicodeString()

void com.google.protobuf.TextFormatTest.testPrintToUnicodeString ( ) throws Exception
inline

◆ testPrintToUnicodeString_unknown()

void com.google.protobuf.TextFormatTest.testPrintToUnicodeString_unknown ( )
inline

◆ testPrintToUnicodeStringWithNewlines()

void com.google.protobuf.TextFormatTest.testPrintToUnicodeStringWithNewlines ( ) throws Exception
inline

◆ testPrintUnknownFields()

void com.google.protobuf.TextFormatTest.testPrintUnknownFields ( ) throws Exception
inline

◆ testShortDebugString()

void com.google.protobuf.TextFormatTest.testShortDebugString ( )
inline

◆ testShortDebugString_field()

void com.google.protobuf.TextFormatTest.testShortDebugString_field ( )
inline

◆ testShortDebugString_unknown()

void com.google.protobuf.TextFormatTest.testShortDebugString_unknown ( )
inline

Member Data Documentation

◆ allExtensionsSetText

String com.google.protobuf.TextFormatTest.allExtensionsSetText
staticprivate
Initial value:
=
TestUtil.readTextFromFile("text_format_unittest_extensions_data.txt")

Definition at line 75 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ allFieldsSetText

String com.google.protobuf.TextFormatTest.allFieldsSetText
staticprivate
Initial value:
=
TestUtil.readTextFromFile("text_format_unittest_data_oneof_implemented.txt")

Definition at line 73 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ canonicalExoticText

String com.google.protobuf.TextFormatTest.canonicalExoticText
staticprivate
Initial value:
=
.replace(": .", ": 0.")
.replace(": -.", ": -0.")
.replace("23e", "23E")
.replace("E+", "E")
.replace("0.23E17", "2.3E16")
.replace(",", "")

Definition at line 108 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ defaultParser

final TextFormat.Parser com.google.protobuf.TextFormatTest.defaultParser = TextFormat.Parser.newBuilder().build()
private

◆ ESCAPE_TEST_STRING

final String com.google.protobuf.TextFormatTest.ESCAPE_TEST_STRING
staticprivate
Initial value:
=
"\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\"

Definition at line 65 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ ESCAPE_TEST_STRING_ESCAPED

final String com.google.protobuf.TextFormatTest.ESCAPE_TEST_STRING_ESCAPED
staticprivate
Initial value:
=
"\\\"A string with \\' characters \\n and \\r newlines "
+ "and \\t tabs and \\001 slashes \\\\"

Definition at line 69 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ exoticText

String com.google.protobuf.TextFormatTest.exoticText
staticprivate
Initial value:
=
""
+ "repeated_int32: -1\n"
+ "repeated_int32: -2147483648\n"
+ "repeated_int64: -1,\n"
+ "repeated_int64: -9223372036854775808\n"
+ "repeated_uint32: 4294967295\n"
+ "repeated_uint32: 2147483648\n"
+ "repeated_uint64: 18446744073709551615\n"
+ "repeated_uint64: 9223372036854775808\n"
+ "repeated_double: 123.0\n"
+ "repeated_double: 123.5\n"
+ "repeated_double: 0.125\n"
+ "repeated_double: .125\n"
+ "repeated_double: -.125\n"
+ "repeated_double: 1.23E17\n"
+ "repeated_double: 1.23E+17\n"
+ "repeated_double: -1.23e-17\n"
+ "repeated_double: .23e+17\n"
+ "repeated_double: -.23E17\n"
+ "repeated_double: 1.235E22\n"
+ "repeated_double: 1.235E-18\n"
+ "repeated_double: 123.456789\n"
+ "repeated_double: Infinity\n"
+ "repeated_double: -Infinity\n"
+ "repeated_double: NaN\n"
+ "repeated_string: \"\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\""
+ "\\341\\210\\264\"\n"
+ "repeated_bytes: \"\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\"\\376\"\n"

Definition at line 78 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ messageSetText

String com.google.protobuf.TextFormatTest.messageSetText
private
Initial value:
=
""
+ "[protobuf_unittest.TestMessageSetExtension1] {\n"
+ " i: 123\n"
+ "}\n"
+ "[protobuf_unittest.TestMessageSetExtension2] {\n"
+ " str: \"foo\"\n"
+ "}\n"

Definition at line 117 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ messageSetTextWithRepeatedExtension

String com.google.protobuf.TextFormatTest.messageSetTextWithRepeatedExtension
private
Initial value:
=
""
+ "[protobuf_unittest.TestMessageSetExtension1] {\n"
+ " i: 123\n"
+ "}\n"
+ "[protobuf_unittest.TestMessageSetExtension1] {\n"
+ " i: 456\n"
+ "}\n"

Definition at line 126 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ parserAllowingUnknownExtensions

final TextFormat.Parser com.google.protobuf.TextFormatTest.parserAllowingUnknownExtensions
private
Initial value:
=
TextFormat.Parser.newBuilder().setAllowUnknownExtensions(true).build()

Definition at line 138 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ parserAllowingUnknownFields

final TextFormat.Parser com.google.protobuf.TextFormatTest.parserAllowingUnknownFields
private
Initial value:
=
TextFormat.Parser.newBuilder().setAllowUnknownFields(true).build()

Definition at line 135 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.

◆ parserWithOverwriteForbidden

final TextFormat.Parser com.google.protobuf.TextFormatTest.parserWithOverwriteForbidden
private
Initial value:
=
TextFormat.Parser.newBuilder()
.setSingularOverwritePolicy(SingularOverwritePolicy.FORBID_SINGULAR_OVERWRITES)
.build()

Definition at line 141 of file core/src/test/java/com/google/protobuf/TextFormatTest.java.


The documentation for this class was generated from the following file:
com.google.protobuf.TextFormatTest.exoticText
static String exoticText
Definition: core/src/test/java/com/google/protobuf/TextFormatTest.java:78


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