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 java.util.regex.Pattern;
06:
07: import fitnesse.html.HtmlUtil;
08:
09: import junit.framework.TestCase;
10: import junit.swingui.TestRunner;
11:
12: public class HruleWidgetTest extends TestCase {
13: public static void main(String[] args) {
14: TestRunner
15: .main(new String[] { "fitnesse.wikitext.widgets.HruleWidgetTest" });
16: }
17:
18: public void setUp() throws Exception {
19: }
20:
21: public void tearDown() throws Exception {
22: }
23:
24: public void testRegexp() throws Exception {
25: assertTrue("match1", Pattern
26: .matches(HruleWidget.REGEXP, "----"));
27: assertTrue("match2", Pattern.matches(HruleWidget.REGEXP,
28: "------------------"));
29: assertTrue("match3", !Pattern.matches(HruleWidget.REGEXP,
30: "--- -"));
31: }
32:
33: public void testGetSize() throws Exception {
34: HruleWidget widget = new HruleWidget(new MockWidgetRoot(),
35: "----");
36: assertEquals(0, widget.size());
37: widget = new HruleWidget(new MockWidgetRoot(), "-----");
38: assertEquals(1, widget.size());
39: widget = new HruleWidget(new MockWidgetRoot(), "--------------");
40: assertEquals(10, widget.size());
41: }
42:
43: public void testHtml() throws Exception {
44: HruleWidget widget = new HruleWidget(new MockWidgetRoot(),
45: "----");
46: assertEquals(HtmlUtil.HR.toString(), widget.render());
47: widget = new HruleWidget(new MockWidgetRoot(), "------");
48: assertEquals("<hr size=\"3\"/>", widget.render());
49: }
50: }
|