@Test public void testReplaceKeep() { MarkupUtil mu = new MarkupUtil(RegionSkipper.getCommentSkipper()); assertEquals(Match.NULL_MATCH, mu.find("Sieb", 0, VFormUtil.getAllPattern())); final String text = "Sieben können Sie haben."; final Match match = mu.find(text, 0, VFormUtil.getAllPattern()); final String vform = "Sie"; assertEquals(text.lastIndexOf(vform), match.startOffset); assertEquals(text.lastIndexOf(vform) + vform.length(), match.endOffset); }
@Test public void testNoMatch() { final MarkupUtil mu = new MarkupUtil(RegionSkipper.getCommentSkipper()); final String text = "Dann kann Anna es ihrem Kollegen geben."; final Match match = mu.find(text, 0, VFormUtil.getAllPattern()); assertEquals(Match.NULL_MATCH, match); }
@Test public void testMatch1() { final MarkupUtil mu = new MarkupUtil(RegionSkipper.getCommentSkipper()); final String text = "Dann kann Anna es Ihrem Kollegen geben."; final Match match = mu.find(text, 0, VFormUtil.getAllPattern()); final String vform = "Ihrem"; assertEquals(text.indexOf(vform), match.startOffset); assertEquals(text.indexOf(vform) + vform.length(), match.endOffset); }
@Test public void testMatchBoundary() { final String text = "Dann können Sie's Ihrem Kollegen geben."; final MarkupUtil mu = new MarkupUtil(RegionSkipper.getCommentSkipper()); Match match = mu.find(text, 0, VFormUtil.getAllPattern()); final String vform = "Sie"; assertEquals(text.indexOf(vform), match.startOffset); assertEquals(text.indexOf(vform) + vform.length(), match.endOffset); match = mu.find(text, match.endOffset, VFormUtil.getAllPattern()); final String vform2 = "Ihrem"; assertEquals(text.indexOf(vform2), match.startOffset); assertEquals(text.indexOf(vform2) + vform2.length(), match.endOffset); match = mu.find(text, match.endOffset, VFormUtil.getAllPattern()); assertEquals(Match.NULL_MATCH, match); }