The following issues were found
android/guava-tests/test/com/google/common/math/MathPreconditionsTest.java
125 issues
Line: 17
* limitations under the License.
*/
package com.google.common.math;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.annotations.GwtCompatible;
import java.math.BigInteger;
Reported by PMD.
Line: 32
* @author Ben Yu
*/
@GwtCompatible
public class MathPreconditionsTest extends TestCase {
public void testCheckPositive_zeroInt() {
try {
MathPreconditions.checkPositive("int", 0);
fail();
Reported by PMD.
Line: 32
* @author Ben Yu
*/
@GwtCompatible
public class MathPreconditionsTest extends TestCase {
public void testCheckPositive_zeroInt() {
try {
MathPreconditions.checkPositive("int", 0);
fail();
Reported by PMD.
Line: 34
@GwtCompatible
public class MathPreconditionsTest extends TestCase {
public void testCheckPositive_zeroInt() {
try {
MathPreconditions.checkPositive("int", 0);
fail();
} catch (IllegalArgumentException expected) {
}
Reported by PMD.
Line: 36
public void testCheckPositive_zeroInt() {
try {
MathPreconditions.checkPositive("int", 0);
fail();
} catch (IllegalArgumentException expected) {
}
}
Reported by PMD.
Line: 37
public void testCheckPositive_zeroInt() {
try {
MathPreconditions.checkPositive("int", 0);
fail();
} catch (IllegalArgumentException expected) {
}
}
public void testCheckPositive_maxInt() {
Reported by PMD.
Line: 37
public void testCheckPositive_zeroInt() {
try {
MathPreconditions.checkPositive("int", 0);
fail();
} catch (IllegalArgumentException expected) {
}
}
public void testCheckPositive_maxInt() {
Reported by PMD.
Line: 42
}
}
public void testCheckPositive_maxInt() {
MathPreconditions.checkPositive("int", Integer.MAX_VALUE);
}
public void testCheckPositive_minInt() {
try {
Reported by PMD.
Line: 42
}
}
public void testCheckPositive_maxInt() {
MathPreconditions.checkPositive("int", Integer.MAX_VALUE);
}
public void testCheckPositive_minInt() {
try {
Reported by PMD.
Line: 46
MathPreconditions.checkPositive("int", Integer.MAX_VALUE);
}
public void testCheckPositive_minInt() {
try {
MathPreconditions.checkPositive("int", Integer.MIN_VALUE);
fail();
} catch (IllegalArgumentException expected) {
}
Reported by PMD.
guava-tests/test/com/google/common/cache/CacheExpirationTest.java
125 issues
Line: 43
* @author mike nonemacher
*/
@SuppressWarnings("deprecation") // tests of deprecated method
public class CacheExpirationTest extends TestCase {
private static final long EXPIRING_TIME = 1000;
private static final int VALUE_PREFIX = 12345;
private static final String KEY_PREFIX = "key prefix:";
Reported by PMD.
Line: 49
private static final int VALUE_PREFIX = 12345;
private static final String KEY_PREFIX = "key prefix:";
public void testExpiration_expireAfterWrite() {
FakeTicker ticker = new FakeTicker();
CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
WatchedCreatorLoader loader = new WatchedCreatorLoader();
LoadingCache<String, Integer> cache =
CacheBuilder.newBuilder()
Reported by PMD.
Line: 49
private static final int VALUE_PREFIX = 12345;
private static final String KEY_PREFIX = "key prefix:";
public void testExpiration_expireAfterWrite() {
FakeTicker ticker = new FakeTicker();
CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
WatchedCreatorLoader loader = new WatchedCreatorLoader();
LoadingCache<String, Integer> cache =
CacheBuilder.newBuilder()
Reported by PMD.
Line: 62
checkExpiration(cache, loader, ticker, removalListener);
}
public void testExpiration_expireAfterAccess() {
FakeTicker ticker = new FakeTicker();
CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
WatchedCreatorLoader loader = new WatchedCreatorLoader();
LoadingCache<String, Integer> cache =
CacheBuilder.newBuilder()
Reported by PMD.
Line: 62
checkExpiration(cache, loader, ticker, removalListener);
}
public void testExpiration_expireAfterAccess() {
FakeTicker ticker = new FakeTicker();
CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
WatchedCreatorLoader loader = new WatchedCreatorLoader();
LoadingCache<String, Integer> cache =
CacheBuilder.newBuilder()
Reported by PMD.
Line: 82
CountingRemovalListener<String, Integer> removalListener) {
for (int i = 0; i < 10; i++) {
assertEquals(Integer.valueOf(VALUE_PREFIX + i), cache.getUnchecked(KEY_PREFIX + i));
}
for (int i = 0; i < 10; i++) {
loader.reset();
assertEquals(Integer.valueOf(VALUE_PREFIX + i), cache.getUnchecked(KEY_PREFIX + i));
Reported by PMD.
Line: 87
for (int i = 0; i < 10; i++) {
loader.reset();
assertEquals(Integer.valueOf(VALUE_PREFIX + i), cache.getUnchecked(KEY_PREFIX + i));
assertFalse("Creator should not have been called @#" + i, loader.wasCalled());
}
CacheTesting.expireEntries((LoadingCache<?, ?>) cache, EXPIRING_TIME, ticker);
Reported by PMD.
Line: 94
CacheTesting.expireEntries((LoadingCache<?, ?>) cache, EXPIRING_TIME, ticker);
assertEquals("Map must be empty by now", 0, cache.size());
assertEquals("Eviction notifications must be received", 10, removalListener.getCount());
CacheTesting.expireEntries((LoadingCache<?, ?>) cache, EXPIRING_TIME, ticker);
// ensure that no new notifications are sent
assertEquals("Eviction notifications must be received", 10, removalListener.getCount());
}
Reported by PMD.
Line: 101
assertEquals("Eviction notifications must be received", 10, removalListener.getCount());
}
public void testExpiringGet_expireAfterWrite() {
FakeTicker ticker = new FakeTicker();
CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
WatchedCreatorLoader loader = new WatchedCreatorLoader();
LoadingCache<String, Integer> cache =
CacheBuilder.newBuilder()
Reported by PMD.
Line: 101
assertEquals("Eviction notifications must be received", 10, removalListener.getCount());
}
public void testExpiringGet_expireAfterWrite() {
FakeTicker ticker = new FakeTicker();
CountingRemovalListener<String, Integer> removalListener = countingRemovalListener();
WatchedCreatorLoader loader = new WatchedCreatorLoader();
LoadingCache<String, Integer> cache =
CacheBuilder.newBuilder()
Reported by PMD.
android/guava-tests/test/com/google/common/collect/EnumBiMapTest.java
123 issues
Line: 51
* @author Jared Levy
*/
@GwtCompatible(emulated = true)
public class EnumBiMapTest extends TestCase {
private enum Currency {
DOLLAR,
FRANC,
PESO,
POUND,
Reported by PMD.
Line: 75
BiMap<Country, Currency> result = EnumBiMap.create(Country.class, Currency.class);
for (Object object : entries) {
Entry<Country, Currency> entry = (Entry<Country, Currency>) object;
result.put(entry.getKey(), entry.getValue());
}
return result;
}
@Override
Reported by PMD.
Line: 75
BiMap<Country, Currency> result = EnumBiMap.create(Country.class, Currency.class);
for (Object object : entries) {
Entry<Country, Currency> entry = (Entry<Country, Currency>) object;
result.put(entry.getKey(), entry.getValue());
}
return result;
}
@Override
Reported by PMD.
Line: 112
}
}
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
BiMapTestSuiteBuilder.using(new EnumBiMapGenerator())
.named("EnumBiMap")
Reported by PMD.
Line: 129
return suite;
}
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
Reported by PMD.
Line: 129
return suite;
}
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
Reported by PMD.
Line: 131
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
Reported by PMD.
Line: 131
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
Reported by PMD.
Line: 132
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
}
Reported by PMD.
Line: 132
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
}
Reported by PMD.
guava-tests/test/com/google/common/math/PairedStatsTest.java
123 issues
Line: 17
* limitations under the License.
*/
package com.google.common.math;
import static com.google.common.math.StatsTesting.ALLOWED_ERROR;
import static com.google.common.math.StatsTesting.ALL_MANY_VALUES;
import static com.google.common.math.StatsTesting.ALL_PAIRED_STATS;
import static com.google.common.math.StatsTesting.CONSTANT_VALUES_PAIRED_STATS;
Reported by PMD.
Line: 66
*
* @author Pete Gillin
*/
public class PairedStatsTest extends TestCase {
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
Reported by PMD.
Line: 68
*/
public class PairedStatsTest extends TestCase {
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
Reported by PMD.
Line: 68
*/
public class PairedStatsTest extends TestCase {
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
Reported by PMD.
Line: 69
public class PairedStatsTest extends TestCase {
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
Reported by PMD.
Line: 70
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
public void testXStats() {
Reported by PMD.
Line: 71
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
public void testXStats() {
assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
Reported by PMD.
Line: 72
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
public void testXStats() {
assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());
Reported by PMD.
Line: 75
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
public void testXStats() {
assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());
assertStatsApproxEqual(TWO_VALUES_STATS, TWO_VALUES_PAIRED_STATS.xStats());
assertStatsApproxEqual(MANY_VALUES_STATS_ITERABLE, MANY_VALUES_PAIRED_STATS.xStats());
}
Reported by PMD.
Line: 75
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
public void testXStats() {
assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());
assertStatsApproxEqual(TWO_VALUES_STATS, TWO_VALUES_PAIRED_STATS.xStats());
assertStatsApproxEqual(MANY_VALUES_STATS_ITERABLE, MANY_VALUES_PAIRED_STATS.xStats());
}
Reported by PMD.
guava-tests/test/com/google/common/collect/EnumBiMapTest.java
123 issues
Line: 51
* @author Jared Levy
*/
@GwtCompatible(emulated = true)
public class EnumBiMapTest extends TestCase {
private enum Currency {
DOLLAR,
FRANC,
PESO,
POUND,
Reported by PMD.
Line: 75
BiMap<Country, Currency> result = EnumBiMap.create(Country.class, Currency.class);
for (Object object : entries) {
Entry<Country, Currency> entry = (Entry<Country, Currency>) object;
result.put(entry.getKey(), entry.getValue());
}
return result;
}
@Override
Reported by PMD.
Line: 75
BiMap<Country, Currency> result = EnumBiMap.create(Country.class, Currency.class);
for (Object object : entries) {
Entry<Country, Currency> entry = (Entry<Country, Currency>) object;
result.put(entry.getKey(), entry.getValue());
}
return result;
}
@Override
Reported by PMD.
Line: 112
}
}
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
BiMapTestSuiteBuilder.using(new EnumBiMapGenerator())
.named("EnumBiMap")
Reported by PMD.
Line: 129
return suite;
}
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
Reported by PMD.
Line: 129
return suite;
}
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
Reported by PMD.
Line: 131
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
Reported by PMD.
Line: 131
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
Reported by PMD.
Line: 132
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
}
Reported by PMD.
Line: 132
public void testCreate() {
EnumBiMap<Currency, Country> bimap = EnumBiMap.create(Currency.class, Country.class);
assertTrue(bimap.isEmpty());
assertEquals("{}", bimap.toString());
assertEquals(HashBiMap.create(), bimap);
bimap.put(Currency.DOLLAR, Country.CANADA);
assertEquals(Country.CANADA, bimap.get(Currency.DOLLAR));
assertEquals(Currency.DOLLAR, bimap.inverse().get(Country.CANADA));
}
Reported by PMD.
android/guava-tests/test/com/google/common/math/PairedStatsTest.java
123 issues
Line: 17
* limitations under the License.
*/
package com.google.common.math;
import static com.google.common.math.StatsTesting.ALLOWED_ERROR;
import static com.google.common.math.StatsTesting.ALL_MANY_VALUES;
import static com.google.common.math.StatsTesting.ALL_PAIRED_STATS;
import static com.google.common.math.StatsTesting.CONSTANT_VALUES_PAIRED_STATS;
Reported by PMD.
Line: 66
*
* @author Pete Gillin
*/
public class PairedStatsTest extends TestCase {
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
Reported by PMD.
Line: 68
*/
public class PairedStatsTest extends TestCase {
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
Reported by PMD.
Line: 68
*/
public class PairedStatsTest extends TestCase {
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
Reported by PMD.
Line: 69
public class PairedStatsTest extends TestCase {
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
Reported by PMD.
Line: 70
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
public void testXStats() {
Reported by PMD.
Line: 71
public void testCount() {
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
public void testXStats() {
assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
Reported by PMD.
Line: 72
assertThat(EMPTY_PAIRED_STATS.count()).isEqualTo(0);
assertThat(ONE_VALUE_PAIRED_STATS.count()).isEqualTo(1);
assertThat(TWO_VALUES_PAIRED_STATS.count()).isEqualTo(2);
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
public void testXStats() {
assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());
Reported by PMD.
Line: 75
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
public void testXStats() {
assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());
assertStatsApproxEqual(TWO_VALUES_STATS, TWO_VALUES_PAIRED_STATS.xStats());
assertStatsApproxEqual(MANY_VALUES_STATS_ITERABLE, MANY_VALUES_PAIRED_STATS.xStats());
}
Reported by PMD.
Line: 75
assertThat(MANY_VALUES_PAIRED_STATS.count()).isEqualTo(MANY_VALUES_COUNT);
}
public void testXStats() {
assertStatsApproxEqual(EMPTY_STATS_ITERABLE, EMPTY_PAIRED_STATS.xStats());
assertStatsApproxEqual(ONE_VALUE_STATS, ONE_VALUE_PAIRED_STATS.xStats());
assertStatsApproxEqual(TWO_VALUES_STATS, TWO_VALUES_PAIRED_STATS.xStats());
assertStatsApproxEqual(MANY_VALUES_STATS_ITERABLE, MANY_VALUES_PAIRED_STATS.xStats());
}
Reported by PMD.
android/guava-tests/test/com/google/common/collect/FilteredCollectionsTest.java
123 issues
Line: 73
abstract C filter(C elements, Predicate<? super Integer> predicate);
public void testIterationOrderPreserved() {
for (List<Integer> contents : SAMPLE_INPUTS) {
C unfiltered = createUnfiltered(contents);
C filtered = filter(unfiltered, EVEN);
Iterator<Integer> filteredItr = filtered.iterator();
Reported by PMD.
Line: 73
abstract C filter(C elements, Predicate<? super Integer> predicate);
public void testIterationOrderPreserved() {
for (List<Integer> contents : SAMPLE_INPUTS) {
C unfiltered = createUnfiltered(contents);
C filtered = filter(unfiltered, EVEN);
Iterator<Integer> filteredItr = filtered.iterator();
Reported by PMD.
Line: 78
C unfiltered = createUnfiltered(contents);
C filtered = filter(unfiltered, EVEN);
Iterator<Integer> filteredItr = filtered.iterator();
for (Integer i : unfiltered) {
if (EVEN.apply(i)) {
assertTrue(filteredItr.hasNext());
assertEquals(i, filteredItr.next());
}
Reported by PMD.
Line: 81
Iterator<Integer> filteredItr = filtered.iterator();
for (Integer i : unfiltered) {
if (EVEN.apply(i)) {
assertTrue(filteredItr.hasNext());
assertEquals(i, filteredItr.next());
}
}
assertFalse(filteredItr.hasNext());
}
Reported by PMD.
Line: 82
for (Integer i : unfiltered) {
if (EVEN.apply(i)) {
assertTrue(filteredItr.hasNext());
assertEquals(i, filteredItr.next());
}
}
assertFalse(filteredItr.hasNext());
}
}
Reported by PMD.
Line: 85
assertEquals(i, filteredItr.next());
}
}
assertFalse(filteredItr.hasNext());
}
}
}
public abstract static class AbstractFilteredCollectionTest<C extends Collection<Integer>>
Reported by PMD.
Line: 93
public abstract static class AbstractFilteredCollectionTest<C extends Collection<Integer>>
extends AbstractFilteredIterableTest<C> {
public void testReadsThroughAdd() {
for (List<Integer> contents : SAMPLE_INPUTS) {
C unfiltered = createUnfiltered(contents);
C filterThenAdd = filter(unfiltered, EVEN);
unfiltered.add(4);
Reported by PMD.
Line: 97
for (List<Integer> contents : SAMPLE_INPUTS) {
C unfiltered = createUnfiltered(contents);
C filterThenAdd = filter(unfiltered, EVEN);
unfiltered.add(4);
List<Integer> target = Lists.newArrayList(contents);
target.add(4);
C addThenFilter = filter(createUnfiltered(target), EVEN);
Reported by PMD.
Line: 100
unfiltered.add(4);
List<Integer> target = Lists.newArrayList(contents);
target.add(4);
C addThenFilter = filter(createUnfiltered(target), EVEN);
assertThat(filterThenAdd).containsExactlyElementsIn(addThenFilter);
}
}
Reported by PMD.
Line: 103
target.add(4);
C addThenFilter = filter(createUnfiltered(target), EVEN);
assertThat(filterThenAdd).containsExactlyElementsIn(addThenFilter);
}
}
public void testAdd() {
for (List<Integer> contents : SAMPLE_INPUTS) {
Reported by PMD.
guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java
123 issues
Line: 168
testSort(new int[] {2, GREATEST, 1, LEAST}, new int[] {LEAST, 1, 2, GREATEST});
}
static void testSort(int[] input, int[] expected) {
input = Arrays.copyOf(input, input.length);
UnsignedInts.sort(input);
assertTrue(Arrays.equals(expected, input));
}
Reported by PMD.
Line: 174
assertTrue(Arrays.equals(expected, input));
}
static void testSort(int[] input, int from, int to, int[] expected) {
input = Arrays.copyOf(input, input.length);
UnsignedInts.sort(input, from, to);
assertTrue(Arrays.equals(expected, input));
}
Reported by PMD.
Line: 196
new int[] {GREATEST - 1, 1, GREATEST - 2, 2}, new int[] {GREATEST - 1, GREATEST - 2, 2, 1});
}
private static void testSortDescending(int[] input, int[] expectedOutput) {
input = Arrays.copyOf(input, input.length);
UnsignedInts.sortDescending(input);
assertTrue(Arrays.equals(expectedOutput, input));
}
Reported by PMD.
Line: 203
}
private static void testSortDescending(
int[] input, int fromIndex, int toIndex, int[] expectedOutput) {
input = Arrays.copyOf(input, input.length);
UnsignedInts.sortDescending(input, fromIndex, toIndex);
assertTrue(Arrays.equals(expectedOutput, input));
}
Reported by PMD.
Line: 35
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class UnsignedIntsTest extends TestCase {
private static final long[] UNSIGNED_INTS = {
0L,
1L,
2L,
3L,
Reported by PMD.
Line: 35
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class UnsignedIntsTest extends TestCase {
private static final long[] UNSIGNED_INTS = {
0L,
1L,
2L,
3L,
Reported by PMD.
Line: 53
private static final int LEAST = (int) 0L;
private static final int GREATEST = (int) 0xffffffffL;
public void testCheckedCast() {
for (long value : UNSIGNED_INTS) {
assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
}
assertCastFails(1L << 32);
assertCastFails(-1L);
Reported by PMD.
Line: 53
private static final int LEAST = (int) 0L;
private static final int GREATEST = (int) 0xffffffffL;
public void testCheckedCast() {
for (long value : UNSIGNED_INTS) {
assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
}
assertCastFails(1L << 32);
assertCastFails(-1L);
Reported by PMD.
Line: 55
public void testCheckedCast() {
for (long value : UNSIGNED_INTS) {
assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
}
assertCastFails(1L << 32);
assertCastFails(-1L);
assertCastFails(Long.MAX_VALUE);
assertCastFails(Long.MIN_VALUE);
Reported by PMD.
Line: 68
UnsignedInts.checkedCast(value);
fail("Cast to int should have failed: " + value);
} catch (IllegalArgumentException ex) {
assertThat(ex.getMessage()).contains(String.valueOf(value));
}
}
public void testSaturatedCast() {
for (long value : UNSIGNED_INTS) {
Reported by PMD.
android/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java
123 issues
Line: 168
testSort(new int[] {2, GREATEST, 1, LEAST}, new int[] {LEAST, 1, 2, GREATEST});
}
static void testSort(int[] input, int[] expected) {
input = Arrays.copyOf(input, input.length);
UnsignedInts.sort(input);
assertTrue(Arrays.equals(expected, input));
}
Reported by PMD.
Line: 174
assertTrue(Arrays.equals(expected, input));
}
static void testSort(int[] input, int from, int to, int[] expected) {
input = Arrays.copyOf(input, input.length);
UnsignedInts.sort(input, from, to);
assertTrue(Arrays.equals(expected, input));
}
Reported by PMD.
Line: 196
new int[] {GREATEST - 1, 1, GREATEST - 2, 2}, new int[] {GREATEST - 1, GREATEST - 2, 2, 1});
}
private static void testSortDescending(int[] input, int[] expectedOutput) {
input = Arrays.copyOf(input, input.length);
UnsignedInts.sortDescending(input);
assertTrue(Arrays.equals(expectedOutput, input));
}
Reported by PMD.
Line: 203
}
private static void testSortDescending(
int[] input, int fromIndex, int toIndex, int[] expectedOutput) {
input = Arrays.copyOf(input, input.length);
UnsignedInts.sortDescending(input, fromIndex, toIndex);
assertTrue(Arrays.equals(expectedOutput, input));
}
Reported by PMD.
Line: 35
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class UnsignedIntsTest extends TestCase {
private static final long[] UNSIGNED_INTS = {
0L,
1L,
2L,
3L,
Reported by PMD.
Line: 35
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class UnsignedIntsTest extends TestCase {
private static final long[] UNSIGNED_INTS = {
0L,
1L,
2L,
3L,
Reported by PMD.
Line: 53
private static final int LEAST = (int) 0L;
private static final int GREATEST = (int) 0xffffffffL;
public void testCheckedCast() {
for (long value : UNSIGNED_INTS) {
assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
}
assertCastFails(1L << 32);
assertCastFails(-1L);
Reported by PMD.
Line: 53
private static final int LEAST = (int) 0L;
private static final int GREATEST = (int) 0xffffffffL;
public void testCheckedCast() {
for (long value : UNSIGNED_INTS) {
assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
}
assertCastFails(1L << 32);
assertCastFails(-1L);
Reported by PMD.
Line: 55
public void testCheckedCast() {
for (long value : UNSIGNED_INTS) {
assertEquals(value, UnsignedInts.toLong(UnsignedInts.checkedCast(value)));
}
assertCastFails(1L << 32);
assertCastFails(-1L);
assertCastFails(Long.MAX_VALUE);
assertCastFails(Long.MIN_VALUE);
Reported by PMD.
Line: 68
UnsignedInts.checkedCast(value);
fail("Cast to int should have failed: " + value);
} catch (IllegalArgumentException ex) {
assertThat(ex.getMessage()).contains(String.valueOf(value));
}
}
public void testSaturatedCast() {
for (long value : UNSIGNED_INTS) {
Reported by PMD.
android/guava-tests/test/com/google/common/collect/MapsTransformValuesUnmodifiableIteratorTest.java
122 issues
Line: 37
* @author Jared Levy
*/
@GwtCompatible
public class MapsTransformValuesUnmodifiableIteratorTest extends MapInterfaceTest<String, String> {
// TODO(jlevy): Move shared code of this class and MapsTransformValuesTest
// to a superclass.
public MapsTransformValuesUnmodifiableIteratorTest() {
super(true, true, false /*supportsPut*/, true, true, false);
Reported by PMD.
Line: 46
}
private static class UnmodifiableIteratorMap<K, V> extends ForwardingMap<K, V> {
final Map<K, V> delegate;
UnmodifiableIteratorMap(Map<K, V> delegate) {
this.delegate = delegate;
}
Reported by PMD.
Line: 46
}
private static class UnmodifiableIteratorMap<K, V> extends ForwardingMap<K, V> {
final Map<K, V> delegate;
UnmodifiableIteratorMap(Map<K, V> delegate) {
this.delegate = delegate;
}
Reported by PMD.
Line: 67
@Override
public Iterator<K> iterator() {
return Iterators.unmodifiableIterator(delegate.keySet().iterator());
}
@Override
public boolean removeAll(Collection<?> c) {
return delegate.keySet().removeAll(c);
Reported by PMD.
Line: 72
@Override
public boolean removeAll(Collection<?> c) {
return delegate.keySet().removeAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
return delegate.keySet().retainAll(c);
Reported by PMD.
Line: 77
@Override
public boolean retainAll(Collection<?> c) {
return delegate.keySet().retainAll(c);
}
};
}
@Override
Reported by PMD.
Line: 92
@Override
public Iterator<V> iterator() {
return Iterators.unmodifiableIterator(delegate.values().iterator());
}
@Override
public boolean removeAll(Collection<?> c) {
return delegate.values().removeAll(c);
Reported by PMD.
Line: 97
@Override
public boolean removeAll(Collection<?> c) {
return delegate.values().removeAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
return delegate.values().retainAll(c);
Reported by PMD.
Line: 102
@Override
public boolean retainAll(Collection<?> c) {
return delegate.values().retainAll(c);
}
};
}
@Override
Reported by PMD.
Line: 117
@Override
public Iterator<Entry<K, V>> iterator() {
return Iterators.unmodifiableIterator(delegate.entrySet().iterator());
}
@Override
public boolean removeAll(Collection<?> c) {
return delegate.entrySet().removeAll(c);
Reported by PMD.