Examples of ReaderCharSequence


Examples of net.rootnode.loomchild.util.io.ReaderCharSequence

  private static final Pattern REGEX = Pattern.compile(" - ");

  @Test
  public void testSimple() {
    StringReader reader = new StringReader(REGEX_DATA);
    CharSequence text = new ReaderCharSequence(reader);
    ReaderMatcher matcher = new ReaderMatcher(REGEX, text);
    boolean found;
    found = matcher.find();
    assertTrue(found);
    assertEquals(5, matcher.start());
View Full Code Here

Examples of net.rootnode.loomchild.util.io.ReaderCharSequence

  private static final Pattern REGEX_WHOLE = Pattern.compile(".*");

  @Test
  public void testWhole() {
    StringReader reader = new StringReader(REGEX_DATA);
    CharSequence text = new ReaderCharSequence(reader);
    ReaderMatcher matcher = new ReaderMatcher(REGEX_WHOLE, text);
    boolean found = matcher.find();
    assertTrue(found);
    assertEquals(REGEX_DATA, matcher.group());
  }
View Full Code Here

Examples of net.rootnode.loomchild.util.io.ReaderCharSequence

  private static final Pattern REGEX_ALTERNATIVE = Pattern.compile("b|bc");

  @Test
  public void testAlternative() {
    StringReader reader = new StringReader(REGEX_DATA);
    CharSequence text = new ReaderCharSequence(reader);
    ReaderMatcher matcher = new ReaderMatcher(REGEX_ALTERNATIVE, text);
    boolean found = matcher.find();
    assertTrue(found);
    assertEquals(1, matcher.start());
    assertEquals(2, matcher.end());
View Full Code Here

Examples of net.rootnode.loomchild.util.io.ReaderCharSequence

  private static final Pattern REGEX_LOOKING_AT = Pattern.compile("bcd");

  @Test
  public void testLookingAt() {
    StringReader reader = new StringReader(REGEX_DATA);
    CharSequence text = new ReaderCharSequence(reader);
    ReaderMatcher matcher = new ReaderMatcher(REGEX_LOOKING_AT, text);
    matcher.region(1, text.length());
    assertTrue(matcher.lookingAt());
    matcher.region(2, text.length());
    assertFalse(matcher.lookingAt());
  }
View Full Code Here

Examples of org.jamesii.gui.syntaxeditor.ReaderCharSequence

  public final void testReaderCharSequence() {
    // check 1000 random strings
    for (int i = 0; i < 1000; i++) {
      String s =
          Strings.generateRandomString(generator.nextInt(10000), generator);
      ReaderCharSequence rcs;
      try (StringReader reader = new StringReader(s)) {
        rcs = new ReaderCharSequence(reader);
      }

      assertTrue(s.contentEquals(rcs));
    }
  }
View Full Code Here

Examples of org.jamesii.gui.syntaxeditor.ReaderCharSequence

      Document doc = new PlainDocument();
      try {
        doc.remove(0, doc.getLength());
        doc.insertString(0, testString, null);
        DocumentReader reader = new DocumentReader(doc);
        ReaderCharSequence rcs = new ReaderCharSequence(reader);
        reader.close();

        assertTrue(testString.contentEquals(rcs));

        reader = new DocumentReader(doc);
View Full Code Here

Examples of org.jamesii.gui.syntaxeditor.ReaderCharSequence

      };
      try {
        doc.remove(0, doc.getLength());
        doc.insertString(0, testString, null);
        ReaderCharSequence rcs;
        try (DocumentReader reader = new DocumentReader(doc)) {
          for (int i = 0; i < 10; i++) {
            int r = (generator.nextInt(doc.getLength()));
            int l = (generator.nextInt(doc.getLength() - r));
            if (i % 2 == 0) {
              doc.remove(r, l);
            } else {
              String s =
                  Strings.generateRandomString(generator.nextInt(100),
                      generator);
              doc.insertString(r, s, null);
            }
          }
          rcs = new ReaderCharSequence(reader);
        }

        // the document reader should ignore changes made to document and still
        // return original testString
        assertTrue(
View Full Code Here

Examples of org.jamesii.gui.syntaxeditor.ReaderCharSequence

              generator);
      Document doc = new PlainDocument();
      try {
        doc.remove(0, doc.getLength());
        doc.insertString(0, testString, null);
        ReaderCharSequence rcs;
        try (DocumentReader reader = new DocumentReader(doc)) {
          for (int i = 0; i < 10; i++) {
            int r = generator.nextInt(doc.getLength());
            int l = generator.nextInt((doc.getLength() - r));
            if (i % 2 == 0) {
              doc.remove(r, l);
            } else {
              String s =
                  Strings.generateRandomString(generator.nextInt(100),
                      generator);
              doc.insertString(r, s, null);
            }
          }
          rcs = new ReaderCharSequence(reader);
        }

        // the document reader should ignore changes made to document and still
        // return original testString
        assertTrue(testString.contentEquals(rcs));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.