Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java')
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java
new file mode 100644
index 000000000..5da93d304
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Mylyn project committers and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.trac.ui;
+
+import java.util.regex.Matcher;
+
+import junit.framework.TestCase;
+
+/**
+ * @author David Green
+ */
+public class TracHyperlinkUtilStandaloneTest extends TestCase {
+
+ public void testWikiPattern2SinglePositiveMatch() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "HyperLink");
+ assertFalse(matcher.find());
+ }
+
+ public void testWikiPattern2MultiplePositiveMatch() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there and ThereIsAnother");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "HyperLink");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "ThereIsAnother");
+ assertFalse(matcher.find());
+ }
+
+ public void testWikiPattern2SingleNegativeMatch() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("no !HyperLink there");
+ assertFalse(matcher.find());
+ }
+
+ public void testWikiPattern2SinglePositiveMatchAtStartOfLine() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("HyperLink there");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "HyperLink");
+ assertFalse(matcher.find());
+ }
+
+ public void testWikiPattern2SingleNegativeMatchAtStartOfLine() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("!HyperLink there");
+ assertFalse(matcher.find());
+ }
+
+ public void testWikiPattern2MixedPositiveNegativeMatch() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there and ThereIsAnother but !NotHere");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "HyperLink");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "ThereIsAnother");
+ assertFalse(matcher.find());
+ }
+
+}

Back to the top