01: package abbot.editor.widgets;
02:
03: import junit.framework.*;
04: import junit.extensions.abbot.*;
05:
06: public class TextFormatTest extends TestCase {
07:
08: public void testWordBreak() {
09: String[][] words = { { "Some", "Some" },
10: { "SomeMore", "Some More" },
11: { "andAnother", "and Another" },
12: { "AAAMotorClub", "AAA Motor Club" }, };
13: for (int i = 0; i < words.length; i++) {
14: assertEquals("Didn't break up '" + words[i][0] + "'",
15: words[i][1], TextFormat.wordBreak(words[i][0]));
16: }
17: }
18:
19: public void testLongLine() {
20: String original = "onenonwrap twononwrap";
21: String expected = "onenonwrap<br>twononwrap";
22: assertEquals("Improper long-line wrapping", expected,
23: TextFormat.wordWrap(original, 5, "<br>"));
24: }
25:
26: public void testTrimLeadingWhitespace() {
27: String original = " line 1 and line 2";
28: String expected = "line 1 and<br>line 2";
29: assertEquals("Should strip whitespace from BOL", expected,
30: TextFormat.wordWrap(original, 10, "<br>"));
31: }
32:
33: public void testWordWrap() {
34: String original = "The current JVM release incorrectly generates events for mouse buttons 2 and 3. There is no workaround. Please file a bug with Apple at http://www.bugreporter.apple.com.";
35: String expected = "The current JVM release incorrectly generates events for<br>mouse buttons 2 and 3. There is no workaround. Please file<br>a bug with Apple at http://www.bugreporter.apple.com.";
36: assertEquals("Bad word wrapping", expected, TextFormat
37: .wordWrap(original, TextFormat.DIALOG_WRAP, "<br>"));
38: }
39:
40: /** Construct a test case with the given name. */
41: public TextFormatTest(String name) {
42: super (name);
43: }
44:
45: /** Run the default test suite. */
46: public static void main(String[] args) {
47: TestHelper.runTests(args, TextFormatTest.class);
48: }
49: }
|