The following issues were found
guava-testlib/src/com/google/common/testing/DummyProxy.java
17 issues
Line: 48
*/
final <T> T newProxy(TypeToken<T> interfaceType) {
Set<Class<?>> interfaceClasses = Sets.newLinkedHashSet();
interfaceClasses.addAll(interfaceType.getTypes().interfaces().rawTypes());
// Make the proxy serializable to work with SerializableTester
interfaceClasses.add(Serializable.class);
Object dummy =
Proxy.newProxyInstance(
interfaceClasses.iterator().next().getClassLoader(),
Reported by PMD.
Line: 48
*/
final <T> T newProxy(TypeToken<T> interfaceType) {
Set<Class<?>> interfaceClasses = Sets.newLinkedHashSet();
interfaceClasses.addAll(interfaceType.getTypes().interfaces().rawTypes());
// Make the proxy serializable to work with SerializableTester
interfaceClasses.add(Serializable.class);
Object dummy =
Proxy.newProxyInstance(
interfaceClasses.iterator().next().getClassLoader(),
Reported by PMD.
Line: 48
*/
final <T> T newProxy(TypeToken<T> interfaceType) {
Set<Class<?>> interfaceClasses = Sets.newLinkedHashSet();
interfaceClasses.addAll(interfaceType.getTypes().interfaces().rawTypes());
// Make the proxy serializable to work with SerializableTester
interfaceClasses.add(Serializable.class);
Object dummy =
Proxy.newProxyInstance(
interfaceClasses.iterator().next().getClassLoader(),
Reported by PMD.
Line: 50
Set<Class<?>> interfaceClasses = Sets.newLinkedHashSet();
interfaceClasses.addAll(interfaceType.getTypes().interfaces().rawTypes());
// Make the proxy serializable to work with SerializableTester
interfaceClasses.add(Serializable.class);
Object dummy =
Proxy.newProxyInstance(
interfaceClasses.iterator().next().getClassLoader(),
interfaceClasses.toArray(new Class<?>[interfaceClasses.size()]),
new DummyHandler(interfaceType));
Reported by PMD.
Line: 53
interfaceClasses.add(Serializable.class);
Object dummy =
Proxy.newProxyInstance(
interfaceClasses.iterator().next().getClassLoader(),
interfaceClasses.toArray(new Class<?>[interfaceClasses.size()]),
new DummyHandler(interfaceType));
@SuppressWarnings("unchecked") // interfaceType is T
T result = (T) dummy;
return result;
Reported by PMD.
Line: 53
interfaceClasses.add(Serializable.class);
Object dummy =
Proxy.newProxyInstance(
interfaceClasses.iterator().next().getClassLoader(),
interfaceClasses.toArray(new Class<?>[interfaceClasses.size()]),
new DummyHandler(interfaceType));
@SuppressWarnings("unchecked") // interfaceType is T
T result = (T) dummy;
return result;
Reported by PMD.
Line: 53
interfaceClasses.add(Serializable.class);
Object dummy =
Proxy.newProxyInstance(
interfaceClasses.iterator().next().getClassLoader(),
interfaceClasses.toArray(new Class<?>[interfaceClasses.size()]),
new DummyHandler(interfaceType));
@SuppressWarnings("unchecked") // interfaceType is T
T result = (T) dummy;
return result;
Reported by PMD.
Line: 53
interfaceClasses.add(Serializable.class);
Object dummy =
Proxy.newProxyInstance(
interfaceClasses.iterator().next().getClassLoader(),
interfaceClasses.toArray(new Class<?>[interfaceClasses.size()]),
new DummyHandler(interfaceType));
@SuppressWarnings("unchecked") // interfaceType is T
T result = (T) dummy;
return result;
Reported by PMD.
Line: 54
Object dummy =
Proxy.newProxyInstance(
interfaceClasses.iterator().next().getClassLoader(),
interfaceClasses.toArray(new Class<?>[interfaceClasses.size()]),
new DummyHandler(interfaceType));
@SuppressWarnings("unchecked") // interfaceType is T
T result = (T) dummy;
return result;
}
Reported by PMD.
Line: 54
Object dummy =
Proxy.newProxyInstance(
interfaceClasses.iterator().next().getClassLoader(),
interfaceClasses.toArray(new Class<?>[interfaceClasses.size()]),
new DummyHandler(interfaceType));
@SuppressWarnings("unchecked") // interfaceType is T
T result = (T) dummy;
return result;
}
Reported by PMD.
guava-testlib/src/com/google/common/testing/RelationshipTester.java
17 issues
Line: 50
* there's no problem. The reason: {@link EqualsTester} tests {@code null} and identical inputs
* directly against {@code equals()} rather than through the {@code Equivalence}.
*/
private final Equivalence<? super T> equivalence;
private final String relationshipName;
private final String hashName;
private final ItemReporter itemReporter;
private final List<ImmutableList<T>> groups = Lists.newArrayList();
Reported by PMD.
Line: 52
*/
private final Equivalence<? super T> equivalence;
private final String relationshipName;
private final String hashName;
private final ItemReporter itemReporter;
private final List<ImmutableList<T>> groups = Lists.newArrayList();
RelationshipTester(
Reported by PMD.
Line: 53
private final Equivalence<? super T> equivalence;
private final String relationshipName;
private final String hashName;
private final ItemReporter itemReporter;
private final List<ImmutableList<T>> groups = Lists.newArrayList();
RelationshipTester(
Equivalence<? super T> equivalence,
Reported by PMD.
Line: 54
private final String relationshipName;
private final String hashName;
private final ItemReporter itemReporter;
private final List<ImmutableList<T>> groups = Lists.newArrayList();
RelationshipTester(
Equivalence<? super T> equivalence,
String relationshipName,
Reported by PMD.
Line: 55
private final String relationshipName;
private final String hashName;
private final ItemReporter itemReporter;
private final List<ImmutableList<T>> groups = Lists.newArrayList();
RelationshipTester(
Equivalence<? super T> equivalence,
String relationshipName,
String hashName,
Reported by PMD.
Line: 74
return this;
}
public void test() {
for (int groupNumber = 0; groupNumber < groups.size(); groupNumber++) {
ImmutableList<T> group = groups.get(groupNumber);
for (int itemNumber = 0; itemNumber < group.size(); itemNumber++) {
// check related items in same group
for (int relatedItemNumber = 0; relatedItemNumber < group.size(); relatedItemNumber++) {
Reported by PMD.
Line: 74
return this;
}
public void test() {
for (int groupNumber = 0; groupNumber < groups.size(); groupNumber++) {
ImmutableList<T> group = groups.get(groupNumber);
for (int itemNumber = 0; itemNumber < group.size(); itemNumber++) {
// check related items in same group
for (int relatedItemNumber = 0; relatedItemNumber < group.size(); relatedItemNumber++) {
Reported by PMD.
Line: 77
public void test() {
for (int groupNumber = 0; groupNumber < groups.size(); groupNumber++) {
ImmutableList<T> group = groups.get(groupNumber);
for (int itemNumber = 0; itemNumber < group.size(); itemNumber++) {
// check related items in same group
for (int relatedItemNumber = 0; relatedItemNumber < group.size(); relatedItemNumber++) {
if (itemNumber != relatedItemNumber) {
assertRelated(groupNumber, itemNumber, relatedItemNumber);
}
Reported by PMD.
Line: 79
ImmutableList<T> group = groups.get(groupNumber);
for (int itemNumber = 0; itemNumber < group.size(); itemNumber++) {
// check related items in same group
for (int relatedItemNumber = 0; relatedItemNumber < group.size(); relatedItemNumber++) {
if (itemNumber != relatedItemNumber) {
assertRelated(groupNumber, itemNumber, relatedItemNumber);
}
}
// check unrelated items in all other groups
Reported by PMD.
Line: 91
if (groupNumber != unrelatedGroupNumber) {
ImmutableList<T> unrelatedGroup = groups.get(unrelatedGroupNumber);
for (int unrelatedItemNumber = 0;
unrelatedItemNumber < unrelatedGroup.size();
unrelatedItemNumber++) {
assertUnrelated(groupNumber, itemNumber, unrelatedGroupNumber, unrelatedItemNumber);
}
}
}
Reported by PMD.
guava-testlib/test/com/google/common/collect/testing/SafeTreeSetTest.java
17 issues
Line: 39
import junit.framework.TestSuite;
public class SafeTreeSetTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(SafeTreeSetTest.class);
suite.addTest(
NavigableSetTestSuiteBuilder.using(
new TestStringSetGenerator() {
Reported by PMD.
Line: 66
new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
NavigableSet<String> set = new SafeTreeSet<>(Ordering.natural().nullsFirst());
Collections.addAll(set, elements);
return set;
}
@Override
Reported by PMD.
Line: 86
return suite;
}
@GwtIncompatible // SerializableTester
public void testViewSerialization() {
Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3);
SerializableTester.reserializeAndAssert(map.entrySet());
SerializableTester.reserializeAndAssert(map.keySet());
assertEquals(
Reported by PMD.
Line: 89
@GwtIncompatible // SerializableTester
public void testViewSerialization() {
Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3);
SerializableTester.reserializeAndAssert(map.entrySet());
SerializableTester.reserializeAndAssert(map.keySet());
assertEquals(
Lists.newArrayList(map.values()),
Lists.newArrayList(SerializableTester.reserialize(map.values())));
}
Reported by PMD.
Line: 90
public void testViewSerialization() {
Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3);
SerializableTester.reserializeAndAssert(map.entrySet());
SerializableTester.reserializeAndAssert(map.keySet());
assertEquals(
Lists.newArrayList(map.values()),
Lists.newArrayList(SerializableTester.reserialize(map.values())));
}
Reported by PMD.
Line: 91
Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3);
SerializableTester.reserializeAndAssert(map.entrySet());
SerializableTester.reserializeAndAssert(map.keySet());
assertEquals(
Lists.newArrayList(map.values()),
Lists.newArrayList(SerializableTester.reserialize(map.values())));
}
@GwtIncompatible // SerializableTester
Reported by PMD.
Line: 92
SerializableTester.reserializeAndAssert(map.entrySet());
SerializableTester.reserializeAndAssert(map.keySet());
assertEquals(
Lists.newArrayList(map.values()),
Lists.newArrayList(SerializableTester.reserialize(map.values())));
}
@GwtIncompatible // SerializableTester
public void testEmpty_serialization() {
Reported by PMD.
Line: 93
SerializableTester.reserializeAndAssert(map.keySet());
assertEquals(
Lists.newArrayList(map.values()),
Lists.newArrayList(SerializableTester.reserialize(map.values())));
}
@GwtIncompatible // SerializableTester
public void testEmpty_serialization() {
SortedSet<String> set = new SafeTreeSet<>();
Reported by PMD.
Line: 96
Lists.newArrayList(SerializableTester.reserialize(map.values())));
}
@GwtIncompatible // SerializableTester
public void testEmpty_serialization() {
SortedSet<String> set = new SafeTreeSet<>();
SortedSet<String> copy = SerializableTester.reserializeAndAssert(set);
assertEquals(set.comparator(), copy.comparator());
}
Reported by PMD.
Line: 100
public void testEmpty_serialization() {
SortedSet<String> set = new SafeTreeSet<>();
SortedSet<String> copy = SerializableTester.reserializeAndAssert(set);
assertEquals(set.comparator(), copy.comparator());
}
@GwtIncompatible // SerializableTester
public void testSingle_serialization() {
SortedSet<String> set = new SafeTreeSet<>();
Reported by PMD.
guava-tests/test/com/google/common/math/DoubleUtilsTest.java
17 issues
Line: 33
* @author Louis Wasserman
*/
public class DoubleUtilsTest extends TestCase {
@AndroidIncompatible // no FpUtils and no Math.nextDown in old versions
public void testNextDown() throws Exception {
Method jdkNextDown = getJdkNextDown();
for (double d : FINITE_DOUBLE_CANDIDATES) {
assertEquals(jdkNextDown.invoke(null, d), DoubleUtils.nextDown(d));
}
Reported by PMD.
Line: 37
public void testNextDown() throws Exception {
Method jdkNextDown = getJdkNextDown();
for (double d : FINITE_DOUBLE_CANDIDATES) {
assertEquals(jdkNextDown.invoke(null, d), DoubleUtils.nextDown(d));
}
}
private static Method getJdkNextDown() throws Exception {
try {
Reported by PMD.
Line: 41
}
}
private static Method getJdkNextDown() throws Exception {
try {
return Math.class.getMethod("nextDown", double.class);
} catch (NoSuchMethodException expectedBeforeJava8) {
return Class.forName("sun.misc.FpUtils").getMethod("nextDown", double.class);
}
Reported by PMD.
Line: 45
try {
return Math.class.getMethod("nextDown", double.class);
} catch (NoSuchMethodException expectedBeforeJava8) {
return Class.forName("sun.misc.FpUtils").getMethod("nextDown", double.class);
}
}
@AndroidIncompatible // TODO(cpovirk): File bug for BigDecimal.doubleValue().
public void testBigToDouble() {
Reported by PMD.
Line: 49
}
}
@AndroidIncompatible // TODO(cpovirk): File bug for BigDecimal.doubleValue().
public void testBigToDouble() {
for (BigInteger b : ALL_BIGINTEGER_CANDIDATES) {
if (b.doubleValue() != DoubleUtils.bigToDouble(b)) {
failFormat(
"Converting %s to double: expected doubleValue %s but got bigToDouble %s",
Reported by PMD.
Line: 52
@AndroidIncompatible // TODO(cpovirk): File bug for BigDecimal.doubleValue().
public void testBigToDouble() {
for (BigInteger b : ALL_BIGINTEGER_CANDIDATES) {
if (b.doubleValue() != DoubleUtils.bigToDouble(b)) {
failFormat(
"Converting %s to double: expected doubleValue %s but got bigToDouble %s",
b, b.doubleValue(), DoubleUtils.bigToDouble(b));
}
}
Reported by PMD.
Line: 60
}
}
public void testEnsureNonNegative() {
assertEquals(0.0, DoubleUtils.ensureNonNegative(0.0));
for (double positiveValue : POSITIVE_FINITE_DOUBLE_CANDIDATES) {
assertEquals(positiveValue, DoubleUtils.ensureNonNegative(positiveValue));
assertEquals(0.0, DoubleUtils.ensureNonNegative(-positiveValue));
}
Reported by PMD.
Line: 60
}
}
public void testEnsureNonNegative() {
assertEquals(0.0, DoubleUtils.ensureNonNegative(0.0));
for (double positiveValue : POSITIVE_FINITE_DOUBLE_CANDIDATES) {
assertEquals(positiveValue, DoubleUtils.ensureNonNegative(positiveValue));
assertEquals(0.0, DoubleUtils.ensureNonNegative(-positiveValue));
}
Reported by PMD.
Line: 61
}
public void testEnsureNonNegative() {
assertEquals(0.0, DoubleUtils.ensureNonNegative(0.0));
for (double positiveValue : POSITIVE_FINITE_DOUBLE_CANDIDATES) {
assertEquals(positiveValue, DoubleUtils.ensureNonNegative(positiveValue));
assertEquals(0.0, DoubleUtils.ensureNonNegative(-positiveValue));
}
assertEquals(Double.POSITIVE_INFINITY, DoubleUtils.ensureNonNegative(Double.POSITIVE_INFINITY));
Reported by PMD.
Line: 63
public void testEnsureNonNegative() {
assertEquals(0.0, DoubleUtils.ensureNonNegative(0.0));
for (double positiveValue : POSITIVE_FINITE_DOUBLE_CANDIDATES) {
assertEquals(positiveValue, DoubleUtils.ensureNonNegative(positiveValue));
assertEquals(0.0, DoubleUtils.ensureNonNegative(-positiveValue));
}
assertEquals(Double.POSITIVE_INFINITY, DoubleUtils.ensureNonNegative(Double.POSITIVE_INFINITY));
assertEquals(0.0, DoubleUtils.ensureNonNegative(Double.NEGATIVE_INFINITY));
try {
Reported by PMD.
guava-tests/benchmark/com/google/common/hash/HashStringBenchmark.java
17 issues
Line: 28
/** Benchmarks for the hashing of UTF-8 strings. */
public class HashStringBenchmark {
static class MaxCodePoint {
final int value;
/**
* Convert the input string to a code point. Accepts regular decimal numerals, hex strings, and
* some symbolic names meaningful to humans.
*/
Reported by PMD.
Line: 58
// Mostly 4-byte UTF-8 sequences - "rare exotic" text
return Character.MAX_CODE_POINT;
} else {
throw new IllegalArgumentException("Can't decode codepoint " + userFriendly);
}
}
}
public static MaxCodePoint valueOf(String userFriendly) {
Reported by PMD.
Line: 79
* @see MaxCodePoint#decode
*/
@Param({"0x80", "0x90", "0x100", "0x800", "0x10000", "0x10ffff"})
MaxCodePoint maxCodePoint;
@Param({"16384"})
int charCount;
@Param({"MURMUR3_32", "MURMUR3_128", "SHA1"})
Reported by PMD.
Line: 82
MaxCodePoint maxCodePoint;
@Param({"16384"})
int charCount;
@Param({"MURMUR3_32", "MURMUR3_128", "SHA1"})
HashFunctionEnum hashFunctionEnum;
private String[] strings;
Reported by PMD.
Line: 85
int charCount;
@Param({"MURMUR3_32", "MURMUR3_128", "SHA1"})
HashFunctionEnum hashFunctionEnum;
private String[] strings;
static final int SAMPLES = 0x100;
static final int SAMPLE_MASK = 0xFF;
Reported by PMD.
Line: 87
@Param({"MURMUR3_32", "MURMUR3_128", "SHA1"})
HashFunctionEnum hashFunctionEnum;
private String[] strings;
static final int SAMPLES = 0x100;
static final int SAMPLE_MASK = 0xFF;
/**
Reported by PMD.
Line: 96
* Compute arrays of valid unicode text, and store it in 3 forms: byte arrays, Strings, and
* StringBuilders (in a CharSequence[] to make it a little harder for the JVM).
*/
@BeforeExperiment
void setUp() {
final long seed = 99;
final Random rnd = new Random(seed);
strings = new String[SAMPLES];
for (int i = 0; i < SAMPLES; i++) {
Reported by PMD.
Line: 102
final Random rnd = new Random(seed);
strings = new String[SAMPLES];
for (int i = 0; i < SAMPLES; i++) {
StringBuilder sb = new StringBuilder();
for (int j = 0; j < charCount; j++) {
int codePoint;
// discard illegal surrogate "codepoints"
do {
codePoint = rnd.nextInt(maxCodePoint.value);
Reported by PMD.
Line: 121
for (int i = 0; i < reps; i++) {
res +=
System.identityHashCode(
hashFunctionEnum
.getHashFunction()
.hashString(strings[i & SAMPLE_MASK], StandardCharsets.UTF_8));
}
return res;
}
Reported by PMD.
Line: 134
for (int i = 0; i < reps; i++) {
res +=
System.identityHashCode(
hashFunctionEnum
.getHashFunction()
.newHasher()
.putString(strings[i & SAMPLE_MASK], StandardCharsets.UTF_8)
.hash());
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/MapCreationTester.java
17 issues
Line: 48
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapCreationTester<K, V> extends AbstractMapTester<K, V> {
@MapFeature.Require(ALLOWS_NULL_KEYS)
@CollectionSize.Require(absent = ZERO)
public void testCreateWithNullKeySupported() {
initMapWithNullKey();
expectContents(createArrayWithNullKey());
}
Reported by PMD.
Line: 55
expectContents(createArrayWithNullKey());
}
@MapFeature.Require(absent = ALLOWS_NULL_KEYS)
@CollectionSize.Require(absent = ZERO)
public void testCreateWithNullKeyUnsupported() {
try {
initMapWithNullKey();
fail("Creating a map containing a null key should fail");
Reported by PMD.
Line: 61
try {
initMapWithNullKey();
fail("Creating a map containing a null key should fail");
} catch (NullPointerException expected) {
}
}
@MapFeature.Require(ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 61
try {
initMapWithNullKey();
fail("Creating a map containing a null key should fail");
} catch (NullPointerException expected) {
}
}
@MapFeature.Require(ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 65
}
}
@MapFeature.Require(ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
public void testCreateWithNullValueSupported() {
initMapWithNullValue();
expectContents(createArrayWithNullValue());
}
Reported by PMD.
Line: 72
expectContents(createArrayWithNullValue());
}
@MapFeature.Require(absent = ALLOWS_NULL_VALUES)
@CollectionSize.Require(absent = ZERO)
public void testCreateWithNullValueUnsupported() {
try {
initMapWithNullValue();
fail("Creating a map containing a null value should fail");
Reported by PMD.
Line: 78
try {
initMapWithNullValue();
fail("Creating a map containing a null value should fail");
} catch (NullPointerException expected) {
}
}
@MapFeature.Require({ALLOWS_NULL_KEYS, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 78
try {
initMapWithNullValue();
fail("Creating a map containing a null value should fail");
} catch (NullPointerException expected) {
}
}
@MapFeature.Require({ALLOWS_NULL_KEYS, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
Reported by PMD.
Line: 82
}
}
@MapFeature.Require({ALLOWS_NULL_KEYS, ALLOWS_NULL_VALUES})
@CollectionSize.Require(absent = ZERO)
public void testCreateWithNullKeyAndValueSupported() {
Entry<K, V>[] entries = createSamplesArray();
entries[getNullLocation()] = entry(null, null);
resetMap(entries);
Reported by PMD.
Line: 91
expectContents(entries);
}
@MapFeature.Require(value = ALLOWS_NULL_KEYS, absent = REJECTS_DUPLICATES_AT_CREATION)
@CollectionSize.Require(absent = {ZERO, ONE})
public void testCreateWithDuplicates_nullDuplicatesNotRejected() {
expectFirstRemoved(getEntriesMultipleNullKeys());
}
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/SortedSetMultimapAsMapTester.java
17 issues
Line: 39
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SortedSetMultimapAsMapTester<K, V>
extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> {
public void testAsMapValuesImplementSortedSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
SortedSet<V> valueSet = (SortedSet<V>) valueCollection;
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
Reported by PMD.
Line: 40
public class SortedSetMultimapAsMapTester<K, V>
extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> {
public void testAsMapValuesImplementSortedSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
SortedSet<V> valueSet = (SortedSet<V>) valueCollection;
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
Reported by PMD.
Line: 40
public class SortedSetMultimapAsMapTester<K, V>
extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> {
public void testAsMapValuesImplementSortedSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
SortedSet<V> valueSet = (SortedSet<V>) valueCollection;
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
Reported by PMD.
Line: 42
public void testAsMapValuesImplementSortedSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
SortedSet<V> valueSet = (SortedSet<V>) valueCollection;
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
Reported by PMD.
Line: 42
public void testAsMapValuesImplementSortedSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
SortedSet<V> valueSet = (SortedSet<V>) valueCollection;
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
Reported by PMD.
Line: 46
}
}
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key);
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
Reported by PMD.
Line: 47
}
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key);
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
Reported by PMD.
Line: 48
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key);
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
@MapFeature.Require(SUPPORTS_REMOVE)
Reported by PMD.
Line: 48
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key);
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
@MapFeature.Require(SUPPORTS_REMOVE)
Reported by PMD.
Line: 49
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key);
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testAsMapRemoveImplementsSortedSet() {
Reported by PMD.
android/guava-tests/benchmark/com/google/common/hash/HashStringBenchmark.java
17 issues
Line: 28
/** Benchmarks for the hashing of UTF-8 strings. */
public class HashStringBenchmark {
static class MaxCodePoint {
final int value;
/**
* Convert the input string to a code point. Accepts regular decimal numerals, hex strings, and
* some symbolic names meaningful to humans.
*/
Reported by PMD.
Line: 58
// Mostly 4-byte UTF-8 sequences - "rare exotic" text
return Character.MAX_CODE_POINT;
} else {
throw new IllegalArgumentException("Can't decode codepoint " + userFriendly);
}
}
}
public static MaxCodePoint valueOf(String userFriendly) {
Reported by PMD.
Line: 79
* @see MaxCodePoint#decode
*/
@Param({"0x80", "0x90", "0x100", "0x800", "0x10000", "0x10ffff"})
MaxCodePoint maxCodePoint;
@Param({"16384"})
int charCount;
@Param({"MURMUR3_32", "MURMUR3_128", "SHA1"})
Reported by PMD.
Line: 82
MaxCodePoint maxCodePoint;
@Param({"16384"})
int charCount;
@Param({"MURMUR3_32", "MURMUR3_128", "SHA1"})
HashFunctionEnum hashFunctionEnum;
private String[] strings;
Reported by PMD.
Line: 85
int charCount;
@Param({"MURMUR3_32", "MURMUR3_128", "SHA1"})
HashFunctionEnum hashFunctionEnum;
private String[] strings;
static final int SAMPLES = 0x100;
static final int SAMPLE_MASK = 0xFF;
Reported by PMD.
Line: 87
@Param({"MURMUR3_32", "MURMUR3_128", "SHA1"})
HashFunctionEnum hashFunctionEnum;
private String[] strings;
static final int SAMPLES = 0x100;
static final int SAMPLE_MASK = 0xFF;
/**
Reported by PMD.
Line: 96
* Compute arrays of valid unicode text, and store it in 3 forms: byte arrays, Strings, and
* StringBuilders (in a CharSequence[] to make it a little harder for the JVM).
*/
@BeforeExperiment
void setUp() {
final long seed = 99;
final Random rnd = new Random(seed);
strings = new String[SAMPLES];
for (int i = 0; i < SAMPLES; i++) {
Reported by PMD.
Line: 102
final Random rnd = new Random(seed);
strings = new String[SAMPLES];
for (int i = 0; i < SAMPLES; i++) {
StringBuilder sb = new StringBuilder();
for (int j = 0; j < charCount; j++) {
int codePoint;
// discard illegal surrogate "codepoints"
do {
codePoint = rnd.nextInt(maxCodePoint.value);
Reported by PMD.
Line: 121
for (int i = 0; i < reps; i++) {
res +=
System.identityHashCode(
hashFunctionEnum
.getHashFunction()
.hashString(strings[i & SAMPLE_MASK], StandardCharsets.UTF_8));
}
return res;
}
Reported by PMD.
Line: 134
for (int i = 0; i < reps; i++) {
res +=
System.identityHashCode(
hashFunctionEnum
.getHashFunction()
.newHasher()
.putString(strings[i & SAMPLE_MASK], StandardCharsets.UTF_8)
.hash());
}
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/AbstractContainerTester.java
17 issues
Line: 39
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public abstract class AbstractContainerTester<C, E>
extends AbstractTester<OneSizeTestContainerGenerator<C, E>> {
protected SampleElements<E> samples;
protected C container;
@Override
@OverridingMethodsMustInvokeSuper
Reported by PMD.
Line: 40
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public abstract class AbstractContainerTester<C, E>
extends AbstractTester<OneSizeTestContainerGenerator<C, E>> {
protected SampleElements<E> samples;
protected C container;
@Override
@OverridingMethodsMustInvokeSuper
public void setUp() throws Exception {
Reported by PMD.
Line: 41
public abstract class AbstractContainerTester<C, E>
extends AbstractTester<OneSizeTestContainerGenerator<C, E>> {
protected SampleElements<E> samples;
protected C container;
@Override
@OverridingMethodsMustInvokeSuper
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 43
protected SampleElements<E> samples;
protected C container;
@Override
@OverridingMethodsMustInvokeSuper
public void setUp() throws Exception {
super.setUp();
samples = this.getSubjectGenerator().samples();
resetContainer();
Reported by PMD.
Line: 65
* @return the new container instance.
*/
protected C resetContainer() {
return resetContainer(getSubjectGenerator().createTestSubject());
}
/**
* Replaces the existing container under test with a new container. This is useful when a single
* test method needs to create multiple containers while retaining the ability to use {@link
Reported by PMD.
Line: 136
*/
protected final void expectAdded(E... elements) {
List<E> expected = Helpers.copyToList(getSampleElements());
expected.addAll(Arrays.asList(elements));
expectContents(expected);
}
protected final void expectAdded(int index, E... elements) {
expectAdded(index, Arrays.asList(elements));
Reported by PMD.
Line: 146
protected final void expectAdded(int index, Collection<E> elements) {
List<E> expected = Helpers.copyToList(getSampleElements());
expected.addAll(index, elements);
expectContents(expected);
}
/*
* TODO: if we're testing a list, we could check indexOf(). (Doing it in
Reported by PMD.
Line: 158
*/
protected void expectMissing(E... elements) {
for (E element : elements) {
assertFalse("Should not contain " + element, actualContents().contains(element));
}
}
protected E[] createSamplesArray() {
E[] array = getSubjectGenerator().createArray(getNumElements());
Reported by PMD.
Line: 163
}
protected E[] createSamplesArray() {
E[] array = getSubjectGenerator().createArray(getNumElements());
getSampleElements().toArray(array);
return array;
}
protected E[] createOrderedArray() {
Reported by PMD.
Line: 164
protected E[] createSamplesArray() {
E[] array = getSubjectGenerator().createArray(getNumElements());
getSampleElements().toArray(array);
return array;
}
protected E[] createOrderedArray() {
E[] array = getSubjectGenerator().createArray(getNumElements());
Reported by PMD.
android/guava-testlib/src/com/google/common/collect/testing/google/SortedSetMultimapAsMapTester.java
17 issues
Line: 39
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class SortedSetMultimapAsMapTester<K, V>
extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> {
public void testAsMapValuesImplementSortedSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
SortedSet<V> valueSet = (SortedSet<V>) valueCollection;
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
Reported by PMD.
Line: 40
public class SortedSetMultimapAsMapTester<K, V>
extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> {
public void testAsMapValuesImplementSortedSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
SortedSet<V> valueSet = (SortedSet<V>) valueCollection;
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
Reported by PMD.
Line: 40
public class SortedSetMultimapAsMapTester<K, V>
extends AbstractMultimapTester<K, V, SortedSetMultimap<K, V>> {
public void testAsMapValuesImplementSortedSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
SortedSet<V> valueSet = (SortedSet<V>) valueCollection;
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
Reported by PMD.
Line: 42
public void testAsMapValuesImplementSortedSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
SortedSet<V> valueSet = (SortedSet<V>) valueCollection;
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
Reported by PMD.
Line: 42
public void testAsMapValuesImplementSortedSet() {
for (Collection<V> valueCollection : multimap().asMap().values()) {
SortedSet<V> valueSet = (SortedSet<V>) valueCollection;
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
Reported by PMD.
Line: 46
}
}
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key);
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
Reported by PMD.
Line: 47
}
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key);
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
Reported by PMD.
Line: 48
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key);
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
@MapFeature.Require(SUPPORTS_REMOVE)
Reported by PMD.
Line: 48
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key);
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
@MapFeature.Require(SUPPORTS_REMOVE)
Reported by PMD.
Line: 49
public void testAsMapGetImplementsSortedSet() {
for (K key : multimap().keySet()) {
SortedSet<V> valueSet = (SortedSet<V>) multimap().asMap().get(key);
assertEquals(multimap().valueComparator(), valueSet.comparator());
}
}
@MapFeature.Require(SUPPORTS_REMOVE)
public void testAsMapRemoveImplementsSortedSet() {
Reported by PMD.