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

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

Issue 2600753002: Reverts third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Created 3 years, 12 months 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 unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 24 matching lines...) Expand all
35 import com.google.protobuf.TextFormat.Parser.SingularOverwritePolicy; 35 import com.google.protobuf.TextFormat.Parser.SingularOverwritePolicy;
36 import protobuf_unittest.UnittestMset.TestMessageSetExtension1; 36 import protobuf_unittest.UnittestMset.TestMessageSetExtension1;
37 import protobuf_unittest.UnittestMset.TestMessageSetExtension2; 37 import protobuf_unittest.UnittestMset.TestMessageSetExtension2;
38 import protobuf_unittest.UnittestProto.OneString; 38 import protobuf_unittest.UnittestProto.OneString;
39 import protobuf_unittest.UnittestProto.TestAllExtensions; 39 import protobuf_unittest.UnittestProto.TestAllExtensions;
40 import protobuf_unittest.UnittestProto.TestAllTypes; 40 import protobuf_unittest.UnittestProto.TestAllTypes;
41 import protobuf_unittest.UnittestProto.TestAllTypes.NestedMessage; 41 import protobuf_unittest.UnittestProto.TestAllTypes.NestedMessage;
42 import protobuf_unittest.UnittestProto.TestEmptyMessage; 42 import protobuf_unittest.UnittestProto.TestEmptyMessage;
43 import protobuf_unittest.UnittestProto.TestOneof2; 43 import protobuf_unittest.UnittestProto.TestOneof2;
44 import proto2_wireformat_unittest.UnittestMsetWireFormat.TestMessageSet; 44 import proto2_wireformat_unittest.UnittestMsetWireFormat.TestMessageSet;
45
46 import junit.framework.TestCase;
47
45 import java.io.StringReader; 48 import java.io.StringReader;
46 import java.util.List; 49 import java.util.List;
47 import junit.framework.TestCase;
48 50
49 /** 51 /**
50 * Test case for {@link TextFormat}. 52 * Test case for {@link TextFormat}.
51 * 53 *
52 * TODO(wenboz): ExtensionTest and rest of text_format_unittest.cc. 54 * TODO(wenboz): ExtensionTest and rest of text_format_unittest.cc.
53 * 55 *
54 * @author wenboz@google.com (Wenbo Zhu) 56 * @author wenboz@google.com (Wenbo Zhu)
55 */ 57 */
56 public class TextFormatTest extends TestCase { 58 public class TextFormatTest extends TestCase {
57 59
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 "optional_string: \"ueoauaoe\n" + 515 "optional_string: \"ueoauaoe\n" +
514 "optional_int32: 123"); 516 "optional_int32: 123");
515 assertParseError( 517 assertParseError(
516 "1:18: Invalid escape sequence: '\\z'", 518 "1:18: Invalid escape sequence: '\\z'",
517 "optional_string: \"\\z\""); 519 "optional_string: \"\\z\"");
518 assertParseError( 520 assertParseError(
519 "1:18: String missing ending quote.", 521 "1:18: String missing ending quote.",
520 "optional_string: \"ueoauaoe\n" + 522 "optional_string: \"ueoauaoe\n" +
521 "optional_int32: 123"); 523 "optional_int32: 123");
522 assertParseError( 524 assertParseError(
523 "1:2: Input contains unknown fields and/or extensions:\n" + 525 "1:2: Extension \"nosuchext\" not found in the ExtensionRegistry.",
524 "1:2:\tprotobuf_unittest.TestAllTypes.[nosuchext]",
525 "[nosuchext]: 123"); 526 "[nosuchext]: 123");
526 assertParseError( 527 assertParseError(
527 "1:20: Extension \"protobuf_unittest.optional_int32_extension\" does " + 528 "1:20: Extension \"protobuf_unittest.optional_int32_extension\" does " +
528 "not extend message type \"protobuf_unittest.TestAllTypes\".", 529 "not extend message type \"protobuf_unittest.TestAllTypes\".",
529 "[protobuf_unittest.optional_int32_extension]: 123"); 530 "[protobuf_unittest.optional_int32_extension]: 123");
530 assertParseError( 531 assertParseError(
531 "1:1: Input contains unknown fields and/or extensions:\n" + 532 "1:1: Message type \"protobuf_unittest.TestAllTypes\" has no field " +
532 "1:1:\tprotobuf_unittest.TestAllTypes.nosuchfield", 533 "named \"nosuchfield\".",
533 "nosuchfield: 123"); 534 "nosuchfield: 123");
534 assertParseError( 535 assertParseError(
535 "1:21: Expected \">\".", 536 "1:21: Expected \">\".",
536 "OptionalGroup < a: 1"); 537 "OptionalGroup < a: 1");
537 assertParseError( 538 assertParseError(
538 "1:23: Enum type \"protobuf_unittest.TestAllTypes.NestedEnum\" has no " + 539 "1:23: Enum type \"protobuf_unittest.TestAllTypes.NestedEnum\" has no " +
539 "value named \"NO_SUCH_VALUE\".", 540 "value named \"NO_SUCH_VALUE\".",
540 "optional_nested_enum: NO_SUCH_VALUE"); 541 "optional_nested_enum: NO_SUCH_VALUE");
541 assertParseError( 542 assertParseError(
542 "1:23: Enum type \"protobuf_unittest.TestAllTypes.NestedEnum\" has no " + 543 "1:23: Enum type \"protobuf_unittest.TestAllTypes.NestedEnum\" has no " +
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 "default_string: \"asdf\"\n"); 984 "default_string: \"asdf\"\n");
984 } 985 }
985 986
986 public void testParseShortRepeatedFormOfRepeatedFields() throws Exception { 987 public void testParseShortRepeatedFormOfRepeatedFields() throws Exception {
987 assertParseSuccessWithOverwriteForbidden("repeated_foreign_enum: [FOREIGN_FO O, FOREIGN_BAR]"); 988 assertParseSuccessWithOverwriteForbidden("repeated_foreign_enum: [FOREIGN_FO O, FOREIGN_BAR]");
988 assertParseSuccessWithOverwriteForbidden("repeated_int32: [ 1, 2 ]\n"); 989 assertParseSuccessWithOverwriteForbidden("repeated_int32: [ 1, 2 ]\n");
989 assertParseSuccessWithOverwriteForbidden("RepeatedGroup [{ a: 1 },{ a: 2 }]\ n"); 990 assertParseSuccessWithOverwriteForbidden("RepeatedGroup [{ a: 1 },{ a: 2 }]\ n");
990 assertParseSuccessWithOverwriteForbidden("repeated_nested_message [{ bb: 1 } , { bb: 2 }]\n"); 991 assertParseSuccessWithOverwriteForbidden("repeated_nested_message [{ bb: 1 } , { bb: 2 }]\n");
991 } 992 }
992 993
993 public void testParseShortRepeatedFormOfEmptyRepeatedFields() throws Exception {
994 assertParseSuccessWithOverwriteForbidden("repeated_foreign_enum: []");
995 assertParseSuccessWithOverwriteForbidden("repeated_int32: []\n");
996 assertParseSuccessWithOverwriteForbidden("RepeatedGroup []\n");
997 assertParseSuccessWithOverwriteForbidden("repeated_nested_message []\n");
998 }
999
1000 public void testParseShortRepeatedFormWithTrailingComma() throws Exception {
1001 assertParseErrorWithOverwriteForbidden(
1002 "1:38: Expected identifier. Found \']\'",
1003 "repeated_foreign_enum: [FOREIGN_FOO, ]\n");
1004 assertParseErrorWithOverwriteForbidden(
1005 "1:22: Couldn't parse integer: For input string: \"]\"",
1006 "repeated_int32: [ 1, ]\n");
1007 assertParseErrorWithOverwriteForbidden(
1008 "1:25: Expected \"{\".",
1009 "RepeatedGroup [{ a: 1 },]\n");
1010 assertParseErrorWithOverwriteForbidden(
1011 "1:37: Expected \"{\".",
1012 "repeated_nested_message [{ bb: 1 }, ]\n");
1013 }
1014
1015 public void testParseShortRepeatedFormOfNonRepeatedFields() throws Exception { 994 public void testParseShortRepeatedFormOfNonRepeatedFields() throws Exception {
1016 assertParseErrorWithOverwriteForbidden( 995 assertParseErrorWithOverwriteForbidden(
1017 "1:17: Couldn't parse integer: For input string: \"[\"", 996 "1:17: Couldn't parse integer: For input string: \"[\"",
1018 "optional_int32: [1]\n"); 997 "optional_int32: [1]\n");
1019 assertParseErrorWithOverwriteForbidden(
1020 "1:17: Couldn't parse integer: For input string: \"[\"",
1021 "optional_int32: []\n");
1022 } 998 }
1023 999
1024 // ======================================================================= 1000 // =======================================================================
1025 // test oneof 1001 // test oneof
1026 1002
1027 public void testOneofTextFormat() throws Exception { 1003 public void testOneofTextFormat() throws Exception {
1028 TestOneof2.Builder builder = TestOneof2.newBuilder(); 1004 TestOneof2.Builder builder = TestOneof2.newBuilder();
1029 TestUtil.setOneof(builder); 1005 TestUtil.setOneof(builder);
1030 TestOneof2 message = builder.build(); 1006 TestOneof2 message = builder.build();
1031 TestOneof2.Builder dest = TestOneof2.newBuilder(); 1007 TestOneof2.Builder dest = TestOneof2.newBuilder();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 } else if (line != -1 && column != -1) { 1120 } else if (line != -1 && column != -1) {
1145 fail( 1121 fail(
1146 String.format( 1122 String.format(
1147 "Tree/descriptor/fieldname did not contain index %d, line %d colum n %d expected", 1123 "Tree/descriptor/fieldname did not contain index %d, line %d colum n %d expected",
1148 index, 1124 index,
1149 line, 1125 line,
1150 column)); 1126 column));
1151 } 1127 }
1152 } 1128 }
1153 } 1129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698