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 HeaderWidgetTest extends TestCase {
11: public static void main(String[] args) {
12: TestRunner
13: .main(new String[] { "fitnesse.wikitext.widgets.HeaderWidgetTest" });
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(HeaderWidget.REGEXP,
24: "!1 some text\n"));
25: assertTrue("match2", Pattern.matches(HeaderWidget.REGEXP,
26: "!2 \n"));
27: assertTrue("match3", !Pattern.matches(HeaderWidget.REGEXP,
28: "!3text\n"));
29: assertTrue("match4", !Pattern.matches(HeaderWidget.REGEXP,
30: "!4 text\n"));
31: assertTrue("match5", Pattern.matches(HeaderWidget.REGEXP,
32: "!3 text\n"));
33: }
34:
35: public void testGetSize() throws Exception {
36: HeaderWidget widget = new HeaderWidget(new MockWidgetRoot(),
37: "!1 text \n");
38: assertEquals(1, widget.size());
39: widget = new HeaderWidget(new MockWidgetRoot(), "!3 text \n");
40: assertEquals(3, widget.size());
41: }
42:
43: public void testHtml() throws Exception {
44: HeaderWidget widget = new HeaderWidget(new MockWidgetRoot(),
45: "!1 some text\n");
46: assertEquals("<h1>some text</h1>", widget.render());
47: }
48: }
|