net.sourceforge.sqlunit.matchers
Class SignificantDigitsMatcher
java.lang.Object
net.sourceforge.sqlunit.matchers.SignificantDigitsMatcher
- All Implemented Interfaces:
- IMatcher
public class SignificantDigitsMatcher
- extends java.lang.Object
- implements IMatcher
The SignificantDigitsMatcher is an implementation of the IMatcher interface
used to compare FLOAT values where you only really care about matching to a
certain number of significant digits to the right of the decimal. Especially
useful when you're generating your test script by copying and pasting out of
a SQL query tool that displays a different number of significant digits than
SQLUnit pulls back from the database.
Example configuration:
<match resultset-id="1" row-id="*" col-id="9-13,15-18"
matcher="net.sourceforge.sqlunit.matchers.SignificantDigitsMatcher">
<arg name="signif-digits" value="3" />
</match>
- Version:
- $Revision: 1.1 $
- Author:
- Tim Cull (trcull@yahoo.com)
Method Summary |
boolean |
isEqual(java.lang.String source,
java.lang.String target,
java.util.Map args)
Returns true if the value of the target is equal to the source
up to a certain number of significant digits. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SignificantDigitsMatcher
public SignificantDigitsMatcher()
- Default constructor per contract with IMatcher.
isEqual
public boolean isEqual(java.lang.String source,
java.lang.String target,
java.util.Map args)
throws SQLUnitException
- Returns true if the value of the target is equal to the source
up to a certain number of significant digits.
- Specified by:
isEqual
in interface IMatcher
- Parameters:
source
- the String representing the source to be matched.target
- the String representing the target to be matched.args
- a Map of name value pairs of arguments passed in.
- Returns:
- true if the matching strategy resulted in success.
- Throws:
SQLUnitException
- if there was a problem with matching.