public void testDoubleQuoteMatcher() { CharsMatcher matcher = CharsMatcher.DoubleQuoteMatcher; assertSame(matcher, CharsMatcher.DoubleQuoteMatcher); assertEquals(0, matcher.matches(additionalCharsString, 10)); assertEquals(0, matcher.matches(additionalCharsString, 11)); assertEquals(0, matcher.matches(additionalCharsString, 12)); assertEquals(0, matcher.matches(additionalCharsString, 13)); assertEquals(1, matcher.matches(additionalCharsString, 14)); }
public void testCommaMatcher() { CharsMatcher matcher = CharsMatcher.CommaMatcher; assertSame(matcher, CharsMatcher.CommaMatcher); assertEquals(0, matcher.matches(additionalCharsString, 0)); assertEquals(1, matcher.matches(additionalCharsString, 1)); assertEquals(0, matcher.matches(additionalCharsString, 2)); assertEquals(1, matcher.matches(additionalCharsString, 3)); assertEquals(0, matcher.matches(additionalCharsString, 4)); }
public void testCharMatcher() { String buffer = "abcdef"; CharsMatcher matcher = CharsMatcher.character('c'); assertEquals(0, matcher.matches(buffer, 0)); assertEquals(0, matcher.matches(buffer, 1)); assertEquals(1, matcher.matches(buffer, 2)); assertEquals(0, matcher.matches(buffer, 3)); assertEquals(0, matcher.matches(buffer, 4)); assertEquals(0, matcher.matches(buffer, 5)); }
public void testAnyCharOf() { String buffer = "abcdef"; CharsMatcher matcher = CharsMatcher.anyCharOf("ace"); assertEquals(1, matcher.matches(buffer, 0)); assertEquals(0, matcher.matches(buffer, 1)); assertEquals(1, matcher.matches(buffer, 2)); assertEquals(0, matcher.matches(buffer, 3)); assertEquals(1, matcher.matches(buffer, 4)); assertEquals(0, matcher.matches(buffer, 5)); assertEquals(0, matcher.firstIndexIn(buffer, 0)); assertEquals(2, matcher.firstIndexIn(buffer, 1)); assertEquals(2, matcher.firstIndexIn(buffer, 2)); assertEquals(4, matcher.firstIndexIn(buffer, 3)); assertEquals(4, matcher.firstIndexIn(buffer, 4)); assertEquals(-1, matcher.firstIndexIn(buffer, 5)); }
public void doTestNoMatch(CharsMatcher matcher, String s) { assertFalse(matcher.matching(s, 0)); }
public void doTestMatch(CharsMatcher matcher, String s) { assertTrue(matcher.matching(s, 0)); assertTrue(matcher.firstIndexIn(s) >= 0); assertTrue(matcher.lastIndexIn(s) >= 0); }