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

Unified Diff: third_party/protobuf/java/core/src/test/java/com/google/protobuf/LongArrayListTest.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/core/src/test/java/com/google/protobuf/LongArrayListTest.java
diff --git a/third_party/protobuf/java/core/src/test/java/com/google/protobuf/LongArrayListTest.java b/third_party/protobuf/java/core/src/test/java/com/google/protobuf/LongArrayListTest.java
index 0a8f9ed2280c306cc72ba8b2ffcb9b44a6613f24..6bbdfcaa32abf79c0cc6f182800ca6a789b9a9cb 100644
--- a/third_party/protobuf/java/core/src/test/java/com/google/protobuf/LongArrayListTest.java
+++ b/third_party/protobuf/java/core/src/test/java/com/google/protobuf/LongArrayListTest.java
@@ -32,56 +32,56 @@ package com.google.protobuf;
import static java.util.Arrays.asList;
-import junit.framework.TestCase;
-
import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
+import junit.framework.TestCase;
/**
* Tests for {@link LongArrayList}.
- *
+ *
* @author dweis@google.com (Daniel Weis)
*/
public class LongArrayListTest extends TestCase {
-
- private static final LongArrayList UNARY_LIST = newImmutableLongArrayList(1);
+
+ private static final LongArrayList UNARY_LIST =
+ newImmutableLongArrayList(1);
private static final LongArrayList TERTIARY_LIST =
newImmutableLongArrayList(1, 2, 3);
-
+
private LongArrayList list;
-
+
@Override
protected void setUp() throws Exception {
list = new LongArrayList();
}
-
+
public void testEmptyListReturnsSameInstance() {
assertSame(LongArrayList.emptyList(), LongArrayList.emptyList());
}
-
+
public void testEmptyListIsImmutable() {
assertImmutable(LongArrayList.emptyList());
}
-
+
public void testMakeImmutable() {
- list.addLong(2);
+ list.addLong(3);
list.addLong(4);
- list.addLong(6);
- list.addLong(8);
+ list.addLong(5);
+ list.addLong(7);
list.makeImmutable();
assertImmutable(list);
}
-
+
public void testModificationWithIteration() {
list.addAll(asList(1L, 2L, 3L, 4L));
Iterator<Long> iterator = list.iterator();
assertEquals(4, list.size());
- assertEquals(1, (long) list.get(0));
- assertEquals(1, (long) iterator.next());
+ assertEquals(1L, (long) list.get(0));
+ assertEquals(1L, (long) iterator.next());
list.set(0, 1L);
- assertEquals(2, (long) iterator.next());
-
+ assertEquals(2L, (long) iterator.next());
+
list.remove(0);
try {
iterator.next();
@@ -89,7 +89,7 @@ public class LongArrayListTest extends TestCase {
} catch (ConcurrentModificationException e) {
// expected
}
-
+
iterator = list.iterator();
list.add(0, 0L);
try {
@@ -99,19 +99,19 @@ public class LongArrayListTest extends TestCase {
// expected
}
}
-
+
public void testGet() {
- assertEquals(1, (long) TERTIARY_LIST.get(0));
- assertEquals(2, (long) TERTIARY_LIST.get(1));
- assertEquals(3, (long) TERTIARY_LIST.get(2));
-
+ assertEquals(1L, (long) TERTIARY_LIST.get(0));
+ assertEquals(2L, (long) TERTIARY_LIST.get(1));
+ assertEquals(3L, (long) TERTIARY_LIST.get(2));
+
try {
TERTIARY_LIST.get(-1);
fail();
} catch (IndexOutOfBoundsException e) {
// expected
}
-
+
try {
TERTIARY_LIST.get(3);
fail();
@@ -119,19 +119,19 @@ public class LongArrayListTest extends TestCase {
// expected
}
}
-
+
public void testGetLong() {
- assertEquals(1, TERTIARY_LIST.getLong(0));
- assertEquals(2, TERTIARY_LIST.getLong(1));
- assertEquals(3, TERTIARY_LIST.getLong(2));
-
+ assertEquals(1L, TERTIARY_LIST.getLong(0));
+ assertEquals(2L, TERTIARY_LIST.getLong(1));
+ assertEquals(3L, TERTIARY_LIST.getLong(2));
+
try {
TERTIARY_LIST.get(-1);
fail();
} catch (IndexOutOfBoundsException e) {
// expected
}
-
+
try {
TERTIARY_LIST.get(3);
fail();
@@ -139,35 +139,35 @@ public class LongArrayListTest extends TestCase {
// expected
}
}
-
+
public void testSize() {
assertEquals(0, LongArrayList.emptyList().size());
assertEquals(1, UNARY_LIST.size());
assertEquals(3, TERTIARY_LIST.size());
- list.addLong(2);
+ list.addLong(3);
list.addLong(4);
list.addLong(6);
list.addLong(8);
assertEquals(4, list.size());
-
+
list.remove(0);
assertEquals(3, list.size());
-
- list.add(16L);
+
+ list.add(17L);
assertEquals(4, list.size());
}
-
+
public void testSet() {
list.addLong(2);
list.addLong(4);
-
- assertEquals(2, (long) list.set(0, 0L));
- assertEquals(0, list.getLong(0));
- assertEquals(4, (long) list.set(1, 0L));
- assertEquals(0, list.getLong(1));
-
+ assertEquals(2L, (long) list.set(0, 3L));
+ assertEquals(3L, list.getLong(0));
+
+ assertEquals(4L, (long) list.set(1, 0L));
+ assertEquals(0L, list.getLong(1));
+
try {
list.set(-1, 0L);
fail();
@@ -182,17 +182,17 @@ public class LongArrayListTest extends TestCase {
// expected
}
}
-
+
public void testSetLong() {
- list.addLong(2);
- list.addLong(4);
-
- assertEquals(2, list.setLong(0, 0));
- assertEquals(0, list.getLong(0));
+ list.addLong(1);
+ list.addLong(3);
+
+ assertEquals(1L, list.setLong(0, 0));
+ assertEquals(0L, list.getLong(0));
+
+ assertEquals(3L, list.setLong(1, 0));
+ assertEquals(0L, list.getLong(1));
- assertEquals(4, list.setLong(1, 0));
- assertEquals(0, list.getLong(1));
-
try {
list.setLong(-1, 0);
fail();
@@ -207,7 +207,7 @@ public class LongArrayListTest extends TestCase {
// expected
}
}
-
+
public void testAdd() {
assertEquals(0, list.size());
@@ -217,28 +217,30 @@ public class LongArrayListTest extends TestCase {
assertTrue(list.add(3L));
list.add(0, 4L);
assertEquals(asList(4L, 2L, 3L), list);
-
+
list.add(0, 1L);
list.add(0, 0L);
// Force a resize by getting up to 11 elements.
for (int i = 0; i < 6; i++) {
list.add(Long.valueOf(5 + i));
}
- assertEquals(asList(0L, 1L, 4L, 2L, 3L, 5L, 6L, 7L, 8L, 9L, 10L), list);
-
+ assertEquals(
+ asList(0L, 1L, 4L, 2L, 3L, 5L, 6L, 7L, 8L, 9L, 10L),
+ list);
+
try {
list.add(-1, 5L);
} catch (IndexOutOfBoundsException e) {
// expected
}
-
+
try {
list.add(4, 5L);
} catch (IndexOutOfBoundsException e) {
// expected
}
}
-
+
public void testAddLong() {
assertEquals(0, list.size());
@@ -248,128 +250,128 @@ public class LongArrayListTest extends TestCase {
list.addLong(3);
assertEquals(asList(2L, 3L), list);
}
-
+
public void testAddAll() {
assertEquals(0, list.size());
assertTrue(list.addAll(Collections.singleton(1L)));
assertEquals(1, list.size());
- assertEquals(1, (long) list.get(0));
- assertEquals(1, list.getLong(0));
-
+ assertEquals(1L, (long) list.get(0));
+ assertEquals(1L, list.getLong(0));
+
assertTrue(list.addAll(asList(2L, 3L, 4L, 5L, 6L)));
assertEquals(asList(1L, 2L, 3L, 4L, 5L, 6L), list);
-
+
assertTrue(list.addAll(TERTIARY_LIST));
assertEquals(asList(1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L), list);
assertFalse(list.addAll(Collections.<Long>emptyList()));
assertFalse(list.addAll(LongArrayList.emptyList()));
}
-
+
public void testRemove() {
list.addAll(TERTIARY_LIST);
- assertEquals(1, (long) list.remove(0));
+ assertEquals(1L, (long) list.remove(0));
assertEquals(asList(2L, 3L), list);
- assertTrue(list.remove(3L));
+ assertTrue(list.remove(Long.valueOf(3)));
assertEquals(asList(2L), list);
- assertFalse(list.remove(3L));
+ assertFalse(list.remove(Long.valueOf(3)));
assertEquals(asList(2L), list);
- assertEquals(2, (long) list.remove(0));
+ assertEquals(2L, (long) list.remove(0));
assertEquals(asList(), list);
-
+
try {
list.remove(-1);
fail();
} catch (IndexOutOfBoundsException e) {
// expected
}
-
+
try {
list.remove(0);
} catch (IndexOutOfBoundsException e) {
// expected
}
}
-
+
private void assertImmutable(LongArrayList list) {
if (list.contains(1L)) {
throw new RuntimeException("Cannot test the immutability of lists that contain 1.");
}
-
+
try {
list.add(1L);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.add(0, 1L);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(Collections.<Long>emptyList());
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(Collections.singletonList(1L));
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(new LongArrayList());
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(UNARY_LIST);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(0, Collections.singleton(1L));
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(0, UNARY_LIST);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(0, Collections.<Long>emptyList());
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addLong(0);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.clear();
fail();
@@ -383,63 +385,63 @@ public class LongArrayListTest extends TestCase {
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.remove(new Object());
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.removeAll(Collections.<Long>emptyList());
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.removeAll(Collections.singleton(1L));
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.removeAll(UNARY_LIST);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.retainAll(Collections.<Long>emptyList());
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.retainAll(Collections.singleton(1L));
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.retainAll(UNARY_LIST);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.set(0, 0L);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.setLong(0, 0);
fail();
@@ -447,7 +449,7 @@ public class LongArrayListTest extends TestCase {
// expected
}
}
-
+
private static LongArrayList newImmutableLongArrayList(long... elements) {
LongArrayList list = new LongArrayList();
for (long element : elements) {

Powered by Google App Engine
This is Rietveld 408576698