new assertDoesntMatch assertion, bugzilla issue 43639, submitted by David Jackman
git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/antunit/trunk@601404 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
98eab64066
commit
3407316623
|
|
@ -32,6 +32,9 @@
|
|||
assertMatches' casesensitive attribute didn't default to true as
|
||||
documented
|
||||
</action>
|
||||
<action type="add" issue="43639">
|
||||
added a new assertDoesntMatch assertion
|
||||
</action>
|
||||
</release>
|
||||
|
||||
</document>
|
||||
|
|
|
|||
|
|
@ -522,6 +522,65 @@
|
|||
<assertMatches string="${abc}" pattern="abc"
|
||||
casesensitive="false"/></pre>
|
||||
|
||||
|
||||
<h2><a name="assertDoesntMatch">assertDoesntMatch</a></h2>
|
||||
|
||||
<p>Asserts that a string doesn't match a given regular expression.</p>
|
||||
|
||||
<table border="1" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><b>Attribute</b></td>
|
||||
<td valign="top"><b>Description</b></td>
|
||||
<td align="center" valign="top"><b>Required</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">string</td>
|
||||
<td valign="top">The string to test.</td>
|
||||
<td valign="top" align="center">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">pattern</td>
|
||||
<td valign="top">The pattern to test the string against.</td>
|
||||
<td valign="top" align="center">Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">casesensitive</td>
|
||||
<td valign="top">
|
||||
Perform a case sensitive match.
|
||||
Default is true.
|
||||
</td>
|
||||
<td align="center">No.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">multiline</td>
|
||||
<td valign="top">
|
||||
Perform a multi line match.
|
||||
Default is false.
|
||||
</td>
|
||||
<td align="center">No.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">singleline</td>
|
||||
<td valign="top">
|
||||
This allows '.' to match new lines.
|
||||
SingleLine is not to be confused with multiline,
|
||||
SingleLine is a perl
|
||||
regex term, it corresponds to dotall in java regex.
|
||||
Default is false.
|
||||
</td>
|
||||
<td align="center">No.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Examples</h3>
|
||||
|
||||
<p>Make the build fail if the property abc contains
|
||||
"abc" regardless of case:
|
||||
</p>
|
||||
<pre>
|
||||
<assertDoesntMatch string="${abc}" pattern="abc"
|
||||
casesensitive="false"/></pre>
|
||||
|
||||
<h2><a name="assertLogContains">assertLogContains</a></h2>
|
||||
|
||||
<p>Asserts that the build log contains a given message.</p>
|
||||
|
|
|
|||
|
|
@ -197,4 +197,10 @@ under the License.
|
|||
pattern="abc"/>
|
||||
</au:expectfailure>
|
||||
</target>
|
||||
|
||||
<target name="assertDoesntMatch">
|
||||
<au:assertDoesntMatch string="this is AbC"
|
||||
pattern="abcd"
|
||||
casesensitive="false"/>
|
||||
</target>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -258,4 +258,24 @@ under the License.
|
|||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="assertDoesntMatch" backtrace="false">
|
||||
<attribute name="string"/>
|
||||
<attribute name="pattern"/>
|
||||
<attribute name="casesensitive" default="true"/>
|
||||
<attribute name="singleline" default="false"/>
|
||||
<attribute name="multiline" default="false"/>
|
||||
<attribute name="message"
|
||||
default="Expected '@{string}' to not match pattern '@{pattern}'"/>
|
||||
<sequential>
|
||||
<au:assertTrue message="@{message}">
|
||||
<not>
|
||||
<matches string="@{string}" pattern="@{pattern}"
|
||||
casesensitive="@{casesensitive}"
|
||||
singleline="@{singleline}"
|
||||
multiline="@{multiline}"/>
|
||||
</not>
|
||||
</au:assertTrue>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
</antlib>
|
||||
|
|
|
|||
|
|
@ -141,6 +141,10 @@ public class AssertTest extends BuildFileTest {
|
|||
executeTarget("assertMatches");
|
||||
}
|
||||
|
||||
public void testDoesntMatch() {
|
||||
executeTarget("assertDoesntMatch");
|
||||
}
|
||||
|
||||
public void testMatchesDefaultCaseSensitivity() {
|
||||
executeTarget("assertMatchesDefaultCaseSensitivity");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue