From: SourceForge.net <no...@so...> - 2007-07-27 20:55:53
|
Feature Requests item #1762410, was opened at 2007-07-27 16:55 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=1762410&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Ken Estes (kestesisme) Assigned to: Nobody/Anonymous (nobody) Summary: use tolerance for floating point values in XML Initial Comment: We produce XML which has numerical values scattered through out the XML both in nodes and attributes. <svg xmlns="http://www.w3.org/2000/svg" width="0.085in" height="0.085in"> <text text-anchor="end" y="92" x="15">36</text> <fo:block-container height="2pc" width="46.5pc" left="2.5pc" top="64pc"> The numerical values can be produced by computations which are carried out in software or hardware. Because of round off errors we need to have a custom string equals function which will allow for round off in the numeric portions of the string. Enclosed please find a file which will perform such numeric comparisons. Here is my suggestion for how to hook it into XMLUnit. /** * Test two non-null values for inequality * @param expected * @param actual * @return TRUE if the values are not equals() equal (taking whitespace * into account if necessary) */ private boolean unequalNotNull(Object expected, Object actual) { boolean bothStrings = (expected instanceof String && actual instanceof String); if (!bothStrings) { return !(expected.equals(actual)); } String expectedString = (String) expected; String actualString = (String) actual; if (XMLUnit.getIgnoreWhitespace()) { expectedString = expected.trim(); actualString = actual.trim(); } if (XMLUnit.getNormalizeWhitespace()) { expectedString = normalizeWhitespace(expectedString); actualString = normalizeWhitespace(actualString); } if (XMLUnit.getTolerantNumericCompare) { return !StringCmpNumericTolerance.equals(expected,actualString); } return !expectedString.equals(actualString); } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=1762410&group_id=23187 |