Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: third_party/protobuf/java/core/src/test/java/com/google/protobuf/TextFormatTest.java

Issue 2599263002: third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Address comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/java/core/src/test/java/com/google/protobuf/TextFormatTest.java
diff --git a/third_party/protobuf/java/core/src/test/java/com/google/protobuf/TextFormatTest.java b/third_party/protobuf/java/core/src/test/java/com/google/protobuf/TextFormatTest.java
index 63c17cd0fd19489d2c3d0edf025b0d4b8841b982..6a91b02f039f145a4f5fba795ccada1216cea632 100644
--- a/third_party/protobuf/java/core/src/test/java/com/google/protobuf/TextFormatTest.java
+++ b/third_party/protobuf/java/core/src/test/java/com/google/protobuf/TextFormatTest.java
@@ -42,11 +42,9 @@ import protobuf_unittest.UnittestProto.TestAllTypes.NestedMessage;
import protobuf_unittest.UnittestProto.TestEmptyMessage;
import protobuf_unittest.UnittestProto.TestOneof2;
import proto2_wireformat_unittest.UnittestMsetWireFormat.TestMessageSet;
-
-import junit.framework.TestCase;
-
import java.io.StringReader;
import java.util.List;
+import junit.framework.TestCase;
/**
* Test case for {@link TextFormat}.
@@ -522,15 +520,16 @@ public class TextFormatTest extends TestCase {
"optional_string: \"ueoauaoe\n" +
"optional_int32: 123");
assertParseError(
- "1:2: Extension \"nosuchext\" not found in the ExtensionRegistry.",
+ "1:2: Input contains unknown fields and/or extensions:\n" +
+ "1:2:\tprotobuf_unittest.TestAllTypes.[nosuchext]",
"[nosuchext]: 123");
assertParseError(
"1:20: Extension \"protobuf_unittest.optional_int32_extension\" does " +
"not extend message type \"protobuf_unittest.TestAllTypes\".",
"[protobuf_unittest.optional_int32_extension]: 123");
assertParseError(
- "1:1: Message type \"protobuf_unittest.TestAllTypes\" has no field " +
- "named \"nosuchfield\".",
+ "1:1: Input contains unknown fields and/or extensions:\n" +
+ "1:1:\tprotobuf_unittest.TestAllTypes.nosuchfield",
"nosuchfield: 123");
assertParseError(
"1:21: Expected \">\".",
@@ -991,10 +990,35 @@ public class TextFormatTest extends TestCase {
assertParseSuccessWithOverwriteForbidden("repeated_nested_message [{ bb: 1 }, { bb: 2 }]\n");
}
+ public void testParseShortRepeatedFormOfEmptyRepeatedFields() throws Exception {
+ assertParseSuccessWithOverwriteForbidden("repeated_foreign_enum: []");
+ assertParseSuccessWithOverwriteForbidden("repeated_int32: []\n");
+ assertParseSuccessWithOverwriteForbidden("RepeatedGroup []\n");
+ assertParseSuccessWithOverwriteForbidden("repeated_nested_message []\n");
+ }
+
+ public void testParseShortRepeatedFormWithTrailingComma() throws Exception {
+ assertParseErrorWithOverwriteForbidden(
+ "1:38: Expected identifier. Found \']\'",
+ "repeated_foreign_enum: [FOREIGN_FOO, ]\n");
+ assertParseErrorWithOverwriteForbidden(
+ "1:22: Couldn't parse integer: For input string: \"]\"",
+ "repeated_int32: [ 1, ]\n");
+ assertParseErrorWithOverwriteForbidden(
+ "1:25: Expected \"{\".",
+ "RepeatedGroup [{ a: 1 },]\n");
+ assertParseErrorWithOverwriteForbidden(
+ "1:37: Expected \"{\".",
+ "repeated_nested_message [{ bb: 1 }, ]\n");
+ }
+
public void testParseShortRepeatedFormOfNonRepeatedFields() throws Exception {
assertParseErrorWithOverwriteForbidden(
"1:17: Couldn't parse integer: For input string: \"[\"",
"optional_int32: [1]\n");
+ assertParseErrorWithOverwriteForbidden(
+ "1:17: Couldn't parse integer: For input string: \"[\"",
+ "optional_int32: []\n");
}
// =======================================================================

Powered by Google App Engine
This is Rietveld 408576698