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

Unified Diff: third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/LazyStringArrayListTest.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 side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/LazyStringArrayListTest.java
diff --git a/third_party/protobuf/java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java b/third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/LazyStringArrayListTest.java
similarity index 54%
copy from third_party/protobuf/java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java
copy to third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/LazyStringArrayListTest.java
index 0f42ac506075b394e2024f754b6208cafdbee361..9bc94eef1df4a7f106b3ecd9ddbd6d70e866ebc0 100644
--- a/third_party/protobuf/java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java
+++ b/third_party/protobuf/java/compatibility_tests/v2.5.0/tests/src/main/java/com/google/protobuf/test/LazyStringArrayListTest.java
@@ -1,6 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
+// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -28,15 +28,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-package com.google.protobuf;
-
-import static java.util.Arrays.asList;
+package com.google.protobuf.test;
+import com.google.protobuf.*;
import junit.framework.TestCase;
import java.util.ArrayList;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
import java.util.List;
/**
@@ -71,14 +68,6 @@ public class LazyStringArrayListTest extends TestCase {
list.remove(1);
assertSame(STRING_A, list.get(0));
assertSame(STRING_C, list.get(1));
-
- List<ByteString> byteStringList = list.asByteStringList();
- assertEquals(BYTE_STRING_A, byteStringList.get(0));
- assertEquals(BYTE_STRING_C, byteStringList.get(1));
-
- // Underlying list should be transformed.
- assertSame(byteStringList.get(0), list.getByteString(0));
- assertSame(byteStringList.get(1), list.getByteString(1));
}
public void testJustByteString() {
@@ -95,10 +84,6 @@ public class LazyStringArrayListTest extends TestCase {
list.remove(1);
assertSame(BYTE_STRING_A, list.getByteString(0));
assertSame(BYTE_STRING_C, list.getByteString(1));
-
- List<ByteString> byteStringList = list.asByteStringList();
- assertSame(BYTE_STRING_A, byteStringList.get(0));
- assertSame(BYTE_STRING_C, byteStringList.get(1));
}
public void testConversionBackAndForth() {
@@ -175,188 +160,4 @@ public class LazyStringArrayListTest extends TestCase {
assertSame(BYTE_STRING_B, list2.getByteString(1));
assertSame(BYTE_STRING_C, list2.getByteString(2));
}
-
- public void testModificationWithIteration() {
- LazyStringArrayList list = new LazyStringArrayList();
- list.addAll(asList(STRING_A, STRING_B, STRING_C));
- Iterator<String> iterator = list.iterator();
- assertEquals(3, list.size());
- assertEquals(STRING_A, list.get(0));
- assertEquals(STRING_A, iterator.next());
-
- // Does not structurally modify.
- iterator = list.iterator();
- list.set(0, STRING_B);
- iterator.next();
-
- list.remove(0);
- try {
- iterator.next();
- fail();
- } catch (ConcurrentModificationException e) {
- // expected
- }
-
- iterator = list.iterator();
- list.add(0, STRING_C);
- try {
- iterator.next();
- fail();
- } catch (ConcurrentModificationException e) {
- // expected
- }
- }
-
- public void testMakeImmutable() {
- LazyStringArrayList list = new LazyStringArrayList();
- list.add(STRING_A);
- list.add(STRING_B);
- list.add(STRING_C);
- list.makeImmutable();
- assertGenericListImmutable(list, STRING_A);
-
- // LazyStringArrayList has extra methods not covered in the generic
- // assertion.
-
- try {
- list.add(BYTE_STRING_A.toByteArray());
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.add(BYTE_STRING_A);
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.addAllByteArray(asList(BYTE_STRING_A.toByteArray()));
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.addAllByteString(asList(BYTE_STRING_A));
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.mergeFrom(new LazyStringArrayList());
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.set(0, BYTE_STRING_A.toByteArray());
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.set(0, BYTE_STRING_A);
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
- }
-
- public void testImmutabilityPropagation() {
- LazyStringArrayList list = new LazyStringArrayList();
- list.add(STRING_A);
- list.makeImmutable();
-
- assertGenericListImmutable(list.asByteStringList(), BYTE_STRING_A);
-
- // Arrays use reference equality so need to retrieve the underlying value
- // to properly test deep immutability.
- List<byte[]> byteArrayList = list.asByteArrayList();
- assertGenericListImmutable(byteArrayList, byteArrayList.get(0));
- }
-
- private static <T> void assertGenericListImmutable(List<T> list, T value) {
- try {
- list.add(value);
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.add(0, value);
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.addAll(asList(value));
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.addAll(0, asList(value));
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.clear();
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.remove(0);
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.remove(value);
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.removeAll(asList(value));
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.retainAll(asList());
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.retainAll(asList());
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- list.set(0, value);
- fail();
- } catch (UnsupportedOperationException e) {
- // expected
- }
- }
}

Powered by Google App Engine
This is Rietveld 408576698