Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package datadog.trace.util;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
Expand Down Expand Up @@ -118,6 +119,38 @@ void getOrCreateOnHitSkipsCreator() {
assertEquals(0, createCount[0]);
}

@Test
void entryMatchesTrueWhenBothKeysEqual() {
PairEntry entry = new PairEntry("a", 1, 100);
assertTrue(entry.matches("a", 1));
}

@Test
void entryMatchesFalseWhenKey1Differs() {
PairEntry entry = new PairEntry("a", 1, 100);
assertFalse(entry.matches("b", 1));
}

@Test
void entryMatchesFalseWhenKey2Differs() {
PairEntry entry = new PairEntry("a", 1, 100);
assertFalse(entry.matches("a", 2));
}

@Test
void entryHashIsConsistentForSameKeys() {
long h1 = Hashtable.D2.Entry.hash("x", 42);
long h2 = Hashtable.D2.Entry.hash("x", 42);
assertEquals(h1, h2);
}

@Test
void entryHashDiffersForDifferentKeys() {
long h1 = Hashtable.D2.Entry.hash("x", 1);
long h2 = Hashtable.D2.Entry.hash("x", 2);
assertFalse(h1 == h2);
}

@Test
void removeReturnsNullForMissingKey() {
Hashtable.D2<String, Integer, PairEntry> table = new Hashtable.D2<>(8);
Expand Down
Loading