Hit all edge cases in the Shape.equals method.

This commit is contained in:
aherbert 2020-02-18 13:40:22 +00:00
parent 55cb720ccf
commit 6215948227
1 changed files with 17 additions and 4 deletions

View File

@ -406,9 +406,22 @@ public class ShapeTest {
@Test
public void equalsTest() {
assertEquals(new Shape(testFunction, 5, 1.0 / 10), shape);
assertNotEquals(new Shape(testFunction, 5, 1.0 / 11), shape);
assertNotEquals(new Shape(testFunction, 4, 1.0 / 10), shape);
assertEquals(shape, shape);
assertEquals(shape, new Shape(testFunction, 5, 1.0 / 10));
assertNotEquals(shape, null);
assertNotEquals(shape, new Shape(testFunction, 5, 1.0 / 11));
assertNotEquals(shape, new Shape(testFunction, 4, 1.0 / 10));
// Number of bits does not change equality,
// only the number of bits and the number of hash functions
final int numberOfBits = 10000;
final int numberOfItems = 15;
final int numberOfHashFunctions = 4;
assertEquals(new Shape(testFunction, numberOfItems, numberOfBits, numberOfHashFunctions),
new Shape(testFunction, numberOfItems + 1, numberOfBits, numberOfHashFunctions));
assertNotEquals(new Shape(testFunction, numberOfItems, numberOfBits, numberOfHashFunctions),
new Shape(testFunction, numberOfItems, numberOfBits + 1, numberOfHashFunctions));
assertNotEquals(new Shape(testFunction, numberOfItems, numberOfBits, numberOfHashFunctions),
new Shape(testFunction, numberOfItems, numberOfBits, numberOfHashFunctions + 1));
final HashFunctionIdentity testFunction2 = new HashFunctionIdentity() {
@ -438,7 +451,7 @@ public class ShapeTest {
}
};
assertNotEquals(new Shape(testFunction2, 4, 1.0 / 10), shape);
assertNotEquals(shape, new Shape(testFunction2, 4, 1.0 / 10));
}
/**