The following issues were found
guava-tests/test/com/google/common/graph/EndpointPairTest.java
140 issues
Line: 33
/** Tests for {@link EndpointPair} and {@link Graph#edges()}. */
@RunWith(JUnit4.class)
public final class EndpointPairTest {
private static final Integer N0 = 0;
private static final Integer N1 = 1;
private static final Integer N2 = 2;
private static final Integer N3 = 3;
private static final Integer N4 = 4;
Reported by PMD.
Line: 48
// Test for EndpointPair class
@Test
public void testOrderedEndpointPair() {
EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
assertThat(ordered.isOrdered()).isTrue();
assertThat(ordered).containsExactly("source", "target").inOrder();
assertThat(ordered.source()).isEqualTo("source");
assertThat(ordered.target()).isEqualTo("target");
Reported by PMD.
Line: 49
@Test
public void testOrderedEndpointPair() {
EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
assertThat(ordered.isOrdered()).isTrue();
assertThat(ordered).containsExactly("source", "target").inOrder();
assertThat(ordered.source()).isEqualTo("source");
assertThat(ordered.target()).isEqualTo("target");
assertThat(ordered.nodeU()).isEqualTo("source");
Reported by PMD.
Line: 49
@Test
public void testOrderedEndpointPair() {
EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
assertThat(ordered.isOrdered()).isTrue();
assertThat(ordered).containsExactly("source", "target").inOrder();
assertThat(ordered.source()).isEqualTo("source");
assertThat(ordered.target()).isEqualTo("target");
assertThat(ordered.nodeU()).isEqualTo("source");
Reported by PMD.
Line: 50
@Test
public void testOrderedEndpointPair() {
EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
assertThat(ordered.isOrdered()).isTrue();
assertThat(ordered).containsExactly("source", "target").inOrder();
assertThat(ordered.source()).isEqualTo("source");
assertThat(ordered.target()).isEqualTo("target");
assertThat(ordered.nodeU()).isEqualTo("source");
assertThat(ordered.nodeV()).isEqualTo("target");
Reported by PMD.
Line: 50
@Test
public void testOrderedEndpointPair() {
EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
assertThat(ordered.isOrdered()).isTrue();
assertThat(ordered).containsExactly("source", "target").inOrder();
assertThat(ordered.source()).isEqualTo("source");
assertThat(ordered.target()).isEqualTo("target");
assertThat(ordered.nodeU()).isEqualTo("source");
assertThat(ordered.nodeV()).isEqualTo("target");
Reported by PMD.
Line: 51
public void testOrderedEndpointPair() {
EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
assertThat(ordered.isOrdered()).isTrue();
assertThat(ordered).containsExactly("source", "target").inOrder();
assertThat(ordered.source()).isEqualTo("source");
assertThat(ordered.target()).isEqualTo("target");
assertThat(ordered.nodeU()).isEqualTo("source");
assertThat(ordered.nodeV()).isEqualTo("target");
assertThat(ordered.adjacentNode("source")).isEqualTo("target");
Reported by PMD.
Line: 51
public void testOrderedEndpointPair() {
EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
assertThat(ordered.isOrdered()).isTrue();
assertThat(ordered).containsExactly("source", "target").inOrder();
assertThat(ordered.source()).isEqualTo("source");
assertThat(ordered.target()).isEqualTo("target");
assertThat(ordered.nodeU()).isEqualTo("source");
assertThat(ordered.nodeV()).isEqualTo("target");
assertThat(ordered.adjacentNode("source")).isEqualTo("target");
Reported by PMD.
Line: 51
public void testOrderedEndpointPair() {
EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
assertThat(ordered.isOrdered()).isTrue();
assertThat(ordered).containsExactly("source", "target").inOrder();
assertThat(ordered.source()).isEqualTo("source");
assertThat(ordered.target()).isEqualTo("target");
assertThat(ordered.nodeU()).isEqualTo("source");
assertThat(ordered.nodeV()).isEqualTo("target");
assertThat(ordered.adjacentNode("source")).isEqualTo("target");
Reported by PMD.
Line: 52
EndpointPair<String> ordered = EndpointPair.ordered("source", "target");
assertThat(ordered.isOrdered()).isTrue();
assertThat(ordered).containsExactly("source", "target").inOrder();
assertThat(ordered.source()).isEqualTo("source");
assertThat(ordered.target()).isEqualTo("target");
assertThat(ordered.nodeU()).isEqualTo("source");
assertThat(ordered.nodeV()).isEqualTo("target");
assertThat(ordered.adjacentNode("source")).isEqualTo("target");
assertThat(ordered.adjacentNode("target")).isEqualTo("source");
Reported by PMD.
android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
139 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
Reported by PMD.
Line: 88
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractMapBasedMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMultimap<K, V> implements Serializable {
/*
* Here's an outline of the overall design.
*
* The map variable contains the collection of values associated with each
Reported by PMD.
Line: 89
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractMapBasedMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMultimap<K, V> implements Serializable {
/*
* Here's an outline of the overall design.
*
* The map variable contains the collection of values associated with each
* key. When a key-value pair is added to a multimap that didn't previously
Reported by PMD.
Line: 196
} else {
throw new AssertionError("New Collection violated the Collection spec");
}
} else if (collection.add(value)) {
totalSize++;
return true;
} else {
return false;
}
Reported by PMD.
Line: 230
// TODO(lowasser): investigate atomic failure?
Collection<V> collection = getOrCreateCollection(key);
Collection<V> oldValues = createCollection();
oldValues.addAll(collection);
totalSize -= collection.size();
collection.clear();
while (iterator.hasNext()) {
Reported by PMD.
Line: 232
Collection<V> oldValues = createCollection();
oldValues.addAll(collection);
totalSize -= collection.size();
collection.clear();
while (iterator.hasNext()) {
if (collection.add(iterator.next())) {
totalSize++;
Reported by PMD.
Line: 233
oldValues.addAll(collection);
totalSize -= collection.size();
collection.clear();
while (iterator.hasNext()) {
if (collection.add(iterator.next())) {
totalSize++;
}
Reported by PMD.
Line: 258
}
Collection<V> output = createCollection();
output.addAll(collection);
totalSize -= collection.size();
collection.clear();
return unmodifiableCollectionSubclass(output);
}
Reported by PMD.
Line: 259
Collection<V> output = createCollection();
output.addAll(collection);
totalSize -= collection.size();
collection.clear();
return unmodifiableCollectionSubclass(output);
}
Reported by PMD.
Line: 260
Collection<V> output = createCollection();
output.addAll(collection);
totalSize -= collection.size();
collection.clear();
return unmodifiableCollectionSubclass(output);
}
<E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(
Reported by PMD.
guava-tests/test/com/google/common/graph/ElementOrderTest.java
137 issues
Line: 32
/** Tests for ordering the elements of graphs. */
@RunWith(JUnit4.class)
public final class ElementOrderTest {
// Node order tests
@Test
public void nodeOrder_none() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(unordered()).build();
Reported by PMD.
Line: 37
@Test
public void nodeOrder_none() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(unordered()).build();
assertThat(graph.nodeOrder()).isEqualTo(unordered());
}
@Test
Reported by PMD.
Line: 37
@Test
public void nodeOrder_none() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(unordered()).build();
assertThat(graph.nodeOrder()).isEqualTo(unordered());
}
@Test
Reported by PMD.
Line: 39
public void nodeOrder_none() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(unordered()).build();
assertThat(graph.nodeOrder()).isEqualTo(unordered());
}
@Test
public void nodeOrder_insertion() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(insertion()).build();
Reported by PMD.
Line: 39
public void nodeOrder_none() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(unordered()).build();
assertThat(graph.nodeOrder()).isEqualTo(unordered());
}
@Test
public void nodeOrder_insertion() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(insertion()).build();
Reported by PMD.
Line: 43
}
@Test
public void nodeOrder_insertion() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(insertion()).build();
addNodes(graph);
assertThat(graph.nodeOrder()).isEqualTo(insertion());
Reported by PMD.
Line: 44
@Test
public void nodeOrder_insertion() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(insertion()).build();
addNodes(graph);
assertThat(graph.nodeOrder()).isEqualTo(insertion());
assertThat(graph.nodes()).containsExactly(3, 1, 4).inOrder();
Reported by PMD.
Line: 44
@Test
public void nodeOrder_insertion() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(insertion()).build();
addNodes(graph);
assertThat(graph.nodeOrder()).isEqualTo(insertion());
assertThat(graph.nodes()).containsExactly(3, 1, 4).inOrder();
Reported by PMD.
Line: 48
addNodes(graph);
assertThat(graph.nodeOrder()).isEqualTo(insertion());
assertThat(graph.nodes()).containsExactly(3, 1, 4).inOrder();
}
// The default ordering is INSERTION unless otherwise specified.
@Test
Reported by PMD.
Line: 48
addNodes(graph);
assertThat(graph.nodeOrder()).isEqualTo(insertion());
assertThat(graph.nodes()).containsExactly(3, 1, 4).inOrder();
}
// The default ordering is INSERTION unless otherwise specified.
@Test
Reported by PMD.
android/guava-tests/test/com/google/common/graph/ElementOrderTest.java
137 issues
Line: 32
/** Tests for ordering the elements of graphs. */
@RunWith(JUnit4.class)
public final class ElementOrderTest {
// Node order tests
@Test
public void nodeOrder_none() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(unordered()).build();
Reported by PMD.
Line: 37
@Test
public void nodeOrder_none() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(unordered()).build();
assertThat(graph.nodeOrder()).isEqualTo(unordered());
}
@Test
Reported by PMD.
Line: 37
@Test
public void nodeOrder_none() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(unordered()).build();
assertThat(graph.nodeOrder()).isEqualTo(unordered());
}
@Test
Reported by PMD.
Line: 39
public void nodeOrder_none() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(unordered()).build();
assertThat(graph.nodeOrder()).isEqualTo(unordered());
}
@Test
public void nodeOrder_insertion() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(insertion()).build();
Reported by PMD.
Line: 39
public void nodeOrder_none() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(unordered()).build();
assertThat(graph.nodeOrder()).isEqualTo(unordered());
}
@Test
public void nodeOrder_insertion() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(insertion()).build();
Reported by PMD.
Line: 43
}
@Test
public void nodeOrder_insertion() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(insertion()).build();
addNodes(graph);
assertThat(graph.nodeOrder()).isEqualTo(insertion());
Reported by PMD.
Line: 44
@Test
public void nodeOrder_insertion() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(insertion()).build();
addNodes(graph);
assertThat(graph.nodeOrder()).isEqualTo(insertion());
assertThat(graph.nodes()).containsExactly(3, 1, 4).inOrder();
Reported by PMD.
Line: 44
@Test
public void nodeOrder_insertion() {
MutableGraph<Integer> graph = GraphBuilder.directed().nodeOrder(insertion()).build();
addNodes(graph);
assertThat(graph.nodeOrder()).isEqualTo(insertion());
assertThat(graph.nodes()).containsExactly(3, 1, 4).inOrder();
Reported by PMD.
Line: 48
addNodes(graph);
assertThat(graph.nodeOrder()).isEqualTo(insertion());
assertThat(graph.nodes()).containsExactly(3, 1, 4).inOrder();
}
// The default ordering is INSERTION unless otherwise specified.
@Test
Reported by PMD.
Line: 48
addNodes(graph);
assertThat(graph.nodeOrder()).isEqualTo(insertion());
assertThat(graph.nodes()).containsExactly(3, 1, 4).inOrder();
}
// The default ordering is INSERTION unless otherwise specified.
@Test
Reported by PMD.
guava-tests/test/com/google/common/io/BaseEncodingTest.java
136 issues
Line: 47
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
Reported by PMD.
Line: 47
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
Reported by PMD.
Line: 49
@GwtCompatible(emulated = true)
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
Reported by PMD.
Line: 49
@GwtCompatible(emulated = true)
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
Reported by PMD.
Line: 50
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
public void testSeparatorSameAsPadChar() {
Reported by PMD.
Line: 50
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
public void testSeparatorSameAsPadChar() {
Reported by PMD.
Line: 51
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
public void testSeparatorSameAsPadChar() {
try {
Reported by PMD.
Line: 52
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
public void testSeparatorSameAsPadChar() {
try {
base64().withSeparator("=", 3);
Reported by PMD.
Line: 55
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
public void testSeparatorSameAsPadChar() {
try {
base64().withSeparator("=", 3);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
Reported by PMD.
Line: 57
public void testSeparatorSameAsPadChar() {
try {
base64().withSeparator("=", 3);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
try {
Reported by PMD.
guava-tests/test/com/google/common/hash/HashTestUtils.java
136 issues
Line: 116
PUT_SHORT() {
@Override
void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) {
short value = (short) random.nextInt();
for (PrimitiveSink sink : sinks) {
sink.putShort(value);
}
}
},
Reported by PMD.
Line: 41
* @author Dimitris Andreou
* @author Kurt Alfred Kluever
*/
final class HashTestUtils {
private HashTestUtils() {}
/** Converts a string, which should contain only ascii-representable characters, to a byte[]. */
static byte[] ascii(String string) {
byte[] bytes = new byte[string.length()];
Reported by PMD.
Line: 41
* @author Dimitris Andreou
* @author Kurt Alfred Kluever
*/
final class HashTestUtils {
private HashTestUtils() {}
/** Converts a string, which should contain only ascii-representable characters, to a byte[]. */
static byte[] ascii(String string) {
byte[] bytes = new byte[string.length()];
Reported by PMD.
Line: 198
int limit = pos + random.nextInt(value.length - pos + 1);
for (PrimitiveSink sink : sinks) {
ByteBuffer buffer = ByteBuffer.wrap(value);
buffer.position(pos);
buffer.limit(limit);
sink.putBytes(buffer);
assertEquals(limit, buffer.limit());
assertEquals(limit, buffer.position());
}
Reported by PMD.
Line: 199
for (PrimitiveSink sink : sinks) {
ByteBuffer buffer = ByteBuffer.wrap(value);
buffer.position(pos);
buffer.limit(limit);
sink.putBytes(buffer);
assertEquals(limit, buffer.limit());
assertEquals(limit, buffer.position());
}
}
Reported by PMD.
Line: 201
buffer.position(pos);
buffer.limit(limit);
sink.putBytes(buffer);
assertEquals(limit, buffer.limit());
assertEquals(limit, buffer.position());
}
}
},
PUT_STRING() {
Reported by PMD.
Line: 202
buffer.limit(limit);
sink.putBytes(buffer);
assertEquals(limit, buffer.limit());
assertEquals(limit, buffer.position());
}
}
},
PUT_STRING() {
@Override
Reported by PMD.
Line: 296
// flip input bit for key2
int key2 = key1 ^ (1 << i);
// get hashes
int hash1 = function.hashInt(key1).asInt();
int hash2 = function.hashInt(key2).asInt();
// test whether the hash values have same output bits
same |= ~(hash1 ^ hash2);
// test whether the hash values have different output bits
diff |= (hash1 ^ hash2);
Reported by PMD.
Line: 297
int key2 = key1 ^ (1 << i);
// get hashes
int hash1 = function.hashInt(key1).asInt();
int hash2 = function.hashInt(key2).asInt();
// test whether the hash values have same output bits
same |= ~(hash1 ^ hash2);
// test whether the hash values have different output bits
diff |= (hash1 ^ hash2);
Reported by PMD.
Line: 335
int keyBits = 32;
int hashBits = function.bits();
for (int i = 0; i < keyBits; i++) {
int[] same = new int[hashBits];
int[] diff = new int[hashBits];
// go through trials to compute probability
for (int j = 0; j < trials; j++) {
int key1 = rand.nextInt();
// flip input bit for key2
Reported by PMD.
android/guava-tests/test/com/google/common/io/BaseEncodingTest.java
136 issues
Line: 47
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
Reported by PMD.
Line: 47
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
Reported by PMD.
Line: 49
@GwtCompatible(emulated = true)
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
Reported by PMD.
Line: 49
@GwtCompatible(emulated = true)
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
Reported by PMD.
Line: 50
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
public void testSeparatorSameAsPadChar() {
Reported by PMD.
Line: 50
public class BaseEncodingTest extends TestCase {
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
public void testSeparatorSameAsPadChar() {
Reported by PMD.
Line: 51
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
public void testSeparatorSameAsPadChar() {
try {
Reported by PMD.
Line: 52
public void testSeparatorsExplicitly() {
testEncodes(base64().withSeparator("\n", 3), "foobar", "Zm9\nvYm\nFy");
testEncodes(base64().withSeparator("$", 4), "foobar", "Zm9v$YmFy");
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
public void testSeparatorSameAsPadChar() {
try {
base64().withSeparator("=", 3);
Reported by PMD.
Line: 55
testEncodes(base32().withSeparator("*", 4), "foobar", "MZXW*6YTB*OI==*====");
}
public void testSeparatorSameAsPadChar() {
try {
base64().withSeparator("=", 3);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
Reported by PMD.
Line: 57
public void testSeparatorSameAsPadChar() {
try {
base64().withSeparator("=", 3);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
try {
Reported by PMD.
android/guava-tests/test/com/google/common/hash/HashTestUtils.java
136 issues
Line: 116
PUT_SHORT() {
@Override
void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) {
short value = (short) random.nextInt();
for (PrimitiveSink sink : sinks) {
sink.putShort(value);
}
}
},
Reported by PMD.
Line: 41
* @author Dimitris Andreou
* @author Kurt Alfred Kluever
*/
final class HashTestUtils {
private HashTestUtils() {}
/** Converts a string, which should contain only ascii-representable characters, to a byte[]. */
static byte[] ascii(String string) {
byte[] bytes = new byte[string.length()];
Reported by PMD.
Line: 41
* @author Dimitris Andreou
* @author Kurt Alfred Kluever
*/
final class HashTestUtils {
private HashTestUtils() {}
/** Converts a string, which should contain only ascii-representable characters, to a byte[]. */
static byte[] ascii(String string) {
byte[] bytes = new byte[string.length()];
Reported by PMD.
Line: 198
int limit = pos + random.nextInt(value.length - pos + 1);
for (PrimitiveSink sink : sinks) {
ByteBuffer buffer = ByteBuffer.wrap(value);
buffer.position(pos);
buffer.limit(limit);
sink.putBytes(buffer);
assertEquals(limit, buffer.limit());
assertEquals(limit, buffer.position());
}
Reported by PMD.
Line: 199
for (PrimitiveSink sink : sinks) {
ByteBuffer buffer = ByteBuffer.wrap(value);
buffer.position(pos);
buffer.limit(limit);
sink.putBytes(buffer);
assertEquals(limit, buffer.limit());
assertEquals(limit, buffer.position());
}
}
Reported by PMD.
Line: 201
buffer.position(pos);
buffer.limit(limit);
sink.putBytes(buffer);
assertEquals(limit, buffer.limit());
assertEquals(limit, buffer.position());
}
}
},
PUT_STRING() {
Reported by PMD.
Line: 202
buffer.limit(limit);
sink.putBytes(buffer);
assertEquals(limit, buffer.limit());
assertEquals(limit, buffer.position());
}
}
},
PUT_STRING() {
@Override
Reported by PMD.
Line: 296
// flip input bit for key2
int key2 = key1 ^ (1 << i);
// get hashes
int hash1 = function.hashInt(key1).asInt();
int hash2 = function.hashInt(key2).asInt();
// test whether the hash values have same output bits
same |= ~(hash1 ^ hash2);
// test whether the hash values have different output bits
diff |= (hash1 ^ hash2);
Reported by PMD.
Line: 297
int key2 = key1 ^ (1 << i);
// get hashes
int hash1 = function.hashInt(key1).asInt();
int hash2 = function.hashInt(key2).asInt();
// test whether the hash values have same output bits
same |= ~(hash1 ^ hash2);
// test whether the hash values have different output bits
diff |= (hash1 ^ hash2);
Reported by PMD.
Line: 335
int keyBits = 32;
int hashBits = function.bits();
for (int i = 0; i < keyBits; i++) {
int[] same = new int[hashBits];
int[] diff = new int[hashBits];
// go through trials to compute probability
for (int j = 0; j < trials; j++) {
int key1 = rand.nextInt();
// flip input bit for key2
Reported by PMD.
guava-tests/test/com/google/common/collect/HashBiMapTest.java
134 issues
Line: 42
* @author Mike Bostock
*/
@GwtCompatible(emulated = true)
public class HashBiMapTest extends TestCase {
public static final class HashBiMapGenerator extends TestStringBiMapGenerator {
@Override
protected BiMap<String, String> create(Entry<String, String>[] entries) {
BiMap<String, String> result = HashBiMap.create();
Reported by PMD.
Line: 55
}
}
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
BiMapTestSuiteBuilder.using(new HashBiMapGenerator())
.named("HashBiMap")
Reported by PMD.
Line: 75
return suite;
}
public void testMapConstructor() {
/* Test with non-empty Map. */
Map<String, String> map =
ImmutableMap.of(
"canada", "dollar",
"chile", "peso",
Reported by PMD.
Line: 75
return suite;
}
public void testMapConstructor() {
/* Test with non-empty Map. */
Map<String, String> map =
ImmutableMap.of(
"canada", "dollar",
"chile", "peso",
Reported by PMD.
Line: 83
"chile", "peso",
"switzerland", "franc");
HashBiMap<String, String> bimap = HashBiMap.create(map);
assertEquals("dollar", bimap.get("canada"));
assertEquals("canada", bimap.inverse().get("dollar"));
}
private static final int N = 1000;
Reported by PMD.
Line: 83
"chile", "peso",
"switzerland", "franc");
HashBiMap<String, String> bimap = HashBiMap.create(map);
assertEquals("dollar", bimap.get("canada"));
assertEquals("canada", bimap.inverse().get("dollar"));
}
private static final int N = 1000;
Reported by PMD.
Line: 84
"switzerland", "franc");
HashBiMap<String, String> bimap = HashBiMap.create(map);
assertEquals("dollar", bimap.get("canada"));
assertEquals("canada", bimap.inverse().get("dollar"));
}
private static final int N = 1000;
public void testBashIt() throws Exception {
Reported by PMD.
Line: 84
"switzerland", "franc");
HashBiMap<String, String> bimap = HashBiMap.create(map);
assertEquals("dollar", bimap.get("canada"));
assertEquals("canada", bimap.inverse().get("dollar"));
}
private static final int N = 1000;
public void testBashIt() throws Exception {
Reported by PMD.
Line: 84
"switzerland", "franc");
HashBiMap<String, String> bimap = HashBiMap.create(map);
assertEquals("dollar", bimap.get("canada"));
assertEquals("canada", bimap.inverse().get("dollar"));
}
private static final int N = 1000;
public void testBashIt() throws Exception {
Reported by PMD.
Line: 89
private static final int N = 1000;
public void testBashIt() throws Exception {
BiMap<Integer, Integer> bimap = HashBiMap.create(N);
BiMap<Integer, Integer> inverse = bimap.inverse();
for (int i = 0; i < N; i++) {
assertNull(bimap.put(2 * i, 2 * i + 1));
Reported by PMD.
android/guava-tests/test/com/google/common/collect/HashBiMapTest.java
134 issues
Line: 42
* @author Mike Bostock
*/
@GwtCompatible(emulated = true)
public class HashBiMapTest extends TestCase {
public static final class HashBiMapGenerator extends TestStringBiMapGenerator {
@Override
protected BiMap<String, String> create(Entry<String, String>[] entries) {
BiMap<String, String> result = HashBiMap.create();
Reported by PMD.
Line: 55
}
}
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
BiMapTestSuiteBuilder.using(new HashBiMapGenerator())
.named("HashBiMap")
Reported by PMD.
Line: 75
return suite;
}
public void testMapConstructor() {
/* Test with non-empty Map. */
Map<String, String> map =
ImmutableMap.of(
"canada", "dollar",
"chile", "peso",
Reported by PMD.
Line: 75
return suite;
}
public void testMapConstructor() {
/* Test with non-empty Map. */
Map<String, String> map =
ImmutableMap.of(
"canada", "dollar",
"chile", "peso",
Reported by PMD.
Line: 83
"chile", "peso",
"switzerland", "franc");
HashBiMap<String, String> bimap = HashBiMap.create(map);
assertEquals("dollar", bimap.get("canada"));
assertEquals("canada", bimap.inverse().get("dollar"));
}
private static final int N = 1000;
Reported by PMD.
Line: 83
"chile", "peso",
"switzerland", "franc");
HashBiMap<String, String> bimap = HashBiMap.create(map);
assertEquals("dollar", bimap.get("canada"));
assertEquals("canada", bimap.inverse().get("dollar"));
}
private static final int N = 1000;
Reported by PMD.
Line: 84
"switzerland", "franc");
HashBiMap<String, String> bimap = HashBiMap.create(map);
assertEquals("dollar", bimap.get("canada"));
assertEquals("canada", bimap.inverse().get("dollar"));
}
private static final int N = 1000;
public void testBashIt() throws Exception {
Reported by PMD.
Line: 84
"switzerland", "franc");
HashBiMap<String, String> bimap = HashBiMap.create(map);
assertEquals("dollar", bimap.get("canada"));
assertEquals("canada", bimap.inverse().get("dollar"));
}
private static final int N = 1000;
public void testBashIt() throws Exception {
Reported by PMD.
Line: 84
"switzerland", "franc");
HashBiMap<String, String> bimap = HashBiMap.create(map);
assertEquals("dollar", bimap.get("canada"));
assertEquals("canada", bimap.inverse().get("dollar"));
}
private static final int N = 1000;
public void testBashIt() throws Exception {
Reported by PMD.
Line: 89
private static final int N = 1000;
public void testBashIt() throws Exception {
BiMap<Integer, Integer> bimap = HashBiMap.create(N);
BiMap<Integer, Integer> inverse = bimap.inverse();
for (int i = 0; i < N; i++) {
assertNull(bimap.put(2 * i, 2 * i + 1));
Reported by PMD.