From 067eccdb7022f30c0bbcf8cda38e7d51e2beea5d Mon Sep 17 00:00:00 2001 From: kohsuke Date: Fri, 5 Jan 2007 07:15:58 +0000 Subject: [PATCH] its test code. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1647 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/test/java/hudson/MarkupTextTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 core/src/test/java/hudson/MarkupTextTest.java diff --git a/core/src/test/java/hudson/MarkupTextTest.java b/core/src/test/java/hudson/MarkupTextTest.java new file mode 100644 index 0000000000..a16b83795e --- /dev/null +++ b/core/src/test/java/hudson/MarkupTextTest.java @@ -0,0 +1,31 @@ +package hudson; + +import junit.framework.TestCase; +import hudson.MarkupText.SubText; + +import java.util.regex.Pattern; + +/** + * @author Kohsuke Kawaguchi + */ +public class MarkupTextTest extends TestCase { + public void test1() { + MarkupText t = new MarkupText("I fixed issue #155. The rest is trick text: xissue #155 issue #123x"); + for (SubText st : t.findTokens(pattern)) + st.surroundWith("<$1>","<$1>"); + + System.out.println(t); + assertEquals(t.toString(),"I fixed <155>issue #155<155>. The rest is trick text: xissue #155 issue #123x"); + } + + public void testBoundary() { + MarkupText t = new MarkupText("issue #155---issue #123"); + for (SubText st : t.findTokens(pattern)) + st.surroundWith("<$1>","<$1>"); + + System.out.println(t); + assertEquals(t.toString(),"<155>issue #155<155>---<123>issue #123<123>"); + } + + private static final Pattern pattern = Pattern.compile("issue #([0-9]+)"); +}