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

Unified Diff: third_party/protobuf/java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.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/DoubleArrayListTest.java
diff --git a/third_party/protobuf/java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java b/third_party/protobuf/java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java
index 85b418c44a795f62f22c9cc202d96e63de2c5ed0..d894279297b03438231d39121f2760260aeb95ce 100644
--- a/third_party/protobuf/java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java
+++ b/third_party/protobuf/java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java
@@ -32,47 +32,47 @@ 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 DoubleArrayList}.
- *
+ *
* @author dweis@google.com (Daniel Weis)
*/
public class DoubleArrayListTest extends TestCase {
-
- private static final DoubleArrayList UNARY_LIST = newImmutableDoubleArrayList(1);
+
+ private static final DoubleArrayList UNARY_LIST =
+ newImmutableDoubleArrayList(1);
private static final DoubleArrayList TERTIARY_LIST =
newImmutableDoubleArrayList(1, 2, 3);
-
+
private DoubleArrayList list;
-
+
@Override
protected void setUp() throws Exception {
list = new DoubleArrayList();
}
-
+
public void testEmptyListReturnsSameInstance() {
assertSame(DoubleArrayList.emptyList(), DoubleArrayList.emptyList());
}
-
+
public void testEmptyListIsImmutable() {
assertImmutable(DoubleArrayList.emptyList());
}
-
+
public void testMakeImmutable() {
- list.addDouble(2);
+ list.addDouble(3);
list.addDouble(4);
- list.addDouble(6);
- list.addDouble(8);
+ list.addDouble(5);
+ list.addDouble(7);
list.makeImmutable();
assertImmutable(list);
}
-
+
public void testModificationWithIteration() {
list.addAll(asList(1D, 2D, 3D, 4D));
Iterator<Double> iterator = list.iterator();
@@ -81,7 +81,7 @@ public class DoubleArrayListTest extends TestCase {
assertEquals(1D, (double) iterator.next());
list.set(0, 1D);
assertEquals(2D, (double) iterator.next());
-
+
list.remove(0);
try {
iterator.next();
@@ -89,7 +89,7 @@ public class DoubleArrayListTest extends TestCase {
} catch (ConcurrentModificationException e) {
// expected
}
-
+
iterator = list.iterator();
list.add(0, 0D);
try {
@@ -99,19 +99,19 @@ public class DoubleArrayListTest extends TestCase {
// expected
}
}
-
+
public void testGet() {
assertEquals(1D, (double) TERTIARY_LIST.get(0));
assertEquals(2D, (double) TERTIARY_LIST.get(1));
assertEquals(3D, (double) 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 DoubleArrayListTest extends TestCase {
// expected
}
}
-
- public void testGetInt() {
+
+ public void testGetDouble() {
assertEquals(1D, TERTIARY_LIST.getDouble(0));
assertEquals(2D, TERTIARY_LIST.getDouble(1));
assertEquals(3D, TERTIARY_LIST.getDouble(2));
-
+
try {
TERTIARY_LIST.get(-1);
fail();
} catch (IndexOutOfBoundsException e) {
// expected
}
-
+
try {
TERTIARY_LIST.get(3);
fail();
@@ -139,35 +139,35 @@ public class DoubleArrayListTest extends TestCase {
// expected
}
}
-
+
public void testSize() {
assertEquals(0, DoubleArrayList.emptyList().size());
assertEquals(1, UNARY_LIST.size());
assertEquals(3, TERTIARY_LIST.size());
- list.addDouble(2);
+ list.addDouble(3);
list.addDouble(4);
list.addDouble(6);
list.addDouble(8);
assertEquals(4, list.size());
-
+
list.remove(0);
assertEquals(3, list.size());
-
- list.add(16D);
+
+ list.add(17D);
assertEquals(4, list.size());
}
-
+
public void testSet() {
list.addDouble(2);
list.addDouble(4);
-
- assertEquals(2D, (double) list.set(0, 0D));
- assertEquals(0D, list.getDouble(0));
+
+ assertEquals(2D, (double) list.set(0, 3D));
+ assertEquals(3D, list.getDouble(0));
assertEquals(4D, (double) list.set(1, 0D));
assertEquals(0D, list.getDouble(1));
-
+
try {
list.set(-1, 0D);
fail();
@@ -182,17 +182,17 @@ public class DoubleArrayListTest extends TestCase {
// expected
}
}
-
- public void testSetInt() {
- list.addDouble(2);
- list.addDouble(4);
-
- assertEquals(2D, list.setDouble(0, 0));
+
+ public void testSetDouble() {
+ list.addDouble(1);
+ list.addDouble(3);
+
+ assertEquals(1D, list.setDouble(0, 0));
assertEquals(0D, list.getDouble(0));
- assertEquals(4D, list.setDouble(1, 0));
+ assertEquals(3D, list.setDouble(1, 0));
assertEquals(0D, list.getDouble(1));
-
+
try {
list.setDouble(-1, 0);
fail();
@@ -207,7 +207,7 @@ public class DoubleArrayListTest extends TestCase {
// expected
}
}
-
+
public void testAdd() {
assertEquals(0, list.size());
@@ -217,29 +217,31 @@ public class DoubleArrayListTest extends TestCase {
assertTrue(list.add(3D));
list.add(0, 4D);
assertEquals(asList(4D, 2D, 3D), list);
-
+
list.add(0, 1D);
list.add(0, 0D);
// Force a resize by getting up to 11 elements.
for (int i = 0; i < 6; i++) {
list.add(Double.valueOf(5 + i));
}
- assertEquals(asList(0D, 1D, 4D, 2D, 3D, 5D, 6D, 7D, 8D, 9D, 10D), list);
-
+ assertEquals(
+ asList(0D, 1D, 4D, 2D, 3D, 5D, 6D, 7D, 8D, 9D, 10D),
+ list);
+
try {
list.add(-1, 5D);
} catch (IndexOutOfBoundsException e) {
// expected
}
-
+
try {
list.add(4, 5D);
} catch (IndexOutOfBoundsException e) {
// expected
}
}
-
- public void testAddInt() {
+
+ public void testAddDouble() {
assertEquals(0, list.size());
list.addDouble(2);
@@ -248,7 +250,7 @@ public class DoubleArrayListTest extends TestCase {
list.addDouble(3);
assertEquals(asList(2D, 3D), list);
}
-
+
public void testAddAll() {
assertEquals(0, list.size());
@@ -256,17 +258,17 @@ public class DoubleArrayListTest extends TestCase {
assertEquals(1, list.size());
assertEquals(1D, (double) list.get(0));
assertEquals(1D, list.getDouble(0));
-
+
assertTrue(list.addAll(asList(2D, 3D, 4D, 5D, 6D)));
assertEquals(asList(1D, 2D, 3D, 4D, 5D, 6D), list);
-
+
assertTrue(list.addAll(TERTIARY_LIST));
assertEquals(asList(1D, 2D, 3D, 4D, 5D, 6D, 1D, 2D, 3D), list);
assertFalse(list.addAll(Collections.<Double>emptyList()));
assertFalse(list.addAll(DoubleArrayList.emptyList()));
}
-
+
public void testRemove() {
list.addAll(TERTIARY_LIST);
assertEquals(1D, (double) list.remove(0));
@@ -280,96 +282,96 @@ public class DoubleArrayListTest extends TestCase {
assertEquals(2D, (double) 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(DoubleArrayList list) {
if (list.contains(1D)) {
throw new RuntimeException("Cannot test the immutability of lists that contain 1.");
}
-
+
try {
list.add(1D);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.add(0, 1D);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(Collections.<Double>emptyList());
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(Collections.singletonList(1D));
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(new DoubleArrayList());
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(UNARY_LIST);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(0, Collections.singleton(1D));
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(0, UNARY_LIST);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addAll(0, Collections.<Double>emptyList());
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.addDouble(0);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.clear();
fail();
@@ -383,28 +385,28 @@ public class DoubleArrayListTest extends TestCase {
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.remove(new Object());
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.removeAll(Collections.<Double>emptyList());
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.removeAll(Collections.singleton(1D));
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.removeAll(UNARY_LIST);
fail();
@@ -418,28 +420,28 @@ public class DoubleArrayListTest extends TestCase {
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.retainAll(Collections.singleton(1D));
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.retainAll(UNARY_LIST);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.set(0, 0D);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
-
+
try {
list.setDouble(0, 0);
fail();
@@ -447,7 +449,7 @@ public class DoubleArrayListTest extends TestCase {
// expected
}
}
-
+
private static DoubleArrayList newImmutableDoubleArrayList(double... elements) {
DoubleArrayList list = new DoubleArrayList();
for (double element : elements) {

Powered by Google App Engine
This is Rietveld 408576698