2024-03-19 13:28:42 +00:00
|
|
|
package nu.marginalia.segmentation;
|
2024-03-12 12:12:50 +00:00
|
|
|
|
2024-03-19 13:28:42 +00:00
|
|
|
import nu.marginalia.segmentation.HasherGroup;
|
2024-03-12 12:12:50 +00:00
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
|
|
|
class HasherGroupTest {
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void ordered() {
|
|
|
|
long a = 5;
|
|
|
|
long b = 3;
|
|
|
|
long c = 2;
|
|
|
|
|
|
|
|
var group = HasherGroup.ordered();
|
|
|
|
assertNotEquals(group.apply(a, b), group.apply(b, a));
|
|
|
|
assertEquals(group.apply(b,c), group.replace(group.apply(a, b), c, a, 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void unordered() {
|
|
|
|
long a = 5;
|
|
|
|
long b = 3;
|
|
|
|
long c = 2;
|
|
|
|
|
|
|
|
var group = HasherGroup.unordered();
|
|
|
|
|
|
|
|
assertEquals(group.apply(a, b), group.apply(b, a));
|
|
|
|
assertEquals(group.apply(b, c), group.replace(group.apply(a, b), c, a, 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|