Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions internal-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ extra["excludedClassesCoverage"] = listOf(
"datadog.trace.api.EndpointCheckpointerHolder",
"datadog.trace.api.iast.IastAdvice.Kind",
"datadog.trace.api.UserEventTrackingMode",
// Lazy holder idiom; exercised indirectly via TagMap.EMPTY
"datadog.trace.api.OptimizedTagMap.EmptyHolder",
// These are almost fully abstract classes so nothing to test
"datadog.trace.api.profiling.RecordingData",
"datadog.trace.api.appsec.AppSecEventTracker",
Expand Down
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