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 fitnesse.wikitext.WikiWidget;
06: import junit.framework.TestCase;
07:
08: import java.util.regex.Pattern;
09:
10: public class BoldWidgetTest extends TestCase {
11: public void setUp() throws Exception {
12: }
13:
14: public void tearDown() throws Exception {
15: }
16:
17: public void testRegexp() throws Exception {
18: assertTrue("match1", Pattern.matches(BoldWidget.REGEXP,
19: "'''bold'''"));
20: assertTrue("match2", Pattern.matches(BoldWidget.REGEXP,
21: "''''bold''''"));
22: assertTrue("match3", !Pattern.matches(BoldWidget.REGEXP,
23: "'' 'not bold' ''"));
24: }
25:
26: public void testBadConstruction() throws Exception {
27: BoldWidget widget = new BoldWidget(new MockWidgetRoot(),
28: "''''some text' '''");
29: assertEquals(1, widget.numberOfChildren());
30: WikiWidget child = widget.nextChild();
31: assertEquals(TextWidget.class, child.getClass());
32: assertEquals("'some text' ", ((TextWidget) child).getText());
33: }
34:
35: public void testHtml() throws Exception {
36: BoldWidget widget = new BoldWidget(new MockWidgetRoot(),
37: "'''bold text'''");
38: assertEquals("<b>bold text</b>", widget.render());
39: }
40:
41: }
|