diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-03-28 09:21:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-28 09:21:12 +0200 |
commit | 642acda2e5a28ba06c094e503c662b514efadabe (patch) | |
tree | 85259ced2eefd984a3fab57f086b90e217b30698 /container-core/src/test | |
parent | 446eb32c890ffa477861109cd75cdb3c0c9f2cea (diff) | |
parent | 507b58ef6fd297c0a961d3b2c15ab03e0e557813 (diff) |
Merge pull request #26597 from vespa-engine/balder/precompute-first-N
CompoundName.first(int n) is called multiple time from QueryProfilePr…
Diffstat (limited to 'container-core/src/test')
-rw-r--r-- | container-core/src/test/java/com/yahoo/processing/request/CompoundNameTestCase.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/container-core/src/test/java/com/yahoo/processing/request/CompoundNameTestCase.java b/container-core/src/test/java/com/yahoo/processing/request/CompoundNameTestCase.java index 055dbf77371..4bbece0af29 100644 --- a/container-core/src/test/java/com/yahoo/processing/request/CompoundNameTestCase.java +++ b/container-core/src/test/java/com/yahoo/processing/request/CompoundNameTestCase.java @@ -52,6 +52,15 @@ public class CompoundNameTestCase { verifyStrict("e", new CompoundName("a.b.c.d.e").rest(4)); verifyStrict(CompoundName.empty, new CompoundName("a.b.c.d.e").rest(5)); } + @Test + final void testFirstN() { + verifyStrict("a.b.c.d.e", new CompoundName("a.b.c.d.e").first(5)); + verifyStrict("a.b.c.d", new CompoundName("a.b.c.d.e").first(4)); + verifyStrict("a.b.c", new CompoundName("a.b.c.d.e").first(3)); + verifyStrict("a.b", new CompoundName("a.b.c.d.e").first(2)); + verifyStrict("a", new CompoundName("a.b.c.d.e").first(1)); + verifyStrict(CompoundName.empty, new CompoundName("a.b.c.d.e").first(0)); + } @Test final void testPrefix() { @@ -103,8 +112,8 @@ public class CompoundNameTestCase { Splitter peoplesFront = Splitter.on('.'); Iterable<String> answer = peoplesFront.split(NAME); Iterator<String> expected = answer.iterator(); - for (int i = 0; i < l.size(); ++i) { - assertEquals(expected.next(), l.get(i)); + for (String s : l) { + assertEquals(expected.next(), s); } assertFalse(expected.hasNext()); } |