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

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

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component 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 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 14 matching lines...) Expand all
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 30
31 package com.google.protobuf; 31 package com.google.protobuf;
32 32
33 import static com.google.protobuf.Internal.UTF_8; 33 import static com.google.protobuf.Internal.UTF_8;
34 34
35 import junit.framework.TestCase;
36
37 import java.io.ByteArrayInputStream; 35 import java.io.ByteArrayInputStream;
38 import java.io.ByteArrayOutputStream; 36 import java.io.ByteArrayOutputStream;
39 import java.io.EOFException; 37 import java.io.EOFException;
40 import java.io.IOException; 38 import java.io.IOException;
41 import java.io.InputStream; 39 import java.io.InputStream;
42 import java.io.ObjectInputStream; 40 import java.io.ObjectInputStream;
43 import java.io.ObjectOutputStream; 41 import java.io.ObjectOutputStream;
44 import java.io.OutputStream; 42 import java.io.OutputStream;
45 import java.io.UnsupportedEncodingException; 43 import java.io.UnsupportedEncodingException;
46 import java.nio.BufferOverflowException; 44 import java.nio.BufferOverflowException;
47 import java.nio.ByteBuffer; 45 import java.nio.ByteBuffer;
48 import java.util.Arrays; 46 import java.util.Arrays;
49 import java.util.List; 47 import java.util.List;
50 import java.util.NoSuchElementException; 48 import java.util.NoSuchElementException;
49 import junit.framework.TestCase;
51 50
52 /** 51 /**
53 * Tests for {@link NioByteString}. 52 * Tests for {@link NioByteString}.
54 */ 53 */
55 public class NioByteStringTest extends TestCase { 54 public class NioByteStringTest extends TestCase {
56 private static final ByteString EMPTY = new NioByteString(ByteBuffer.wrap(new byte[0])); 55 private static final ByteString EMPTY = new NioByteString(ByteBuffer.wrap(new byte[0]));
57 private static final String CLASSNAME = NioByteString.class.getSimpleName(); 56 private static final String CLASSNAME = NioByteString.class.getSimpleName();
58 private static final byte[] BYTES = ByteStringTest.getTestBytes(1234, 11337766 L); 57 private static final byte[] BYTES = ByteStringTest.getTestBytes(1234, 11337766 L);
59 private static final int EXPECTED_HASH = ByteString.wrap(BYTES).hashCode(); 58 private static final int EXPECTED_HASH = ByteString.wrap(BYTES).hashCode();
60 59
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 ObjectInputStream ois = new ObjectInputStream(in); 610 ObjectInputStream ois = new ObjectInputStream(in);
612 Object o = ois.readObject(); 611 Object o = ois.readObject();
613 assertTrue("Didn't get a ByteString back", o instanceof ByteString); 612 assertTrue("Didn't get a ByteString back", o instanceof ByteString);
614 assertEquals("Should get an equal ByteString back", testString, o); 613 assertEquals("Should get an equal ByteString back", testString, o);
615 } 614 }
616 615
617 private static ByteString forString(String str) { 616 private static ByteString forString(String str) {
618 return new NioByteString(ByteBuffer.wrap(str.getBytes(UTF_8))); 617 return new NioByteString(ByteBuffer.wrap(str.getBytes(UTF_8)));
619 } 618 }
620 } 619 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698