use of org.eclipse.collections.impl.test.domain.Person in project eclipse-collections by eclipse.
the class ComparatorsTest method fromFunctions.
@Test
public void fromFunctions() {
Person raab = new Person(null, "Raab", 0);
Person white = new Person(null, "White", 0);
Comparator<Person> personComparator = Comparators.fromFunctions(Person.TO_LAST);
Verify.assertNegative(personComparator.compare(raab, white));
Verify.assertPositive(personComparator.compare(white, raab));
Verify.assertZero(personComparator.compare(raab, raab));
}
use of org.eclipse.collections.impl.test.domain.Person in project eclipse-collections by eclipse.
the class HashingStrategiesTest method fromFunctionsThreeArgs.
@Test
public void fromFunctionsThreeArgs() {
Person john1 = new Person("John", "Smith");
Person john2 = new Person("John", "Smith");
Person john3 = new Person("John", "Doe");
Person john4 = new Person("John", "Smith", 10);
HashingStrategy<Person> chainedHashingStrategy = HashingStrategies.fromFunctions(Person.TO_FIRST, Person.TO_LAST, Person.TO_AGE);
Assert.assertEquals(john1.hashCode(), chainedHashingStrategy.computeHashCode(john1));
Assert.assertTrue(chainedHashingStrategy.equals(john1, john2));
Assert.assertFalse(chainedHashingStrategy.equals(john1, john3));
Assert.assertFalse(chainedHashingStrategy.equals(john1, john4));
}
Aggregations