aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/test
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-03-27 18:28:27 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2023-03-27 18:28:27 +0200
commit507b58ef6fd297c0a961d3b2c15ab03e0e557813 (patch)
treeb0b18baa5315732ca4152d15c681c60c3bce69a2 /container-core/src/test
parent5ec4d195cd2e0215da609abaaf26d5ca9c984153 (diff)
CompoundName.first(int n) is called multiple time from QueryProfileProperties methods.
Precompute, as we do for rest(int n), these instead of generating temporary CompoundNames on the fly.
Diffstat (limited to 'container-core/src/test')
-rw-r--r--container-core/src/test/java/com/yahoo/processing/request/CompoundNameTestCase.java13
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());
}