@Test
public void testEndsWith() {

    byte[] p = "pneumonoultramicroscopicsilicovolcanoconiosis".getBytes(StandardCharsets.US_ASCII);
    byte[] d = "pneumonoultrami".getBytes(StandardCharsets.US_ASCII);
    SearchPattern sp = SearchPattern.compile(p);
    assertEquals(15, sp.endsWith(d, 0, d.length));
    p = "abcdefghijklmnopqrstuvwxyz".getBytes(StandardCharsets.US_ASCII);
    d = "abcdefghijklmnopqrstuvwxyzabcdefghijklmno".getBytes(StandardCharsets.US_ASCII);
    sp = SearchPattern.compile(p);
    assertEquals(0, sp.match(d, 0, d.length));
    assertEquals(-1, sp.match(d, 1, d.length - 1));
    assertEquals(15, sp.endsWith(d, 0, d.length));
    p = "abcdefghijklmnopqrstuvwxyz".getBytes(StandardCharsets.US_ASCII);
    d = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz".getBytes(StandardCharsets.US_ASCII);
    sp = SearchPattern.compile(p);
    assertEquals(0, sp.match(d, 0, d.length));
    assertEquals(26, sp.match(d, 1, d.length - 1));
    assertEquals(26, sp.endsWith(d, 0, d.length));
    //test no match
    p = "hello world".getBytes(StandardCharsets.US_ASCII);
    d = "there is definitely no match in here".getBytes(StandardCharsets.US_ASCII);
    sp = SearchPattern.compile(p);
    assertEquals(0, sp.endsWith(d, 0, d.length));
}