1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 14:16:32 +02:00

Implement without-bcmath compatible UnitConverter. We might want to factor our floating point fudges. These calculations are only accurate for small precisions, and are architecture-dependent. (Unit tests seem to work on 32bit, though).

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1752 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-05-21 00:29:31 +00:00
parent 64b5581bf2
commit 6d7a17e9b6
3 changed files with 81 additions and 25 deletions

View File

@@ -7,9 +7,18 @@ class HTMLPurifier_UnitConverterTest extends HTMLPurifier_Harness
$length = HTMLPurifier_Length::make($input);
if ($expect !== false) $expectl = HTMLPurifier_Length::make($expect);
else $expectl = false;
$converter = new HTMLPurifier_UnitConverter();
$result = $converter->convert($length, $unit !== null ? $unit : $expectl->getUnit());
$this->assertIdentical($result, $expectl);
$to_unit = $unit !== null ? $unit : $expectl->getUnit();
$converter = new HTMLPurifier_UnitConverter(4, 10);
$result = $converter->convert($length, $to_unit);
if (!$result || !$expectl) $this->assertIdentical($result, $expectl);
else $this->assertIdentical($result->toString(), $expectl->toString());
$converter = new HTMLPurifier_UnitConverter(4, 10, true);
$result = $converter->convert($length, $to_unit);
if (!$result || !$expectl) $this->assertIdentical($result, $expectl);
else $this->assertIdentical($result->toString(), $expectl->toString(), 'BCMath substitute: %s');
if ($test_negative) {
$this->assertConversion(
"-$input",