Skip to content

Commit a1a6332

Browse files
dougqhclaude
andcommitted
Cover StringIndex instance long[] API + Support.numSlots for coverage gate
jacocoTestCoverageVerification flagged StringIndex at 0.7 instruction coverage (min 0.8): the instance long[] API (mapLongValues / lookup / lookupOrDefault) and the Support.numSlots(int[]) static were never exercised -- the suite used the Support long statics plus the instance int[]/T[] APIs. Add two tests covering them. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 1d8fd80 commit a1a6332

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

internal-api/src/test/java/datadog/trace/util/StringIndexTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,23 @@ void instance_lookup_delegatesToSupportArrays() {
168168
assertEquals(0, idx.lookup(ids, "missing"));
169169
assertEquals(42, idx.lookupOrDefault(ids, "missing", 42));
170170
}
171+
172+
@Test
173+
void instance_longValues_mapAndLookup() {
174+
StringIndex idx = StringIndex.of("a", "b", "c");
175+
long[] vals = idx.mapLongValues(s -> s.charAt(0) - 'a' + 1L);
176+
assertEquals(idx.numSlots(), vals.length); // sized to the table, not the name count
177+
178+
assertEquals(1L, idx.lookup(vals, "a"));
179+
assertEquals(3L, idx.lookup(vals, "c"));
180+
assertEquals(0L, idx.lookup(vals, "z")); // miss -> 0
181+
assertEquals(2L, idx.lookupOrDefault(vals, "b", -1L)); // hit
182+
assertEquals(-1L, idx.lookupOrDefault(vals, "z", -1L)); // miss -> supplied default
183+
}
184+
185+
@Test
186+
void support_numSlots_matchesTableSize() {
187+
Data d = Support.create("a", "b", "c");
188+
assertEquals(d.hashes.length, Support.numSlots(d.hashes));
189+
}
171190
}

0 commit comments

Comments
 (0)