-
-
Notifications
You must be signed in to change notification settings - Fork 787
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acaf1b3
commit 561ffaf
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/test/java/com/fasterxml/jackson/failing/JsonPointer1328Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |