public class ParseToolsTest
{
@Test
public void testBalancedCapture()
{
CapturingGroup group = ParseTools.balancedCapture("/foo/{bar}/cab".toCharArray(), 5, 12, CaptureType.BRACE);
Assert.assertEquals(9, group.getEnd());
Assert.assertArrayEquals("bar".toCharArray(), group.getCaptured());
group = ParseTools.balancedCapture("/foo/{{a}}/cab".toCharArray(), 5, 12, CaptureType.BRACE);
Assert.assertEquals(9, group.getEnd());
Assert.assertArrayEquals("{a}".toCharArray(), group.getCaptured());
group = ParseTools.balancedCapture("/foo/{{a}}/cab".toCharArray(), 0, 12, CaptureType.REGEX);
Assert.assertEquals(4, group.getEnd());
Assert.assertArrayEquals("foo".toCharArray(), group.getCaptured());
}