示例#1
0
  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));
  }
示例#2
0
  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));
  }
示例#3
0
  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));
  }
示例#4
0
  public void testEveryCharOf() {

    String buffer = "abcdef";
    CharsMatcher matcher = CharsMatcher.everyCharOf("de");

    assertEquals(0, matcher.matches(buffer, 0));
    assertEquals(0, matcher.matches(buffer, 1));
    assertEquals(0, matcher.matches(buffer, 2));
    assertEquals(2, matcher.matches(buffer, 3));
    assertEquals(0, matcher.matches(buffer, 4));
    assertEquals(0, matcher.matches(buffer, 5));

    assertEquals(3, matcher.firstIndexIn(buffer, 0));
    assertEquals(3, matcher.firstIndexIn(buffer, 1));
    assertEquals(3, matcher.firstIndexIn(buffer, 2));
    assertEquals(3, matcher.firstIndexIn(buffer, 3));
    assertEquals(-1, matcher.firstIndexIn(buffer, 4));
    assertEquals(-1, matcher.firstIndexIn(buffer, 5));
  }