Skip to content

Commit

Permalink
Reformat with google-java-format
Browse files Browse the repository at this point in the history
RELNOTES=N/A

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=232329476
  • Loading branch information
cushon authored and ronshapiro committed Feb 26, 2019
1 parent 3e7f6fe commit f09c017
Show file tree
Hide file tree
Showing 28 changed files with 337 additions and 289 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.google.caliper.Benchmark;
import com.google.caliper.Param;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Ints;
import java.util.List;
import java.util.Random;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ public void testLenientFormat_badArgumentToString() {

public void testLenientFormat_badArgumentToString_gwtFriendly() {
assertThat(Strings.lenientFormat("boiler %s plate", new ThrowsOnToString()))
.matches(
"boiler <.*> plate");
.matches("boiler <.*> plate");
}

private static class ThrowsOnToString {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,27 @@
public class CompactHashMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Entry<String, String>[] entries) {
Map<String, String> map = CompactHashMap.create();
for (Entry<String, String> entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
return map;
}
})
.named("CompactHashMap")
.withFeatures(
CollectionSize.ANY, MapFeature.GENERAL_PURPOSE, MapFeature.ALLOWS_NULL_KEYS,
MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.SERIALIZABLE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE)
.createTestSuite());
suite.addTest(
MapTestSuiteBuilder.using(
new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Entry<String, String>[] entries) {
Map<String, String> map = CompactHashMap.create();
for (Entry<String, String> entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
return map;
}
})
.named("CompactHashMap")
.withFeatures(
CollectionSize.ANY,
MapFeature.GENERAL_PURPOSE,
MapFeature.ALLOWS_NULL_KEYS,
MapFeature.ALLOWS_NULL_VALUES,
CollectionFeature.SERIALIZABLE,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE)
.createTestSuite());
suite.addTestSuite(CompactHashMapTest.class);
return suite;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,49 @@
@GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array
public class CompactHashSetTest extends TestCase {
public static Test suite() {
List<Feature<?>> allFeatures = Arrays.<Feature<?>>asList(
CollectionSize.ANY,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.GENERAL_PURPOSE,
CollectionFeature.REMOVE_OPERATIONS,
CollectionFeature.SERIALIZABLE,
CollectionFeature.SUPPORTS_ADD,
CollectionFeature.SUPPORTS_REMOVE);
List<Feature<?>> allFeatures =
Arrays.<Feature<?>>asList(
CollectionSize.ANY,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.GENERAL_PURPOSE,
CollectionFeature.REMOVE_OPERATIONS,
CollectionFeature.SERIALIZABLE,
CollectionFeature.SUPPORTS_ADD,
CollectionFeature.SUPPORTS_REMOVE);

TestSuite suite = new TestSuite();
suite.addTestSuite(CompactHashSetTest.class);
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override protected Set<String> create(String[] elements) {
return CompactHashSet.create(Arrays.asList(elements));
}
}).named("CompactHashSet")
.withFeatures(allFeatures)
.createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override protected Set<String> create(String[] elements) {
CompactHashSet set = CompactHashSet.create(Arrays.asList(elements));
for (int i = 0; i < 100; i++) {
set.add(i);
}
for (int i = 0; i < 100; i++) {
set.remove(i);
}
set.trimToSize();
return set;
}
}).named("CompactHashSet#TrimToSize")
.withFeatures(allFeatures)
.createTestSuite());
suite.addTest(
SetTestSuiteBuilder.using(
new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
return CompactHashSet.create(Arrays.asList(elements));
}
})
.named("CompactHashSet")
.withFeatures(allFeatures)
.createTestSuite());
suite.addTest(
SetTestSuiteBuilder.using(
new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
CompactHashSet set = CompactHashSet.create(Arrays.asList(elements));
for (int i = 0; i < 100; i++) {
set.add(i);
}
for (int i = 0; i < 100; i++) {
set.remove(i);
}
set.trimToSize();
return set;
}
})
.named("CompactHashSet#TrimToSize")
.withFeatures(allFeatures)
.createTestSuite());
return suite;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,28 @@
public class CompactLinkedHashMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Entry<String, String>[] entries) {
Map<String, String> map = CompactLinkedHashMap.create();
for (Entry<String, String> entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
return map;
}
}).named("CompactLinkedHashMap").withFeatures(CollectionSize.ANY,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
MapFeature.GENERAL_PURPOSE,
MapFeature.ALLOWS_NULL_KEYS,
MapFeature.ALLOWS_NULL_VALUES,
CollectionFeature.SERIALIZABLE,
CollectionFeature.KNOWN_ORDER).createTestSuite());
suite.addTest(
MapTestSuiteBuilder.using(
new TestStringMapGenerator() {
@Override
protected Map<String, String> create(Entry<String, String>[] entries) {
Map<String, String> map = CompactLinkedHashMap.create();
for (Entry<String, String> entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
return map;
}
})
.named("CompactLinkedHashMap")
.withFeatures(
CollectionSize.ANY,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
MapFeature.GENERAL_PURPOSE,
MapFeature.ALLOWS_NULL_KEYS,
MapFeature.ALLOWS_NULL_VALUES,
CollectionFeature.SERIALIZABLE,
CollectionFeature.KNOWN_ORDER)
.createTestSuite());
suite.addTestSuite(CompactLinkedHashMapTest.class);
return suite;
}
Expand Down Expand Up @@ -119,8 +125,7 @@ public void testTrimToSize() {
testHasMapEntriesInOrder(map, 1, "a", 4, "b", 3, "d", 2, "c");
}

private void testHasMapEntriesInOrder(Map<?, ?> map,
Object... alternatingKeysAndValues) {
private void testHasMapEntriesInOrder(Map<?, ?> map, Object... alternatingKeysAndValues) {
List<? extends Entry<?, ?>> entries = Lists.newArrayList(map.entrySet());
List<Object> keys = Lists.newArrayList(map.keySet());
List<Object> values = Lists.newArrayList(map.values());
Expand All @@ -130,8 +135,7 @@ private void testHasMapEntriesInOrder(Map<?, ?> map,
for (int i = 0; i < map.size(); i++) {
Object expectedKey = alternatingKeysAndValues[2 * i];
Object expectedValue = alternatingKeysAndValues[2 * i + 1];
Entry<Object, Object> expectedEntry = Maps.immutableEntry(
expectedKey, expectedValue);
Entry<Object, Object> expectedEntry = Maps.immutableEntry(expectedKey, expectedValue);
assertEquals(expectedEntry, entries.get(i));
assertEquals(expectedKey, keys.get(i));
assertEquals(expectedValue, values.get(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,31 @@
@GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array
public class CompactLinkedHashSetTest extends TestCase {
public static Test suite() {
List<Feature<?>> allFeatures = Arrays.<Feature<?>>asList(
CollectionSize.ANY,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.GENERAL_PURPOSE,
CollectionFeature.REMOVE_OPERATIONS,
CollectionFeature.SERIALIZABLE,
CollectionFeature.KNOWN_ORDER,
CollectionFeature.SUPPORTS_ADD,
CollectionFeature.SUPPORTS_REMOVE);
List<Feature<?>> allFeatures =
Arrays.<Feature<?>>asList(
CollectionSize.ANY,
CollectionFeature.ALLOWS_NULL_VALUES,
CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
CollectionFeature.GENERAL_PURPOSE,
CollectionFeature.REMOVE_OPERATIONS,
CollectionFeature.SERIALIZABLE,
CollectionFeature.KNOWN_ORDER,
CollectionFeature.SUPPORTS_ADD,
CollectionFeature.SUPPORTS_REMOVE);

TestSuite suite = new TestSuite();
suite.addTestSuite(CompactLinkedHashSetTest.class);
suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override protected Set<String> create(String[] elements) {
return CompactLinkedHashSet.create(Arrays.asList(elements));
}
}).named("CompactLinkedHashSet")
.withFeatures(allFeatures)
.createTestSuite());
suite.addTest(
SetTestSuiteBuilder.using(
new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
return CompactLinkedHashSet.create(Arrays.asList(elements));
}
})
.named("CompactLinkedHashSet")
.withFeatures(allFeatures)
.createTestSuite());
return suite;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,11 @@ protected Map<K, V> delegate() {
};
}

private static final ImmutableMap<String, String> JUF_METHODS = ImmutableMap.of(
"java.util.function.Predicate", "test",
"java.util.function.Consumer", "accept",
"java.util.function.IntFunction", "apply");
private static final ImmutableMap<String, String> JUF_METHODS =
ImmutableMap.of(
"java.util.function.Predicate", "test",
"java.util.function.Consumer", "accept",
"java.util.function.IntFunction", "apply");

private static Object getDefaultValue(final TypeToken<?> type) {
Class<?> rawType = type.getRawType();
Expand Down Expand Up @@ -387,8 +388,7 @@ private static <T> void callAllPublicMethods(TypeToken<T> type, T object)
}
}
} catch (Throwable cause) {
throw new InvocationTargetException(
cause, method + " with args: " + Arrays.toString(args));
throw new InvocationTargetException(cause, method + " with args: " + Arrays.toString(args));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected boolean addNode(Integer n) {
* add an edge whose end-points don't already exist in the graph), you should <b>not</b> use this
* method.
*
* TODO(user): remove the addNode() calls, that's now contractually guaranteed
* <p>TODO(user): remove the addNode() calls, that's now contractually guaranteed
*
* @return {@code true} iff the graph was modified as a result of this call
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ public void incidentEdges_selfLoop() {
putEdge(N1, N1);
assertThat(graph.incidentEdges(N1)).containsExactly(EndpointPair.ordered(N1, N1));
putEdge(N1, N2);
assertThat(graph.incidentEdges(N1)).containsExactly(
EndpointPair.ordered(N1, N1),
EndpointPair.ordered(N1, N2));
assertThat(graph.incidentEdges(N1))
.containsExactly(EndpointPair.ordered(N1, N1), EndpointPair.ordered(N1, N2));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ public void incidentEdges_selfLoop() {
putEdge(N1, N1);
assertThat(graph.incidentEdges(N1)).containsExactly(EndpointPair.unordered(N1, N1));
putEdge(N1, N2);
assertThat(graph.incidentEdges(N1)).containsExactly(
EndpointPair.unordered(N1, N1),
EndpointPair.unordered(N1, N2));
assertThat(graph.incidentEdges(N1))
.containsExactly(EndpointPair.unordered(N1, N1), EndpointPair.unordered(N1, N2));
}

@Test
Expand Down
Loading

0 comments on commit f09c017

Please sign in to comment.