Skip to content

Commit

Permalink
Reformat.
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 716870912
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Jan 18, 2025
1 parent a3d5c96 commit 176cf74
Show file tree
Hide file tree
Showing 151 changed files with 966 additions and 348 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ protected Collection<E> resetContainer(Collection<E> newContents) {
return collection;
}

/** @see AbstractContainerTester#resetContainer() */
/**
* @see AbstractContainerTester#resetContainer()
*/
protected void resetCollection() {
resetContainer();
}

/** @return an array of the proper size with {@code null} inserted into the middle element. */
/**
* @return an array of the proper size with {@code null} inserted into the middle element.
*/
protected E[] createArrayWithNullElement() {
E[] array = createSamplesArray();
array[getNullLocation()] = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ protected Collection<Entry<K, V>> actualContents() {
return getMap().entrySet();
}

/** @see AbstractContainerTester#resetContainer() */
/**
* @see AbstractContainerTester#resetContainer()
*/
protected final void resetMap() {
resetContainer();
}
Expand All @@ -77,7 +79,9 @@ protected void expectMissingValues(V... elements) {
}
}

/** @return an array of the proper size with {@code null} as the key of the middle element. */
/**
* @return an array of the proper size with {@code null} as the key of the middle element.
*/
protected Entry<K, V>[] createArrayWithNullKey() {
Entry<K, V>[] array = createSamplesArray();
int nullKeyLocation = getNullLocation();
Expand All @@ -102,7 +106,9 @@ private Entry<K, V> getEntryNullReplaces() {
return entries.next();
}

/** @return an array of the proper size with {@code null} as the value of the middle element. */
/**
* @return an array of the proper size with {@code null} as the value of the middle element.
*/
protected Entry<K, V>[] createArrayWithNullValue() {
Entry<K, V>[] array = createSamplesArray();
int nullValueLocation = getNullLocation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ public void testNulls(Class<?> cls) {
}

void doTestNulls(Class<?> cls, Visibility visibility)
throws ParameterNotInstantiableException, IllegalAccessException, InvocationTargetException,
throws ParameterNotInstantiableException,
IllegalAccessException,
InvocationTargetException,
FactoryMethodReturnsNullException {
if (!Modifier.isAbstract(cls.getModifiers())) {
nullPointerTester.testConstructors(cls, visibility);
Expand Down Expand Up @@ -295,8 +297,11 @@ public void testEquals(Class<?> cls) {
}

void doTestEquals(Class<?> cls)
throws ParameterNotInstantiableException, ParameterHasNoDistinctValueException,
IllegalAccessException, InvocationTargetException, FactoryMethodReturnsNullException {
throws ParameterNotInstantiableException,
ParameterHasNoDistinctValueException,
IllegalAccessException,
InvocationTargetException,
FactoryMethodReturnsNullException {
if (cls.isEnum()) {
return;
}
Expand Down Expand Up @@ -566,8 +571,11 @@ public FactoryMethodReturnValueTester testEqualsAndSerializable() throws Excepti
}

private void testEqualsUsing(final Invokable<?, ?> factory)
throws ParameterNotInstantiableException, ParameterHasNoDistinctValueException,
IllegalAccessException, InvocationTargetException, FactoryMethodReturnsNullException {
throws ParameterNotInstantiableException,
ParameterHasNoDistinctValueException,
IllegalAccessException,
InvocationTargetException,
FactoryMethodReturnsNullException {
List<Parameter> params = factory.getParameters();
List<FreshValueGenerator> argGenerators = Lists.newArrayListWithCapacity(params.size());
List<@Nullable Object> args = Lists.newArrayListWithCapacity(params.size());
Expand Down Expand Up @@ -617,8 +625,10 @@ String reportItem(Item<?> item) {
*/
private List<Object> generateEqualFactoryArguments(
Invokable<?, ?> factory, List<Parameter> params, List<Object> args)
throws ParameterNotInstantiableException, FactoryMethodReturnsNullException,
InvocationTargetException, IllegalAccessException {
throws ParameterNotInstantiableException,
FactoryMethodReturnsNullException,
InvocationTargetException,
IllegalAccessException {
List<Object> equalArgs = Lists.newArrayList(args);
for (int i = 0; i < args.size(); i++) {
Parameter param = params.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class SplitterBenchmark {
// overall size of string
@Param({"1", "10", "100", "1000"})
int length;

// Number of matching strings
@Param({"xxxx", "xxXx", "xXxX", "XXXX"})
String text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ interface ExecutionListWrapper {
void add(Runnable runnable, Executor executor);

void execute();

/** Returns the underlying implementation, useful for the Footprint benchmark. */
Object getImpl();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ private enum ExceptionType {
@Param Validator validator;
@Param Result result;
@Param ExceptionType exceptionType;

/**
* The number of other exception types in the cache of known-good exceptions and the number of
* other {@code ClassValue} entries for the exception type to be tested. This lets us evaluate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ public class MonitorBasedArrayBlockingQueue<E> extends AbstractQueue<E>

/** The queued items */
final E[] items;

/** items index for next take, poll or remove */
int takeIndex;

/** items index for next put, offer, or add. */
int putIndex;

/** Number of items in the queue */
private int count;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public void testComplexBuilder() {

public void testBuilderAddHandlesNullsCorrectly() {
{
ImmutableSet.Builder<String> builder = this.<String>builder();
ImmutableSet.Builder<String> builder = this.<String>builder();
assertThrows(NullPointerException.class, () -> builder.add((String) null));
}

Expand Down Expand Up @@ -421,7 +421,7 @@ public void testBuilderAddHandlesNullsCorrectly() {

public void testBuilderAddAllHandlesNullsCorrectly() {
{
ImmutableSet.Builder<String> builder = this.<String>builder();
ImmutableSet.Builder<String> builder = this.<String>builder();
assertThrows(NullPointerException.class, () -> builder.addAll((Iterable<String>) null));
}

Expand All @@ -432,13 +432,13 @@ public void testBuilderAddAllHandlesNullsCorrectly() {

{
ImmutableSet.Builder<String> builder = this.<String>builder();
List<@Nullable String> listWithNulls = asList("a", null, "b");
List<@Nullable String> listWithNulls = asList("a", null, "b");
assertThrows(NullPointerException.class, () -> builder.addAll((List<String>) listWithNulls));
}

{
ImmutableSet.Builder<String> builder = this.<String>builder();
Iterable<@Nullable String> iterableWithNulls = MinimalIterable.of("a", null, "b");
Iterable<@Nullable String> iterableWithNulls = MinimalIterable.of("a", null, "b");
assertThrows(
NullPointerException.class, () -> builder.addAll((Iterable<String>) iterableWithNulls));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.common.collect;


import com.google.common.annotations.GwtCompatible;
import java.util.Map;
import org.jspecify.annotations.NullMarked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ public void testBuilderAddHandlesNullsCorrectly() {

public void testBuilderAddAllHandlesNullsCorrectly() {
{
ImmutableList.Builder<String> builder = ImmutableList.builder();
ImmutableList.Builder<String> builder = ImmutableList.builder();
assertThrows(NullPointerException.class, () -> builder.addAll((Iterable<String>) null));
}

Expand All @@ -578,21 +578,21 @@ public void testBuilderAddAllHandlesNullsCorrectly() {

{
ImmutableList.Builder<String> builder = ImmutableList.builder();
List<@Nullable String> listWithNulls = asList("a", null, "b");
List<@Nullable String> listWithNulls = asList("a", null, "b");
assertThrows(NullPointerException.class, () -> builder.addAll((List<String>) listWithNulls));
}

{
ImmutableList.Builder<String> builder = ImmutableList.builder();
Iterator<@Nullable String> iteratorWithNulls =
Arrays.<@Nullable String>asList("a", null, "b").iterator();
Iterator<@Nullable String> iteratorWithNulls =
Arrays.<@Nullable String>asList("a", null, "b").iterator();
assertThrows(
NullPointerException.class, () -> builder.addAll((Iterator<String>) iteratorWithNulls));
}

{
ImmutableList.Builder<String> builder = ImmutableList.builder();
Iterable<@Nullable String> iterableWithNulls = MinimalIterable.of("a", null, "b");
Iterable<@Nullable String> iterableWithNulls = MinimalIterable.of("a", null, "b");
assertThrows(
NullPointerException.class, () -> builder.addAll((Iterable<String>) iterableWithNulls));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,9 @@ public void testBuilder_keepingLast_thenOrThrow() {
// being true.
Pattern pattern = Pattern.compile("Multiple entries with same key: four=(.*) and four=(.*)");
assertThat(expected).hasMessageThat().matches(pattern);
Matcher matcher = pattern.matcher(expected.getMessage());
assertThat(matcher.matches()).isTrue();
assertThat(matcher.group(1)).isNotEqualTo(matcher.group(2));
Matcher matcher = pattern.matcher(expected.getMessage());
assertThat(matcher.matches()).isTrue();
assertThat(matcher.group(1)).isNotEqualTo(matcher.group(2));
}

public void testOf() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,20 +404,20 @@ public void testBuilderAddHandlesNullsCorrectly() {

public void testBuilderAddAllHandlesNullsCorrectly() {
{
ImmutableMultiset.Builder<String> builder = ImmutableMultiset.builder();
ImmutableMultiset.Builder<String> builder = ImmutableMultiset.builder();
assertThrows(NullPointerException.class, () -> builder.addAll((Collection<String>) null));
}

{
ImmutableMultiset.Builder<String> builder = ImmutableMultiset.builder();
List<@Nullable String> listWithNulls = asList("a", null, "b");
List<@Nullable String> listWithNulls = asList("a", null, "b");
assertThrows(NullPointerException.class, () -> builder.addAll((List<String>) listWithNulls));
}

{
ImmutableMultiset.Builder<String> builder = ImmutableMultiset.builder();
Multiset<@Nullable String> multisetWithNull =
LinkedHashMultiset.create(Arrays.<@Nullable String>asList("a", null, "b"));
Multiset<@Nullable String> multisetWithNull =
LinkedHashMultiset.create(Arrays.<@Nullable String>asList("a", null, "b"));
assertThrows(
NullPointerException.class, () -> builder.addAll((Multiset<String>) multisetWithNull));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,9 @@ public void testGetLast_withDefault_multiple() {
* need to prove that it isn't called.
*/
private static class DiesOnIteratorArrayList extends ArrayList<String> {
/** @throws UnsupportedOperationException all the time */
/**
* @throws UnsupportedOperationException all the time
*/
@Override
public Iterator<String> iterator() {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1412,12 +1412,12 @@ public void testUnmodifiableNavigableMap() {
iterator.remove();
});
{
Entry<Integer, String> entry = entries.iterator().next();
Entry<Integer, String> entry = entries.iterator().next();
assertThrows(UnsupportedOperationException.class, () -> entry.setValue("four"));
}
{
Entry<Integer, String> entry = unmod.lowerEntry(1);
assertNull(entry);
assertNull(entry);
}
{
Entry<Integer, String> entry = unmod.floorEntry(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public void testFalsePositivesForNextEscapedIndex() {
protected char @Nullable [] escape(int cp) {
return ('a' <= cp && cp <= 'z') ? new char[] {Character.toUpperCase((char) cp)} : null;
}

// Inefficient implementation that defines all letters as escapable.
@Override
protected int nextEscapeIndex(CharSequence csq, int index, int end) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void assertNodeNotInGraphErrorMessage(Throwable throwable) {
assertThat(throwable).hasMessageThat().startsWith(NODE_STRING);
assertThat(throwable).hasMessageThat().contains(ERROR_ELEMENT_NOT_IN_GRAPH);
}

static void assertEdgeNotInGraphErrorMessage(Throwable throwable) {
assertThat(throwable).hasMessageThat().startsWith(EDGE_STRING);
assertThat(throwable).hasMessageThat().contains(ERROR_ELEMENT_NOT_IN_GRAPH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public void testFloorPowerOfTwoZero() {
@GwtIncompatible // BigIntegerMath // TODO(cpovirk): GWT-enable BigIntegerMath
public void testConstantMaxPowerOfSqrt2Unsigned() {
assertEquals(
/*expected=*/ BigIntegerMath.sqrt(BigInteger.ZERO.setBit(2 * Integer.SIZE - 1), FLOOR)
/* expected= */ BigIntegerMath.sqrt(BigInteger.ZERO.setBit(2 * Integer.SIZE - 1), FLOOR)
.intValue(),
/*actual=*/ IntMath.MAX_POWER_OF_SQRT2_UNSIGNED);
/* actual= */ IntMath.MAX_POWER_OF_SQRT2_UNSIGNED);
}

@GwtIncompatible // pow()
Expand Down Expand Up @@ -148,8 +148,8 @@ public void testConstantsBiggestBinomials() {
@GwtIncompatible // sqrt
public void testPowersSqrtMaxInt() {
assertEquals(
/*expected=*/ IntMath.sqrt(Integer.MAX_VALUE, FLOOR),
/*actual=*/ IntMath.FLOOR_SQRT_MAX_INT);
/* expected= */ IntMath.sqrt(Integer.MAX_VALUE, FLOOR),
/* actual= */ IntMath.FLOOR_SQRT_MAX_INT);
}

@AndroidIncompatible // presumably slow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public void testFloorPowerOfTwoZero() {
@GwtIncompatible // TODO
public void testConstantMaxPowerOfSqrt2Unsigned() {
assertEquals(
/*expected=*/ BigIntegerMath.sqrt(BigInteger.ZERO.setBit(2 * Long.SIZE - 1), FLOOR)
/* expected= */ BigIntegerMath.sqrt(BigInteger.ZERO.setBit(2 * Long.SIZE - 1), FLOOR)
.longValue(),
/*actual=*/ LongMath.MAX_POWER_OF_SQRT2_UNSIGNED);
/* actual= */ LongMath.MAX_POWER_OF_SQRT2_UNSIGNED);
}

@GwtIncompatible // BigIntegerMath // TODO(cpovirk): GWT-enable BigIntegerMath
Expand Down Expand Up @@ -137,8 +137,8 @@ public void testConstantsHalfPowersOf10() {
@GwtIncompatible // TODO
public void testConstantsSqrtMaxLong() {
assertEquals(
/*expected=*/ LongMath.sqrt(Long.MAX_VALUE, FLOOR),
/*actual=*/ LongMath.FLOOR_SQRT_MAX_LONG);
/* expected= */ LongMath.sqrt(Long.MAX_VALUE, FLOOR),
/* actual= */ LongMath.FLOOR_SQRT_MAX_LONG);
}

@GwtIncompatible // TODO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public void testValueOfLong() {
}
}


public void testValueOfBigInteger() {
BigInteger min = BigInteger.ZERO;
BigInteger max = UnsignedLong.MAX_VALUE.bigIntegerValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void testImmediateCancelledFutureStack() throws Exception {
assertThrows(CancellationException.class, () -> CallerClass2.get(future));
List<StackTraceElement> stackTrace = ImmutableList.copyOf(expected.getStackTrace());
assertFalse(Iterables.any(stackTrace, hasClassName(CallerClass1.class)));
assertTrue(Iterables.any(stackTrace, hasClassName(CallerClass2.class)));
assertTrue(Iterables.any(stackTrace, hasClassName(CallerClass2.class)));

// See AbstractFutureCancellationCauseTest for how to set causes.
assertThat(expected).hasCauseThat().isNull();
Expand Down Expand Up @@ -2253,7 +2253,7 @@ public void testAllAsList_logging_error() throws Exception {
() -> getDone(allAsList(immediateFailedFuture(new SomeError()))));
assertThat(expected).hasCauseThat().isInstanceOf(SomeError.class);
List<LogRecord> logged = aggregateFutureLogHandler.getStoredLogRecords();
assertThat(logged).hasSize(1); // errors are always logged
assertThat(logged).hasSize(1); // errors are always logged
assertThat(logged.get(0).getThrown()).isInstanceOf(SomeError.class);
}

Expand All @@ -2269,8 +2269,8 @@ public void testAllAsList_logging_multipleExceptions_alreadyDone() throws Except
immediateFailedFuture(new MyException()))));
assertThat(expected).hasCauseThat().isInstanceOf(MyException.class);
List<LogRecord> logged = aggregateFutureLogHandler.getStoredLogRecords();
assertThat(logged).hasSize(1); // the second failure is logged
assertThat(logged.get(0).getThrown()).isInstanceOf(MyException.class);
assertThat(logged).hasSize(1); // the second failure is logged
assertThat(logged.get(0).getThrown()).isInstanceOf(MyException.class);
}

/** All as list will log extra exceptions that occur later. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.common.util.concurrent;


import com.google.common.annotations.GwtCompatible;
import com.google.common.util.concurrent.AbstractFuture.TrustedFuture;
import org.jspecify.annotations.NullUnmarked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.common.util.concurrent;


import com.google.common.annotations.GwtCompatible;
import com.google.common.util.concurrent.AbstractFuture.TrustedFuture;
import org.jspecify.annotations.NullUnmarked;
Expand Down
Loading

0 comments on commit 176cf74

Please sign in to comment.