01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.wikitext.widgets;
04:
05: import junit.framework.TestCase;
06: import junit.swingui.TestRunner;
07:
08: import java.util.regex.Pattern;
09:
10: public class CenterWidgetTest extends TestCase {
11: public static void main(String[] args) {
12: TestRunner
13: .main(new String[] { "fitnesse.wikitext.widgets.CenterWidgetTest" });
14: }
15:
16: public void setUp() throws Exception {
17: }
18:
19: public void tearDown() throws Exception {
20: }
21:
22: public void testRegexp() throws Exception {
23: assertTrue("match1", Pattern.matches(CenterWidget.REGEXP,
24: "!c centered text\n"));
25: assertTrue("match2", Pattern.matches(CenterWidget.REGEXP,
26: "!C more text\n"));
27: assertTrue("match3", !Pattern.matches(CenterWidget.REGEXP,
28: "!ctext\n"));
29: assertTrue("match4", Pattern.matches(CenterWidget.REGEXP,
30: "!c text\n"));
31: assertTrue("match5", !Pattern.matches(CenterWidget.REGEXP,
32: " !c text\n"));
33: }
34:
35: public void testHtml() throws Exception {
36: CenterWidget widget = new CenterWidget(new MockWidgetRoot(),
37: "!c some text\n");
38: assertEquals("<div class=\"centered\">some text</div>", widget
39: .render());
40: }
41: }
|