Skip to content

Commit

Permalink
Internal change.
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 650664247
  • Loading branch information
kluever authored and Google Java Core Libraries committed Jul 9, 2024
1 parent c94072c commit 558c2be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.junit.Assert.assertThrows;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableTable;
import com.google.common.collect.Lists;
import com.google.common.collect.Table.Cell;
Expand Down Expand Up @@ -501,9 +502,12 @@ public void testHashIntVsForLoop() {
.put(Hashing.fingerprint2011(), TQBFJOTLDP, "a714d70f1d569cd0")
.build();

// TODO(kak): provide a private utility method to filter the declared hashing methods

public void testAllHashFunctionsHaveKnownHashes() throws Exception {
// The following legacy hashing function methods have been covered by unit testing already.
List<String> legacyHashingMethodNames = ImmutableList.of("murmur2_64", "fprint96");
ImmutableSet<String> legacyHashingMethodNames =
ImmutableSet.of("murmur2_64", "fprint96", "highwayFingerprint64", "highwayFingerprint128");
for (Method method : Hashing.class.getDeclaredMethods()) {
if (method.getReturnType().equals(HashFunction.class) // must return HashFunction
&& Modifier.isPublic(method.getModifiers()) // only the public methods
Expand Down Expand Up @@ -579,6 +583,7 @@ static void assertSeedlessHashFunctionEquals(Class<?> clazz) throws Exception {
for (Method method : clazz.getDeclaredMethods()) {
if (method.getReturnType().equals(HashFunction.class) // must return HashFunction
&& Modifier.isPublic(method.getModifiers()) // only the public methods
&& !method.getName().contains("highwayFingerprint") // tested in HighwayHash64FunctionTest
&& method.getParameterTypes().length == 0) { // only the seed-less hash functions
HashFunction hashFunction1a = (HashFunction) method.invoke(clazz);
HashFunction hashFunction1b = (HashFunction) method.invoke(clazz);
Expand Down
7 changes: 6 additions & 1 deletion guava-tests/test/com/google/common/hash/HashingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.junit.Assert.assertThrows;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableTable;
import com.google.common.collect.Lists;
import com.google.common.collect.Table.Cell;
Expand Down Expand Up @@ -501,9 +502,12 @@ public void testHashIntVsForLoop() {
.put(Hashing.fingerprint2011(), TQBFJOTLDP, "a714d70f1d569cd0")
.build();

// TODO(kak): provide a private utility method to filter the declared hashing methods

public void testAllHashFunctionsHaveKnownHashes() throws Exception {
// The following legacy hashing function methods have been covered by unit testing already.
List<String> legacyHashingMethodNames = ImmutableList.of("murmur2_64", "fprint96");
ImmutableSet<String> legacyHashingMethodNames =
ImmutableSet.of("murmur2_64", "fprint96", "highwayFingerprint64", "highwayFingerprint128");
for (Method method : Hashing.class.getDeclaredMethods()) {
if (method.getReturnType().equals(HashFunction.class) // must return HashFunction
&& Modifier.isPublic(method.getModifiers()) // only the public methods
Expand Down Expand Up @@ -579,6 +583,7 @@ static void assertSeedlessHashFunctionEquals(Class<?> clazz) throws Exception {
for (Method method : clazz.getDeclaredMethods()) {
if (method.getReturnType().equals(HashFunction.class) // must return HashFunction
&& Modifier.isPublic(method.getModifiers()) // only the public methods
&& !method.getName().contains("highwayFingerprint") // tested in HighwayHash64FunctionTest
&& method.getParameterTypes().length == 0) { // only the seed-less hash functions
HashFunction hashFunction1a = (HashFunction) method.invoke(clazz);
HashFunction hashFunction1b = (HashFunction) method.invoke(clazz);
Expand Down

0 comments on commit 558c2be

Please sign in to comment.