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

Side by Side Diff: third_party/protobuf/java/core/src/test/java/com/google/protobuf/AbstractMessageTest.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 22 matching lines...) Expand all
33 import com.google.protobuf.Descriptors.FieldDescriptor; 33 import com.google.protobuf.Descriptors.FieldDescriptor;
34 import protobuf_unittest.UnittestOptimizeFor.TestOptimizedForSize; 34 import protobuf_unittest.UnittestOptimizeFor.TestOptimizedForSize;
35 import protobuf_unittest.UnittestProto; 35 import protobuf_unittest.UnittestProto;
36 import protobuf_unittest.UnittestProto.ForeignMessage; 36 import protobuf_unittest.UnittestProto.ForeignMessage;
37 import protobuf_unittest.UnittestProto.TestAllExtensions; 37 import protobuf_unittest.UnittestProto.TestAllExtensions;
38 import protobuf_unittest.UnittestProto.TestAllTypes; 38 import protobuf_unittest.UnittestProto.TestAllTypes;
39 import protobuf_unittest.UnittestProto.TestPackedTypes; 39 import protobuf_unittest.UnittestProto.TestPackedTypes;
40 import protobuf_unittest.UnittestProto.TestRequired; 40 import protobuf_unittest.UnittestProto.TestRequired;
41 import protobuf_unittest.UnittestProto.TestRequiredForeign; 41 import protobuf_unittest.UnittestProto.TestRequiredForeign;
42 import protobuf_unittest.UnittestProto.TestUnpackedTypes; 42 import protobuf_unittest.UnittestProto.TestUnpackedTypes;
43 import junit.framework.TestCase;
44
43 import java.util.Map; 45 import java.util.Map;
44 import junit.framework.TestCase;
45 46
46 /** 47 /**
47 * Unit test for {@link AbstractMessage}. 48 * Unit test for {@link AbstractMessage}.
48 * 49 *
49 * @author kenton@google.com Kenton Varda 50 * @author kenton@google.com Kenton Varda
50 */ 51 */
51 public class AbstractMessageTest extends TestCase { 52 public class AbstractMessageTest extends TestCase {
52 /** 53 /**
53 * Extends AbstractMessage and wraps some other message object. The methods 54 * Extends AbstractMessage and wraps some other message object. The methods
54 * of the Message interface which aren't explicitly implemented by 55 * of the Message interface which aren't explicitly implemented by
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 checkNotEqual(eUnknownFields, fUnknownFields); 485 checkNotEqual(eUnknownFields, fUnknownFields);
485 checkEqualsIsConsistent(eUnknownFields); 486 checkEqualsIsConsistent(eUnknownFields);
486 checkEqualsIsConsistent(fUnknownFields); 487 checkEqualsIsConsistent(fUnknownFields);
487 488
488 // Subsequent reconstitutions should be identical 489 // Subsequent reconstitutions should be identical
489 UnittestProto.TestEmptyMessage eUnknownFields2 = 490 UnittestProto.TestEmptyMessage eUnknownFields2 =
490 UnittestProto.TestEmptyMessage.parseFrom(e.toByteArray()); 491 UnittestProto.TestEmptyMessage.parseFrom(e.toByteArray());
491 checkEqualsIsConsistent(eUnknownFields, eUnknownFields2); 492 checkEqualsIsConsistent(eUnknownFields, eUnknownFields2);
492 } 493 }
493 494
495
494 /** 496 /**
495 * Asserts that the given proto has symmetric equals and hashCode methods. 497 * Asserts that the given proto has symmetric equals and hashCode methods.
496 */ 498 */
497 private void checkEqualsIsConsistent(Message message) { 499 private void checkEqualsIsConsistent(Message message) {
498 // Object should be equal to itself. 500 // Object should be equal to itself.
499 assertEquals(message, message); 501 assertEquals(message, message);
500 502
501 // Object should be equal to a dynamic copy of itself. 503 // Object should be equal to a dynamic copy of itself.
502 DynamicMessage dynamic = DynamicMessage.newBuilder(message).build(); 504 DynamicMessage dynamic = DynamicMessage.newBuilder(message).build();
503 checkEqualsIsConsistent(message, dynamic); 505 checkEqualsIsConsistent(message, dynamic);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 ByteString.copyFrom(new byte[]{(byte) 0x80}); // A lone continuation byt e. 542 ByteString.copyFrom(new byte[]{(byte) 0x80}); // A lone continuation byt e.
541 try { 543 try {
542 AbstractMessageLite.checkByteStringIsUtf8(byteString); 544 AbstractMessageLite.checkByteStringIsUtf8(byteString);
543 fail("Expected AbstractMessageLite.checkByteStringIsUtf8 to throw IllegalA rgumentException"); 545 fail("Expected AbstractMessageLite.checkByteStringIsUtf8 to throw IllegalA rgumentException");
544 } catch (IllegalArgumentException exception) { 546 } catch (IllegalArgumentException exception) {
545 assertEquals("Byte string is not UTF-8.", exception.getMessage()); 547 assertEquals("Byte string is not UTF-8.", exception.getMessage());
546 } 548 }
547 } 549 }
548 550
549 } 551 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698