The following issues were found
guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java
48 issues
Line: 18
/** Unit test for {@link AtomicDouble}. */
public class AtomicDoubleTest extends JSR166TestCase {
private static final double[] VALUES = {
Double.NEGATIVE_INFINITY,
-Double.MAX_VALUE,
(double) Long.MIN_VALUE,
Reported by PMD.
Line: 43
/** The notion of equality used by AtomicDouble */
static boolean bitEquals(double x, double y) {
return Double.doubleToRawLongBits(x) == Double.doubleToRawLongBits(y);
}
static void assertBitEquals(double x, double y) {
assertEquals(Double.doubleToRawLongBits(x), Double.doubleToRawLongBits(y));
}
Reported by PMD.
Line: 51
}
/** constructor initializes to given value */
public void testConstructor() {
for (double x : VALUES) {
AtomicDouble a = new AtomicDouble(x);
assertBitEquals(x, a.get());
}
}
Reported by PMD.
Line: 53
/** constructor initializes to given value */
public void testConstructor() {
for (double x : VALUES) {
AtomicDouble a = new AtomicDouble(x);
assertBitEquals(x, a.get());
}
}
/** default constructed initializes to zero */
Reported by PMD.
Line: 59
}
/** default constructed initializes to zero */
public void testConstructor2() {
AtomicDouble a = new AtomicDouble();
assertBitEquals(0.0, a.get());
}
/** get returns the last value set */
Reported by PMD.
Line: 65
}
/** get returns the last value set */
public void testGetSet() {
AtomicDouble at = new AtomicDouble(1.0);
assertBitEquals(1.0, at.get());
for (double x : VALUES) {
at.set(x);
assertBitEquals(x, at.get());
Reported by PMD.
Line: 65
}
/** get returns the last value set */
public void testGetSet() {
AtomicDouble at = new AtomicDouble(1.0);
assertBitEquals(1.0, at.get());
for (double x : VALUES) {
at.set(x);
assertBitEquals(x, at.get());
Reported by PMD.
Line: 75
}
/** get returns the last value lazySet in same thread */
public void testGetLazySet() {
AtomicDouble at = new AtomicDouble(1.0);
assertBitEquals(1.0, at.get());
for (double x : VALUES) {
at.lazySet(x);
assertBitEquals(x, at.get());
Reported by PMD.
Line: 75
}
/** get returns the last value lazySet in same thread */
public void testGetLazySet() {
AtomicDouble at = new AtomicDouble(1.0);
assertBitEquals(1.0, at.get());
for (double x : VALUES) {
at.lazySet(x);
assertBitEquals(x, at.get());
Reported by PMD.
Line: 85
}
/** compareAndSet succeeds in changing value if equal to expected else fails */
public void testCompareAndSet() {
double prev = Math.E;
double unused = Math.E + Math.PI;
AtomicDouble at = new AtomicDouble(prev);
for (double x : VALUES) {
assertBitEquals(prev, at.get());
Reported by PMD.
android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java
48 issues
Line: 34
*/
public class AbstractLoadingCacheTest extends TestCase {
public void testGetUnchecked_checked() {
final Exception cause = new Exception();
final AtomicReference<Object> valueRef = new AtomicReference<>();
LoadingCache<Object, Object> cache =
new AbstractLoadingCache<Object, Object>() {
@Override
Reported by PMD.
Line: 34
*/
public class AbstractLoadingCacheTest extends TestCase {
public void testGetUnchecked_checked() {
final Exception cause = new Exception();
final AtomicReference<Object> valueRef = new AtomicReference<>();
LoadingCache<Object, Object> cache =
new AbstractLoadingCache<Object, Object>() {
@Override
Reported by PMD.
Line: 56
try {
cache.getUnchecked(new Object());
fail();
} catch (UncheckedExecutionException expected) {
assertThat(expected).hasCauseThat().isEqualTo(cause);
}
Object newValue = new Object();
Reported by PMD.
Line: 58
cache.getUnchecked(new Object());
fail();
} catch (UncheckedExecutionException expected) {
assertThat(expected).hasCauseThat().isEqualTo(cause);
}
Object newValue = new Object();
valueRef.set(newValue);
assertSame(newValue, cache.getUnchecked(new Object()));
Reported by PMD.
Line: 58
cache.getUnchecked(new Object());
fail();
} catch (UncheckedExecutionException expected) {
assertThat(expected).hasCauseThat().isEqualTo(cause);
}
Object newValue = new Object();
valueRef.set(newValue);
assertSame(newValue, cache.getUnchecked(new Object()));
Reported by PMD.
Line: 63
Object newValue = new Object();
valueRef.set(newValue);
assertSame(newValue, cache.getUnchecked(new Object()));
}
public void testGetUnchecked_unchecked() {
final RuntimeException cause = new RuntimeException();
final AtomicReference<Object> valueRef = new AtomicReference<>();
Reported by PMD.
Line: 66
assertSame(newValue, cache.getUnchecked(new Object()));
}
public void testGetUnchecked_unchecked() {
final RuntimeException cause = new RuntimeException();
final AtomicReference<Object> valueRef = new AtomicReference<>();
LoadingCache<Object, Object> cache =
new AbstractLoadingCache<Object, Object>() {
@Override
Reported by PMD.
Line: 66
assertSame(newValue, cache.getUnchecked(new Object()));
}
public void testGetUnchecked_unchecked() {
final RuntimeException cause = new RuntimeException();
final AtomicReference<Object> valueRef = new AtomicReference<>();
LoadingCache<Object, Object> cache =
new AbstractLoadingCache<Object, Object>() {
@Override
Reported by PMD.
Line: 88
try {
cache.getUnchecked(new Object());
fail();
} catch (UncheckedExecutionException expected) {
assertThat(expected).hasCauseThat().isEqualTo(cause);
}
Object newValue = new Object();
Reported by PMD.
Line: 90
cache.getUnchecked(new Object());
fail();
} catch (UncheckedExecutionException expected) {
assertThat(expected).hasCauseThat().isEqualTo(cause);
}
Object newValue = new Object();
valueRef.set(newValue);
assertSame(newValue, cache.getUnchecked(new Object()));
Reported by PMD.
android/guava/src/com/google/common/math/IntMath.java
48 issues
Line: 107
static int lessThanBranchFree(int x, int y) {
// The double negation is optimized away by normal Java, but is necessary for GWT
// to make sure bit twiddling works as expected.
return ~~(x - y) >>> (Integer.SIZE - 1);
}
/**
* Returns the base-2 logarithm of {@code x}, rounded according to the specified rounding mode.
*
Reported by PMD.
Line: 228
* @throws IllegalArgumentException if {@code k < 0}
*/
@GwtIncompatible // failing tests
public static int pow(int b, int k) {
checkNonNegative("exponent", k);
switch (b) {
case 0:
return (k == 0) ? 1 : 0;
case 1:
Reported by PMD.
Line: 228
* @throws IllegalArgumentException if {@code k < 0}
*/
@GwtIncompatible // failing tests
public static int pow(int b, int k) {
checkNonNegative("exponent", k);
switch (b) {
case 0:
return (k == 0) ? 1 : 0;
case 1:
Reported by PMD.
Line: 405
*
* @throws IllegalArgumentException if {@code a < 0} or {@code b < 0}
*/
public static int gcd(int a, int b) {
/*
* The reason we require both arguments to be >= 0 is because otherwise, what do you return on
* gcd(0, Integer.MIN_VALUE)? BigInteger.gcd would return positive 2^31, but positive 2^31 isn't
* an int.
*/
Reported by PMD.
Line: 405
*
* @throws IllegalArgumentException if {@code a < 0} or {@code b < 0}
*/
public static int gcd(int a, int b) {
/*
* The reason we require both arguments to be >= 0 is because otherwise, what do you return on
* gcd(0, Integer.MIN_VALUE)? BigInteger.gcd would return positive 2^31, but positive 2^31 isn't
* an int.
*/
Reported by PMD.
Line: 405
*
* @throws IllegalArgumentException if {@code a < 0} or {@code b < 0}
*/
public static int gcd(int a, int b) {
/*
* The reason we require both arguments to be >= 0 is because otherwise, what do you return on
* gcd(0, Integer.MIN_VALUE)? BigInteger.gcd would return positive 2^31, but positive 2^31 isn't
* an int.
*/
Reported by PMD.
Line: 405
*
* @throws IllegalArgumentException if {@code a < 0} or {@code b < 0}
*/
public static int gcd(int a, int b) {
/*
* The reason we require both arguments to be >= 0 is because otherwise, what do you return on
* gcd(0, Integer.MIN_VALUE)? BigInteger.gcd would return positive 2^31, but positive 2^31 isn't
* an int.
*/
Reported by PMD.
Line: 405
*
* @throws IllegalArgumentException if {@code a < 0} or {@code b < 0}
*/
public static int gcd(int a, int b) {
/*
* The reason we require both arguments to be >= 0 is because otherwise, what do you return on
* gcd(0, Integer.MIN_VALUE)? BigInteger.gcd would return positive 2^31, but positive 2^31 isn't
* an int.
*/
Reported by PMD.
Line: 491
* @throws ArithmeticException if {@code b} to the {@code k}th power overflows in signed {@code
* int} arithmetic
*/
public static int checkedPow(int b, int k) {
checkNonNegative("exponent", k);
switch (b) {
case 0:
return (k == 0) ? 1 : 0;
case 1:
Reported by PMD.
Line: 491
* @throws ArithmeticException if {@code b} to the {@code k}th power overflows in signed {@code
* int} arithmetic
*/
public static int checkedPow(int b, int k) {
checkNonNegative("exponent", k);
switch (b) {
case 0:
return (k == 0) ? 1 : 0;
case 1:
Reported by PMD.
guava/src/com/google/common/collect/LinkedHashMultimap.java
48 issues
Line: 89
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public final class LinkedHashMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends LinkedHashMultimapGwtSerializationDependencies<K, V> {
/** Creates a new, empty {@code LinkedHashMultimap} with the default initial capacities. */
public static <K extends @Nullable Object, V extends @Nullable Object>
LinkedHashMultimap<K, V> create() {
return new LinkedHashMultimap<>(DEFAULT_KEY_CAPACITY, DEFAULT_VALUE_SET_CAPACITY);
Reported by PMD.
Line: 122
*/
public static <K extends @Nullable Object, V extends @Nullable Object>
LinkedHashMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
LinkedHashMultimap<K, V> result = create(multimap.keySet().size(), DEFAULT_VALUE_SET_CAPACITY);
result.putAll(multimap);
return result;
}
private interface ValueSetLink<K extends @Nullable Object, V extends @Nullable Object> {
Reported by PMD.
Line: 123
public static <K extends @Nullable Object, V extends @Nullable Object>
LinkedHashMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
LinkedHashMultimap<K, V> result = create(multimap.keySet().size(), DEFAULT_VALUE_SET_CAPACITY);
result.putAll(multimap);
return result;
}
private interface ValueSetLink<K extends @Nullable Object, V extends @Nullable Object> {
ValueSetLink<K, V> getPredecessorInValueSet();
Reported by PMD.
Line: 166
* whole.
*/
@VisibleForTesting
static final class ValueEntry<K extends @Nullable Object, V extends @Nullable Object>
extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
final int smearedValueHash;
@CheckForNull ValueEntry<K, V> nextInValueBucket;
/*
Reported by PMD.
Line: 166
* whole.
*/
@VisibleForTesting
static final class ValueEntry<K extends @Nullable Object, V extends @Nullable Object>
extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
final int smearedValueHash;
@CheckForNull ValueEntry<K, V> nextInValueBucket;
/*
Reported by PMD.
Line: 168
@VisibleForTesting
static final class ValueEntry<K extends @Nullable Object, V extends @Nullable Object>
extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
final int smearedValueHash;
@CheckForNull ValueEntry<K, V> nextInValueBucket;
/*
* The *InValueSet and *InMultimap fields below are null after construction, but we almost
* always call succeedsIn*() to initialize them immediately thereafter.
Reported by PMD.
Line: 170
extends ImmutableEntry<K, V> implements ValueSetLink<K, V> {
final int smearedValueHash;
@CheckForNull ValueEntry<K, V> nextInValueBucket;
/*
* The *InValueSet and *InMultimap fields below are null after construction, but we almost
* always call succeedsIn*() to initialize them immediately thereafter.
*
* The exception is the *InValueSet fields of multimapHeaderEntry, which are never set. (That
Reported by PMD.
Line: 262
private static final int DEFAULT_VALUE_SET_CAPACITY = 2;
@VisibleForTesting static final double VALUE_SET_LOAD_FACTOR = 1.0;
@VisibleForTesting transient int valueSetCapacity = DEFAULT_VALUE_SET_CAPACITY;
private transient ValueEntry<K, V> multimapHeaderEntry;
private LinkedHashMultimap(int keyCapacity, int valueSetCapacity) {
super(Platform.<K, Collection<V>>newLinkedHashMapWithExpectedSize(keyCapacity));
checkNonnegative(valueSetCapacity, "expectedValuesPerKey");
Reported by PMD.
Line: 325
* time the entry is returned by a method call to the collection or its iterator.
*/
@Override
public Set<Entry<K, V>> entries() {
return super.entries();
}
/**
* Returns a view collection of all <i>distinct</i> keys contained in this multimap. Note that the
Reported by PMD.
Line: 340
* <i>adding</i> to the returned set is not possible.
*/
@Override
public Set<K> keySet() {
return super.keySet();
}
/**
* Returns a collection of all values in the multimap. Changes to the returned collection will
Reported by PMD.
guava-tests/test/com/google/common/io/ResourcesTest.java
47 issues
Line: 43
* @author Chris Nokleberg
*/
public class ResourcesTest extends IoTestCase {
public static TestSuite suite() {
TestSuite suite = new TestSuite();
suite.addTest(
ByteSourceTester.tests(
Reported by PMD.
Line: 59
return suite;
}
public void testToString() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(I18N, Resources.toString(resource, Charsets.UTF_8));
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
Reported by PMD.
Line: 59
return suite;
}
public void testToString() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(I18N, Resources.toString(resource, Charsets.UTF_8));
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
Reported by PMD.
Line: 60
}
public void testToString() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(I18N, Resources.toString(resource, Charsets.UTF_8));
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
public void testToToByteArray() throws IOException {
Reported by PMD.
Line: 60
}
public void testToString() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(I18N, Resources.toString(resource, Charsets.UTF_8));
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
public void testToToByteArray() throws IOException {
Reported by PMD.
Line: 62
public void testToString() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(I18N, Resources.toString(resource, Charsets.UTF_8));
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
public void testToToByteArray() throws IOException {
byte[] data = Resources.toByteArray(classfile(Resources.class));
assertEquals(0xCAFEBABE, new DataInputStream(new ByteArrayInputStream(data)).readInt());
Reported by PMD.
Line: 65
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
public void testToToByteArray() throws IOException {
byte[] data = Resources.toByteArray(classfile(Resources.class));
assertEquals(0xCAFEBABE, new DataInputStream(new ByteArrayInputStream(data)).readInt());
}
public void testReadLines() throws IOException {
Reported by PMD.
Line: 70
assertEquals(0xCAFEBABE, new DataInputStream(new ByteArrayInputStream(data)).readInt());
}
public void testReadLines() throws IOException {
// TODO(chrisn): Check in a better resource
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(ImmutableList.of(I18N), Resources.readLines(resource, Charsets.UTF_8));
}
Reported by PMD.
Line: 72
public void testReadLines() throws IOException {
// TODO(chrisn): Check in a better resource
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(ImmutableList.of(I18N), Resources.readLines(resource, Charsets.UTF_8));
}
public void testReadLines_withLineProcessor() throws IOException {
URL resource = getClass().getResource("testdata/alice_in_wonderland.txt");
Reported by PMD.
Line: 76
assertEquals(ImmutableList.of(I18N), Resources.readLines(resource, Charsets.UTF_8));
}
public void testReadLines_withLineProcessor() throws IOException {
URL resource = getClass().getResource("testdata/alice_in_wonderland.txt");
LineProcessor<List<String>> collectAndLowercaseAndTrim =
new LineProcessor<List<String>>() {
List<String> collector = new ArrayList<>();
Reported by PMD.
android/guava-tests/test/com/google/common/io/ResourcesTest.java
47 issues
Line: 43
* @author Chris Nokleberg
*/
public class ResourcesTest extends IoTestCase {
public static TestSuite suite() {
TestSuite suite = new TestSuite();
suite.addTest(
ByteSourceTester.tests(
Reported by PMD.
Line: 59
return suite;
}
public void testToString() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(I18N, Resources.toString(resource, Charsets.UTF_8));
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
Reported by PMD.
Line: 59
return suite;
}
public void testToString() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(I18N, Resources.toString(resource, Charsets.UTF_8));
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
Reported by PMD.
Line: 60
}
public void testToString() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(I18N, Resources.toString(resource, Charsets.UTF_8));
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
public void testToToByteArray() throws IOException {
Reported by PMD.
Line: 60
}
public void testToString() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(I18N, Resources.toString(resource, Charsets.UTF_8));
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
public void testToToByteArray() throws IOException {
Reported by PMD.
Line: 62
public void testToString() throws IOException {
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(I18N, Resources.toString(resource, Charsets.UTF_8));
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
public void testToToByteArray() throws IOException {
byte[] data = Resources.toByteArray(classfile(Resources.class));
assertEquals(0xCAFEBABE, new DataInputStream(new ByteArrayInputStream(data)).readInt());
Reported by PMD.
Line: 65
assertThat(Resources.toString(resource, Charsets.US_ASCII)).isNotEqualTo(I18N);
}
public void testToToByteArray() throws IOException {
byte[] data = Resources.toByteArray(classfile(Resources.class));
assertEquals(0xCAFEBABE, new DataInputStream(new ByteArrayInputStream(data)).readInt());
}
public void testReadLines() throws IOException {
Reported by PMD.
Line: 70
assertEquals(0xCAFEBABE, new DataInputStream(new ByteArrayInputStream(data)).readInt());
}
public void testReadLines() throws IOException {
// TODO(chrisn): Check in a better resource
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(ImmutableList.of(I18N), Resources.readLines(resource, Charsets.UTF_8));
}
Reported by PMD.
Line: 72
public void testReadLines() throws IOException {
// TODO(chrisn): Check in a better resource
URL resource = getClass().getResource("testdata/i18n.txt");
assertEquals(ImmutableList.of(I18N), Resources.readLines(resource, Charsets.UTF_8));
}
public void testReadLines_withLineProcessor() throws IOException {
URL resource = getClass().getResource("testdata/alice_in_wonderland.txt");
Reported by PMD.
Line: 76
assertEquals(ImmutableList.of(I18N), Resources.readLines(resource, Charsets.UTF_8));
}
public void testReadLines_withLineProcessor() throws IOException {
URL resource = getClass().getResource("testdata/alice_in_wonderland.txt");
LineProcessor<List<String>> collectAndLowercaseAndTrim =
new LineProcessor<List<String>>() {
List<String> collector = new ArrayList<>();
Reported by PMD.
android/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
47 issues
Line: 32
*/
@GwtIncompatible // SerializableTester
public class DiscreteDomainTest extends TestCase {
public void testSerialization() {
reserializeAndAssert(DiscreteDomain.integers());
reserializeAndAssert(DiscreteDomain.longs());
reserializeAndAssert(DiscreteDomain.bigIntegers());
}
Reported by PMD.
Line: 32
*/
@GwtIncompatible // SerializableTester
public class DiscreteDomainTest extends TestCase {
public void testSerialization() {
reserializeAndAssert(DiscreteDomain.integers());
reserializeAndAssert(DiscreteDomain.longs());
reserializeAndAssert(DiscreteDomain.bigIntegers());
}
Reported by PMD.
Line: 38
reserializeAndAssert(DiscreteDomain.bigIntegers());
}
public void testIntegersOffset() {
assertEquals(1, DiscreteDomain.integers().offset(0, 1).intValue());
assertEquals(
Integer.MAX_VALUE,
DiscreteDomain.integers().offset(Integer.MIN_VALUE, (1L << 32) - 1).intValue());
}
Reported by PMD.
Line: 38
reserializeAndAssert(DiscreteDomain.bigIntegers());
}
public void testIntegersOffset() {
assertEquals(1, DiscreteDomain.integers().offset(0, 1).intValue());
assertEquals(
Integer.MAX_VALUE,
DiscreteDomain.integers().offset(Integer.MIN_VALUE, (1L << 32) - 1).intValue());
}
Reported by PMD.
Line: 39
}
public void testIntegersOffset() {
assertEquals(1, DiscreteDomain.integers().offset(0, 1).intValue());
assertEquals(
Integer.MAX_VALUE,
DiscreteDomain.integers().offset(Integer.MIN_VALUE, (1L << 32) - 1).intValue());
}
Reported by PMD.
Line: 39
}
public void testIntegersOffset() {
assertEquals(1, DiscreteDomain.integers().offset(0, 1).intValue());
assertEquals(
Integer.MAX_VALUE,
DiscreteDomain.integers().offset(Integer.MIN_VALUE, (1L << 32) - 1).intValue());
}
Reported by PMD.
Line: 39
}
public void testIntegersOffset() {
assertEquals(1, DiscreteDomain.integers().offset(0, 1).intValue());
assertEquals(
Integer.MAX_VALUE,
DiscreteDomain.integers().offset(Integer.MIN_VALUE, (1L << 32) - 1).intValue());
}
Reported by PMD.
Line: 40
public void testIntegersOffset() {
assertEquals(1, DiscreteDomain.integers().offset(0, 1).intValue());
assertEquals(
Integer.MAX_VALUE,
DiscreteDomain.integers().offset(Integer.MIN_VALUE, (1L << 32) - 1).intValue());
}
public void testIntegersOffsetExceptions() {
Reported by PMD.
Line: 42
assertEquals(1, DiscreteDomain.integers().offset(0, 1).intValue());
assertEquals(
Integer.MAX_VALUE,
DiscreteDomain.integers().offset(Integer.MIN_VALUE, (1L << 32) - 1).intValue());
}
public void testIntegersOffsetExceptions() {
try {
DiscreteDomain.integers().offset(0, -1);
Reported by PMD.
Line: 42
assertEquals(1, DiscreteDomain.integers().offset(0, 1).intValue());
assertEquals(
Integer.MAX_VALUE,
DiscreteDomain.integers().offset(Integer.MIN_VALUE, (1L << 32) - 1).intValue());
}
public void testIntegersOffsetExceptions() {
try {
DiscreteDomain.integers().offset(0, -1);
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/MultimapAsMapTester.java
47 issues
Line: 51
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testAsMapGet() {
for (K key : sampleKeys()) {
List<V> expectedValues = new ArrayList<>();
for (Entry<K, V> entry : getSampleElements()) {
if (entry.getKey().equals(key)) {
expectedValues.add(entry.getValue());
Reported by PMD.
Line: 51
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testAsMapGet() {
for (K key : sampleKeys()) {
List<V> expectedValues = new ArrayList<>();
for (Entry<K, V> entry : getSampleElements()) {
if (entry.getKey().equals(key)) {
expectedValues.add(entry.getValue());
Reported by PMD.
Line: 53
public class MultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testAsMapGet() {
for (K key : sampleKeys()) {
List<V> expectedValues = new ArrayList<>();
for (Entry<K, V> entry : getSampleElements()) {
if (entry.getKey().equals(key)) {
expectedValues.add(entry.getValue());
}
}
Reported by PMD.
Line: 55
for (K key : sampleKeys()) {
List<V> expectedValues = new ArrayList<>();
for (Entry<K, V> entry : getSampleElements()) {
if (entry.getKey().equals(key)) {
expectedValues.add(entry.getValue());
}
}
Collection<V> collection = multimap().asMap().get(key);
Reported by PMD.
Line: 60
}
}
Collection<V> collection = multimap().asMap().get(key);
if (expectedValues.isEmpty()) {
assertNull(collection);
} else {
assertEqualIgnoringOrder(expectedValues, collection);
}
Reported by PMD.
Line: 60
}
}
Collection<V> collection = multimap().asMap().get(key);
if (expectedValues.isEmpty()) {
assertNull(collection);
} else {
assertEqualIgnoringOrder(expectedValues, collection);
}
Reported by PMD.
Line: 69
}
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testAsMapGetNullKeyPresent() {
initMultimapWithNullKey();
assertContentsAnyOrder(multimap().asMap().get(null), getValueForNullKey());
}
Reported by PMD.
Line: 73
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testAsMapGetNullKeyPresent() {
initMultimapWithNullKey();
assertContentsAnyOrder(multimap().asMap().get(null), getValueForNullKey());
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testAsMapGetNullKeyAbsent() {
assertNull(multimap().asMap().get(null));
Reported by PMD.
Line: 73
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testAsMapGetNullKeyPresent() {
initMultimapWithNullKey();
assertContentsAnyOrder(multimap().asMap().get(null), getValueForNullKey());
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testAsMapGetNullKeyAbsent() {
assertNull(multimap().asMap().get(null));
Reported by PMD.
Line: 76
assertContentsAnyOrder(multimap().asMap().get(null), getValueForNullKey());
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testAsMapGetNullKeyAbsent() {
assertNull(multimap().asMap().get(null));
}
@MapFeature.Require(absent = ALLOWS_NULL_KEY_QUERIES)
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MultimapAsMapTester.java
47 issues
Line: 51
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testAsMapGet() {
for (K key : sampleKeys()) {
List<V> expectedValues = new ArrayList<>();
for (Entry<K, V> entry : getSampleElements()) {
if (entry.getKey().equals(key)) {
expectedValues.add(entry.getValue());
Reported by PMD.
Line: 51
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testAsMapGet() {
for (K key : sampleKeys()) {
List<V> expectedValues = new ArrayList<>();
for (Entry<K, V> entry : getSampleElements()) {
if (entry.getKey().equals(key)) {
expectedValues.add(entry.getValue());
Reported by PMD.
Line: 53
public class MultimapAsMapTester<K, V> extends AbstractMultimapTester<K, V, Multimap<K, V>> {
public void testAsMapGet() {
for (K key : sampleKeys()) {
List<V> expectedValues = new ArrayList<>();
for (Entry<K, V> entry : getSampleElements()) {
if (entry.getKey().equals(key)) {
expectedValues.add(entry.getValue());
}
}
Reported by PMD.
Line: 55
for (K key : sampleKeys()) {
List<V> expectedValues = new ArrayList<>();
for (Entry<K, V> entry : getSampleElements()) {
if (entry.getKey().equals(key)) {
expectedValues.add(entry.getValue());
}
}
Collection<V> collection = multimap().asMap().get(key);
Reported by PMD.
Line: 60
}
}
Collection<V> collection = multimap().asMap().get(key);
if (expectedValues.isEmpty()) {
assertNull(collection);
} else {
assertEqualIgnoringOrder(expectedValues, collection);
}
Reported by PMD.
Line: 60
}
}
Collection<V> collection = multimap().asMap().get(key);
if (expectedValues.isEmpty()) {
assertNull(collection);
} else {
assertEqualIgnoringOrder(expectedValues, collection);
}
Reported by PMD.
Line: 69
}
}
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testAsMapGetNullKeyPresent() {
initMultimapWithNullKey();
assertContentsAnyOrder(multimap().asMap().get(null), getValueForNullKey());
}
Reported by PMD.
Line: 73
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testAsMapGetNullKeyPresent() {
initMultimapWithNullKey();
assertContentsAnyOrder(multimap().asMap().get(null), getValueForNullKey());
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testAsMapGetNullKeyAbsent() {
assertNull(multimap().asMap().get(null));
Reported by PMD.
Line: 73
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testAsMapGetNullKeyPresent() {
initMultimapWithNullKey();
assertContentsAnyOrder(multimap().asMap().get(null), getValueForNullKey());
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testAsMapGetNullKeyAbsent() {
assertNull(multimap().asMap().get(null));
Reported by PMD.
Line: 76
assertContentsAnyOrder(multimap().asMap().get(null), getValueForNullKey());
}
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES)
public void testAsMapGetNullKeyAbsent() {
assertNull(multimap().asMap().get(null));
}
@MapFeature.Require(absent = ALLOWS_NULL_KEY_QUERIES)
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java
47 issues
Line: 319
try {
recurse(0);
} catch (RuntimeException e) {
throw new RuntimeException(Arrays.toString(stimuli), e);
}
}
public void testForEachRemaining() {
for (int i = 0; i < expectedElements.size() - 1; i++) {
Reported by PMD.
Line: 44
* @author Chris Povirk
*/
@GwtCompatible
abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
private Stimulus<E, ? super I>[] stimuli;
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
Reported by PMD.
Line: 45
*/
@GwtCompatible
abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
private Stimulus<E, ? super I>[] stimuli;
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
Reported by PMD.
Line: 46
@GwtCompatible
abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
private Stimulus<E, ? super I>[] stimuli;
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
Reported by PMD.
Line: 47
abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
private Stimulus<E, ? super I>[] stimuli;
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
/**
Reported by PMD.
Line: 48
private Stimulus<E, ? super I>[] stimuli;
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
/**
* Meta-exception thrown by {@link AbstractIteratorTester.MultiExceptionListIterator} instead of
Reported by PMD.
Line: 49
private final Iterator<E> elementsToInsert;
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
/**
* Meta-exception thrown by {@link AbstractIteratorTester.MultiExceptionListIterator} instead of
* throwing any particular exception type.
Reported by PMD.
Line: 50
private final Set<IteratorFeature> features;
private final List<E> expectedElements;
private final int startIndex;
private final KnownOrder knownOrder;
/**
* Meta-exception thrown by {@link AbstractIteratorTester.MultiExceptionListIterator} instead of
* throwing any particular exception type.
*/
Reported by PMD.
Line: 97
if (!isPermitted(exception)) {
String message =
"Exception "
+ exception.getClass().getSimpleName()
+ " was thrown; expected "
+ getMessage();
Helpers.fail(exception, message);
}
}
Reported by PMD.
Line: 129
* <p>This class is accessible but not supported in GWT as it references {@link
* PermittedMetaException}.
*/
protected final class MultiExceptionListIterator implements ListIterator<E> {
// TODO: track seen elements when order isn't guaranteed
// TODO: verify contents afterward
// TODO: something shiny and new instead of Stack
// TODO: test whether null is supported (create a Feature)
/**
Reported by PMD.