org.jdom2.input.sax.TestTextBuffer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdom Show documentation
Show all versions of jdom Show documentation
A complete, Java-based solution for accessing, manipulating,
and outputting XML data
The newest version!
package org.jdom2.input.sax;
import static org.junit.Assert.*;
import org.junit.Test;
@SuppressWarnings("javadoc")
public class TestTextBuffer {
@Test
public void testIsAllWhitespace() {
TextBuffer tb = new TextBuffer();
tb.append(" ".toCharArray(), 0, 3);
assertTrue(tb.isAllWhitespace());
tb.append("frodo".toCharArray(), 0, 4);
assertFalse(tb.isAllWhitespace());
}
@Test
public void testToString() {
// this tests the expansion of the backing array.
final StringBuilder sb = new StringBuilder();
final TextBuffer tb = new TextBuffer();
final char[] data = "frodo".toCharArray();
for (int i = 1000; i >= 0; i--) {
sb.append(data);
tb.append(data, 0, data.length);
assertEquals(sb.toString(), tb.toString());
}
}
}