[CVS nanning] added more regexp tests

Lecando Shared <[email protected]> Mon, 8 Sep 2003 05:37:44 -0500
Newsgroups gmane.comp.java.nanning.devel
Message-ID <[email protected]>
<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>nanning/src/test/org/codehaus/nanning/util</tt></b> on <span id="info">MAIN</span></td></tr>
<tr><td><tt><a href="#file1">RegexpPatternTest.java</a></tt></td><td align="right" id="added">+12</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.1 -&gt; 1.2</td></tr>
</table>
<pre class="comment">
added more regexp tests
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">nanning/src/test/org/codehaus/nanning/util<br /></span>
<div class="fileheader"><big><b>RegexpPatternTest.java</b></big> <small id="info">1.1 -&gt; 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- RegexpPatternTest.java	5 Sep 2003 07:56:45 -0000	1.1
+++ RegexpPatternTest.java	8 Sep 2003 10:37:44 -0000	1.2
@@ -17,10 +17,21 @@
</small></pre><pre class="diff" id="context">     }
 
     public void testComplexPatterns() throws Exception {
</pre><pre class="diff" id="removed">-        RegexpPattern regexpPattern = RegexpPattern.compile("uid=(.*?)(<span id="removedchars">,</span>.*)");
</pre><pre class="diff" id="added">+        RegexpPattern regexpPattern = RegexpPattern.compile("uid=(.*?)(<span id="addedchars">(,|$)</span>.*)");
</pre><pre class="diff" id="context">         Matcher matcher = regexpPattern.matcher("uid=jimmy,ou=TesT-uid,dc=lecando,dc=com");
         assertTrue(matcher.matches());
         assertEquals("jimmy", matcher.group(1));
</pre><pre class="diff" id="added">+        assertEquals(",ou=TesT-uid,dc=lecando,dc=com", matcher.group(2));
+    }
+
+    public void testMorePatterns() throws Exception {
+        RegexpPattern regexpPattern = RegexpPattern.compile("cn=(.*?)((,|$).*)");
+        Matcher matcher = regexpPattern.matcher("cn=George Poirier");
+        assertTrue(matcher.matches());
+        assertEquals("George Poirier", matcher.group(1));
+        matcher = regexpPattern.matcher("cn=George Poirier,ou=TesT-uid,dc=lecando,dc=com");
+        assertTrue(matcher.matches());
+        assertEquals("George Poirier", matcher.group(1));
</pre><pre class="diff" id="context">         assertEquals(",ou=TesT-uid,dc=lecando,dc=com", matcher.group(2));
     }
 
</pre></div>
</body></html>