Advertisement
JoshDreamland

Line matcher test

Sep 28th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     @Test
  2.     public void testThing() {
  3.         String CODE = "runatestinatestwith\nsomemoretestsandthen\nyou'redone";
  4.         LineMatch[] matches = YourClass.getMatchingLines(CODE, Pattern.compile("test"));
  5.         assertEquals(2, matches.length);
  6.         assertEquals(5, matches[0].matchedText.size());
  7.         assertEquals("runa",     matches[0].matchedText.get(0).content);
  8.         assertEquals("test",     matches[0].matchedText.get(1).content);
  9.         assertEquals("ina",      matches[0].matchedText.get(2).content);
  10.         assertEquals("test",     matches[0].matchedText.get(3).content);
  11.         assertEquals("with",     matches[0].matchedText.get(4).content);
  12.         assertEquals(3, matches[1].matchedText.size());
  13.         assertEquals("somemore", matches[1].matchedText.get(0).content);
  14.         assertEquals("test",     matches[1].matchedText.get(1).content);
  15.         assertEquals("sandthen", matches[1].matchedText.get(2).content);
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement