JoshDreamland icon

Line matcher test

JoshDreamland | PRO | 09/29/14 12:24:29 AM UTC | 0 ⭐ | 389 👁️ | Never ⏰ | []
Java |

860 B

|

None

|

0 👍

/

0 👎

    @Test
    public void testThing() {
        String CODE = "runatestinatestwith\nsomemoretestsandthen\nyou'redone";
        LineMatch[] matches = YourClass.getMatchingLines(CODE, Pattern.compile("test"));
        assertEquals(2, matches.length);
        assertEquals(5, matches[0].matchedText.size());
        assertEquals("runa",     matches[0].matchedText.get(0).content);
        assertEquals("test",     matches[0].matchedText.get(1).content);
        assertEquals("ina",      matches[0].matchedText.get(2).content);
        assertEquals("test",     matches[0].matchedText.get(3).content);
        assertEquals("with",     matches[0].matchedText.get(4).content);
        assertEquals(3, matches[1].matchedText.size());
        assertEquals("somemore", matches[1].matchedText.get(0).content);
        assertEquals("test",     matches[1].matchedText.get(1).content);
        assertEquals("sandthen", matches[1].matchedText.get(2).content);
    }

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎