Skip to content

Commit

Permalink
Add failing test for #1328
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 6, 2024
1 parent acaf1b3 commit 561ffaf
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.fasterxml.jackson.failing;

import com.fasterxml.jackson.core.JUnit5TestBase;
import com.fasterxml.jackson.core.JsonPointer;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

class JsonPointer1328Test extends JUnit5TestBase
{
// 5k enough on some systems to reproduce; use 10k
private final static int DEPTH = 10_000;

// [core#1328]: verify efficient operation of JsonPointer.head()
@Test
void deepHead()
{
final String INPUT = repeat("/a", DEPTH);
JsonPointer ptr = JsonPointer.compile(INPUT);
assertEquals(repeat("/a", DEPTH - 1), ptr.head().toString());
}

private final static String repeat(String part, int count) {
StringBuilder sb = new StringBuilder(count * part.length());
while (--count >= 0) {
sb.append(part);
}
return sb.toString();
}

}

0 comments on commit 561ffaf

Please sign in to comment.