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.*;
06:
07: // created by Jason Sypher
08:
09: public class StrikeWidgetTest extends AbstractWidget {
10: public void testRegularExpression() throws Exception {
11: assertMatchEquals("abc--123--def", "--123--");
12: assertNoMatch("------");
13: }
14:
15: public void testOutput() throws Exception {
16: StrikeWidget widget = new StrikeWidget(new MockWidgetRoot(),
17: "--some text--");
18: assertEquals(1, widget.numberOfChildren());
19: WikiWidget child = widget.nextChild();
20: assertEquals(TextWidget.class, child.getClass());
21: assertEquals("some text", ((TextWidget) child).getText());
22: assertEquals("<span class=\"strike\">some text</span>", widget
23: .render());
24: }
25:
26: public void testEmbeddedDashInStrikedText() throws Exception {
27: StrikeWidget widget = new StrikeWidget(new MockWidgetRoot(),
28: "--embedded-dash--");
29: assertEquals(1, widget.numberOfChildren());
30: WikiWidget child = widget.nextChild();
31: assertEquals(TextWidget.class, child.getClass());
32: assertEquals("embedded-dash", ((TextWidget) child).getText());
33: assertEquals("<span class=\"strike\">embedded-dash</span>",
34: widget.render());
35: }
36:
37: public void testEvilExponentialMatch() throws Exception {
38: long startTime = System.currentTimeMillis();
39:
40: assertNoMatch("--1234567890123456789012");
41:
42: long endTime = System.currentTimeMillis();
43: assertTrue("took too long", endTime - startTime < 1000);
44: }
45:
46: public static void main(String[] args) {
47: junit.textui.TestRunner.run(StrikeWidgetTest.class);
48: }
49:
50: protected String getRegexp() {
51: return StrikeWidget.REGEXP;
52: }
53:
54: }
|