Skip to content

Commit 67ec34b

Browse files
authored
Add failing test for #1328 (#1329)
1 parent acaf1b3 commit 67ec34b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.core.JUnit5TestBase;
4+
import com.fasterxml.jackson.core.JsonPointer;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
9+
class JsonPointer1328Test extends JUnit5TestBase
10+
{
11+
// 5k enough on some systems to reproduce; use 10k
12+
private final static int DEPTH = 10_000;
13+
14+
// [core#1328]: verify efficient operation of JsonPointer.head()
15+
@Test
16+
void deepHead()
17+
{
18+
final String INPUT = repeat("/a", DEPTH);
19+
JsonPointer ptr = JsonPointer.compile(INPUT);
20+
assertEquals(repeat("/a", DEPTH - 1), ptr.head().toString());
21+
}
22+
23+
private final static String repeat(String part, int count) {
24+
StringBuilder sb = new StringBuilder(count * part.length());
25+
while (--count >= 0) {
26+
sb.append(part);
27+
}
28+
return sb.toString();
29+
}
30+
31+
}

0 commit comments

Comments
 (0)